diff options
author | Khaled Hosny <khaled@aliftype.com> | 2022-11-18 22:16:52 +0200 |
---|---|---|
committer | خالد حسني <khaled@aliftype.com> | 2022-11-19 12:43:32 +0100 |
commit | 0cf71ca47b463c0b944e31aa7bd66fdaf9097f8e (patch) | |
tree | 63645e84d02d77c65e27b0f87b143d20d6b9b997 | |
parent | 6f0736c2981042f90e83cdd71b3f9c91dbe77661 (diff) |
vcl: remove unused D2DWriteTextOutRenderer code
Change-Id: I873d13e3a230c2679daea2080a102d89003c90c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142955
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
-rw-r--r-- | vcl/inc/win/DWriteTextRenderer.hxx | 11 | ||||
-rw-r--r-- | vcl/win/gdi/DWriteTextRenderer.cxx | 80 |
2 files changed, 6 insertions, 85 deletions
diff --git a/vcl/inc/win/DWriteTextRenderer.hxx b/vcl/inc/win/DWriteTextRenderer.hxx index b64cc48a1c6a..5f0dc35ddd58 100644 --- a/vcl/inc/win/DWriteTextRenderer.hxx +++ b/vcl/inc/win/DWriteTextRenderer.hxx @@ -47,14 +47,6 @@ public: HRESULT BindDC(HDC hDC, tools::Rectangle const & rRect = tools::Rectangle(0, 0, 1, 1)); - bool BindFont(HDC hDC) /*override*/; - bool ReleaseFont() /*override*/; - - std::vector<tools::Rectangle> GetGlyphInkBoxes(uint16_t const * pGid, uint16_t const * pGidEnd) const /*override*/; - ID2D1RenderTarget * GetRenderTarget() const { return mpRT; } - IDWriteFontFace * GetFontFace() const { return mpFontFace; } - float GetEmHeight() const { return mlfEmHeight; } - HRESULT CreateRenderTarget(bool bRenderingModeNatural); bool Ready() const; @@ -77,9 +69,6 @@ private: ID2D1DCRenderTarget * mpRT; const D2D1_RENDER_TARGET_PROPERTIES mRTProps; - IDWriteFontFace * mpFontFace; - float mlfEmHeight; - HDC mhDC; bool mbRenderingModeNatural; D2DTextAntiAliasMode meTextAntiAliasMode; }; diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx index c160166a541e..64d49696b102 100644 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -107,9 +107,6 @@ D2DWriteTextOutRenderer::D2DWriteTextOutRenderer(bool bRenderingModeNatural) mRTProps(D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED), 0, 0)), - mpFontFace(nullptr), - mlfEmHeight(0.0f), - mhDC(nullptr), mbRenderingModeNatural(bRenderingModeNatural), meTextAntiAliasMode(D2DTextAntiAliasMode::Default) { @@ -229,8 +226,9 @@ bool D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa return ExTextOutRenderer()(rLayout, rGraphics, hDC, bRenderingModeNatural); } - mlfEmHeight = 0; - if (!GetDWriteFaceFromHDC(hDC, &mpFontFace, &mlfEmHeight)) + IDWriteFontFace* pFontFace; + float lfEmHeight = 0; + if (!GetDWriteFaceFromHDC(hDC, &pFontFace, &lfEmHeight)) return false; const WinFontInstance& rWinFont = static_cast<const WinFontInstance&>(rLayout.GetFont()); @@ -268,8 +266,8 @@ bool D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa static_cast<FLOAT>(aPos.getY() - bounds.Top()) }; WinFontTransformGuard aTransformGuard(mpRT, fHScale, rLayout, baseline, pGlyph->IsVertical()); DWRITE_GLYPH_RUN glyphs = { - mpFontFace, - mlfEmHeight, + pFontFace, + lfEmHeight, 1, glyphIndices, glyphAdvances, @@ -287,7 +285,7 @@ bool D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa if (pBrush) pBrush->Release(); - ReleaseFont(); + pFontFace->Release(); if (hr == D2DERR_RECREATE_TARGET) { @@ -298,72 +296,6 @@ bool D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa return succeeded; } -bool D2DWriteTextOutRenderer::BindFont(HDC hDC) -{ - // A TextOutRender can only be bound to one font at a time, so the - assert(mpFontFace == nullptr); - if (mpFontFace) - { - ReleaseFont(); - return false; - } - - // Initially bind to an empty rectangle to get access to the font face, - // we'll update it once we've calculated a bounding rect in DrawGlyphs - if (FAILED(BindDC(mhDC = hDC))) - return false; - - mlfEmHeight = 0; - return GetDWriteFaceFromHDC(hDC, &mpFontFace, &mlfEmHeight); -} - -bool D2DWriteTextOutRenderer::ReleaseFont() -{ - mpFontFace->Release(); - mpFontFace = nullptr; - mhDC = nullptr; - - return true; -} - -// GetGlyphInkBoxes -// The inkboxes returned have their origin on the baseline, to a -ve value -// of Top() means the glyph extends abs(Top()) many pixels above the -// baseline, and +ve means the ink starts that many pixels below. -std::vector<tools::Rectangle> D2DWriteTextOutRenderer::GetGlyphInkBoxes(uint16_t const * pGid, uint16_t const * pGidEnd) const -{ - ptrdiff_t nGlyphs = pGidEnd - pGid; - if (nGlyphs < 0) - return std::vector<tools::Rectangle>(); - - DWRITE_FONT_METRICS aFontMetrics; - mpFontFace->GetMetrics(&aFontMetrics); - - std::vector<DWRITE_GLYPH_METRICS> metrics(nGlyphs); - if (!SUCCEEDED(CHECKHR(mpFontFace->GetDesignGlyphMetrics(pGid, nGlyphs, metrics.data())))) - return std::vector<tools::Rectangle>(); - - std::vector<tools::Rectangle> aOut(nGlyphs); - auto pOut = aOut.begin(); - for (auto &m : metrics) - { - const auto left = m.leftSideBearing; - const auto top = m.topSideBearing - m.verticalOriginY; - const auto right = m.advanceWidth - m.rightSideBearing; - const auto bottom = INT32(m.advanceHeight) - m.verticalOriginY - m.bottomSideBearing; - - // Scale to screen space. - pOut->SetLeft( std::floor(left * mlfEmHeight / aFontMetrics.designUnitsPerEm) ); - pOut->SetTop( std::floor(top * mlfEmHeight / aFontMetrics.designUnitsPerEm) ); - pOut->SetRight( std::ceil(right * mlfEmHeight / aFontMetrics.designUnitsPerEm) ); - pOut->SetBottom( std::ceil(bottom * mlfEmHeight / aFontMetrics.designUnitsPerEm) ); - - ++pOut; - } - - return aOut; -} - bool D2DWriteTextOutRenderer::GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** ppFontFace, float * lfSize) const { bool succeeded = SUCCEEDED(CHECKHR(mpGdiInterop->CreateFontFaceFromHdc(hDC, ppFontFace))); |