LibreOffice Module vcl (master) 1
win/gdiimpl.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
10#ifndef INCLUDED_VCL_INC_SKIA_WIN_GDIIMPL_HXX
11#define INCLUDED_VCL_INC_SKIA_WIN_GDIIMPL_HXX
12
13#include <memory>
14#include <systools/win32/comtools.hxx>
15
16#include <vcl/dllapi.h>
17#include <skia/gdiimpl.hxx>
18#include <skia/utils.hxx>
19#include <win/salgdi.h>
20#include <win/wingdiimpl.hxx>
21#include <o3tl/lru_map.hxx>
22#include <ControlCacheKey.hxx>
23#include <svdata.hxx>
24
25#include <SkFont.h>
26#include <SkFontMgr.h>
27
28#include <dwrite_3.h>
29
30class SkTypeface;
31class ControlCacheKey;
32
34{
35public:
36 SkiaCompatibleDC(SalGraphics& rGraphics, int x, int y, int width, int height);
37
38 sk_sp<SkImage> getAsImageDiff(const SkiaCompatibleDC& white) const;
39};
40
42{
43private:
45
46public:
48
49 virtual bool UseRenderNativeControl() const override { return true; }
50 virtual bool TryRenderCachedNativeControl(ControlCacheKey const& rControlCacheKey, int nX,
51 int nY) override;
52 virtual bool RenderAndCacheNativeControl(CompatibleDC& rWhite, CompatibleDC& rBlack, int nX,
53 int nY, ControlCacheKey& aControlCacheKey) override;
54
55 virtual bool DrawTextLayout(const GenericSalLayout& layout) override;
56 virtual void ClearDevFontCache() override;
57 virtual void ClearNativeControlCache() override;
58
59 virtual void freeResources() override;
60 virtual void Flush() override;
61
62 static void prepareSkia();
63
64protected:
65 virtual void createWindowSurfaceInternal(bool forceRaster = false) override;
66 static sk_sp<SkTypeface> createDirectWriteTypeface(HDC hdc, HFONT hfont);
67 static void initFontInfo();
68 inline static sal::systools::COMReference<IDWriteFactory> dwriteFactory;
69 inline static sal::systools::COMReference<IDWriteGdiInterop> dwriteGdiInterop;
70 inline static sal::systools::COMReference<IDWriteFontSetBuilder> dwriteFontSetBuilder;
71 inline static sal::systools::COMReference<IDWriteFontCollection1> dwritePrivateCollection;
72 inline static sk_sp<SkFontMgr> dwriteFontMgr;
73 inline static bool dwriteDone = false;
74 static SkFont::Edging fontEdging;
75};
76
77typedef std::pair<ControlCacheKey, sk_sp<SkImage>> SkiaControlCachePair;
80
82{
84
86
87public:
89};
90
91#endif
92
93/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Class that creates (and destroys) a compatible Device Context.
Definition: win/salgdi.h:92
Interface used to share logic on sizing between SalVirtualDevices and SalFrames.
Definition: salgeom.hxx:80
SkiaCompatibleDC(SalGraphics &rGraphics, int x, int y, int width, int height)
sk_sp< SkImage > getAsImageDiff(const SkiaCompatibleDC &white) const
static SkiaControlCacheType & get()
SkiaControlCacheType cache
Definition: win/gdiimpl.hxx:83
WinSalGraphics never owns the HDC it uses to draw, because the HDC can have various origins with diff...
Definition: win/salgdi.h:139
static sal::systools::COMReference< IDWriteFactory > dwriteFactory
Definition: win/gdiimpl.hxx:68
virtual void createWindowSurfaceInternal(bool forceRaster=false) override
virtual bool TryRenderCachedNativeControl(ControlCacheKey const &rControlCacheKey, int nX, int nY) override
static void initFontInfo()
static sal::systools::COMReference< IDWriteFontCollection1 > dwritePrivateCollection
Definition: win/gdiimpl.hxx:71
WinSalGraphics & mWinParent
Definition: win/gdiimpl.hxx:44
static sal::systools::COMReference< IDWriteFontSetBuilder > dwriteFontSetBuilder
Definition: win/gdiimpl.hxx:70
virtual bool UseRenderNativeControl() const override
Definition: win/gdiimpl.hxx:49
virtual void ClearNativeControlCache() override
virtual bool RenderAndCacheNativeControl(CompatibleDC &rWhite, CompatibleDC &rBlack, int nX, int nY, ControlCacheKey &aControlCacheKey) override
static sk_sp< SkTypeface > createDirectWriteTypeface(HDC hdc, HFONT hfont)
virtual bool DrawTextLayout(const GenericSalLayout &layout) override
virtual void freeResources() override
WinSkiaSalGraphicsImpl(WinSalGraphics &rGraphics, SalGeometryProvider *mpProvider)
static sal::systools::COMReference< IDWriteGdiInterop > dwriteGdiInterop
Definition: win/gdiimpl.hxx:69
virtual void Flush() override
virtual void ClearDevFontCache() override
static void prepareSkia()
static sk_sp< SkFontMgr > dwriteFontMgr
Definition: win/gdiimpl.hxx:72
static SkFont::Edging fontEdging
Definition: win/gdiimpl.hxx:74
std::pair< ControlCacheKey, sk_sp< SkImage > > SkiaControlCachePair
Definition: win/gdiimpl.hxx:77
o3tl::lru_map< ControlCacheKey, sk_sp< SkImage >, ControlCacheHashFunction > SkiaControlCacheType
Definition: win/gdiimpl.hxx:79