diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-11-06 16:14:50 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2019-11-27 09:55:16 +0100 |
commit | 54be644c092eebb8be57a251556fe3f0e5f99e57 (patch) | |
tree | 812d0e907d51ed41ba3441a4e9e427311eb29ed7 /vcl/skia/x11/gdiimpl.cxx | |
parent | 76ee0452b82f69f273526ba8a8c879ce17acb547 (diff) |
make SkiaSalGraphicsImpl use GPU-backed SkSurface also for offscreen
Skia's sk_app::WindowContext can create GPU-backed SkSurface only
for windows, but we also use virtual devices that are not windows.
Fortunately, SkSurface can be created GPU-backed from GrContext*
and sk_gpu_test::GrContextFactory seems to provide it easily.
It is not completely clear to me what the rules are on mixing
SkSurface's with different GrContext* (see the comment
in SkiaSalGraphicsImpl::copyBits()), but it seems to work fine.
Change-Id: I8110b67c41ab092e0c4b6a0973d6bed8a408c4c1
Diffstat (limited to 'vcl/skia/x11/gdiimpl.cxx')
-rw-r--r-- | vcl/skia/x11/gdiimpl.cxx | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx index fff94936a33d..af602d35bede 100644 --- a/vcl/skia/x11/gdiimpl.cxx +++ b/vcl/skia/x11/gdiimpl.cxx @@ -21,6 +21,8 @@ #include <tools/sk_app/unix/WindowContextFactory_unix.h> #include <tools/sk_app/WindowContext.h> +#include <skia/vulkan.hxx> + X11SkiaSalGraphicsImpl::X11SkiaSalGraphicsImpl(X11SalGraphics& rParent) : SkiaSalGraphicsImpl(rParent, rParent.GetGeometryProvider()) , mX11Parent(rParent) @@ -38,8 +40,25 @@ void X11SkiaSalGraphicsImpl::Init() void X11SkiaSalGraphicsImpl::createSurface() { + destroySurface(); if (isOffscreen()) + { + switch (renderMethodToUse()) + { + case RenderVulkan: + mSurface = SkSurface::MakeRenderTarget( + SkiaVulkanGrContext::getGrContext(), SkBudgeted::kNo, + SkImageInfo::MakeN32Premul(GetWidth(), GetHeight())); + assert(mSurface.get()); +#ifdef DBG_UTIL + prefillSurface(); +#endif + return; + default: + break; + } return SkiaSalGraphicsImpl::createSurface(); + } sk_app::DisplayParams displayParams; // TODO The Skia Xlib code actually requires the non-native color type to work properly. // Use a macro to hide an unreachable code warning. @@ -59,7 +78,6 @@ void X11SkiaSalGraphicsImpl::createSurface() // Avoid this somehow. winInfo.fWidth = GetWidth(); winInfo.fHeight = GetHeight(); - destroySurface(); switch (renderMethodToUse()) { case RenderRaster: |