summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-08-29 09:02:31 +0300
committerAndras Timar <andras.timar@collabora.com>2015-08-31 15:12:04 +0200
commit94a0e0126fc5fba02b965b24b248f48bc2358670 (patch)
tree8d74ad7c51c7c9e433a67de9edf8468d91aeebe2
parentAvoid accidental leftover unconditional debug printout (diff)
downloadcore-94a0e0126fc5fba02b965b24b248f48bc2358670.tar.gz
core-94a0e0126fc5fba02b965b24b248f48bc2358670.zip
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)
-rw-r--r--vcl/win/source/gdi/winlayout.cxx43
1 files 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<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 )
@@ -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;
}