From 0ce35e70da08cccb20302f1acc36521dc1b1bec2 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 11 Mar 2025 15:06:56 +0200 Subject: [PATCH] update to skia m133 Change-Id: Id12146bfd28003acc146fc45fdea4d9e4323539e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182778 Tested-by: Jenkins Reviewed-by: Noel Grandin --- download.lst | 4 +- external/skia/Library_skia.mk | 18 ++++- external/skia/fix-warnings.patch.1 | 4 +- external/skia/make-api-visible.patch.1 | 70 ++++++++++-------- external/skia/share-grcontext.patch.1 | 71 +++++++++++-------- external/skia/swap-buffers-rect.patch.1 | 8 +-- .../windows-raster-surface-no-copies.patch.1 | 4 +- vcl/skia/osx/gdiimpl.cxx | 10 +-- vcl/skia/win/gdiimpl.cxx | 14 ++-- vcl/skia/x11/gdiimpl.cxx | 18 ++--- 10 files changed, 127 insertions(+), 94 deletions(-) diff --git a/download.lst b/download.lst index 4e31ed9c1b86..1895c61fe1f0 100644 --- a/download.lst +++ b/download.lst @@ -631,8 +631,8 @@ RHINO_TARBALL := rhino-1.7.15.zip # three static lines # so that git cherry-pick # will not run into conflicts -SKIA_SHA256SUM := 103f63a8414a506c887cfe788f7653c130df1278b2cc1d1ae6827b2b90e59377 -SKIA_TARBALL := skia-m132-ee9db7d1348f76780fd0184b9b0243d653e36411.tar.xz +SKIA_SHA256SUM := af3676facdf12d59a9ad5a0f63c60e6bb47f7d6bb243acdd0c6abc8c9b0b3c59 +SKIA_TARBALL := skia-m133-ecebe831881cdf52c65df518777210071f7970dd.tar.xz # three static lines # so that git cherry-pick # will not run into conflicts diff --git a/external/skia/Library_skia.mk b/external/skia/Library_skia.mk index e9a43a35bbdf..26e9addf824b 100644 --- a/external/skia/Library_skia.mk +++ b/external/skia/Library_skia.mk @@ -317,6 +317,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/codec/SkCodecImageGenerator \ UnpackedTarball/skia/src/codec/SkColorPalette \ UnpackedTarball/skia/src/codec/SkExif \ + UnpackedTarball/skia/src/codec/SkGainmapInfo \ UnpackedTarball/skia/src/codec/SkImageGenerator_FromEncoded \ UnpackedTarball/skia/src/codec/SkMaskSwizzler \ UnpackedTarball/skia/src/codec/SkPixmapUtils \ @@ -341,6 +342,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/codec/SkPngCodec \ UnpackedTarball/skia/src/codec/SkPngCodecBase \ + UnpackedTarball/skia/src/codec/SkPngCompositeChunkReader \ )) @@ -362,7 +364,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/base/SkQuads \ UnpackedTarball/skia/src/base/SkSafeMath \ UnpackedTarball/skia/src/base/SkSemaphore \ - UnpackedTarball/skia/src/base/SkSharedMutex \ UnpackedTarball/skia/src/base/SkSpinlock \ UnpackedTarball/skia/src/base/SkTDArray \ UnpackedTarball/skia/src/base/SkTSearch \ @@ -639,7 +640,13 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/encode/SkICC \ )) -# from file skia/gn/core.gni:792, target "skia_encode_png_srcs" +# from file skia/gn/core.gni:792, target "skia_encode_png_base" +# +$(eval $(call gb_Library_add_generated_exception_objects,skia,\ + UnpackedTarball/skia/src/encode/SkPngEncoderBase \ +)) + +# from file skia/gn/core.gni:800, target "skia_encode_png_srcs" # $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/encode/SkPngEncoderImpl \ @@ -710,6 +717,12 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/effects/imagefilters/SkShaderImageFilter \ )) +# from file skia/gn/ports.gni:130, target "skia_ports_typeface_proxy_sources" +# +$(eval $(call gb_Library_add_generated_exception_objects,skia,\ + UnpackedTarball/skia/src/ports/SkTypeface_proxy \ +)) + # from file skia/gn/sksl.gni:42, target "skia_sksl_sources" # $(eval $(call gb_Library_add_generated_exception_objects,skia,\ @@ -846,7 +859,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/utils/SkEventTracer \ UnpackedTarball/skia/src/utils/SkFloatToDecimal \ UnpackedTarball/skia/src/sksl/SkSLModuleDataDefault \ - UnpackedTarball/skia/src/utils/SkJSON \ UnpackedTarball/skia/src/utils/SkJSONWriter \ UnpackedTarball/skia/src/utils/SkMatrix22 \ UnpackedTarball/skia/src/utils/SkMultiPictureDocument \ diff --git a/external/skia/fix-warnings.patch.1 b/external/skia/fix-warnings.patch.1 index cc1a6fba0a41..735f6f11aa6b 100644 --- a/external/skia/fix-warnings.patch.1 +++ b/external/skia/fix-warnings.patch.1 @@ -24,8 +24,8 @@ index f143dab013..be3cde0f4f 100644 - virtual void activate(bool isActive) {} + virtual void activate(bool /*isActive*/) {} - const DisplayParams& getDisplayParams() { return fDisplayParams; } - virtual void setDisplayParams(const DisplayParams& params) = 0; + const DisplayParams* getDisplayParams() { return fDisplayParams.get(); } + virtual void setDisplayParams(std::unique_ptr) = 0; --- skia/include/core/SkSamplingOptions.h.orig 2022-05-22 12:25:06.112544528 +0200 +++ skia/include/core/SkSamplingOptions.h 2022-05-22 12:25:09.207636134 +0200 @@ -97,7 +97,7 @@ diff --git a/external/skia/make-api-visible.patch.1 b/external/skia/make-api-visible.patch.1 index 776f987a60f6..6285b4f8f9b5 100644 --- a/external/skia/make-api-visible.patch.1 +++ b/external/skia/make-api-visible.patch.1 @@ -8,7 +8,7 @@ diff -ur skia.org/tools/window/WindowContext.h skia/tools/window/WindowContext.h -class WindowContext { +class SK_API WindowContext { public: - WindowContext(const DisplayParams&); + WindowContext(std::unique_ptr); diff -ur skia.org/tools/window/mac/GaneshMetalWindowContext_mac.h skia/tools/window/mac/GaneshMetalWindowContext_mac.h --- skia.org/tools/window/mac/GaneshMetalWindowContext_mac.h 2024-10-12 15:57:21 @@ -21,12 +21,14 @@ diff -ur skia.org/tools/window/mac/GaneshMetalWindowContext_mac.h skia/tools/win #include namespace skwindow { -@@ -15,7 +16,7 @@ - struct DisplayParams; +@@ -15,8 +16,8 @@ + class DisplayParams; struct MacWindowInfo; --std::unique_ptr MakeGaneshMetalForMac(const MacWindowInfo&, const DisplayParams&); -+SK_API std::unique_ptr MakeGaneshMetalForMac(const MacWindowInfo&, const DisplayParams&); +-std::unique_ptr MakeGaneshMetalForMac(const MacWindowInfo&, +- std::unique_ptr); ++SK_API std::unique_ptr MakeGaneshMetalForMac(const MacWindowInfo&, ++ std::unique_ptr); } // namespace skwindow #endif @@ -41,12 +43,14 @@ diff -ur skia.org/tools/window/unix/GaneshGLWindowContext_unix.h skia/tools/wind #include namespace skwindow { -@@ -15,7 +16,7 @@ - struct DisplayParams; +@@ -15,8 +16,8 @@ + class DisplayParams; struct XlibWindowInfo; --std::unique_ptr MakeGaneshGLForXlib(const XlibWindowInfo&, const DisplayParams&); -+SK_API std::unique_ptr MakeGaneshGLForXlib(const XlibWindowInfo&, const DisplayParams&); +-std::unique_ptr MakeGaneshGLForXlib(const XlibWindowInfo&, +- std::unique_ptr); ++SK_API std::unique_ptr MakeGaneshGLForXlib(const XlibWindowInfo&, ++ std::unique_ptr); } // namespace skwindow #endif @@ -61,12 +65,14 @@ diff -ur skia.org/tools/window/unix/GaneshVulkanWindowContext_unix.h skia/tools/ #include namespace skwindow { -@@ -15,7 +16,7 @@ - struct DisplayParams; +@@ -15,8 +16,8 @@ + class DisplayParams; struct XlibWindowInfo; --std::unique_ptr MakeGaneshVulkanForXlib(const XlibWindowInfo&, const DisplayParams&); -+SK_API std::unique_ptr MakeGaneshVulkanForXlib(const XlibWindowInfo&, const DisplayParams&); +-std::unique_ptr MakeGaneshVulkanForXlib(const XlibWindowInfo&, +- std::unique_ptr); ++SK_API std::unique_ptr MakeGaneshVulkanForXlib(const XlibWindowInfo&, ++ std::unique_ptr); } // namespace skwindow #endif @@ -82,12 +88,12 @@ diff -ur skia.org/tools/window/unix/GraphiteDawnVulkanWindowContext_unix.h skia/ namespace skwindow { @@ -15,7 +16,7 @@ - struct DisplayParams; + class DisplayParams; struct XlibWindowInfo; -std::unique_ptr MakeGraphiteDawnVulkanForXlib(const XlibWindowInfo&, +SK_API std::unique_ptr MakeGraphiteDawnVulkanForXlib(const XlibWindowInfo&, - const DisplayParams&); + std::unique_ptr); } // namespace skwindow diff -ur skia.org/tools/window/unix/RasterWindowContext_unix.h skia/tools/window/unix/RasterWindowContext_unix.h @@ -101,12 +107,14 @@ diff -ur skia.org/tools/window/unix/RasterWindowContext_unix.h skia/tools/window #include namespace skwindow { -@@ -15,7 +16,7 @@ - struct DisplayParams; +@@ -15,8 +16,8 @@ + class DisplayParams; struct XlibWindowInfo; --std::unique_ptr MakeRasterForXlib(const XlibWindowInfo&, const DisplayParams&); -+SK_API std::unique_ptr MakeRasterForXlib(const XlibWindowInfo&, const DisplayParams&); +-std::unique_ptr MakeRasterForXlib(const XlibWindowInfo&, +- std::unique_ptr); ++SK_API std::unique_ptr MakeRasterForXlib(const XlibWindowInfo&, ++ std::unique_ptr); } // namespace skwindow #endif @@ -123,29 +131,29 @@ diff -ur skia.org/tools/window/win/WindowContextFactory_win.h skia/tools/window/ namespace skwindow { class WindowContext; - struct DisplayParams; + class DisplayParams; #ifdef SK_VULKAN --std::unique_ptr MakeVulkanForWin(HWND, const DisplayParams&); -+SK_API std::unique_ptr MakeVulkanForWin(HWND, const DisplayParams&); +-std::unique_ptr MakeVulkanForWin(HWND, std::unique_ptr); ++SK_API std::unique_ptr MakeVulkanForWin(HWND, std::unique_ptr); #if defined(SK_GRAPHITE) - std::unique_ptr MakeGraphiteVulkanForWin(HWND, const DisplayParams&); + std::unique_ptr MakeGraphiteVulkanForWin(HWND, std::unique_ptr); #endif #endif #ifdef SK_GL --std::unique_ptr MakeGLForWin(HWND, const DisplayParams&); -+SK_API std::unique_ptr MakeGLForWin(HWND, const DisplayParams&); +-std::unique_ptr MakeGLForWin(HWND, std::unique_ptr); ++SK_API std::unique_ptr MakeGLForWin(HWND, std::unique_ptr); #endif #ifdef SK_ANGLE --std::unique_ptr MakeANGLEForWin(HWND, const DisplayParams&); -+SK_API std::unique_ptr MakeANGLEForWin(HWND, const DisplayParams&); +-std::unique_ptr MakeANGLEForWin(HWND, std::unique_ptr); ++SK_API std::unique_ptr MakeANGLEForWin(HWND, std::unique_ptr); #endif #ifdef SK_DIRECT3D --std::unique_ptr MakeD3D12ForWin(HWND, const DisplayParams&); -+SK_API std::unique_ptr MakeD3D12ForWin(HWND, const DisplayParams&); +-std::unique_ptr MakeD3D12ForWin(HWND, std::unique_ptr); ++SK_API std::unique_ptr MakeD3D12ForWin(HWND, std::unique_ptr); #endif #ifdef SK_DAWN @@ -153,8 +161,8 @@ diff -ur skia.org/tools/window/win/WindowContextFactory_win.h skia/tools/window/ #endif #endif --std::unique_ptr MakeRasterForWin(HWND, const DisplayParams&); -+SK_API std::unique_ptr MakeRasterForWin(HWND, const DisplayParams&); +-std::unique_ptr MakeRasterForWin(HWND, std::unique_ptr); ++SK_API std::unique_ptr MakeRasterForWin(HWND, std::unique_ptr); } // namespace skwindow diff --git a/external/skia/share-grcontext.patch.1 b/external/skia/share-grcontext.patch.1 index 03ced66e4c31..2526b12a1223 100644 --- a/external/skia/share-grcontext.patch.1 +++ b/external/skia/share-grcontext.patch.1 @@ -74,8 +74,8 @@ diff -ur skia.org/tools/window/MetalWindowContext.h skia/tools/window/MetalWindo diff -ur skia.org/tools/window/MetalWindowContext.mm skia/tools/window/MetalWindowContext.mm --- skia.org/tools/window/MetalWindowContext.mm 2024-10-10 14:11:32.362258108 +0200 +++ skia/tools/window/MetalWindowContext.mm 2024-10-10 14:11:44.341323063 +0200 -@@ -35,50 +35,84 @@ - } +@@ -33,54 +33,88 @@ + , fDrawableHandle(nil) {} void MetalWindowContext::initializeContext() { + fShared = fGlobalShared; @@ -93,10 +93,10 @@ diff -ur skia.org/tools/window/MetalWindowContext.mm skia/tools/window/MetalWind + d->fDevice.reset(MTLCreateSystemDefaultDevice()); + d->fQueue.reset([*d->fDevice newCommandQueue]); - if (fDisplayParams.fMSAASampleCount > 1) { + if (fDisplayParams->msaaSampleCount() > 1) { if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) { -- if (![*fDevice supportsTextureSampleCount:fDisplayParams.fMSAASampleCount]) { -+ if (![*d->fDevice supportsTextureSampleCount:fDisplayParams.fMSAASampleCount]) { +- if (![*fDevice supportsTextureSampleCount:fDisplayParams->msaaSampleCount()]) { ++ if (![*d->fDevice supportsTextureSampleCount:fDisplayParams->msaaSampleCount()]) { + fGlobalShared.reset(); return; } @@ -105,7 +105,7 @@ diff -ur skia.org/tools/window/MetalWindowContext.mm skia/tools/window/MetalWind return; } } -- fSampleCount = fDisplayParams.fMSAASampleCount; +- fSampleCount = fDisplayParams->msaaSampleCount(); - fStencilBits = 8; - - fValid = this->onInitializeContext(); @@ -113,13 +113,17 @@ diff -ur skia.org/tools/window/MetalWindowContext.mm skia/tools/window/MetalWind GrMtlBackendContext backendContext = {}; - backendContext.fDevice.retain((GrMTLHandle)fDevice.get()); - backendContext.fQueue.retain((GrMTLHandle)fQueue.get()); -- fContext = GrDirectContexts::MakeMetal(backendContext, fDisplayParams.fGrContextOptions); -- if (!fContext && fDisplayParams.fMSAASampleCount > 1) { +- fContext = GrDirectContexts::MakeMetal(backendContext, fDisplayParams->grContextOptions()); +- if (!fContext && fDisplayParams->msaaSampleCount() > 1) { + backendContext.fDevice.retain((GrMTLHandle)d->fDevice.get()); + backendContext.fQueue.retain((GrMTLHandle)d->fQueue.get()); -+ d->fContext = GrDirectContexts::MakeMetal(backendContext, fDisplayParams.fGrContextOptions); -+ if (!d->fContext && fDisplayParams.fMSAASampleCount > 1) { - fDisplayParams.fMSAASampleCount /= 2; ++ d->fContext = GrDirectContexts::MakeMetal(backendContext, fDisplayParams->grContextOptions()); ++ if (!d->fContext && fDisplayParams->msaaSampleCount() > 1) { + auto newParams = DisplayParamsBuilder(fDisplayParams.get()); + newParams.msaaSampleCount(fDisplayParams->msaaSampleCount() / 2); + // Don't call this->setDisplayParams because that also calls + // destroyContext() and initializeContext(). + fDisplayParams = newParams.build(); + fGlobalShared.reset(); this->initializeContext(); return; @@ -130,7 +134,7 @@ diff -ur skia.org/tools/window/MetalWindowContext.mm skia/tools/window/MetalWind + + fContext = fShared->fContext; + -+ fSampleCount = fDisplayParams.fMSAASampleCount; ++ fSampleCount = fDisplayParams->msaaSampleCount(); + fStencilBits = 8; + + fValid = this->onInitializeContext(); @@ -224,7 +228,7 @@ diff -ur skia.org/tools/window/unix/GaneshVulkanWindowContext_unix.cpp.orig skia @@ -68,7 +71,7 @@ }; std::unique_ptr ctx(new internal::VulkanWindowContext( - displayParams, createVkSurface, canPresent, instProc)); + std::move(displayParams), createVkSurface, canPresent, instProc)); - if (!ctx->isValid()) { + if (!ctx->isValid() && createVkSurface != nullptr) { return nullptr; @@ -249,7 +253,7 @@ diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanW namespace skwindow::internal { -@@ -55,32 +59,43 @@ +@@ -55,36 +59,47 @@ } void VulkanWindowContext::initializeContext() { @@ -269,11 +273,17 @@ diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanW + skgpu::VulkanBackendContext& backendContext = fGlobalShared->backendContext; skgpu::VulkanExtensions extensions; VkPhysicalDeviceFeatures2 features; - if (!sk_gpu_test::CreateVkBackendContext(getInstanceProc, &backendContext, &extensions, -- &features, &fDebugCallback, &fPresentQueueIndex, -+ &d->features, &d->fDebugCallback, &d->fPresentQueueIndex, + if (!sk_gpu_test::CreateVkBackendContext(getInstanceProc, + &backendContext, + &extensions, +- &features, +- &fDebugCallback, +- &fPresentQueueIndex, ++ &d->features, ++ &d->fDebugCallback, ++ &d->fPresentQueueIndex, fCanPresentFn, - fDisplayParams.fCreateProtectedNativeBackend)) { + fDisplayParams->createProtectedNativeBackend())) { + sk_gpu_test::FreeVulkanFeaturesStructs(&d->features); + fGlobalShared.reset(); sk_gpu_test::FreeVulkanFeaturesStructs(&features); @@ -330,7 +340,7 @@ diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanW - GET_PROC(DestroyInstance); - if (fDebugCallback != VK_NULL_HANDLE) { - GET_PROC(DestroyDebugReportCallbackEXT); -+ d->fContext = GrDirectContexts::MakeVulkan(backendContext, fDisplayParams.fGrContextOptions); ++ d->fContext = GrDirectContexts::MakeVulkan(backendContext, fDisplayParams->grContextOptions()); + + GET_PROC_GLOBAL(DestroyInstance); + GET_DEV_PROC_GLOBAL(DestroyDevice); @@ -364,7 +374,7 @@ diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanW GET_DEV_PROC(CreateSwapchainKHR); GET_DEV_PROC(DestroySwapchainKHR); GET_DEV_PROC(GetSwapchainImagesKHR); -@@ -121,56 +154,44 @@ +@@ -121,55 +154,43 @@ GET_DEV_PROC(QueuePresentKHR); GET_DEV_PROC(GetDeviceQueue); @@ -378,7 +388,7 @@ diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanW - skgpu::ThreadSafe::kNo, - /*blockSize=*/std::nullopt); - -- fContext = GrDirectContexts::MakeVulkan(backendContext, fDisplayParams.fGrContextOptions); +- fContext = GrDirectContexts::MakeVulkan(backendContext, fDisplayParams->grContextOptions()); + // No actual window, used just to create the shared GrContext. + if(fCreateVkSurfaceFn == nullptr) + return; @@ -404,7 +414,7 @@ diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanW return; } - if (!this->createSwapchain(-1, -1, fDisplayParams)) { + if (!this->createSwapchain(-1, -1)) { this->destroyContext(); - sk_gpu_test::FreeVulkanFeaturesStructs(&features); return; @@ -415,8 +425,7 @@ diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanW - sk_gpu_test::FreeVulkanFeaturesStructs(&features); } - bool VulkanWindowContext::createSwapchain(int width, int height, - const DisplayParams& params) { + bool VulkanWindowContext::createSwapchain(int width, int height) { // check for capabilities VkSurfaceCapabilitiesKHR caps; - VkResult res = fGetPhysicalDeviceSurfaceCapabilitiesKHR(fPhysicalDevice, fSurface, &caps); @@ -520,7 +529,7 @@ diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanW info.fLevelCount = 1; - info.fCurrentQueueFamily = fPresentQueueIndex; + info.fCurrentQueueFamily = fShared->fPresentQueueIndex; - info.fProtected = skgpu::Protected(fDisplayParams.fCreateProtectedNativeBackend); + info.fProtected = skgpu::Protected(fDisplayParams->createProtectedNativeBackend()); info.fSharingMode = sharingMode; @@ -418,8 +438,8 @@ @@ -642,7 +651,7 @@ diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanW } if (VK_ERROR_OUT_OF_DATE_KHR == res) { // tear swapchain down and try again - if (!this->createSwapchain(-1, -1, fDisplayParams)) { + if (!this->createSwapchain(-1, -1)) { - GR_VK_CALL(fInterface, DestroySemaphore(fDevice, semaphore, nullptr)); + GR_VK_CALL(fShared->fInterface, DestroySemaphore(fShared->fDevice, semaphore, nullptr)); return nullptr; @@ -704,10 +713,10 @@ diff -ur skia.org/tools/window/VulkanWindowContext.h skia/tools/window/VulkanWin - bool isValid() override { return fDevice != VK_NULL_HANDLE; } + bool isValid() override { return fSurface != VK_NULL_HANDLE; } - void resize(int w, int h) override { - this->createSwapchain(w, h, fDisplayParams); + void resize(int w, int h) override { this->createSwapchain(w, h); } + @@ -45,9 +49,15 @@ - VulkanWindowContext(const DisplayParams&, CreateVkSurfaceFn, CanPresentFn, + CanPresentFn, PFN_vkGetInstanceProcAddr); + static const VkPhysicalDeviceProperties& getPhysDeviceProperties() { @@ -810,8 +819,8 @@ diff -ur skia.org/tools/window/win/VulkanWindowContext_win.cpp skia/tools/window uint32_t queueFamilyIndex) { @@ -66,7 +69,7 @@ - std::unique_ptr ctx( - new internal::VulkanWindowContext(params, createVkSurface, canPresent, instProc)); + std::unique_ptr ctx(new internal::VulkanWindowContext( + std::move(params), createVkSurface, canPresent, instProc)); - if (!ctx->isValid()) { + if (!ctx->isValid() && createVkSurface != nullptr) { return nullptr; diff --git a/external/skia/swap-buffers-rect.patch.1 b/external/skia/swap-buffers-rect.patch.1 index 0b02be761a50..292adc70836b 100644 --- a/external/skia/swap-buffers-rect.patch.1 +++ b/external/skia/swap-buffers-rect.patch.1 @@ -26,7 +26,7 @@ diff -ur skia.org/tools/window/unix/RasterWindowContext_unix.cpp skia/tools/wind --- skia.org/tools/window/unix/RasterWindowContext_unix.cpp 2024-10-05 18:16:04.521814026 +0200 +++ skia/tools/window/unix/RasterWindowContext_unix.cpp 2024-10-05 18:18:49.554847490 +0200 @@ -24,7 +24,7 @@ - void setDisplayParams(const DisplayParams& params) override; + void setDisplayParams(std::unique_ptr params) override; protected: - void onSwapBuffers() override; @@ -70,7 +70,7 @@ diff -ur skia.org/tools/window/VulkanWindowContext.h skia/tools/window/VulkanWin --- skia.org/tools/window/VulkanWindowContext.h 2024-10-05 18:16:04.521814026 +0200 +++ skia/tools/window/VulkanWindowContext.h 2024-10-05 18:19:54.713202674 +0200 @@ -70,7 +70,7 @@ - bool createSwapchain(int width, int height, const DisplayParams& params); + bool createSwapchain(int width, int height); bool createBuffers(VkFormat format, VkImageUsageFlags, SkColorType colorType, VkSharingMode); void destroyBuffers(); - void onSwapBuffers() override; @@ -83,7 +83,7 @@ diff -ur skia.org/tools/window/win/RasterWindowContext_win.cpp skia/tools/window --- skia.org/tools/window/win/RasterWindowContext_win.cpp 2024-10-05 18:16:04.521814026 +0200 +++ skia/tools/window/win/RasterWindowContext_win.cpp 2024-10-05 18:20:58.138561375 +0200 @@ -27,7 +27,7 @@ - void setDisplayParams(const DisplayParams& params) override; + void setDisplayParams(std::unique_ptr params) override; protected: - void onSwapBuffers() override; @@ -125,7 +125,7 @@ diff -ur skia.org/tools/window/WindowContext.cpp skia/tools/window/WindowContext + this->onSwapBuffers(rect); } - #if defined(SK_GRAPHITE) + bool WindowContext::supportsGpuTimer() const { diff -ur skia.org/tools/window/WindowContext.h skia/tools/window/WindowContext.h --- skia.org/tools/window/WindowContext.h 2024-10-05 18:16:04.521814026 +0200 +++ skia/tools/window/WindowContext.h 2024-10-05 18:22:12.945998819 +0200 diff --git a/external/skia/windows-raster-surface-no-copies.patch.1 b/external/skia/windows-raster-surface-no-copies.patch.1 index 9c59c252c1f6..1aaf43a2537c 100644 --- a/external/skia/windows-raster-surface-no-copies.patch.1 +++ b/external/skia/windows-raster-surface-no-copies.patch.1 @@ -18,8 +18,8 @@ diff -ur skia.org/tools/window/win/RasterWindowContext_win.cpp skia/tools/window + // Do not use a packed DIB bitmap, SkSurface_Raster::onNewImageSnapshot() does + // a deep copy if it does not own the pixels. - SkImageInfo info = SkImageInfo::Make(w, h, fDisplayParams.fColorType, kPremul_SkAlphaType, - fDisplayParams.fColorSpace); + SkImageInfo info = SkImageInfo::Make( + w, h, fDisplayParams->colorType(), kPremul_SkAlphaType, fDisplayParams->colorSpace()); - fBackbufferSurface = SkSurfaces::WrapPixels(info, pixels, sizeof(uint32_t) * w); + fBackbufferSurface = SkSurfaces::Raster(info); } diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx index 7fa95e8d9fab..8043fb2e2b72 100644 --- a/vcl/skia/osx/gdiimpl.cxx +++ b/vcl/skia/osx/gdiimpl.cxx @@ -72,8 +72,8 @@ void AquaSkiaSalGraphicsImpl::createWindowSurfaceInternal(bool forceRaster) assert(!mWindowContext); assert(!mSurface); SkiaZone zone; - skwindow::DisplayParams displayParams; - displayParams.fColorType = kN32_SkColorType; + skwindow::DisplayParamsBuilder displayParams; + displayParams.colorType(kN32_SkColorType); skwindow::MacWindowInfo macWindow; macWindow.fMainView = mrShared.mpFrame->mpNSView; mScaling = getWindowScaling(); @@ -86,7 +86,7 @@ void AquaSkiaSalGraphicsImpl::createWindowSurfaceInternal(bool forceRaster) mSurface = createSkSurface(GetWidth() * mScaling, GetHeight() * mScaling); break; case RenderMetal: - mWindowContext = skwindow::MakeGaneshMetalForMac(macWindow, displayParams); + mWindowContext = skwindow::MakeGaneshMetalForMac(macWindow, displayParams.build()); // Like with other GPU contexts, create a proxy offscreen surface (see // flushSurfaceToWindowContext()). Here it's additionally needed because // it appears that Metal surfaces cannot be read from, which would break things @@ -411,10 +411,10 @@ namespace { std::unique_ptr createMetalWindowContext(bool /*temporary*/) { - skwindow::DisplayParams displayParams; + skwindow::DisplayParamsBuilder displayParams; skwindow::MacWindowInfo macWindow; macWindow.fMainView = nullptr; - return skwindow::MakeGaneshMetalForMac(macWindow, displayParams); + return skwindow::MakeGaneshMetalForMac(macWindow, displayParams.build()); } } diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx index 8de57dba2b89..8ce4c33e57d0 100644 --- a/vcl/skia/win/gdiimpl.cxx +++ b/vcl/skia/win/gdiimpl.cxx @@ -104,18 +104,20 @@ void WinSkiaSalGraphicsImpl::createWindowSurfaceInternal(bool forceRaster) assert(!mWindowContext); assert(!mSurface); SkiaZone zone; - skwindow::DisplayParams displayParams; assert(GetWidth() > 0 && GetHeight() > 0); - displayParams.fSurfaceProps = *surfaceProps(); + skwindow::DisplayParamsBuilder aDispParamBuilder; + aDispParamBuilder.surfaceProps(*surfaceProps()); switch (forceRaster ? RenderRaster : renderMethodToUse()) { case RenderRaster: - mWindowContext = skwindow::MakeRasterForWin(mWinParent.gethWnd(), displayParams); + mWindowContext + = skwindow::MakeRasterForWin(mWinParent.gethWnd(), aDispParamBuilder.build()); if (mWindowContext) mSurface = mWindowContext->getBackbufferSurface(); break; case RenderVulkan: - mWindowContext = skwindow::MakeVulkanForWin(mWinParent.gethWnd(), displayParams); + mWindowContext + = skwindow::MakeVulkanForWin(mWinParent.gethWnd(), aDispParamBuilder.build()); // See flushSurfaceToWindowContext(). if (mWindowContext) mSurface = createSkSurface(GetWidth(), GetHeight()); @@ -416,8 +418,8 @@ namespace std::unique_ptr createVulkanWindowContext(bool /*temporary*/) { SkiaZone zone; - skwindow::DisplayParams displayParams; - return skwindow::MakeVulkanForWin(nullptr, displayParams); + skwindow::DisplayParamsBuilder displayParams; + return skwindow::MakeVulkanForWin(nullptr, displayParams.build()); } } diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx index 34df45fa7d09..103aa7329c6a 100644 --- a/vcl/skia/x11/gdiimpl.cxx +++ b/vcl/skia/x11/gdiimpl.cxx @@ -67,14 +67,14 @@ X11SkiaSalGraphicsImpl::createWindowContext(Display* display, Drawable drawable, RenderMethod renderMethod, bool temporary) { SkiaZone zone; - skwindow::DisplayParams displayParams; - displayParams.fColorType = kN32_SkColorType; + skwindow::DisplayParamsBuilder displayParamsBuilder; + displayParamsBuilder.colorType(kN32_SkColorType); #if defined LINUX // WORKAROUND: VSync causes freezes that can even temporarily freeze the entire desktop. // This happens even with the latest 450.66 drivers despite them claiming a fix for vsync. // https://forums.developer.nvidia.com/t/hangs-freezes-when-vulkan-v-sync-vk-present-mode-fifo-khr-is-enabled/67751 if (getVendor() == DriverBlocklist::VendorNVIDIA) - displayParams.fDisableVsync = true; + displayParamsBuilder.disableVsync(true); #endif skwindow::XlibWindowInfo winInfo; assert(display); @@ -103,17 +103,19 @@ X11SkiaSalGraphicsImpl::createWindowContext(Display* display, Drawable drawable, switch (renderMethod) { case RenderRaster: + { // Make sure we ask for color type that matches the X11 visual. If red mask // is larger value than blue mask, then on little endian this means blue is first. // This should also preferably match SK_R32_SHIFT set in config_skia.h, as that // improves performance, the common setup seems to be BGRA (possibly because of // choosing OpenGL-capable visual). - displayParams.fColorType - = (visual->red_mask > visual->blue_mask ? kBGRA_8888_SkColorType - : kRGBA_8888_SkColorType); - return skwindow::MakeRasterForXlib(winInfo, displayParams); + displayParamsBuilder.colorType(visual->red_mask > visual->blue_mask + ? kBGRA_8888_SkColorType + : kRGBA_8888_SkColorType); + return skwindow::MakeRasterForXlib(winInfo, displayParamsBuilder.build()); + } case RenderVulkan: - return skwindow::MakeGaneshVulkanForXlib(winInfo, displayParams); + return skwindow::MakeGaneshVulkanForXlib(winInfo, displayParamsBuilder.build()); case RenderMetal: abort(); break;