diff options
author | Tor Lillqvist <tml@collabora.com> | 2015-08-18 13:43:27 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2015-08-19 09:27:07 +0300 |
commit | df42d08191fd76b38d58a317f9aca804e10df062 (patch) | |
tree | 48ef41989921dedcc3a0e6fe934035b1ff73a9d4 /vcl/win | |
parent | b3c8095de5cf8c8030e3bac0532363def3070c3e (diff) |
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
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/source/gdi/winlayout.cxx | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index e32b8b57dc00..0ab9cd9add16 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::vector<ABC> 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::vector<int> 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::vector<ABC> 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::vector<int> 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; } |