From 4b56c32512305b3c9385981f72e6ce4b609ecff6 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Fri, 22 Nov 2019 15:12:57 +0100 Subject: don't fall back to raster if Skia is first asked for offscreen surface This is rare, but it may happen. Since now the code shared just one GrContext properly, this is not really a problem anymore (and the extra WindowContext creation shouldn't be hopefully noticeable either). Change-Id: I50887b7512e778b70870690a3f672b27cc7f2d21 --- vcl/skia/gdiimpl.cxx | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index dfa7eb7a7320..b109b698914b 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -245,26 +245,22 @@ void SkiaSalGraphicsImpl::createOffscreenSurface() { mOffscreenGrContext = sk_app::VulkanWindowContext::getSharedGrContext(); GrContext* grContext = mOffscreenGrContext.getGrContext(); - // We may not get a GrContext if called before any onscreen window is created, - // but that happens very early, so this should be rare and insignificant. - // Unittests are an exception, they usually do not create any windows, - // so in that case do create GrContext that has no window associated. + // We may not get a GrContext if called before any onscreen window is created. if (!grContext) { - static bool isUnitTest = (getenv("LO_TESTNAME") != nullptr); - if (isUnitTest) - { - // Create temporary WindowContext with no window. That will fail, - // but it will initialize the shared GrContext. - createWindowContext(); - // Keep a reference. - sk_app::VulkanWindowContext::SharedGrContext context - = sk_app::VulkanWindowContext::getSharedGrContext(); - // Destroy the temporary WindowContext. - destroySurface(); - mOffscreenGrContext = context; - grContext = mOffscreenGrContext.getGrContext(); - } + SAL_INFO("vcl.skia", + "creating Vulkan offscreen GPU surface before any window exists"); + // Create temporary WindowContext with no window. That will fail, + // but it will initialize the shared GrContext. + createWindowContext(); + // Keep a reference. + sk_app::VulkanWindowContext::SharedGrContext context + = sk_app::VulkanWindowContext::getSharedGrContext(); + // Destroy the temporary WindowContext. + destroySurface(); + // Keep a reference until the surface is destroyed. + mOffscreenGrContext = context; + grContext = mOffscreenGrContext.getGrContext(); } if (grContext) { -- cgit