[YAROTOWS] Reintegrate the branch. For a brighter future.
[reactos.git] / reactos / subsystems / win32 / win32k / objects / freetype.c
index 7475847..f4d17cc 100644 (file)
@@ -302,7 +302,9 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
     PSECTION_OBJECT SectionObject;
     ULONG ViewSize = 0;
     LARGE_INTEGER SectionSize;
+#if 0 // Wine code
     FT_Fixed XScale, YScale;
+#endif
     UNICODE_STRING FontRegPath = RTL_CONSTANT_STRING(L"\\REGISTRY\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts");
 
     /* Open the font file */
@@ -395,9 +397,9 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
     FontGDI->face = Face;
 
     /* FIXME: Complete text metrics */
+#if 0 /* This (Wine) code doesn't seem to work correctly for us */
     XScale = Face->size->metrics.x_scale;
     YScale = Face->size->metrics.y_scale;
-#if 0 /* This (Wine) code doesn't seem to work correctly for us */
     FontGDI->TextMetric.tmAscent =  (FT_MulFix(Face->ascender, YScale) + 32) >> 6;
     FontGDI->TextMetric.tmDescent = (FT_MulFix(Face->descender, YScale) + 32) >> 6;
     FontGDI->TextMetric.tmHeight =  (FT_MulFix(Face->ascender, YScale) -
@@ -2247,7 +2249,7 @@ TextIntGetTextExtentPoint(PDC dc,
 
     Size->cx = (TotalWidth + 32) >> 6;
     Size->cy = (TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight < 0 ? - TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight : TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight);
-    Size->cy = EngMulDiv(Size->cy, IntGdiGetDeviceCaps(dc, LOGPIXELSY), 72);
+    Size->cy = EngMulDiv(Size->cy, dc->ppdev->gdiinfo.ulLogPixelsY, 72);
 
     return TRUE;
 }
@@ -3158,7 +3160,7 @@ GreExtTextOutW(
     LONGLONG TextLeft, RealXStart;
     ULONG TextTop, previous, BackgroundLeft;
     FT_Bool use_kerning;
-    RECTL DestRect, MaskRect;
+    RECTL DestRect, MaskRect, DummyRect = {0, 0, 0, 0};
     POINTL SourcePoint, BrushOrigin;
     HBITMAP HSourceGlyph;
     SURFOBJ *SourceGlyphSurf;
@@ -3173,8 +3175,6 @@ GreExtTextOutW(
     BOOLEAN Render;
     POINT Start;
     BOOL DoBreak = FALSE;
-    HPALETTE hDestPalette;
-    PPALETTE ppalDst;
     USHORT DxShift;
 
     // TODO: Write test-cases to exactly match real Windows in different
@@ -3194,9 +3194,6 @@ GreExtTextOutW(
 
     pdcattr = dc->pdcattr;
 
-    if (pdcattr->ulDirty_ & DIRTY_TEXT)
-        DC_vUpdateTextBrush(dc);
-
     if ((fuOptions & ETO_OPAQUE) || pdcattr->jBkMode == OPAQUE)
     {
         if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
@@ -3230,13 +3227,6 @@ GreExtTextOutW(
         IntLPtoDP(dc, (POINT *)lprc, 2);
     }
 
-    psurf = dc->dclevel.pSurface;
-    if (!psurf)
-    {
-        goto fail;
-    }
-    SurfObj = &psurf->SurfObj;
-
     Start.x = XStart;
     Start.y = YStart;
     IntLPtoDP(dc, &Start, 1);
@@ -3265,8 +3255,13 @@ GreExtTextOutW(
         DestRect.right  += dc->ptlDCOrig.x;
         DestRect.bottom += dc->ptlDCOrig.y;
 
+        DC_vPrepareDCsForBlit(dc, DestRect, NULL, DestRect);
+
+        if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
+            DC_vUpdateBackgroundBrush(dc);
+
         IntEngBitBlt(
-            &psurf->SurfObj,
+            &dc->dclevel.pSurface->SurfObj,
             NULL,
             NULL,
             dc->rosdc.CombinedClip,
@@ -3278,6 +3273,7 @@ GreExtTextOutW(
             &BrushOrigin,
             ROP3_TO_ROP4(PATCOPY));
         fuOptions &= ~ETO_OPAQUE;
+        DC_vFinishBlit(dc, NULL);
     }
     else
     {
@@ -3442,19 +3438,24 @@ GreExtTextOutW(
     TextTop = YStart;
     BackgroundLeft = (RealXStart + 32) >> 6;
 
-    /* Create the xlateobj */
-    hDestPalette = psurf->hDIBPalette;
-    if (!hDestPalette) hDestPalette = pPrimarySurface->devinfo.hpalDefault;
-    ppalDst = PALETTE_LockPalette(hDestPalette);
-    EXLATEOBJ_vInitialize(&exloRGB2Dst, &gpalRGB, ppalDst, 0, 0, 0);
-    EXLATEOBJ_vInitialize(&exloDst2RGB, ppalDst, &gpalRGB, 0, 0, 0);
-    PALETTE_UnlockPalette(ppalDst);
+    /* Lock blit with a dummy rect */
+    DC_vPrepareDCsForBlit(dc, DummyRect, NULL, DummyRect);
+
+    psurf = dc->dclevel.pSurface ;
+    SurfObj = &psurf->SurfObj ;
+
+    EXLATEOBJ_vInitialize(&exloRGB2Dst, &gpalRGB, psurf->ppal, 0, 0, 0);
+    EXLATEOBJ_vInitialize(&exloDst2RGB, psurf->ppal, &gpalRGB, 0, 0, 0);
+
+       if ((fuOptions & ETO_OPAQUE) && (dc->pdcattr->ulDirty_ & DIRTY_BACKGROUND))
+        DC_vUpdateBackgroundBrush(dc) ;
 
+    if(dc->pdcattr->ulDirty_ & DIRTY_TEXT)
+        DC_vUpdateTextBrush(dc) ;
 
     /*
      * The main rendering loop.
      */
-
     for (i = 0; i < Count; i++)
     {
         if (fuOptions & ETO_GLYPH_INDEX)
@@ -3503,6 +3504,7 @@ GreExtTextOutW(
             DestRect.right = (TextLeft + (realglyph->root.advance.x >> 10) + 32) >> 6;
             DestRect.top = TextTop + yoff - ((face->size->metrics.ascender + 32) >> 6);
             DestRect.bottom = TextTop + yoff + ((32 - face->size->metrics.descender) >> 6);
+            MouseSafetyOnDrawStart(dc->ppdev, DestRect.left, DestRect.top, DestRect.right, DestRect.bottom);
             IntEngBitBlt(
                 &psurf->SurfObj,
                 NULL,
@@ -3515,7 +3517,9 @@ GreExtTextOutW(
                 &dc->eboBackground.BrushObject,
                 &BrushOrigin,
                 ROP3_TO_ROP4(PATCOPY));
+            MouseSafetyOnDrawEnd(dc->ppdev);
             BackgroundLeft = DestRect.right;
+
         }
 
         DestRect.left = ((TextLeft + 32) >> 6) + realglyph->left;
@@ -3568,7 +3572,7 @@ GreExtTextOutW(
             DestRect.right = lprc->right + dc->ptlDCOrig.x;
             DoBreak = TRUE;
         }
-
+        MouseSafetyOnDrawStart(dc->ppdev, DestRect.left, DestRect.top, DestRect.right, DestRect.bottom);
         IntEngMaskBlt(
             SurfObj,
             SourceGlyphSurf,
@@ -3579,6 +3583,7 @@ GreExtTextOutW(
             (PPOINTL)&MaskRect,
             &dc->eboText.BrushObject,
             &BrushOrigin);
+        MouseSafetyOnDrawEnd(dc->ppdev) ;
 
         EngUnlockSurface(SourceGlyphSurf);
         EngDeleteSurface((HSURF)HSourceGlyph);
@@ -3608,9 +3613,9 @@ GreExtTextOutW(
 
         String++;
     }
-
     IntUnLockFreeType;
 
+    DC_vFinishBlit(dc, NULL) ;
     EXLATEOBJ_vCleanup(&exloRGB2Dst);
     EXLATEOBJ_vCleanup(&exloDst2RGB);
     if (TextObj != NULL)
@@ -3626,6 +3631,7 @@ fail2:
 fail:
     if (TextObj != NULL)
         TEXTOBJ_UnlockText(TextObj);
+
     DC_UnlockDc(dc);
 
     return FALSE;