summaryrefslogtreecommitdiff
path: root/vcl/skia
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-08-25 11:01:39 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-08-26 11:47:22 +0200
commiteaf4f6d3b1e64bc7b057e70cffe0bda0ed42c49f (patch)
tree1d0966b937e97558ca8c4778b40f46e88078b092 /vcl/skia
parent5f691db859b277fb7f185cddeace981169e1180e (diff)
update Skia to chrome/m86 snapshot
Change-Id: Id0c0679bc1ca546a75f71d4716ba151ae46569bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101311 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/skia')
-rw-r--r--vcl/skia/README12
-rw-r--r--vcl/skia/SkiaHelper.cxx72
-rw-r--r--vcl/skia/gdiimpl.cxx2
-rw-r--r--vcl/skia/x11/gdiimpl.cxx2
4 files changed, 45 insertions, 43 deletions
diff --git a/vcl/skia/README b/vcl/skia/README
index c2077c5f0c25..f178ef8f3b76 100644
--- a/vcl/skia/README
+++ b/vcl/skia/README
@@ -59,18 +59,18 @@ You can also use 'visualbackendtest' to visually check some operations. Use some
SAL_SKIA=raster SAL_ENABLESKIA=1 SAL_USE_VCLPLUGIN=gen [srcdir]/bin/run visualbackendtest
-GrContext sharing:
-==================
+GrDirectContext sharing:
+========================
We use Skia's sk_app::WindowContext class for creating surfaces for windows, that class
takes care of the internals. But of offscreen drawing, we need an instance of class
-GrContext. There is sk_app::WindowContext::getGrContext(), but each instance creates
-its own GrContext, and apparently it does not work to mix them. Which means that
+GrDirectContext. There is sk_app::WindowContext::getGrDirectContext(), but each instance creates
+its own GrDirectContext, and apparently it does not work to mix them. Which means that
for offscreen drawing we would need to know which window (and only that window)
the contents will be eventually painted to, which is not possible (it may not even
be known at the time).
-To solve this problem we patch sk_app::WindowContext to create just one GrContext object
-and share it between instances. Additionally, using sk_app::WindowContext::SharedGrContext
+To solve this problem we patch sk_app::WindowContext to create just one GrDirectContext object
+and share it between instances. Additionally, using sk_app::WindowContext::SharedGrDirectContext
it is possible to share it also for offscreen drawing, including keeping proper reference
count.
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index cd8fca063a7e..651e0d9c878d 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -37,6 +37,7 @@ bool isVCLSkiaEnabled() { return false; }
#include <SkPaint.h>
#include <SkSurface.h>
#include <SkGraphics.h>
+#include <GrDirectContext.h>
#include <skia_compiler.hxx>
#include <skia_opts.hxx>
@@ -140,7 +141,7 @@ static void writeSkiaRasterInfo()
writeToLog(logFile, "Compiler", skia_compiler_name());
}
-static sk_app::VulkanWindowContext::SharedGrContext getTemporaryGrContext();
+static sk_app::VulkanWindowContext::SharedGrDirectContext getTemporaryGrDirectContext();
static void checkDeviceDenylisted(bool blockDisable = false)
{
@@ -154,23 +155,23 @@ static void checkDeviceDenylisted(bool blockDisable = false)
{
case RenderVulkan:
{
- // First try if a GrContext already exists.
- sk_app::VulkanWindowContext::SharedGrContext grContext
- = sk_app::VulkanWindowContext::getSharedGrContext();
- if (!grContext.getGrContext())
+ // First try if a GrDirectContext already exists.
+ sk_app::VulkanWindowContext::SharedGrDirectContext grDirectContext
+ = sk_app::VulkanWindowContext::getSharedGrDirectContext();
+ if (!grDirectContext.getGrDirectContext())
{
// This function is called from isVclSkiaEnabled(), which
// may be called when deciding which X11 visual to use,
// and that visual is normally needed when creating
- // Skia's VulkanWindowContext, which is needed for the GrContext.
- // Avoid the loop by creating a temporary GrContext
+ // Skia's VulkanWindowContext, which is needed for the GrDirectContext.
+ // Avoid the loop by creating a temporary GrDirectContext
// that will use the default X11 visual (that shouldn't matter
// for just finding out information about Vulkan) and destroying
// the temporary context will clean up again.
- grContext = getTemporaryGrContext();
+ grDirectContext = getTemporaryGrDirectContext();
}
bool denylisted = true; // assume the worst
- if (grContext.getGrContext()) // Vulkan was initialized properly
+ if (grDirectContext.getGrDirectContext()) // Vulkan was initialized properly
{
denylisted
= isVulkanDenylisted(sk_app::VulkanWindowContext::getPhysDeviceProperties());
@@ -324,7 +325,7 @@ void disableRenderMethod(RenderMethod method)
methodToUse = RenderRaster;
}
-static sk_app::VulkanWindowContext::SharedGrContext* sharedGrContext;
+static sk_app::VulkanWindowContext::SharedGrDirectContext* sharedGrDirectContext;
static std::unique_ptr<sk_app::WindowContext> (*createVulkanWindowContextFunction)(bool) = nullptr;
static void setCreateVulkanWindowContext(std::unique_ptr<sk_app::WindowContext> (*function)(bool))
@@ -332,22 +333,22 @@ static void setCreateVulkanWindowContext(std::unique_ptr<sk_app::WindowContext>
createVulkanWindowContextFunction = function;
}
-GrContext* getSharedGrContext()
+GrDirectContext* getSharedGrDirectContext()
{
SkiaZone zone;
assert(renderMethodToUse() == RenderVulkan);
- if (sharedGrContext)
- return sharedGrContext->getGrContext();
+ if (sharedGrDirectContext)
+ return sharedGrDirectContext->getGrDirectContext();
// TODO mutex?
- // Set up the shared GrContext from Skia's (patched) VulkanWindowContext, if it's been
+ // Set up the shared GrDirectContext from Skia's (patched) VulkanWindowContext, if it's been
// already set up.
- sk_app::VulkanWindowContext::SharedGrContext context
- = sk_app::VulkanWindowContext::getSharedGrContext();
- GrContext* grContext = context.getGrContext();
- if (grContext)
+ sk_app::VulkanWindowContext::SharedGrDirectContext context
+ = sk_app::VulkanWindowContext::getSharedGrDirectContext();
+ GrDirectContext* grDirectContext = context.getGrDirectContext();
+ if (grDirectContext)
{
- sharedGrContext = new sk_app::VulkanWindowContext::SharedGrContext(context);
- return grContext;
+ sharedGrDirectContext = new sk_app::VulkanWindowContext::SharedGrDirectContext(context);
+ return grDirectContext;
}
static bool done = false;
if (done)
@@ -357,24 +358,24 @@ GrContext* getSharedGrContext()
return nullptr; // not initialized properly (e.g. used from a VCL backend with no Skia support)
std::unique_ptr<sk_app::WindowContext> tmpContext = createVulkanWindowContextFunction(false);
// Set up using the shared context created by the call above, if successful.
- context = sk_app::VulkanWindowContext::getSharedGrContext();
- grContext = context.getGrContext();
- if (grContext)
+ context = sk_app::VulkanWindowContext::getSharedGrDirectContext();
+ grDirectContext = context.getGrDirectContext();
+ if (grDirectContext)
{
- sharedGrContext = new sk_app::VulkanWindowContext::SharedGrContext(context);
- return grContext;
+ sharedGrDirectContext = new sk_app::VulkanWindowContext::SharedGrDirectContext(context);
+ return grDirectContext;
}
disableRenderMethod(RenderVulkan);
return nullptr;
}
-static sk_app::VulkanWindowContext::SharedGrContext getTemporaryGrContext()
+static sk_app::VulkanWindowContext::SharedGrDirectContext getTemporaryGrDirectContext()
{
if (createVulkanWindowContextFunction == nullptr)
- return sk_app::VulkanWindowContext::SharedGrContext();
+ return sk_app::VulkanWindowContext::SharedGrDirectContext();
std::unique_ptr<sk_app::WindowContext> tmpContext = createVulkanWindowContextFunction(true);
// Set up using the shared context created by the call above, if successful.
- return sk_app::VulkanWindowContext::getSharedGrContext();
+ return sk_app::VulkanWindowContext::getSharedGrDirectContext();
}
sk_sp<SkSurface> createSkSurface(int width, int height, SkColorType type)
@@ -386,10 +387,10 @@ sk_sp<SkSurface> createSkSurface(int width, int height, SkColorType type)
{
case SkiaHelper::RenderVulkan:
{
- if (GrContext* grContext = getSharedGrContext())
+ if (GrDirectContext* grDirectContext = getSharedGrDirectContext())
{
surface = SkSurface::MakeRenderTarget(
- grContext, SkBudgeted::kNo,
+ grDirectContext, SkBudgeted::kNo,
SkImageInfo::Make(width, height, type, kPremul_SkAlphaType));
assert(surface);
#ifdef DBG_UTIL
@@ -419,10 +420,11 @@ sk_sp<SkImage> createSkImage(const SkBitmap& bitmap)
{
case SkiaHelper::RenderVulkan:
{
- if (GrContext* grContext = getSharedGrContext())
+ if (GrDirectContext* grDirectContext = getSharedGrDirectContext())
{
- sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(
- grContext, SkBudgeted::kNo, bitmap.info().makeAlphaType(kPremul_SkAlphaType));
+ sk_sp<SkSurface> surface
+ = SkSurface::MakeRenderTarget(grDirectContext, SkBudgeted::kNo,
+ bitmap.info().makeAlphaType(kPremul_SkAlphaType));
assert(surface);
SkPaint paint;
paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha
@@ -519,8 +521,8 @@ void removeCachedImage(sk_sp<SkImage> image)
void cleanup()
{
- delete sharedGrContext;
- sharedGrContext = nullptr;
+ delete sharedGrDirectContext;
+ sharedGrDirectContext = nullptr;
delete imageCache;
imageCache = nullptr;
imageCacheSize = 0;
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 52ce4cc2b96f..25decef1c0ed 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -282,7 +282,7 @@ void SkiaSalGraphicsImpl::createOffscreenSurface()
{
case SkiaHelper::RenderVulkan:
{
- if (SkiaHelper::getSharedGrContext())
+ if (SkiaHelper::getSharedGrDirectContext())
{
mSurface = SkiaHelper::createSkSurface(width, height);
assert(mSurface);
diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index 1058aaf0f8f4..0f430c4f8100 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -70,7 +70,7 @@ X11SkiaSalGraphicsImpl::createWindowContext(Display* display, Drawable drawable,
winInfo.fWidth = width;
winInfo.fHeight = height;
#ifdef DBG_UTIL
- // Our patched Skia has VulkanWindowContext that shares GrContext, which requires
+ // Our patched Skia has VulkanWindowContext that shares grDirectContext, which requires
// that the X11 visual is always the same. Ensure it is so.
static VisualID checkVisualID = -1U;
// Exception is for the temporary case during startup, when SkiaHelper's