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#pragma once
21
22#include <usp10.h>
23#include <d2d1.h>
24#include <dwrite.h>
25
26#include <win/winlayout.hxx>
27
29{
30 Default,
31 Aliased,
34};
35
37{
38public:
39 explicit D2DWriteTextOutRenderer(bool bRenderingModeNatural);
40 virtual ~D2DWriteTextOutRenderer() override;
41
42 bool operator()(GenericSalLayout const &rLayout,
43 SalGraphics &rGraphics,
44 HDC hDC,
45 bool bRenderingModeNatural) override;
46
47 HRESULT BindDC(HDC hDC, tools::Rectangle const & rRect = tools::Rectangle(0, 0, 1, 1));
48
49 HRESULT CreateRenderTarget(bool bRenderingModeNatural);
50
51 bool Ready() const;
52
53 void applyTextAntiAliasMode(bool bRenderingModeNatural);
54
56
57private:
58 // This is a singleton object disable copy ctor and assignment operator
61
62 IDWriteFontFace* GetDWriteFace(const WinFontInstance& rWinFont, float * lfSize) const;
63 bool performRender(GenericSalLayout const &rLayout, SalGraphics &rGraphics, HDC hDC, bool& bRetry, bool bRenderingModeNatural);
64
65 ID2D1Factory * mpD2DFactory;
66 IDWriteFactory * mpDWriteFactory;
67 ID2D1DCRenderTarget * mpRT;
68 const D2D1_RENDER_TARGET_PROPERTIES mRTProps;
69
72};
73
79{
80public:
81 WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline, bool bIsVertical);
83
84private:
85 ID2D1RenderTarget* mpRenderTarget;
86 D2D1::Matrix3x2F maTransform;
87};
88
89/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
D2DTextAntiAliasMode
HRESULT CreateRenderTarget(bool bRenderingModeNatural)
const D2D1_RENDER_TARGET_PROPERTIES mRTProps
ID2D1DCRenderTarget * mpRT
D2DWriteTextOutRenderer & operator=(const D2DWriteTextOutRenderer &)=delete
void applyTextAntiAliasMode(bool bRenderingModeNatural)
virtual ~D2DWriteTextOutRenderer() override
D2DTextAntiAliasMode meTextAntiAliasMode
bool performRender(GenericSalLayout const &rLayout, SalGraphics &rGraphics, HDC hDC, bool &bRetry, bool bRenderingModeNatural)
IDWriteFontFace * GetDWriteFace(const WinFontInstance &rWinFont, float *lfSize) const
IDWriteFactory * mpDWriteFactory
bool operator()(GenericSalLayout const &rLayout, SalGraphics &rGraphics, HDC hDC, bool bRenderingModeNatural) override
D2DWriteTextOutRenderer(const D2DWriteTextOutRenderer &)=delete
HRESULT BindDC(HDC hDC, tools::Rectangle const &rRect=tools::Rectangle(0, 0, 1, 1))
D2DWriteTextOutRenderer(bool bRenderingModeNatural)
Sets and unsets the needed DirectWrite transform to support the font's horizontal scaling and rotatio...
WinFontTransformGuard(ID2D1RenderTarget *pRenderTarget, float fHScale, const GenericSalLayout &rLayout, const D2D1_POINT_2F &rBaseline, bool bIsVertical)
ID2D1RenderTarget * mpRenderTarget
D2D1::Matrix3x2F maTransform