- Deactivate unneeded debug prints, change DbgPrint to DPRINTx, remove unused perform...
[reactos.git] / reactos / subsystems / win32 / win32k / objects / freetype.c
index 39b53d0..5f20afc 100644 (file)
@@ -75,8 +75,6 @@ static FAST_MUTEX FontListLock;
 static BOOL RenderingEnabled = TRUE;
 
 #define MAX_FONT_CACHE 256
-UINT Hits;
-UINT Misses;
 
 typedef struct _FONT_CACHE_ENTRY
 {
@@ -1322,8 +1320,6 @@ ftGdiGlyphCacheGet(
     PLIST_ENTRY CurrentEntry;
     PFONT_CACHE_ENTRY FontEntry;
 
-//   DbgPrint("CacheGet\n");
-
     CurrentEntry = FontCacheListHead.Flink;
     while (CurrentEntry != &FontCacheListHead)
     {
@@ -1337,29 +1333,11 @@ ftGdiGlyphCacheGet(
 
     if (CurrentEntry == &FontCacheListHead)
     {
-//      DbgPrint("Miss! %x\n", FontEntry->Glyph);
-        /*
-              Misses++;
-              if (Misses>100) {
-                 DbgPrint ("Hits: %d Misses: %d\n", Hits, Misses);
-                 Hits = Misses = 0;
-              }
-        */
         return NULL;
     }
 
     RemoveEntryList(CurrentEntry);
     InsertHeadList(&FontCacheListHead, CurrentEntry);
-
-//   DbgPrint("Hit! %x\n", FontEntry->Glyph);
-    /*
-       Hits++;
-
-          if (Hits>100) {
-             DbgPrint ("Hits: %d Misses: %d\n", Hits, Misses);
-             Hits = Misses = 0;
-          }
-    */
     return FontEntry->Glyph;
 }
 
@@ -1375,25 +1353,23 @@ ftGdiGlyphCacheSet(
     INT error;
     PFONT_CACHE_ENTRY NewEntry;
 
-//   DbgPrint("CacheSet.\n");
-
     error = FT_Get_Glyph(GlyphSlot, &GlyphCopy);
     if (error)
     {
-        DbgPrint("Failure caching glyph.\n");
+        DPRINT1("Failure caching glyph.\n");
         return NULL;
     };
     error = FT_Glyph_To_Bitmap(&GlyphCopy, RenderMode, 0, 1);
     if (error)
     {
-        DbgPrint("Failure rendering glyph.\n");
+        DPRINT1("Failure rendering glyph.\n");
         return NULL;
     };
 
     NewEntry = ExAllocatePoolWithTag(PagedPool, sizeof(FONT_CACHE_ENTRY), TAG_FONT);
     if (!NewEntry)
     {
-        DbgPrint("Alloc failure caching glyph.\n");
+        DPRINT1("Alloc failure caching glyph.\n");
         FT_Done_Glyph(GlyphCopy);
         return NULL;
     }
@@ -1413,8 +1389,6 @@ ftGdiGlyphCacheSet(
         FontCacheNumEntries--;
     }
 
-//   DbgPrint("Returning the glyphcopy: %x\n", GlyphCopy);
-
     return GlyphCopy;
 }
 
@@ -3128,12 +3102,6 @@ GreExtTextOutW(
     FT_Bool use_kerning;
     RECTL DestRect, MaskRect;
     POINTL SourcePoint, BrushOrigin;
-    HBRUSH hbrushText = NULL;
-    PBRUSH pbrushText = NULL;
-    EBRUSHOBJ eboText;
-    HBRUSH hbrushBackGnd = NULL;
-    PBRUSH pbrushBackGnd = NULL;
-    EBRUSHOBJ eboBackGnd;
     HBITMAP HSourceGlyph;
     SURFOBJ *SourceGlyphSurf;
     SIZEL bitSize;
@@ -3142,9 +3110,7 @@ GreExtTextOutW(
     FONTOBJ *FontObj;
     PFONTGDI FontGDI;
     PTEXTOBJ TextObj = NULL;
-    PPALGDI PalDestGDI;
     XLATEOBJ *XlateObj=NULL, *XlateObj2=NULL;
-    ULONG Mode;
     FT_Render_Mode RenderMode;
     BOOLEAN Render;
     POINT Start;
@@ -3169,6 +3135,15 @@ GreExtTextOutW(
 
     pdcattr = dc->pdcattr;
 
+    if (pdcattr->ulDirty_ & DIRTY_TEXT)
+        DC_vUpdateTextBrush(dc);
+
+    if ((fuOptions & ETO_OPAQUE) || pdcattr->jBkMode == OPAQUE)
+    {
+        if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
+            DC_vUpdateBackgroundBrush(dc);
+    }
+
     /* Check if String is valid */
     if ((Count > 0xFFFF) || (Count > 0 && String == NULL))
     {
@@ -3202,7 +3177,6 @@ GreExtTextOutW(
         goto fail;
     }
     SurfObj = &psurf->SurfObj;
-    ASSERT(SurfObj);
 
     Start.x = XStart;
     Start.y = YStart;
@@ -3214,45 +3188,12 @@ GreExtTextOutW(
     /* Create the brushes */
     hDestPalette = psurf->hDIBPalette;
     if (!hDestPalette) hDestPalette = pPrimarySurface->DevInfo.hpalDefault;
-    PalDestGDI = PALETTE_LockPalette(hDestPalette);
-    if ( !PalDestGDI )
-        Mode = PAL_RGB;
-    else
-    {
-        Mode = PalDestGDI->Mode;
-        PALETTE_UnlockPalette(PalDestGDI);
-    }
-    XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, hDestPalette, NULL);
+    XlateObj = (XLATEOBJ*)IntEngCreateXlate(0, PAL_RGB, hDestPalette, NULL);
     if ( !XlateObj )
     {
         goto fail;
     }
-    hbrushText = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, pdcattr->crForegroundClr), 0);
-    if ( !hbrushText )
-    {
-        goto fail;
-    }
-    pbrushText = BRUSH_LockBrush(hbrushText);
-    if ( !pbrushText )
-    {
-        goto fail;
-    }
-    EBRUSHOBJ_vInit(&eboText, pbrushText, NULL);
-    if ((fuOptions & ETO_OPAQUE) || pdcattr->jBkMode == OPAQUE)
-    {
-        hbrushBackGnd = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, pdcattr->crBackgroundClr), 0);
-        if ( !hbrushBackGnd )
-        {
-            goto fail;
-        }
-        pbrushBackGnd = BRUSH_LockBrush(hbrushBackGnd);
-        if ( !pbrushBackGnd )
-        {
-            goto fail;
-        }
-        EBRUSHOBJ_vInit(&eboBackGnd, pbrushBackGnd, NULL);
-    }
-    XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, hDestPalette);
+    XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, 0, NULL, hDestPalette);
     if ( !XlateObj2 )
     {
         goto fail;
@@ -3267,11 +3208,18 @@ GreExtTextOutW(
 
     if ((fuOptions & ETO_OPAQUE) && lprc)
     {
-        DestRect.left   = lprc->left   + dc->ptlDCOrig.x;
-        DestRect.top    = lprc->top    + dc->ptlDCOrig.y;
-        DestRect.right  = lprc->right  + dc->ptlDCOrig.x;
-        DestRect.bottom = lprc->bottom + dc->ptlDCOrig.y;
+        DestRect.left   = lprc->left;
+        DestRect.top    = lprc->top;
+        DestRect.right  = lprc->right;
+        DestRect.bottom = lprc->bottom;
+
         IntLPtoDP(dc, (LPPOINT)&DestRect, 2);
+
+        DestRect.left   += dc->ptlDCOrig.x;
+        DestRect.top    += dc->ptlDCOrig.y;
+        DestRect.right  += dc->ptlDCOrig.x;
+        DestRect.bottom += dc->ptlDCOrig.y;
+
         IntEngBitBlt(
             &psurf->SurfObj,
             NULL,
@@ -3281,7 +3229,7 @@ GreExtTextOutW(
             &DestRect,
             &SourcePoint,
             &SourcePoint,
-            &eboBackGnd.BrushObject,
+            &dc->eboBackground.BrushObject,
             &BrushOrigin,
             ROP3_TO_ROP4(PATCOPY));
         fuOptions &= ~ETO_OPAQUE;
@@ -3483,8 +3431,6 @@ GreExtTextOutW(
                 goto fail;
             }
         }
-//      DbgPrint("realglyph: %x\n", realglyph);
-//      DbgPrint("TextLeft: %d\n", TextLeft);
 
         /* retrieve kerning distance and move pen position */
         if (use_kerning && previous && glyph_index && NULL == Dx)
@@ -3493,12 +3439,12 @@ GreExtTextOutW(
             FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
             TextLeft += delta.x;
         }
-//      DPRINT1("TextLeft: %d\n", TextLeft);
-//      DPRINT1("TextTop: %d\n", TextTop);
+        DPRINT("TextLeft: %d\n", TextLeft);
+        DPRINT("TextTop: %d\n", TextTop);
 
         if (realglyph->format == ft_glyph_format_outline)
         {
-            DbgPrint("Should already be done\n");
+            DPRINT1("Should already be done\n");
 //         error = FT_Render_Glyph(glyph, RenderMode);
             error = FT_Glyph_To_Bitmap(&realglyph, RenderMode, 0, 0);
             if (error)
@@ -3509,8 +3455,7 @@ GreExtTextOutW(
         }
         realglyph2 = (FT_BitmapGlyph)realglyph;
 
-//      DPRINT1("Pitch: %d\n", pitch);
-//      DPRINT1("Advance: %d\n", realglyph->advance.x);
+        DPRINT("Advance: %d\n", realglyph->advance.x);
 
         if (fuOptions & ETO_OPAQUE)
         {
@@ -3527,7 +3472,7 @@ GreExtTextOutW(
                 &DestRect,
                 &SourcePoint,
                 &SourcePoint,
-                &eboBackGnd.BrushObject,
+                &dc->eboBackground.BrushObject,
                 &BrushOrigin,
                 ROP3_TO_ROP4(PATCOPY));
             BackgroundLeft = DestRect.right;
@@ -3597,9 +3542,8 @@ GreExtTextOutW(
             XlateObj,
             XlateObj2,
             &DestRect,
-            &SourcePoint,
             (PPOINTL)&MaskRect,
-            &eboText.BrushObject,
+            &dc->eboText.BrushObject,
             &BrushOrigin);
 
         EngUnlockSurface(SourceGlyphSurf);
@@ -3613,12 +3557,12 @@ GreExtTextOutW(
         if (NULL == Dx)
         {
             TextLeft += realglyph->advance.x >> 10;
-//         DbgPrint("new TextLeft: %d\n", TextLeft);
+             DPRINT("new TextLeft: %d\n", TextLeft);
         }
         else
         {
             TextLeft += Dx[i<<DxShift] << 6;
-//         DbgPrint("new TextLeft2: %d\n", TextLeft);
+             DPRINT("new TextLeft2: %d\n", TextLeft);
         }
 
         if (DxShift)
@@ -3638,13 +3582,6 @@ GreExtTextOutW(
     SURFACE_UnlockSurface(psurf);
     if (TextObj != NULL)
         TEXTOBJ_UnlockText(TextObj);
-    if (hbrushBackGnd != NULL)
-    {
-        BRUSH_UnlockBrush(pbrushBackGnd);
-        NtGdiDeleteObject(hbrushBackGnd);
-    }
-    BRUSH_UnlockBrush(pbrushText);
-    NtGdiDeleteObject(hbrushText);
 good:
     DC_UnlockDc( dc );
 
@@ -3659,16 +3596,6 @@ fail:
         TEXTOBJ_UnlockText(TextObj);
     if (psurf != NULL)
         SURFACE_UnlockSurface(psurf);
-    if (hbrushBackGnd != NULL)
-    {
-        BRUSH_UnlockBrush(pbrushBackGnd);
-        NtGdiDeleteObject(hbrushBackGnd);
-    }
-    if (hbrushText != NULL)
-    {
-        BRUSH_UnlockBrush(pbrushText);
-        NtGdiDeleteObject(hbrushText);
-    }
     DC_UnlockDc(dc);
 
     return FALSE;