From 94a0e0126fc5fba02b965b24b248f48bc2358670 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sat, 29 Aug 2015 09:02:31 +0300 Subject: 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 (cherry picked from commit 15943416240e29a052e3a6e4d338932e8c1ffb06) --- vcl/win/source/gdi/winlayout.cxx | 43 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 9c1ed98c89ae..51c77c0a81cb 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -104,6 +104,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)) @@ -114,47 +118,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(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 & operator <<( std::basic_ostream & stream, const std::vector& rCache ) @@ -431,7 +427,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; } -- cgit