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 <win/salgdi.h>
19 #include <win/wingdiimpl.hxx>
20 #include <o3tl/lru_map.hxx>
21 #include <ControlCacheKey.hxx>
22 #include <svdata.hxx>
23 
24 #include <SkFont.h>
25 #include <SkFontMgr.h>
26 
27 class SkTypeface;
28 class ControlCacheKey;
29 
31 {
32 public:
33  SkiaCompatibleDC(SalGraphics& rGraphics, int x, int y, int width, int height);
34 
35  sk_sp<SkImage> getAsImageDiff(const SkiaCompatibleDC& white) const;
36 };
37 
39 {
40 private:
42 
43 public:
45 
46  virtual void DeInit() override;
47  virtual void freeResources() override;
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 
58  virtual void Flush() override;
59 
60  static void prepareSkia();
61 
62 protected:
63  virtual void createWindowContext(bool forceRaster = false) override;
64  virtual void performFlush() override;
65  static sk_sp<SkTypeface> createDirectWriteTypeface(HDC hdc, HFONT hfont);
66  static void initFontInfo();
67  inline static sal::systools::COMReference<IDWriteFactory> dwriteFactory;
68  inline static sal::systools::COMReference<IDWriteGdiInterop> dwriteGdiInterop;
69  inline static sk_sp<SkFontMgr> dwriteFontMgr;
70  inline static bool dwriteDone = false;
71  static SkFont::Edging fontEdging;
72 };
73 
74 typedef std::pair<ControlCacheKey, sk_sp<SkImage>> SkiaControlCachePair;
77 
79 {
81 
83 
84 public:
85  static SkiaControlCacheType& get();
86 };
87 
88 #endif
89 
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Interface used to share logic on sizing between SalVirtualDevices and SalFrames.
Definition: salgeom.hxx:63
virtual bool RenderAndCacheNativeControl(CompatibleDC &rWhite, CompatibleDC &rBlack, int nX, int nY, ControlCacheKey &aControlCacheKey) override
SkiaCompatibleDC(SalGraphics &rGraphics, int x, int y, int width, int height)
SkiaControlCacheType cache
Definition: win/gdiimpl.hxx:80
float x
virtual void createWindowContext(bool forceRaster=false) override
WinSalGraphics & mWinParent
Definition: win/gdiimpl.hxx:41
std::pair< ControlCacheKey, sk_sp< SkImage > > SkiaControlCachePair
Definition: win/gdiimpl.hxx:74
static void initFontInfo()
static void prepareSkia()
float y
static sk_sp< SkTypeface > createDirectWriteTypeface(HDC hdc, HFONT hfont)
virtual bool TryRenderCachedNativeControl(ControlCacheKey const &rControlCacheKey, int nX, int nY) override
sk_sp< SkImage > getAsImageDiff(const SkiaCompatibleDC &white) const
o3tl::lru_map< ControlCacheKey, sk_sp< SkImage >, ControlCacheHashFunction > SkiaControlCacheType
Definition: win/gdiimpl.hxx:76
virtual void DeInit() override
virtual void Flush() override
static SkFont::Edging fontEdging
Definition: win/gdiimpl.hxx:71
virtual void ClearDevFontCache() override
virtual void freeResources() override
WinSkiaSalGraphicsImpl(WinSalGraphics &rGraphics, SalGeometryProvider *mpProvider)
static sk_sp< SkFontMgr > dwriteFontMgr
Definition: win/gdiimpl.hxx:69
static sal::systools::COMReference< IDWriteFactory > dwriteFactory
Definition: win/gdiimpl.hxx:67
virtual void performFlush() override
virtual bool DrawTextLayout(const GenericSalLayout &layout) override
virtual bool UseRenderNativeControl() const override
Definition: win/gdiimpl.hxx:49
Class that creates (and destroys) a compatible Device Context.
Definition: win/salgdi.h:100
static sal::systools::COMReference< IDWriteGdiInterop > dwriteGdiInterop
Definition: win/gdiimpl.hxx:68