diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2017-03-04 01:37:52 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2017-03-04 02:47:50 +0200 |
commit | c328c26a67a865d965cb8bde1b248eeae92f4e75 (patch) | |
tree | 7e2294b68d22356977f6ba4af08f3341a4f0e135 /vcl | |
parent | df4f30560a1297e2a42a66f20660d53004e44f0b (diff) |
SalLayout::GetBoundRect() works just fine here
Change-Id: Idce9a8f374f62bd92756d7391ccca3122c89683e
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/win/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/inc/win/winlayout.hxx | 13 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 52 |
3 files changed, 19 insertions, 48 deletions
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index e357083e7a4d..3af90cbefae3 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -299,7 +299,7 @@ protected: private: // local helpers - static void DrawTextLayout(const CommonSalLayout&, HDC, bool bUseDWrite); + void DrawTextLayout(const CommonSalLayout&, HDC, bool bUseDWrite); public: // public SalGraphics methods, the interface to the independent vcl part diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx index cca6a46919e3..42b25b62c91f 100644 --- a/vcl/inc/win/winlayout.hxx +++ b/vcl/inc/win/winlayout.hxx @@ -177,7 +177,9 @@ public: virtual ~TextOutRenderer() = default; - virtual bool operator ()(CommonSalLayout const &rLayout, HDC hDC, + virtual bool operator ()(CommonSalLayout const &rLayout, + SalGraphics &rGraphics, + HDC hDC, const Rectangle* pRectToErase, Point* pPos, int* pGetNextGlypInfo) = 0; }; @@ -190,7 +192,9 @@ class ExTextOutRenderer : public TextOutRenderer public: explicit ExTextOutRenderer() = default; - bool operator ()(CommonSalLayout const &rLayout, HDC hDC, + bool operator ()(CommonSalLayout const &rLayout, + SalGraphics &rGraphics, + HDC hDC, const Rectangle* pRectToErase, Point* pPos, int* pGetNextGlypInfo) override; }; @@ -213,7 +217,9 @@ public: explicit D2DWriteTextOutRenderer(); virtual ~D2DWriteTextOutRenderer() override; - bool operator ()(CommonSalLayout const &rLayout, HDC hDC, + bool operator ()(CommonSalLayout const &rLayout, + SalGraphics &rGraphics, + HDC hDC, const Rectangle* pRectToErase, Point* pPos, int* pGetNextGlypInfo) override; @@ -245,7 +251,6 @@ private: D2DWriteTextOutRenderer & operator = (const D2DWriteTextOutRenderer &) = delete; bool GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** ppFontFace, float * lfSize) const; - bool GetDWriteInkBox(CommonSalLayout const &rLayout, Rectangle &) const; ID2D1Factory * mpD2DFactory; IDWriteFactory * mpDWriteFactory; diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 47e98cc93782..c884c9ef6580 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -262,7 +262,9 @@ TextOutRenderer & TextOutRenderer::get(bool bUseDWrite) } -bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout, HDC hDC, +bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout, + SalGraphics & /*rGraphics*/, + HDC hDC, const Rectangle* pRectToErase, Point* pPos, int* pGetNextGlypInfo) { @@ -339,7 +341,9 @@ D2DWriteTextOutRenderer::~D2DWriteTextOutRenderer() CleanupModules(); } -bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout, HDC hDC, +bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout, + SalGraphics &rGraphics, + HDC hDC, const Rectangle* pRectToErase, Point* pPos, int* pGetNextGlypInfo) { @@ -349,11 +353,11 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout, HDC hD if (!BindFont(hDC)) { // If for any reason we can't bind fallback to legacy APIs. - return ExTextOutRenderer()(rLayout, hDC, pRectToErase, pPos, pGetNextGlypInfo); + return ExTextOutRenderer()(rLayout, rGraphics, hDC, pRectToErase, pPos, pGetNextGlypInfo); } Rectangle bounds; - bool succeeded = GetDWriteInkBox(rLayout, bounds); + bool succeeded = rLayout.GetBoundRect(rGraphics, bounds); succeeded &= BindDC(hDC, bounds); // Update the bounding rect. ID2D1SolidColorBrush* pBrush = nullptr; @@ -497,44 +501,6 @@ bool D2DWriteTextOutRenderer::GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** p return succeeded; } -bool D2DWriteTextOutRenderer::GetDWriteInkBox(CommonSalLayout const &rLayout, Rectangle & rOut) const -{ - rOut.SetEmpty(); - - DWRITE_FONT_METRICS aFontMetrics; - mpFontFace->GetMetrics(&aFontMetrics); - - Point aPos; - const GlyphItem* pGlyph; - std::vector<uint16_t> indices; - std::vector<Point> positions; - int nStart = 0; - while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart)) - { - positions.push_back(aPos); - indices.push_back(pGlyph->maGlyphId); - } - - auto aBoxes = GetGlyphInkBoxes(indices.data(), indices.data() + indices.size()); - if (aBoxes.empty()) - return false; - - auto p = positions.begin(); - for (auto &b:aBoxes) - { - b += *p; - p++; - rOut.Union(b); - } - - // The clipping rectangle is sometimes overzealous, add an extra pixel to - // remedy this. - if (!rOut.IsEmpty()) - rOut.expand(1); - - return true; -} - SalLayout* WinSalGraphics::GetTextLayout(ImplLayoutArgs& /*rArgs*/, int nFallbackLevel) { if (!mpWinFontEntry[nFallbackLevel]) @@ -643,7 +609,7 @@ void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout, HDC hDC, boo Point aPos(0, 0); int nGlyphCount(0); TextOutRenderer &render = TextOutRenderer::get(bUseDWrite); - bool result = render(rLayout, hDC, nullptr, &aPos, &nGlyphCount); + bool result = render(rLayout, *this, hDC, nullptr, &aPos, &nGlyphCount); assert(!result); } |