LibreOffice Module vcl (master)  1
DWriteTextRenderer.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX
21 #define INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX
22 
23 #include <usp10.h>
24 #include <d2d1.h>
25 #include <dwrite.h>
26 
27 #include <win/winlayout.hxx>
28 
30 {
31  Default,
32  Aliased,
34  ClearType,
35 };
36 
38 {
39 public:
40  explicit D2DWriteTextOutRenderer();
41  virtual ~D2DWriteTextOutRenderer() override;
42 
43  bool operator ()(GenericSalLayout const &rLayout,
44  SalGraphics &rGraphics,
45  HDC hDC) override;
46 
47  HRESULT BindDC(HDC hDC, tools::Rectangle const & rRect = tools::Rectangle(0, 0, 1, 1));
48 
49  bool BindFont(HDC hDC) /*override*/;
50  bool ReleaseFont() /*override*/;
51 
52  std::vector<tools::Rectangle> GetGlyphInkBoxes(uint16_t const * pGid, uint16_t const * pGidEnd) const /*override*/;
53  ID2D1RenderTarget * GetRenderTarget() const { return mpRT; }
54  IDWriteFontFace * GetFontFace() const { return mpFontFace; }
55  float GetEmHeight() const { return mlfEmHeight; }
56 
57  HRESULT CreateRenderTarget();
58 
59  bool Ready() const;
60 
63 
64 private:
65  // This is a singleton object disable copy ctor and assignment operator
68 
69  bool GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** ppFontFace, float * lfSize) const;
70  bool performRender(GenericSalLayout const &rLayout, SalGraphics &rGraphics, HDC hDC, bool& bRetry);
71 
72  ID2D1Factory * mpD2DFactory;
73  IDWriteFactory * mpDWriteFactory;
74  IDWriteGdiInterop * mpGdiInterop;
75  ID2D1DCRenderTarget * mpRT;
76  const D2D1_RENDER_TARGET_PROPERTIES mRTProps;
77 
78  IDWriteFontFace * mpFontFace;
79  float mlfEmHeight;
80  HDC mhDC;
82 };
83 
89 {
90 public:
91  WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline);
93 
94 private:
95  ID2D1RenderTarget* mpRenderTarget;
96  D2D1::Matrix3x2F maTransform;
97 };
98 
99 #endif // INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX
100 
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< tools::Rectangle > GetGlyphInkBoxes(uint16_t const *pGid, uint16_t const *pGidEnd) const
virtual ~D2DWriteTextOutRenderer() override
IDWriteFontFace * mpFontFace
ID2D1DCRenderTarget * mpRT
IDWriteFontFace * GetFontFace() const
IDWriteFactory * mpDWriteFactory
IDWriteGdiInterop * mpGdiInterop
bool performRender(GenericSalLayout const &rLayout, SalGraphics &rGraphics, HDC hDC, bool &bRetry)
D2DTextAntiAliasMode
D2DWriteTextOutRenderer & operator=(const D2DWriteTextOutRenderer &)=delete
D2D1::Matrix3x2F maTransform
WinFontTransformGuard(ID2D1RenderTarget *pRenderTarget, float fHScale, const GenericSalLayout &rLayout, const D2D1_POINT_2F &rBaseline)
HRESULT BindDC(HDC hDC, tools::Rectangle const &rRect=tools::Rectangle(0, 0, 1, 1))
D2DTextAntiAliasMode meTextAntiAliasMode
ID2D1RenderTarget * GetRenderTarget() const
bool GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace **ppFontFace, float *lfSize) const
const D2D1_RENDER_TARGET_PROPERTIES mRTProps
Sets and unsets the needed DirectWrite transform to support the font's horizontal scaling and rotatio...
void changeTextAntiAliasMode(D2DTextAntiAliasMode eMode)
bool operator()(GenericSalLayout const &rLayout, SalGraphics &rGraphics, HDC hDC) override
ID2D1RenderTarget * mpRenderTarget
bool BindFont(HDC hDC)