[Libreoffice-commits] core.git: Branch 'feature/fixes7' - vcl/win
vcl/win/source/gdi/winlayout.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 12450a5236d9c86390f5a706612bb7935aff332a Author: Tor Lillqvist t...@collabora.com Date: Tue Aug 25 11:52:20 2015 +0300 Turn on glyph caching by default when using OpenGL Can now be turned off with a SAL_DISABLE_GLYPH_CACHING environment variable. Change-Id: I7ac14d72dc0f85c0682d92492eb96bec1d207609 diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index f26d3eb..d341806 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -1658,7 +1658,7 @@ void UniscribeLayout::DrawTextImpl(HDC hDC) const bool UniscribeLayout::CacheGlyphs(SalGraphics rGraphics) const { -static bool bDoGlyphCaching = (std::getenv(SAL_ENABLE_GLYPH_CACHING) != NULL); +static bool bDoGlyphCaching = (std::getenv(SAL_DISABLE_GLYPH_CACHING) == NULL); if (!bDoGlyphCaching) return false; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/fixes7' - vcl/win
vcl/win/source/gdi/winlayout.cxx |3 +++ 1 file changed, 3 insertions(+) New commits: commit 23b46c9b634215b634bf1dd7c711b489aca75342 Author: Tor Lillqvist t...@collabora.com Date: Mon Aug 24 18:08:08 2015 +0300 Don't attempt to cache glyphs that are vertical but the text direction isn't That is a too complex and rare case to bother with, I think. Change-Id: Ica6ef7fa05314d2367dcff32627c1aec6ba8f8df diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 85b1e97..f26d3eb 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -353,6 +353,9 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout rLayou aChunk.mbVertical = false; } +if (aChunk.mbVertical aLogfont.lfEscapement != 2700) +return false; + OpenGLCompatibleDC aDC(rGraphics, 0, 0, nBitmapWidth, nBitmapHeight); HFONT hNonAntialiasedFont = NULL; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/fixes7' - vcl/win
vcl/win/source/gdi/winlayout.cxx | 55 +++ 1 file changed, 45 insertions(+), 10 deletions(-) New commits: commit fe4208066fff7d74059e5eec18aea6dc594b0c14 Author: Tor Lillqvist t...@collabora.com Date: Wed Aug 19 15:44:30 2015 +0300 Still more hacking on OpenGL glyph caching for Windows Show the whole height of the cache bitmap after all (when SAL_LOG contains vcl.gdi.opengl). The interesting pieces are often at the bottom, like the tip of the hook of the j glyphs that used to bleed over into the preceding glyphs, usually i, when they were rendered into the same chunk. Add more space between glyphs and at top and bottom of the bitmap, for anti-aliasing. The glyph ABC widths don't take expansions caused by anti-aliasing into consideration and are misleading. Hopefully anti-aliasing can expand the (partially) painted pixels of a glyph just one column/row in each direction, but for safety use a two-pixel border. (Defensive programming, eek?) Some getWidth() instead of GetWidth() etc craziness. Using tools/gen.hxx types truly is programming-by-coincidence as Thorsten says. In a dbgutil build, setting the environment variable VCL_GLYPH_CACHING_HACK_NO_ANTIALIAS causes the code to turn off anti-aliasing for the fonts used. I used this to verify that it indeed was anti-aliasing that made the ABC widths inconsistent with reality. Not sure if it makes sense to keep this code in? Anyway, now I don't see any leaked pixels in i glyphs any more, touch wood. Change-Id: If527343ff1dcdb1fa208cd5e7fa4d08f812d0d7b diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 540a76b..c1c2d7e 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -147,7 +147,7 @@ OUString DumpGlyphBitmap(OpenGLGlyphCacheChunk rChunk, HDC hDC) } std::cerr std::endl; -for (long y = 0; y std::min(20l, aBitmap.bmHeight); y++) +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)); @@ -279,7 +279,10 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout rLayou std::cerr aABC[i].abcA : aABC[i].abcB : aABC[i].abcC ; std::cerr std::endl; -// Avoid kerning as we want to be able to use individual rectangles for each glyph +// Try hard to avoid overlap as we want to be able to use +// individual rectangles for each glyph. The ABC widths don't +// take anti-alising into consideration. Let's hope that leaving +// four pixels of extra space inbetween glyphs will help. std::vectorint aDX(nCount); int totWidth = 0; for (int i = 0; i nCount; i++) @@ -289,6 +292,7 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout rLayou aDX[0] += std::abs(aABC[0].abcA); if (i nCount-1) aDX[i] += std::abs(aABC[i+1].abcA); +aDX[i] += 4; totWidth += aDX[i]; } @@ -299,9 +303,32 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout rLayou if (!DeleteDC(hDC)) SAL_WARN(vcl.gdi, DeleteDC failed: WindowsErrorString(GetLastError())); -OpenGLCompatibleDC aDC(rGraphics, 0, 0, totWidth, aSize.cy); +// Leave two pixels of extra space also at top and bottom +OpenGLCompatibleDC aDC(rGraphics, 0, 0, totWidth, aSize.cy + 4); -hOrigFont = SelectFont(aDC.getCompatibleHDC(), rLayout.mhFont); +HFONT hNonAntialiasedFont = NULL; + +#ifdef DBG_UTIL +static bool bNoAntialias = (std::getenv(VCL_GLYPH_CACHING_HACK_NO_ANTIALIAS) != NULL); +if (bNoAntialias) +{ +LOGFONTW aLogfont; +if (!GetObjectW(rLayout.mhFont, sizeof(aLogfont), aLogfont)) +{ +SAL_WARN(vcl.gdi, GetObject failed: WindowsErrorString(GetLastError())); +return false; +} +aLogfont.lfQuality = NONANTIALIASED_QUALITY; +hNonAntialiasedFont = CreateFontIndirectW(aLogfont); +if (hNonAntialiasedFont == NULL) +{ +SAL_WARN(vcl.gdi, CreateFontIndirect failed: WindowsErrorString(GetLastError())); +return false; +} +} +#endif + +hOrigFont = SelectFont(aDC.getCompatibleHDC(), hNonAntialiasedFont != NULL ? hNonAntialiasedFont : rLayout.mhFont); if (hOrigFont == NULL) { SAL_WARN(vcl.gdi, SelectObject failed: WindowsErrorString(GetLastError())); @@ -311,9 +338,15 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout rLayou SetTextColor(aDC.getCompatibleHDC(), RGB(0, 0, 0)); SetBkColor(aDC.getCompatibleHDC(), RGB(255, 255, 255)); -if (!ExtTextOutW(aDC.getCompatibleHDC(), 0, 0, ETO_GLYPH_INDEX, NULL, aGlyphIndices.data(), nCount, aDX.data())) +
[Libreoffice-commits] core.git: Branch 'feature/fixes7' - vcl/win
vcl/win/source/gdi/winlayout.cxx | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) New commits: commit e7542ae6b233a95999ad1b313054639819a3af66 Author: Tor Lillqvist t...@collabora.com Date: Wed Aug 19 09:18:37 2015 +0300 More hacking on cached glyph rendering for OpenGL on Windows Change-Id: I934ad7453f35909f4c3ad999e33453b5b6032480 diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 0ab9cd9..7f4c4a4 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -160,7 +160,10 @@ inline std::basic_ostreamcharT, traits operator ( stream {; for (auto i = rCache.cbegin(); i != rCache.cend(); ++i) { -stream [ i-mnFirstGlyph .. (i-mnFirstGlyph + i-mnGlyphCount - 1) ]; +stream [ i-mnFirstGlyph; +if (i-mnGlyphCount 1) +stream .. (i-mnFirstGlyph + i-mnGlyphCount - 1); +stream ]; if (i+1 != rCache.cend()) { stream ,; @@ -278,10 +281,16 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout rLayou int totWidth = 0; for (int i = 0; i nCount; i++) { -aDX[i] = std::abs(aABC[i].abcA) + aABC[i].abcB + std::abs(aABC[i].abcC); +aDX[i] = aABC[i].abcB + std::abs(aABC[i].abcC); +if (i == 0) +aDX[0] += std::abs(aABC[0].abcA); +if (i nCount-1) +aDX[i] += std::abs(aABC[i+1].abcA); totWidth += aDX[i]; } +SAL_INFO(vcl.gdi.opengl, aSize=( aSize.cx , aSize.cy ) totWidth= totWidth); + if (SelectObject(hDC, hOrigFont) == NULL) SAL_WARN(vcl.gdi, SelectObject failed: WindowsErrorString(GetLastError())); if (!DeleteDC(hDC)) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/fixes7' - vcl/win
vcl/win/source/gdi/winlayout.cxx |5 - 1 file changed, 4 insertions(+), 1 deletion(-) New commits: commit ef876630b9874dccb9a2fd10dabdd0acb2334d6c Author: Tor Lillqvist t...@collabora.com Date: Wed Aug 19 12:37:56 2015 +0300 Make the pixel greylevel debug output work as intended Change-Id: I29cb771eb059f560b7cbd449257ffda581b40f11 diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 7f4c4a4..540a76b 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -114,7 +114,10 @@ char ColorFor(COLORREF aColor) { if (aColor == RGB(0xFF, 0xFF, 0xFF)) return ' '; -return '0' + 10*((GetRValue(aColor) + GetGValue(aColor) + GetBValue(aColor)) / (0xFF*3)); +else if (aColor == RGB(0x00, 0x00, 0x00)) +return 'X'; + +return '0' + (10*(GetRValue(aColor) + GetGValue(aColor) + GetBValue(aColor))) / (0xFF*3); } OUString DumpGlyphBitmap(OpenGLGlyphCacheChunk rChunk, HDC hDC) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/fixes7' - vcl/win
vcl/win/source/gdi/winlayout.cxx | 41 +-- 1 file changed, 23 insertions(+), 18 deletions(-) New commits: commit 35f9d5f84c7d1a5058a7908bc68a6f127471e82d Author: Tor Lillqvist t...@collabora.com Date: Tue Aug 18 13:43:27 2015 +0300 More hacking on OpenGL glyph caching on Windows Now text looks better, for instance the lower-case t glyphs on the Start Centre aren't totally weird any more. But for instance the tip of the hook of j leaks into the i texture. I guess I really would need to render glyphs one by one. Change-Id: I69ae2d2f7c559530bcfdfc1a4915503fcb3ab4af diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index e32b8b5..0ab9cd9 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -204,7 +204,7 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout rLayou if (nGlyphIndex == DROPPED_OUTGLYPH) return true; -SAL_INFO(vcl.gdi.opengl, AddChunkOfGlyphs this nGlyphIndex old: maOpenGLGlyphCache); +SAL_INFO(vcl.gdi.opengl, this= this nGlyphIndex old: maOpenGLGlyphCache); auto n = maOpenGLGlyphCache.begin(); while (n != maOpenGLGlyphCache.end() @@ -262,12 +262,32 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout rLayou return false; } +std::vectorABC aABC(nCount); +if (!GetCharABCWidthsI(hDC, 0, nCount, aGlyphIndices.data(), aABC.data())) +{ +SAL_WARN(vcl.gdi, GetCharABCWidthsI failed: WindowsErrorString(GetLastError())); +return false; +} + +for (int i = 0; i nCount; i++) +std::cerr aABC[i].abcA : aABC[i].abcB : aABC[i].abcC ; +std::cerr std::endl; + +// Avoid kerning as we want to be able to use individual rectangles for each glyph +std::vectorint aDX(nCount); +int totWidth = 0; +for (int i = 0; i nCount; i++) +{ +aDX[i] = std::abs(aABC[i].abcA) + aABC[i].abcB + std::abs(aABC[i].abcC); +totWidth += aDX[i]; +} + if (SelectObject(hDC, hOrigFont) == NULL) SAL_WARN(vcl.gdi, SelectObject failed: WindowsErrorString(GetLastError())); if (!DeleteDC(hDC)) SAL_WARN(vcl.gdi, DeleteDC failed: WindowsErrorString(GetLastError())); -OpenGLCompatibleDC aDC(rGraphics, 0, 0, aSize.cx, aSize.cy); +OpenGLCompatibleDC aDC(rGraphics, 0, 0, totWidth, aSize.cy); hOrigFont = SelectFont(aDC.getCompatibleHDC(), rLayout.mhFont); if (hOrigFont == NULL) @@ -279,21 +299,6 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout rLayou SetTextColor(aDC.getCompatibleHDC(), RGB(0, 0, 0)); SetBkColor(aDC.getCompatibleHDC(), RGB(255, 255, 255)); -std::vectorABC aABC(nCount); -if (!GetCharABCWidthsI(aDC.getCompatibleHDC(), 0, nCount, aGlyphIndices.data(), aABC.data())) -{ -SAL_WARN(vcl.gdi, GetCharABCWidthsI failed: WindowsErrorString(GetLastError())); -return false; -} - -for (int i = 0; i nCount; i++) -std::cerr aABC[i].abcA : aABC[i].abcB : aABC[i].abcC ; -std::cerr std::endl; - -// Avoid kerning as we want to be able to use individual rectangles for each glyph -std::vectorint aDX(nCount); -for (int i = 0; i nCount; i++) -aDX[i] = std::abs(aABC[i].abcA) + aABC[i].abcB + std::abs(aABC[i].abcC); if (!ExtTextOutW(aDC.getCompatibleHDC(), 0, 0, ETO_GLYPH_INDEX, NULL, aGlyphIndices.data(), nCount, aDX.data())) { SAL_WARN(vcl.gdi, ExtTextOutW failed: WindowsErrorString(GetLastError())); @@ -317,7 +322,7 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout rLayou SelectFont(aDC.getCompatibleHDC(), hOrigFont); -SAL_INFO(vcl.gdi.opengl, AddChunkOfGlyphs this now: maOpenGLGlyphCache DumpGlyphBitmap(aChunk, aDC.getCompatibleHDC())); +SAL_INFO(vcl.gdi.opengl, this= this now: maOpenGLGlyphCache DumpGlyphBitmap(aChunk, aDC.getCompatibleHDC())); return true; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/fixes7' - vcl/win
vcl/win/source/gdi/winlayout.cxx | 12 ++-- 1 file changed, 2 insertions(+), 10 deletions(-) New commits: commit 32b8b33273764c64515f7fdf97e369fed6406876 Author: Tor Lillqvist t...@collabora.com Date: Mon Aug 17 18:23:11 2015 +0300 Add FIXME comment and bin an #if 0 snippet Change-Id: I0bbea4ef62c8e94d8b8f1bfb440712da5839e532 diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 6f8b4ca..e32b8b5 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -1579,6 +1579,8 @@ bool UniscribeLayout::DrawCachedGlyphs(SalGraphics rGraphics) const pImpl-PreDraw(); +// FIXME: This code snippet is mostly copied from the one in +// UniscribeLayout::DrawTextImpl. Should be factored out. int nBaseClusterOffset = 0; int nBaseGlyphPos = -1; for( int nItem = 0; nItem mnItemCount; ++nItem ) @@ -1626,16 +1628,6 @@ bool UniscribeLayout::DrawCachedGlyphs(SalGraphics rGraphics) const pImpl-DrawMask(*rChunk.mpTexture, salColor, a2Rects); nAdvance += mpGlyphAdvances[i]; } -#if 0 -ScriptTextOut(hDC, rScriptCache, -aPos.X(), aPos.Y(), 0, NULL, -rVisualItem.mpScriptItem-a, NULL, 0, -mpOutGlyphs + nMinGlyphPos, -nEndGlyphPos - nMinGlyphPos, -mpGlyphAdvances + nMinGlyphPos, -mpJustifications ? mpJustifications + nMinGlyphPos : NULL, -mpGlyphOffsets + nMinGlyphPos); -#endif } pImpl-PostDraw(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits