1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX
21 #define INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX
27 #include <win/winlayout.hxx>
29 enum class D2DTextAntiAliasMode
37 class D2DWriteTextOutRenderer
: public TextOutRenderer
40 explicit D2DWriteTextOutRenderer();
41 virtual ~D2DWriteTextOutRenderer() override
;
43 bool operator ()(GenericSalLayout
const &rLayout
,
44 SalGraphics
&rGraphics
,
47 HRESULT
BindDC(HDC hDC
, tools::Rectangle
const & rRect
= tools::Rectangle(0, 0, 1, 1));
49 bool BindFont(HDC hDC
) /*override*/;
50 bool ReleaseFont() /*override*/;
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
; }
57 HRESULT
CreateRenderTarget();
61 void applyTextAntiAliasMode();
62 void changeTextAntiAliasMode(D2DTextAntiAliasMode eMode
);
65 // This is a singleton object disable copy ctor and assignment operator
66 D2DWriteTextOutRenderer(const D2DWriteTextOutRenderer
&) = delete;
67 D2DWriteTextOutRenderer
& operator = (const D2DWriteTextOutRenderer
&) = delete;
69 bool GetDWriteFaceFromHDC(HDC hDC
, IDWriteFontFace
** ppFontFace
, float * lfSize
) const;
70 bool performRender(GenericSalLayout
const &rLayout
, SalGraphics
&rGraphics
, HDC hDC
, bool& bRetry
);
72 ID2D1Factory
* mpD2DFactory
;
73 IDWriteFactory
* mpDWriteFactory
;
74 IDWriteGdiInterop
* mpGdiInterop
;
75 ID2D1DCRenderTarget
* mpRT
;
76 const D2D1_RENDER_TARGET_PROPERTIES mRTProps
;
78 IDWriteFontFace
* mpFontFace
;
81 D2DTextAntiAliasMode meTextAntiAliasMode
;
85 * Sets and unsets the needed DirectWrite transform to support the font's horizontal scaling and
88 class WinFontTransformGuard
91 WinFontTransformGuard(ID2D1RenderTarget
* pRenderTarget
, float fHScale
, const GenericSalLayout
& rLayout
, const D2D1_POINT_2F
& rBaseline
, bool bIsVertical
);
92 ~WinFontTransformGuard();
95 ID2D1RenderTarget
* mpRenderTarget
;
96 D2D1::Matrix3x2F maTransform
;
99 #endif // INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */