[Libreoffice-commits] core.git: vcl/win

Tor Lillqvist tml at collabora.com
Fri Aug 28 23:06:48 PDT 2015


 vcl/win/source/gdi/winlayout.cxx |   43 +++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 22 deletions(-)

New commits:
commit 15943416240e29a052e3a6e4d338932e8c1ffb06
Author: Tor Lillqvist <tml at collabora.com>
Date:   Sat Aug 29 09:02:31 2015 +0300

    Avoid unintended unconditional std::cerr debug output
    
    Can't call a function that as a side effect prints to std::cerr in
    SAL_INFO. It will be called even if the log area doesn't match
    $SAL_LOG. Just use only SAL_INFO and no plain std::cerr output. It's
    fine to output a string with embedded newlines in SAL_INFO.
    
    Also drop the debug output line with the glyph start positions, it was
    less than useful.
    
    Change-Id: I9fb5ed068aae1b835e20cf1ec1097bcd55deb05d

diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 8d5d8bd..7bf8a8f 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -105,6 +105,10 @@ public:
     const OpenGLGlyphCacheChunk&  GetCachedGlyphChunkFor(int nGlyphIndex) const;
 };
 
+#ifdef SAL_DETAIL_ENABLE_LOG_INFO
+
+namespace {
+
 char ColorFor(COLORREF aColor)
 {
     if (aColor == RGB(0xFF, 0xFF, 0xFF))
@@ -115,47 +119,39 @@ char ColorFor(COLORREF aColor)
     return '0' + (10*(GetRValue(aColor) + GetGValue(aColor) + GetBValue(aColor))) / (0xFF*3);
 }
 
-OUString DumpGlyphBitmap(OpenGLGlyphCacheChunk& rChunk, HDC hDC)
+void DumpGlyphBitmap(OpenGLGlyphCacheChunk& rChunk, HDC hDC)
 {
     HBITMAP hBitmap = static_cast<HBITMAP>(GetCurrentObject(hDC, OBJ_BITMAP));
     if (hBitmap == NULL)
     {
         SAL_WARN("vcl.gdi", "GetCurrentObject failed: " << WindowsErrorString(GetLastError()));
-        return "";
+        return;
     }
 
     BITMAP aBitmap;
     if (!GetObjectW(hBitmap, sizeof(aBitmap), &aBitmap))
     {
         SAL_WARN("vcl.gdi", "GetObjectW failed: " << WindowsErrorString(GetLastError()));
-        return "";
+        return;
     }
 
-    std::cerr << "Bitmap " << hBitmap << ": " << aBitmap.bmWidth << "x" << aBitmap.bmHeight << ":" << std::endl;
-
-    // Print out start pos of each glyph only in the horizontal font case
-    int nPos = 0;
-    if (rChunk.mnGlyphCount > 1 && rChunk.maLocation[1].Left() > rChunk.maLocation[0].Left())
-    {
-        for (int i = 1; i < rChunk.mnGlyphCount && nPos < 75; i++)
-        {
-            for (int j = nPos; j < rChunk.maLocation[i].Left(); j++)
-                std::cerr << " ";
-            std::cerr << "!";
-            nPos = rChunk.maLocation[i].Left() + 1;
-        }
-    }
-    std::cerr << std::endl;
+    SAL_INFO("vcl.gdi.opengl", "Bitmap " << hBitmap << ": " << aBitmap.bmWidth << "x" << aBitmap.bmHeight << ":");
 
+    std::ostringstream sLine("\n");
     for (long y = 0; y < aBitmap.bmHeight; y++)
     {
         for (long x = 0; x < std::min(75l, aBitmap.bmWidth); x++)
-            std::cerr << ColorFor(GetPixel(hDC, x, y));
-        std::cerr << std::endl;
+            sLine << ColorFor(GetPixel(hDC, x, y));
+        if (y < aBitmap.bmHeight - 1)
+            sLine << "\n";
     }
-    return "";
+    SAL_INFO("vcl.gdi.opengl", sLine.str());
 }
 
+} // anonymous namespace
+
+#endif // SAL_DETAIL_ENABLE_LOG_INFO
+
 template< typename charT, typename traits >
 inline std::basic_ostream<charT, traits> & operator <<(
     std::basic_ostream<charT, traits> & stream, const std::vector<OpenGLGlyphCacheChunk>& rCache )
@@ -432,7 +428,10 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout& rLayou
     if (hNonAntialiasedFont != NULL)
         DeleteObject(hNonAntialiasedFont);
 
-    SAL_INFO("vcl.gdi.opengl", "this=" << this << " now: " << maOpenGLGlyphCache << DumpGlyphBitmap(aChunk, aDC.getCompatibleHDC()));
+#ifdef SAL_DETAIL_ENABLE_LOG_INFO
+    SAL_INFO("vcl.gdi.opengl", "this=" << this << " now: " << maOpenGLGlyphCache);
+    DumpGlyphBitmap(aChunk, aDC.getCompatibleHDC());
+#endif
 
     return true;
 }


More information about the Libreoffice-commits mailing list