[Libreoffice-commits] core.git: vcl/skia
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Tue Aug 31 08:04:58 UTC 2021
vcl/skia/SkiaHelper.cxx | 54 +++++++++++++++++++++++++++++++++++-------------
1 file changed, 40 insertions(+), 14 deletions(-)
New commits:
commit bbf7dc39abf64c314e9c43c4d0554d1d7bdef3e7
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon Aug 30 11:51:25 2021 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Aug 31 10:04:23 2021 +0200
test at least creating Metal context when initializing Skia
Change-Id: Ic00236e7876039c3f5c0c1e719e829b844d1d2e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121271
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index 6881ad1cbf83..458f415befa4 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -158,7 +158,7 @@ static void writeSkiaRasterInfo()
writeToLog(logFile, "Compiler", skia_compiler_name());
}
-#ifdef SK_VULKAN
+#if defined(SK_VULKAN) || defined(SK_METAL)
static std::unique_ptr<sk_app::WindowContext> getTemporaryWindowContext();
#endif
@@ -170,6 +170,7 @@ static void checkDeviceDenylisted(bool blockDisable = false)
SkiaZone zone;
+ bool useRaster = false;
switch (renderMethodToUse())
{
case RenderVulkan:
@@ -204,32 +205,57 @@ static void checkDeviceDenylisted(bool blockDisable = false)
if (denylisted && !blockDisable)
{
disableRenderMethod(RenderVulkan);
- writeSkiaRasterInfo();
+ useRaster = true;
}
- break;
#else
SAL_WARN("vcl.skia", "Vulkan support not built in");
(void)blockDisable;
- [[fallthrough]];
+ useRaster = true;
#endif
+ break;
}
case RenderMetal:
+ {
#ifdef SK_METAL
- // Try to assume Metal always works, given that Mac doesn't have such as wide range of HW vendors as PC.
- // If there turns out to be problems, handle it similarly to Vulkan.
- SAL_INFO("vcl.skia", "Using Skia Metal mode");
- writeSkiaMetalInfo();
- break;
+ // First try if a GrDirectContext already exists.
+ std::unique_ptr<sk_app::WindowContext> temporaryWindowContext;
+ GrDirectContext* grDirectContext = sk_app::getMetalSharedGrDirectContext();
+ if (!grDirectContext)
+ {
+ // Create a temporary window context just to get the GrDirectContext,
+ // as an initial test of Metal functionality.
+ temporaryWindowContext = getTemporaryWindowContext();
+ grDirectContext = sk_app::getMetalSharedGrDirectContext();
+ }
+ if (grDirectContext) // Metal was initialized properly
+ {
+ // Try to assume Metal always works, given that Mac doesn't have such as wide range of HW vendors as PC.
+ // If there turns out to be problems, handle it similarly to Vulkan.
+ SAL_INFO("vcl.skia", "Using Skia Metal mode");
+ writeSkiaMetalInfo();
+ }
+ else
+ {
+ SAL_INFO("vcl.skia", "Metal could not be initialized");
+ disableRenderMethod(RenderMetal);
+ useRaster = true;
+ }
#else
SAL_WARN("vcl.skia", "Metal support not built in");
- [[fallthrough]];
+ useRaster = true;
#endif
+ break;
+ }
case RenderRaster:
- SAL_INFO("vcl.skia", "Using Skia raster mode");
- // software, never denylisted
- writeSkiaRasterInfo();
+ useRaster = true;
break;
}
+ if (useRaster)
+ {
+ SAL_INFO("vcl.skia", "Using Skia raster mode");
+ // software, never denylisted
+ writeSkiaRasterInfo();
+ }
done = true;
}
@@ -431,7 +457,7 @@ GrDirectContext* getSharedGrDirectContext()
return nullptr;
}
-#ifdef SK_VULKAN
+#if defined(SK_VULKAN) || defined(SK_METAL)
static std::unique_ptr<sk_app::WindowContext> getTemporaryWindowContext()
{
if (createGpuWindowContextFunction == nullptr)
More information about the Libreoffice-commits
mailing list