summaryrefslogtreecommitdiff
path: root/vcl/inc/skia
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-08-24 21:32:20 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-08-25 11:36:59 +0200
commit148ac7de372d0af3c3d20a5c94c12ca0b9cfd4ab (patch)
tree855a70f5151c473d777b6b590c4d4d4591a65daf /vcl/inc/skia
parentd5ec688e4b0aa97eed72ed56d53a5d014b59eb63 (diff)
use our own Skia surface when using GPU screen drawing
Previously the code called window context's getBackbufferSurface() once, and the repeatedly used it for drawing and then did swapBuffers(). This worked until version chrome/m91, now Skia requires that a screen drawing pass is calling getBackbufferSurface(), drawing to it and calling swapBuffers(). Since we do not always draw full window content and instead keep previous content, use a separate offscreen surface for that and for actual screen drawing just blit that to the screen surface. Change-Id: I36a5b3bb23a085936f4473a0e00d8e04c6b40dab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120966 Tested-by: Luboš Luňák <l.lunak@collabora.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/inc/skia')
-rw-r--r--vcl/inc/skia/gdiimpl.hxx12
-rw-r--r--vcl/inc/skia/osx/gdiimpl.hxx8
-rw-r--r--vcl/inc/skia/win/gdiimpl.hxx7
-rw-r--r--vcl/inc/skia/x11/gdiimpl.hxx5
4 files changed, 6 insertions, 26 deletions
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index a7ba10c3273b..c914c26752cc 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -25,13 +25,7 @@
#include <salgdiimpl.hxx>
#include <salgeom.hxx>
-#include <premac.h>
-#include <SkSurface.h>
-#include <SkRegion.h>
-#include <postmac.h>
-
-#include <prewin.h>
-#include <postwin.h>
+#include <skia/utils.hxx>
class SkiaFlushIdle;
class GenericSalLayout;
@@ -240,8 +234,8 @@ protected:
virtual bool avoidRecreateByResize() const;
void createWindowSurface(bool forceRaster = false);
virtual void createWindowSurfaceInternal(bool forceRaster = false) = 0;
- virtual void destroyWindowSurfaceInternal() = 0;
void createOffscreenSurface();
+ void flushSurfaceToWindowContext(const SkIRect& rect);
void privateDrawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth,
tools::Long nHeight, double nTransparency, bool blockAA = false);
@@ -321,6 +315,8 @@ protected:
SalGeometryProvider* mProvider;
// The Skia surface that is target of all the rendering.
sk_sp<SkSurface> mSurface;
+ // Note that mSurface may be a proxy surface and not the one from the window context.
+ std::unique_ptr<sk_app::WindowContext> mWindowContext;
bool mIsGPU; // whether the surface is GPU-backed
SkIRect mDirtyRect; // the area that has been changed since the last performFlush()
vcl::Region mClipRegion;
diff --git a/vcl/inc/skia/osx/gdiimpl.hxx b/vcl/inc/skia/osx/gdiimpl.hxx
index b9adccb370ea..4ffac5985edb 100644
--- a/vcl/inc/skia/osx/gdiimpl.hxx
+++ b/vcl/inc/skia/osx/gdiimpl.hxx
@@ -26,9 +26,7 @@ public:
AquaSkiaSalGraphicsImpl(AquaSalGraphics& rParent, AquaSharedAttributes& rShared);
virtual ~AquaSkiaSalGraphicsImpl() override;
- virtual void DeInit() override;
virtual void freeResources() override;
- // virtual void Flush() override;
virtual void UpdateGeometryProvider(SalGeometryProvider* provider) override
{
@@ -47,13 +45,9 @@ public:
private:
virtual void createWindowSurfaceInternal(bool forceRaster = false) override;
- virtual void destroyWindowSurfaceInternal() override;
virtual void performFlush() override;
- void flushToScreenRaster(const SkIRect& rect);
- void flushToScreenMetal(const SkIRect& rect);
+ void flushSurfaceToScreenCG(const SkIRect& rect);
static inline sk_sp<SkFontMgr> fontManager;
- // This one is used only for Metal, and only indirectly.
- std::unique_ptr<sk_app::WindowContext> mWindowContext;
};
#endif // INCLUDED_VCL_INC_SKIA_OSX_GDIIMPL_HXX
diff --git a/vcl/inc/skia/win/gdiimpl.hxx b/vcl/inc/skia/win/gdiimpl.hxx
index 2f85a9e3cf66..7e3f37ce435c 100644
--- a/vcl/inc/skia/win/gdiimpl.hxx
+++ b/vcl/inc/skia/win/gdiimpl.hxx
@@ -43,10 +43,6 @@ private:
public:
WinSkiaSalGraphicsImpl(WinSalGraphics& rGraphics, SalGeometryProvider* mpProvider);
- virtual ~WinSkiaSalGraphicsImpl() override;
-
- virtual void DeInit() override;
- virtual void freeResources() override;
virtual bool UseRenderNativeControl() const override { return true; }
virtual bool TryRenderCachedNativeControl(ControlCacheKey const& rControlCacheKey, int nX,
@@ -57,13 +53,13 @@ public:
virtual bool DrawTextLayout(const GenericSalLayout& layout) override;
virtual void ClearDevFontCache() override;
+ virtual void freeResources() override;
virtual void Flush() override;
static void prepareSkia();
protected:
virtual void createWindowSurfaceInternal(bool forceRaster = false) override;
- virtual void destroyWindowSurfaceInternal() override;
virtual void performFlush() override;
static sk_sp<SkTypeface> createDirectWriteTypeface(HDC hdc, HFONT hfont);
static void initFontInfo();
@@ -72,7 +68,6 @@ protected:
inline static sk_sp<SkFontMgr> dwriteFontMgr;
inline static bool dwriteDone = false;
static SkFont::Edging fontEdging;
- std::unique_ptr<sk_app::WindowContext> mWindowContext;
};
typedef std::pair<ControlCacheKey, sk_sp<SkImage>> SkiaControlCachePair;
diff --git a/vcl/inc/skia/x11/gdiimpl.hxx b/vcl/inc/skia/x11/gdiimpl.hxx
index df9421f54720..d85c7dc0e5c7 100644
--- a/vcl/inc/skia/x11/gdiimpl.hxx
+++ b/vcl/inc/skia/x11/gdiimpl.hxx
@@ -15,7 +15,6 @@
#include <unx/salgdi.h>
#include <unx/x11/x11gdiimpl.h>
#include <skia/gdiimpl.hxx>
-#include <skia/utils.hxx>
class VCL_PLUGIN_PUBLIC X11SkiaSalGraphicsImpl final : public SkiaSalGraphicsImpl,
public X11GraphicsImpl
@@ -25,10 +24,8 @@ private:
public:
X11SkiaSalGraphicsImpl(X11SalGraphics& rParent);
- virtual ~X11SkiaSalGraphicsImpl() override;
virtual void Init() override;
- virtual void DeInit() override;
virtual void freeResources() override;
virtual void Flush() override;
@@ -36,14 +33,12 @@ public:
private:
virtual void createWindowSurfaceInternal(bool forceRaster = false) override;
- virtual void destroyWindowSurfaceInternal() override;
virtual void performFlush() override;
virtual bool avoidRecreateByResize() const override;
static std::unique_ptr<sk_app::WindowContext>
createWindowContext(Display* display, Drawable drawable, const XVisualInfo* visual, int width,
int height, SkiaHelper::RenderMethod renderMethod, bool temporary);
friend std::unique_ptr<sk_app::WindowContext> createVulkanWindowContext(bool);
- std::unique_ptr<sk_app::WindowContext> mWindowContext;
};
#endif // INCLUDED_VCL_INC_SKIA_X11_GDIIMPL_HXX