LibreOffice Module vcl (master)  1
skia/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 <vcl/dllapi.h>
15 
16 #include <skia/gdiimpl.hxx>
17 #include <win/salgdi.h>
18 #include <win/wingdiimpl.hxx>
19 #include <o3tl/lru_map.hxx>
20 #include <ControlCacheKey.hxx>
21 #include <svdata.hxx>
22 
23 #include <SkFont.h>
24 
25 class SkTypeface;
26 class SkFontMgr;
27 class ControlCacheKey;
28 
30 {
31 public:
32  SkiaCompatibleDC(SalGraphics& rGraphics, int x, int y, int width, int height);
33 
34  virtual std::unique_ptr<Texture> getAsMaskTexture() const override;
35 
36  sk_sp<SkImage> getAsImage() const;
37  sk_sp<SkImage> getAsMaskImage() const;
38  sk_sp<SkImage> getAsImageDiff(const SkiaCompatibleDC& white) const;
39 
40  struct Texture;
41 };
42 
44 {
45  sk_sp<SkImage> image;
46  virtual bool isValid() const { return image.get(); }
47  virtual int GetWidth() const { return image->width(); }
48  virtual int GetHeight() const { return image->height(); }
49 };
50 
52 {
53 private:
55 
56 public:
58 
59  virtual void DeInit() override;
60  virtual void freeResources() override;
61 
62  virtual bool UseRenderNativeControl() const override { return true; }
63  virtual bool TryRenderCachedNativeControl(ControlCacheKey const& rControlCacheKey, int nX,
64  int nY) override;
65  virtual bool RenderAndCacheNativeControl(CompatibleDC& rWhite, CompatibleDC& rBlack, int nX,
66  int nY, ControlCacheKey& aControlCacheKey) override;
67 
68  virtual bool DrawTextLayout(const GenericSalLayout& layout) override;
69  virtual void ClearDevFontCache() override;
70 
71  static void prepareSkia();
72 
73 protected:
74  virtual void createWindowContext() override;
75  virtual void performFlush() override;
76  sk_sp<SkTypeface> createDirectWriteTypeface(const LOGFONTW& logFont);
77  SkFont::Edging getFontEdging();
78  IDWriteFactory* dwriteFactory;
79  IDWriteGdiInterop* dwriteGdiInterop;
80  sk_sp<SkFontMgr> dwriteFontMgr;
81  bool dwriteDone = false;
82  SkFont::Edging fontEdging;
83  bool fontEdgingDone = false;
84 };
85 
86 typedef std::pair<ControlCacheKey, sk_sp<SkImage>> SkiaControlCachePair;
89 
91 {
93 
95 
96 public:
97  static SkiaControlCacheType& get();
98 };
99 
100 #endif
101 
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Interface used to share logic on sizing between SalVirtualDevices and SalFrames.
Definition: salgeom.hxx:62
IDWriteGdiInterop * dwriteGdiInterop
SkFont::Edging getFontEdging()
virtual bool RenderAndCacheNativeControl(CompatibleDC &rWhite, CompatibleDC &rBlack, int nX, int nY, ControlCacheKey &aControlCacheKey) override
sk_sp< SkTypeface > createDirectWriteTypeface(const LOGFONTW &logFont)
virtual int GetHeight() const
virtual int GetWidth() const
o3tl::lru_map< ControlCacheKey, sk_sp< SkImage >, ControlCacheHashFunction > SkiaControlCacheType
SkiaCompatibleDC(SalGraphics &rGraphics, int x, int y, int width, int height)
SkiaControlCacheType cache
float x
WinSalGraphics & mWinParent
sk_sp< SkImage > getAsImage() const
virtual void createWindowContext() override
static void prepareSkia()
float y
virtual bool TryRenderCachedNativeControl(ControlCacheKey const &rControlCacheKey, int nX, int nY) override
sk_sp< SkImage > getAsImageDiff(const SkiaCompatibleDC &white) const
virtual std::unique_ptr< Texture > getAsMaskTexture() const override
Obtain the texture in format for WinSalGraphicsImplBase::DrawTextMask().
virtual void DeInit() override
virtual void ClearDevFontCache() override
sk_sp< SkImage > getAsMaskImage() const
virtual void freeResources() override
WinSkiaSalGraphicsImpl(WinSalGraphics &rGraphics, SalGeometryProvider *mpProvider)
sk_sp< SkFontMgr > dwriteFontMgr
virtual void performFlush() override
IDWriteFactory * dwriteFactory
virtual bool DrawTextLayout(const GenericSalLayout &layout) override
virtual bool UseRenderNativeControl() const override
virtual bool isValid() const
std::pair< ControlCacheKey, sk_sp< SkImage > > SkiaControlCachePair
Class that creates (and destroys) a compatible Device Context.
Definition: win/salgdi.h:100