download.lst | 4 external/skia/Library_skia.mk | 47 - external/skia/UnpackedTarball_skia.mk | 1 external/skia/clang-attributes-warning.patch.1 | 23 external/skia/fix-SkDebugf-link-error.patch.1 | 2 external/skia/fix-warnings.patch.1 | 4 external/skia/fix-without-gl.patch.1 | 53 +- external/skia/help-msvc-analyzer.patch | 18 external/skia/macosmetal.patch.0 | 24 external/skia/make-api-visible.patch.1 | 123 ++-- external/skia/share-grcontext.patch.1 | 424 ++++++++--------- external/skia/sort-comparison-assumption.patch.0 | 16 external/skia/swap-buffers-rect.patch.1 | 126 ++--- external/skia/windows-raster-surface-no-copies.patch.1 | 13 external/skia/windows-text-gamma.patch.0 | 48 + vcl/inc/skia/gdiimpl.hxx | 2 vcl/inc/skia/utils.hxx | 4 vcl/inc/skia/x11/gdiimpl.hxx | 4 vcl/osx/salgdiutils.cxx | 4 vcl/skia/SkiaHelper.cxx | 41 - vcl/skia/gdiimpl.cxx | 7 vcl/skia/osx/gdiimpl.cxx | 20 vcl/skia/quartz/salbmp.mm | 6 vcl/skia/salbmp.cxx | 6 vcl/skia/win/gdiimpl.cxx | 18 vcl/skia/x11/gdiimpl.cxx | 16 26 files changed, 514 insertions(+), 540 deletions(-)
New commits: commit 4e9a21bb0e4981e834de22c1d666f7a83a2771c5 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Sat Oct 5 19:15:52 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Oct 6 21:06:40 2024 +0200 Update to skia m116 The sort comparison patch seems to have been upstreamed. Lots of patches needed to be redone. Followed the skia release notes in replacing calls to SkCanvas::flush and SkSurface::flushAndSubmit. Change-Id: I13179565b95cc0720b4548cd4baecc5adacc7133 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174554 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/download.lst b/download.lst index 412af4e8f2dd..c225475929bd 100644 --- a/download.lst +++ b/download.lst @@ -626,8 +626,8 @@ RHINO_TARBALL := rhino-1.7.15.zip # three static lines # so that git cherry-pick # will not run into conflicts -SKIA_SHA256SUM := 2223ebce534458a37826e8fe4f24635b0712cde7ed1bd3208f089f6fdd796e01 -SKIA_TARBALL := skia-m116-2ddcf183eb260f63698aa74d1bb380f247ad7ccd.tar.xz +SKIA_SHA256SUM := 7bf553d5d10c97ccbcbe4559178658725ba5486d3d1fec5112fe1b2036a5633f +SKIA_TARBALL := skia-m117-817237a3bd19b2a205b038cd09af1cdc4b53fecc.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 a12d339ba7a9..5875b7513fcb 100644 --- a/external/skia/Library_skia.mk +++ b/external/skia/Library_skia.mk @@ -273,21 +273,21 @@ endif # from file skia/BUILD.gn:2719, target "test_lib("sk_app")" # $(eval $(call gb_Library_add_generated_exception_objects,skia,\ - UnpackedTarball/skia/tools/sk_app/WindowContext \ - $(if $(filter LINUX,$(OS)),UnpackedTarball/skia/tools/sk_app/unix/RasterWindowContext_unix) \ - $(if $(filter WNT,$(OS)),UnpackedTarball/skia/tools/sk_app/win/RasterWindowContext_win) \ + UnpackedTarball/skia/tools/window/WindowContext \ + $(if $(filter LINUX,$(OS)),UnpackedTarball/skia/tools/window/unix/RasterWindowContext_unix) \ + $(if $(filter WNT,$(OS)),UnpackedTarball/skia/tools/window/win/RasterWindowContext_win) \ )) ifeq ($(SKIA_GPU),VULKAN) $(eval $(call gb_Library_add_generated_exception_objects,skia,\ - UnpackedTarball/skia/tools/sk_app/VulkanWindowContext \ - $(if $(filter LINUX,$(OS)),UnpackedTarball/skia/tools/sk_app/unix/VulkanWindowContext_unix) \ - $(if $(filter WNT,$(OS)),UnpackedTarball/skia/tools/sk_app/win/VulkanWindowContext_win) \ + UnpackedTarball/skia/tools/window/VulkanWindowContext \ + $(if $(filter LINUX,$(OS)),UnpackedTarball/skia/tools/window/unix/VulkanWindowContext_unix) \ + $(if $(filter WNT,$(OS)),UnpackedTarball/skia/tools/window/win/VulkanWindowContext_win) \ )) endif ifeq ($(SKIA_GPU),METAL) $(eval $(call gb_Library_add_generated_objcxxobjects,skia,\ - UnpackedTarball/skia/tools/sk_app/MetalWindowContext \ - $(if $(filter MACOSX,$(OS)),UnpackedTarball/skia/tools/sk_app/mac/MetalWindowContext_mac) \ + UnpackedTarball/skia/tools/window/MetalWindowContext \ + $(if $(filter MACOSX,$(OS)),UnpackedTarball/skia/tools/window/mac/MetalWindowContext_mac) \ )) endif @@ -351,8 +351,10 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/core/SkBitmapDevice \ UnpackedTarball/skia/src/core/SkBitmapProcState \ UnpackedTarball/skia/src/core/SkBitmapProcState_matrixProcs \ + UnpackedTarball/skia/src/core/SkBitmapProcState_opts \ UnpackedTarball/skia/src/core/SkBlendMode \ UnpackedTarball/skia/src/core/SkBlendModeBlender \ + UnpackedTarball/skia/src/core/SkBlitMask_opts \ UnpackedTarball/skia/src/core/SkBlitRow_D32 \ UnpackedTarball/skia/src/core/SkBlitter \ UnpackedTarball/skia/src/core/SkBlitter_A8 \ @@ -411,7 +413,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/core/SkGlobalInitialization_core \ UnpackedTarball/skia/src/core/SkGlyph \ UnpackedTarball/skia/src/core/SkGlyphRunPainter \ - $(if $(SKIA_GPU),UnpackedTarball/skia/src/core/SkGpuBlurUtils) \ UnpackedTarball/skia/src/core/SkGraphics \ UnpackedTarball/skia/src/core/SkIDChangeListener \ UnpackedTarball/skia/src/core/SkImageFilter \ @@ -504,8 +505,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/core/SkTypefaceCache \ UnpackedTarball/skia/src/core/SkTypeface_remote \ UnpackedTarball/skia/src/core/SkUnPreMultiply \ - UnpackedTarball/skia/src/core/SkVM \ - UnpackedTarball/skia/src/core/SkVMBlitter \ UnpackedTarball/skia/src/core/SkVertState \ UnpackedTarball/skia/src/core/SkVertices \ UnpackedTarball/skia/src/core/SkWriteBuffer \ @@ -678,7 +677,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/effects/imagefilters/SkPictureImageFilter \ UnpackedTarball/skia/src/effects/imagefilters/SkRuntimeImageFilter \ UnpackedTarball/skia/src/effects/imagefilters/SkShaderImageFilter \ - UnpackedTarball/skia/src/effects/imagefilters/SkTileImageFilter \ )) # from file skia/gn/sksl.gni:42, target "skia_sksl_sources" @@ -721,10 +719,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/sksl/analysis/SkSLSymbolTableStackBuilder \ UnpackedTarball/skia/src/sksl/codegen/SkSLRasterPipelineBuilder \ UnpackedTarball/skia/src/sksl/codegen/SkSLRasterPipelineCodeGenerator \ - UnpackedTarball/skia/src/sksl/codegen/SkSLVMCodeGenerator \ - UnpackedTarball/skia/src/sksl/dsl/DSLExpression \ - UnpackedTarball/skia/src/sksl/dsl/DSLStatement \ - UnpackedTarball/skia/src/sksl/dsl/DSLType \ UnpackedTarball/skia/src/sksl/ir/SkSLBinaryExpression \ UnpackedTarball/skia/src/sksl/ir/SkSLBlock \ UnpackedTarball/skia/src/sksl/ir/SkSLChildCall \ @@ -753,7 +747,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/sksl/ir/SkSLInterfaceBlock \ UnpackedTarball/skia/src/sksl/ir/SkSLLayout \ UnpackedTarball/skia/src/sksl/ir/SkSLLiteral \ - UnpackedTarball/skia/src/sksl/ir/SkSLModifiers \ + UnpackedTarball/skia/src/sksl/ir/SkSLModifierFlags \ UnpackedTarball/skia/src/sksl/ir/SkSLModifiersDeclaration \ UnpackedTarball/skia/src/sksl/ir/SkSLPostfixExpression \ UnpackedTarball/skia/src/sksl/ir/SkSLPrefixExpression \ @@ -1020,6 +1014,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/gpu/ganesh/image/SkImage_GaneshYUVA \ UnpackedTarball/skia/src/gpu/ganesh/image/SkImage_LazyTexture \ UnpackedTarball/skia/src/gpu/ganesh/image/SkImage_RasterPinnable \ + UnpackedTarball/skia/src/gpu/ganesh/image/SkSpecialImage_Ganesh \ UnpackedTarball/skia/src/gpu/ganesh/mock/GrMockCaps \ UnpackedTarball/skia/src/gpu/ganesh/mock/GrMockGpu \ UnpackedTarball/skia/src/gpu/ganesh/mock/GrMockTypes \ @@ -1222,7 +1217,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ ifeq ($(OS),MACOSX) ifeq ($(SKIA_GPU),METAL) $(eval $(call gb_Library_add_generated_objcxxobjects,skia,\ - UnpackedTarball/skia/tools/sk_app/mac/WindowContextFactory_mac \ + UnpackedTarball/skia/tools/window/mac/WindowContextFactory_mac \ )) endif endif @@ -1238,22 +1233,20 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ $(LO_SKIA_AVOID_INLINE_COPIES) \ )) $(eval $(call gb_Library_add_generated_exception_objects,skia,\ - UnpackedTarball/skia/src/opts/SkOpts_hsw, \ + UnpackedTarball/skia/src/opts/SkOpts_hsw \ + UnpackedTarball/skia/src/core/SkBitmapProcState_opts_hsw, \ $(CXXFLAGS_INTRINSICS_AVX2) $(CXXFLAGS_INTRINSICS_F16C) $(CXXFLAGS_INTRINSICS_FMA) \ $(LO_CLANG_CXXFLAGS_INTRINSICS_AVX2) $(LO_CLANG_CXXFLAGS_INTRINSICS_F16C) $(LO_CLANG_CXXFLAGS_INTRINSICS_FMA) \ $(LO_SKIA_AVOID_INLINE_COPIES) \ )) $(eval $(call gb_Library_add_generated_exception_objects,skia,\ - UnpackedTarball/skia/src/opts/SkOpts_ssse3, $(CXXFLAGS_INTRINSICS_SSSE3) $(LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3) \ - $(LO_SKIA_AVOID_INLINE_COPIES) \ -)) - -$(eval $(call gb_Library_add_generated_exception_objects,skia,\ - UnpackedTarball/skia/src/opts/SkOpts_skx, $(CXXFLAGS_INTRINSICS_AVX512) $(LO_CLANG_CXXFLAGS_INTRINSICS_AVX512)\ - $(LO_SKIA_AVOID_INLINE_COPIES) \ + UnpackedTarball/skia/src/opts/SkOpts_ssse3 \ + UnpackedTarball/skia/src/core/SkBlitMask_opts_ssse3 \ + UnpackedTarball/skia/src/core/SkBitmapProcState_opts_ssse3, \ + $(CXXFLAGS_INTRINSICS_SSSE3) $(LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3) \ + $(LO_SKIA_AVOID_INLINE_COPIES) \ )) - # Skcms code is used by png writer, which is used by SkiaHelper::dump(). Building # this without optimizations would mean having each pixel of saved images be # processed by unoptimized code. diff --git a/external/skia/UnpackedTarball_skia.mk b/external/skia/UnpackedTarball_skia.mk index bbc51141cda6..ff3a93e74f48 100644 --- a/external/skia/UnpackedTarball_skia.mk +++ b/external/skia/UnpackedTarball_skia.mk @@ -41,7 +41,6 @@ skia_patches := \ ubsan-missing-typeinfo.patch.1 \ incomplete-type-SkImageGenerator.patch.1 \ 0001-AvoidCombiningExtrememelyLargeMeshes.patch.1 \ - sort-comparison-assumption.patch.0 \ help-msvc-analyzer.patch \ $(eval $(call gb_UnpackedTarball_set_patchlevel,skia,1)) diff --git a/external/skia/clang-attributes-warning.patch.1 b/external/skia/clang-attributes-warning.patch.1 index ba48ea8b14ed..fa617c4e831f 100644 --- a/external/skia/clang-attributes-warning.patch.1 +++ b/external/skia/clang-attributes-warning.patch.1 @@ -1,31 +1,30 @@ -diff --git a/include/private/base/SkFloatingPoint.h b/include/private/base/SkFloatingPoint.h -index 3c6d22c310..60500b2d2c 100644 ---- a/include/private/base/SkFloatingPoint.h -+++ b/include/private/base/SkFloatingPoint.h -@@ -159,7 +159,9 @@ static inline int64_t sk_float_saturate2int64(float x) { +diff -ur skia.org/include/private/base/SkFloatingPoint.h skia/include/private/base/SkFloatingPoint.h +--- skia.org/include/private/base/SkFloatingPoint.h 2024-10-04 15:22:58.494566218 +0200 ++++ skia/include/private/base/SkFloatingPoint.h 2024-10-04 15:23:49.102832411 +0200 +@@ -132,7 +132,9 @@ // Cast double to float, ignoring any warning about too-large finite values being cast to float. // Clang thinks this is undefined, but it's actually implementation defined to return either // the largest float or infinity (one of the two bracketing representable floats). Good enough! +#if defined(__clang__) SK_NO_SANITIZE("float-cast-overflow") +#endif - static inline float sk_double_to_float(double x) { + static constexpr float sk_double_to_float(double x) { return static_cast<float>(x); } -@@ -242,12 +244,16 @@ static inline int sk_float_nextlog2(float x) { - // IEEE defines how float divide behaves for non-finite values and zero-denoms, but C does not +@@ -161,12 +163,16 @@ + + // IEEE defines how float divide behaves for non-finite values and zero-denoms, but C does not, // so we have a helper that suppresses the possible undefined-behavior warnings. - +#if defined(__clang__) SK_NO_SANITIZE("float-divide-by-zero") +#endif - static inline float sk_ieee_float_divide(float numer, float denom) { + static constexpr float sk_ieee_float_divide(float numer, float denom) { return numer / denom; } - + +#if defined(__clang__) SK_NO_SANITIZE("float-divide-by-zero") +#endif - static inline double sk_ieee_double_divide(double numer, double denom) { + static constexpr double sk_ieee_double_divide(double numer, double denom) { return numer / denom; } diff --git a/external/skia/fix-SkDebugf-link-error.patch.1 b/external/skia/fix-SkDebugf-link-error.patch.1 index 989e8c407815..fe207f80d685 100644 --- a/external/skia/fix-SkDebugf-link-error.patch.1 +++ b/external/skia/fix-SkDebugf-link-error.patch.1 @@ -6,9 +6,9 @@ diff -ur skia.org/src/ports/SkDebug_stdio.cpp skia/src/ports/SkDebug_stdio.cpp */ +#include "include/private/base/SkAPI.h" + #include "include/private/base/SkDebug.h" #include "include/private/base/SkFeatures.h" #include "include/private/base/SkLoadUserConfig.h" - @@ -13,7 +14,7 @@ #include <stdarg.h> #include <stdio.h> diff --git a/external/skia/fix-warnings.patch.1 b/external/skia/fix-warnings.patch.1 index 46d55e493bd3..cc1a6fba0a41 100644 --- a/external/skia/fix-warnings.patch.1 +++ b/external/skia/fix-warnings.patch.1 @@ -15,8 +15,8 @@ index ae4f1d68b6..71263da7c5 100644 SkFourByteTag tag; diff --git a/tools/sk_app/WindowContext.h b/tools/sk_app/WindowContext.h index f143dab013..be3cde0f4f 100644 ---- a/tools/sk_app/WindowContext.h -+++ b/tools/sk_app/WindowContext.h +--- a/tools/window/WindowContext.h ++++ b/tools/window/WindowContext.h @@ -31,7 +31,7 @@ public: virtual void resize(int w, int h) = 0; diff --git a/external/skia/fix-without-gl.patch.1 b/external/skia/fix-without-gl.patch.1 index 8735dc81d039..1f78e3ebe22d 100644 --- a/external/skia/fix-without-gl.patch.1 +++ b/external/skia/fix-without-gl.patch.1 @@ -1,50 +1,47 @@ -diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h -index e10242b3b7..a1c0058caa 100644 ---- a/include/gpu/gl/GrGLInterface.h -+++ b/include/gpu/gl/GrGLInterface.h -@@ -83,7 +83,9 @@ public: - +diff -ur skia.org/include/gpu/gl/GrGLInterface.h skia/include/gpu/gl/GrGLInterface.h +--- skia.org/include/gpu/gl/GrGLInterface.h 2024-10-04 15:33:38.063875425 +0200 ++++ skia/include/gpu/gl/GrGLInterface.h 2024-10-04 15:34:00.073017585 +0200 +@@ -83,7 +83,9 @@ + GrGLExtensions fExtensions; - + +#ifdef SK_GL bool hasExtension(const char ext[]) const { return fExtensions.has(ext); } +#endif - + /** * The function pointers are in a struct so that we can have a compiler generated assignment -diff --git a/src/gpu/ganesh/gl/GrGLContext.h b/src/gpu/ganesh/gl/GrGLContext.h -index d5424ca6cf..5b730fe176 100644 ---- a/src/gpu/ganesh/gl/GrGLContext.h -+++ b/src/gpu/ganesh/gl/GrGLContext.h -@@ -64,9 +64,11 @@ public: +diff -ur skia.org/src/gpu/ganesh/gl/GrGLContext.h skia/src/gpu/ganesh/gl/GrGLContext.h +--- skia.org/src/gpu/ganesh/gl/GrGLContext.h 2024-10-04 15:33:38.116875769 +0200 ++++ skia/src/gpu/ganesh/gl/GrGLContext.h 2024-10-04 15:34:36.192247894 +0200 +@@ -69,9 +69,11 @@ const GrGLCaps* caps() const { return fGLCaps.get(); } GrGLCaps* caps() { return fGLCaps.get(); } - + +#ifdef SK_GL bool hasExtension(const char* ext) const { return fInterface->hasExtension(ext); } +#endif - + const GrGLExtensions& extensions() const { return fInterface->fExtensions; } - -diff --git a/src/gpu/ganesh/gl/GrGLGpu.h b/src/gpu/ganesh/gl/GrGLGpu.h -index a3ac1ad25d..ffc18093e6 100644 ---- a/src/gpu/ganesh/gl/GrGLGpu.h -+++ b/src/gpu/ganesh/gl/GrGLGpu.h -@@ -279,6 +279,7 @@ private: + +diff -ur skia.org/src/gpu/ganesh/gl/GrGLGpu.h skia/src/gpu/ganesh/gl/GrGLGpu.h +--- skia.org/src/gpu/ganesh/gl/GrGLGpu.h 2024-10-04 15:33:38.116875769 +0200 ++++ skia/src/gpu/ganesh/gl/GrGLGpu.h 2024-10-04 15:35:07.627445512 +0200 +@@ -291,6 +291,7 @@ // compatible stencil format, or negative if there is no compatible stencil format. int getCompatibleStencilIndex(GrGLFormat format); - + +#ifdef SK_GL GrBackendFormat getPreferredStencilFormat(const GrBackendFormat& format) override { - int idx = this->getCompatibleStencilIndex(format.asGLFormat()); + int idx = this->getCompatibleStencilIndex(GrBackendFormats::AsGLFormat(format)); if (idx < 0) { -@@ -287,6 +288,7 @@ private: - return GrBackendFormat::MakeGL(GrGLFormatToEnum(this->glCaps().stencilFormats()[idx]), - GR_GL_TEXTURE_NONE); +@@ -299,6 +300,7 @@ + return GrBackendFormats::MakeGL(GrGLFormatToEnum(this->glCaps().stencilFormats()[idx]), + GR_GL_TEXTURE_NONE); } +#endif - + void onFBOChanged(); - + diff --git a/external/skia/help-msvc-analyzer.patch b/external/skia/help-msvc-analyzer.patch index f9080782ce59..73554111907f 100644 --- a/external/skia/help-msvc-analyzer.patch +++ b/external/skia/help-msvc-analyzer.patch @@ -1,6 +1,6 @@ --- skia/include/private/base/SkAssert.h.orig +++ skia/include/private/base/SkAssert.h -@@ -43,6 +43,13 @@ +@@ -60,6 +60,13 @@ } while (false) #endif @@ -11,15 +11,15 @@ +# define SkANALYSIS_ASSUME(condition) static_cast<void>(0) +#endif + - // SkASSERT, SkASSERTF and SkASSERT_RELEASE can be used as stand alone assertion expressions, e.g. + // SkASSERT, SkASSERTF and SkASSERT_RELEASE can be used as standalone assertion expressions, e.g. // uint32_t foo(int x) { // SkASSERT(x > 4); -@@ -54,7 +60,7 @@ - // x - 4; - // } +@@ -77,7 +83,7 @@ + : []{ SK_ABORT("check(%s)", #cond); }() ) + #else #define SkASSERT_RELEASE(cond) \ -- static_cast<void>( (cond) ? (void)0 : []{ SK_ABORT("assert(%s)", #cond); }() ) -+ static_cast<void>( (cond) ? (void)0 : [&]{ SK_ABORT("assert(%s)", #cond); SkANALYSIS_ASSUME(cond); }() ) - +- static_cast<void>( (cond) ? static_cast<void>(0) : []{ SK_ABORT("check(%s)", #cond); }() ) ++ static_cast<void>( (cond) ? static_cast<void>(0) : [&]{ SK_ABORT("check(%s)", #cond); SkANALYSIS_ASSUME(cond); }() ) + #endif + #if defined(SK_DEBUG) - #define SkASSERT(cond) SkASSERT_RELEASE(cond) diff --git a/external/skia/macosmetal.patch.0 b/external/skia/macosmetal.patch.0 index 3da9fc693fe9..342f735e9ea4 100644 --- a/external/skia/macosmetal.patch.0 +++ b/external/skia/macosmetal.patch.0 @@ -1,5 +1,5 @@ ---- tools/sk_app/mac/WindowContextFactory_mac.h 2022-02-16 06:03:39.000000000 -0500 -+++ tools/sk_app/mac/WindowContextFactory_mac.h 2023-01-25 08:09:00.000000000 -0500 +--- tools/window/mac/WindowContextFactory_mac.h 2022-02-16 06:03:39.000000000 -0500 ++++ tools/window/mac/WindowContextFactory_mac.h 2023-01-25 08:09:00.000000000 -0500 @@ -19,15 +19,8 @@ struct DisplayParams; @@ -16,19 +16,19 @@ +SK_API CGFloat GetBackingScaleFactor(NSView* view); +SK_API void ResetBackingScaleFactor(); - namespace window_context_factory { - + struct MacWindowInfo { + NSView* fMainView; --- /dev/null 2023-01-25 09:20:55.000000000 -0500 -+++ tools/sk_app/mac/WindowContextFactory_mac.mm 2023-01-25 09:21:22.000000000 -0500 ++++ tools/window/mac/WindowContextFactory_mac.mm 2023-01-25 09:21:22.000000000 -0500 @@ -0,0 +1,57 @@ +/* + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + -+#include "tools/sk_app/mac/WindowContextFactory_mac.h" ++#include "tools/window/mac/WindowContextFactory_mac.h" + -+namespace sk_app { ++namespace skwindow { + +static bool bWindowScaling = false; +static float fWindowScale = 1.0f; @@ -78,17 +78,17 @@ +} + +} // namespace sk_app ---- tools/sk_app/mac/MetalWindowContext_mac.mm 2024-08-31 15:49:57 -+++ tools/sk_app/mac/MetalWindowContext_mac.mm 2024-09-25 20:09:32 +--- tools/window/mac/MetalWindowContext_mac.mm 2024-08-31 15:49:57 ++++ tools/window/mac/MetalWindowContext_mac.mm 2024-09-25 20:09:32 @@ -11,6 +11,8 @@ #import <Cocoa/Cocoa.h> #import <QuartzCore/CAConstraintLayoutManager.h> +#include <sal/log.hxx> + - using sk_app::DisplayParams; - using sk_app::window_context_factory::MacWindowInfo; - using sk_app::MetalWindowContext; + using skwindow::DisplayParams; + using skwindow::MacWindowInfo; + using skwindow::internal::MetalWindowContext; @@ -66,8 +68,7 @@ fMetalLayer.autoresizingMask = kCALayerHeightSizable | kCALayerWidthSizable; fMetalLayer.contentsGravity = kCAGravityTopLeft; diff --git a/external/skia/make-api-visible.patch.1 b/external/skia/make-api-visible.patch.1 index 4248fb526ef2..8b8e37359ec5 100644 --- a/external/skia/make-api-visible.patch.1 +++ b/external/skia/make-api-visible.patch.1 @@ -1,99 +1,106 @@ -diff --git a/tools/sk_app/WindowContext.h b/tools/sk_app/WindowContext.h -index 79f6d72f35..428d198159 100644 ---- a/tools/sk_app/WindowContext.h -+++ b/tools/sk_app/WindowContext.h -@@ -22,7 +22,7 @@ class Context; - - namespace sk_app { - --class WindowContext { -+class SK_API WindowContext { - public: - WindowContext(const DisplayParams&); - -diff --git a/tools/sk_app/mac/WindowContextFactory_mac.h b/tools/sk_app/mac/WindowContextFactory_mac.h -index 3e136a8f57..affb89e43e 100644 ---- a/tools/sk_app/mac/WindowContextFactory_mac.h -+++ b/tools/sk_app/mac/WindowContextFactory_mac.h -@@ -52,7 +52,7 @@ std::unique_ptr<WindowContext> MakeDawnMTLForMac(const MacWindowInfo&, const Dis +diff -ur skia.org/tools/window/mac/WindowContextFactory_mac.h skia/tools/window/mac/WindowContextFactory_mac.h +--- skia.org/tools/window/mac/WindowContextFactory_mac.h 2024-10-04 14:26:29.787526193 +0200 ++++ skia/tools/window/mac/WindowContextFactory_mac.h 2024-10-04 14:28:08.353196733 +0200 +@@ -53,7 +53,7 @@ #endif - + #ifdef SK_METAL -std::unique_ptr<WindowContext> MakeMetalForMac(const MacWindowInfo&, const DisplayParams&); +SK_API std::unique_ptr<WindowContext> MakeMetalForMac(const MacWindowInfo&, const DisplayParams&); #if defined(SK_GRAPHITE) std::unique_ptr<WindowContext> MakeGraphiteMetalForMac(const MacWindowInfo&, const DisplayParams&); #endif -diff --git a/tools/sk_app/unix/WindowContextFactory_unix.h b/tools/sk_app/unix/WindowContextFactory_unix.h -index 11bd2d2ac2..09c92dc417 100644 ---- a/tools/sk_app/unix/WindowContextFactory_unix.h -+++ b/tools/sk_app/unix/WindowContextFactory_unix.h -@@ -36,20 +36,20 @@ struct XlibWindowInfo { - int fHeight; +diff -ur skia.org/tools/window/unix/WindowContextFactory_unix.h skia/tools/window/unix/WindowContextFactory_unix.h +--- skia.org/tools/window/unix/WindowContextFactory_unix.h 2024-10-04 14:26:29.787526193 +0200 ++++ skia/tools/window/unix/WindowContextFactory_unix.h 2024-10-04 14:29:16.184625681 +0200 +@@ -35,7 +35,7 @@ }; - + + #ifdef SK_VULKAN -std::unique_ptr<WindowContext> MakeVulkanForXlib(const XlibWindowInfo&, const DisplayParams&); +SK_API std::unique_ptr<WindowContext> MakeVulkanForXlib(const XlibWindowInfo&, const DisplayParams&); - + #if defined(SK_GRAPHITE) + std::unique_ptr<WindowContext> MakeGraphiteVulkanForXlib(const XlibWindowInfo&, + const DisplayParams&); +@@ -43,11 +43,11 @@ + #endif + + #ifdef SK_GL -std::unique_ptr<WindowContext> MakeGLForXlib(const XlibWindowInfo&, const DisplayParams&); +SK_API std::unique_ptr<WindowContext> MakeGLForXlib(const XlibWindowInfo&, const DisplayParams&); - + #endif + #ifdef SK_DAWN -std::unique_ptr<WindowContext> MakeDawnVulkanForXlib(const XlibWindowInfo&, const DisplayParams&); +SK_API std::unique_ptr<WindowContext> MakeDawnVulkanForXlib(const XlibWindowInfo&, const DisplayParams&); #endif - + #if defined(SK_DAWN) && defined(SK_GRAPHITE) - std::unique_ptr<WindowContext> MakeGraphiteDawnVulkanForXlib(const XlibWindowInfo&, +@@ -55,7 +55,7 @@ const DisplayParams&); #endif - + -std::unique_ptr<WindowContext> MakeRasterForXlib(const XlibWindowInfo&, const DisplayParams&); +SK_API std::unique_ptr<WindowContext> MakeRasterForXlib(const XlibWindowInfo&, const DisplayParams&); - - } // namespace window_context_factory - -diff --git a/tools/sk_app/win/WindowContextFactory_win.h b/tools/sk_app/win/WindowContextFactory_win.h -index c05a4f0acf..fc27cd2afb 100644 ---- a/tools/sk_app/win/WindowContextFactory_win.h -+++ b/tools/sk_app/win/WindowContextFactory_win.h -@@ -13,31 +13,33 @@ struct DisplayParams; - + + } // namespace skwindow + +diff -ur skia.org/tools/window/win/WindowContextFactory_win.h skia/tools/window/win/WindowContextFactory_win.h +--- skia.org/tools/window/win/WindowContextFactory_win.h 2024-10-04 14:26:29.787526193 +0200 ++++ skia/tools/window/win/WindowContextFactory_win.h 2024-10-04 14:30:25.346039651 +0200 +@@ -13,28 +13,30 @@ + #include <memory> - + +#include "include/core/SkTypes.h" + - namespace sk_app { - + namespace skwindow { + class WindowContext; struct DisplayParams; - - namespace window_context_factory { - + + #ifdef SK_VULKAN -std::unique_ptr<WindowContext> MakeVulkanForWin(HWND, const DisplayParams&); +SK_API std::unique_ptr<WindowContext> MakeVulkanForWin(HWND, const DisplayParams&); - + #if defined(SK_GRAPHITE) + std::unique_ptr<WindowContext> MakeGraphiteVulkanForWin(HWND, const DisplayParams&); + #endif + #endif + + #ifdef SK_GL -std::unique_ptr<WindowContext> MakeGLForWin(HWND, const DisplayParams&); +SK_API std::unique_ptr<WindowContext> MakeGLForWin(HWND, const DisplayParams&); - + #endif + + #ifdef SK_ANGLE -std::unique_ptr<WindowContext> MakeANGLEForWin(HWND, const DisplayParams&); +SK_API std::unique_ptr<WindowContext> MakeANGLEForWin(HWND, const DisplayParams&); - + #endif + #ifdef SK_DIRECT3D -std::unique_ptr<WindowContext> MakeD3D12ForWin(HWND, const DisplayParams&); +SK_API std::unique_ptr<WindowContext> MakeD3D12ForWin(HWND, const DisplayParams&); #endif - + #ifdef SK_DAWN --std::unique_ptr<WindowContext> MakeDawnD3D12ForWin(HWND, const DisplayParams&); -+SK_API std::unique_ptr<WindowContext> MakeDawnD3D12ForWin(HWND, const DisplayParams&); - #if defined(SK_GRAPHITE) - std::unique_ptr<WindowContext> MakeGraphiteDawnD3D12ForWin(HWND, const DisplayParams&); +@@ -44,7 +46,7 @@ #endif #endif - + -std::unique_ptr<WindowContext> MakeRasterForWin(HWND, const DisplayParams&); +SK_API std::unique_ptr<WindowContext> MakeRasterForWin(HWND, const DisplayParams&); - - } // namespace window_context_factory - + + } // namespace skwindow + +diff -ur skia.org/tools/window/WindowContext.h skia/tools/window/WindowContext.h +--- skia.org/tools/window/WindowContext.h 2024-10-04 14:26:29.787526193 +0200 ++++ skia/tools/window/WindowContext.h 2024-10-04 14:27:39.148004258 +0200 +@@ -23,7 +23,7 @@ + + namespace skwindow { + +-class WindowContext { ++class SK_API WindowContext { + public: + WindowContext(const DisplayParams&); + diff --git a/external/skia/share-grcontext.patch.1 b/external/skia/share-grcontext.patch.1 index 9d491868bf44..1ccf95699593 100644 --- a/external/skia/share-grcontext.patch.1 +++ b/external/skia/share-grcontext.patch.1 @@ -1,34 +1,52 @@ -diff --git a/tools/sk_app/MetalWindowContext.h b/tools/sk_app/MetalWindowContext.h -index 106d366415..08dc19b5c8 100644 ---- a/tools/sk_app/MetalWindowContext.h -+++ b/tools/sk_app/MetalWindowContext.h +diff -ur skia.org/tools/window/mac/MetalWindowContext_mac.mm skia/tools/window/mac/MetalWindowContext_mac.mm +--- skia.org/tools/window/mac/MetalWindowContext_mac.mm 2024-10-06 14:30:21.225939090 +0200 ++++ skia/tools/window/mac/MetalWindowContext_mac.mm 2024-10-06 14:31:51.351498737 +0200 +@@ -47,10 +47,14 @@ + } + + bool MetalWindowContext_mac::onInitializeContext() { ++ // Allow creating just the shared context, without an associated window. ++ if(fMainView == nil) ++ return true; ++ + SkASSERT(nil != fMainView); + + fMetalLayer = [CAMetalLayer layer]; +- fMetalLayer.device = fDevice.get(); ++ fMetalLayer.device = fShared->fDevice.get(); + fMetalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm; + + // resize ignores the passed values and uses the fMainView directly. +diff -ur skia.org/tools/window/MetalWindowContext.h skia/tools/window/MetalWindowContext.h +--- skia.org/tools/window/MetalWindowContext.h 2024-10-06 14:30:21.225939090 +0200 ++++ skia/tools/window/MetalWindowContext.h 2024-10-06 14:31:51.352498743 +0200 @@ -14,13 +14,18 @@ - - #include "tools/sk_app/WindowContext.h" - + + #include "tools/window/WindowContext.h" + +#ifdef __OBJC__ #import <Metal/Metal.h> #import <QuartzCore/CAMetalLayer.h> +#endif - - namespace sk_app { - + + namespace skwindow::internal { + +#ifdef __OBJC__ class MetalWindowContext : public WindowContext { public: + static GrDirectContext* getSharedGrDirectContext() { return fGlobalShared ? fGlobalShared->fContext.get() : nullptr; } + sk_sp<SkSurface> getBackbufferSurface() override; - + bool isValid() override { return fValid; } @@ -44,18 +49,36 @@ void destroyContext(); virtual void onDestroyContext() = 0; - + + static void checkDestroyShared(); + void onSwapBuffers() override; - + bool fValid; + + // We need to use just one GrDirectContext, so share all the relevant data. @@ -57,16 +75,15 @@ index 106d366415..08dc19b5c8 100644 + +// Access function when header is used from C++ code that wouldn't handle ObjC++ headers. +extern "C" SK_API GrDirectContext* getMetalSharedGrDirectContext(); - - } // namespace sk_app - -diff --git a/tools/sk_app/MetalWindowContext.mm b/tools/sk_app/MetalWindowContext.mm -index d972e321a6..9f576944b7 100644 ---- a/tools/sk_app/MetalWindowContext.mm -+++ b/tools/sk_app/MetalWindowContext.mm -@@ -40,24 +40,30 @@ NSURL* MetalWindowContext::CacheURL() { + + } // namespace skwindow::internal + +diff -ur skia.org/tools/window/MetalWindowContext.mm skia/tools/window/MetalWindowContext.mm +--- skia.org/tools/window/MetalWindowContext.mm 2024-10-06 14:30:21.225939090 +0200 ++++ skia/tools/window/MetalWindowContext.mm 2024-10-06 14:31:51.352498743 +0200 +@@ -39,24 +39,30 @@ } - + void MetalWindowContext::initializeContext() { + fShared = fGlobalShared; + if( !fShared ) @@ -77,12 +94,12 @@ index d972e321a6..9f576944b7 100644 + Shared* d = fGlobalShared.get(); // shorter variable name + SkASSERT(!fContext); - + - fDevice.reset(MTLCreateSystemDefaultDevice()); - fQueue.reset([*fDevice newCommandQueue]); + d->fDevice.reset(MTLCreateSystemDefaultDevice()); + d->fQueue.reset([*d->fDevice newCommandQueue]); - + if (fDisplayParams.fMSAASampleCount > 1) { if (@available(macOS 10.11, iOS 9.0, *)) { - if (![*fDevice supportsTextureSampleCount:fDisplayParams.fMSAASampleCount]) { @@ -99,10 +116,10 @@ index d972e321a6..9f576944b7 100644 - fStencilBits = 8; - - fValid = this->onInitializeContext(); - + #if SKGPU_GRAPHITE_METAL_SDK_VERSION >= 230 if (fDisplayParams.fEnableBinaryArchive) { -@@ -62,11 +68,11 @@ void MetalWindowContext::initializeContext() { +@@ -64,11 +70,11 @@ sk_cfp<MTLBinaryArchiveDescriptor*> desc([MTLBinaryArchiveDescriptor new]); (*desc).url = CacheURL(); // try to load NSError* error; @@ -118,7 +135,7 @@ index d972e321a6..9f576944b7 100644 SkDebugf("Error creating MTLBinaryArchive: %s ", error.debugDescription.UTF8String); } -@@ -77,46 +83,75 @@ void MetalWindowContext::initializeContext() { +@@ -76,46 +82,75 @@ } } else { if (@available(macOS 11.0, iOS 14.0, *)) { @@ -127,7 +144,7 @@ index d972e321a6..9f576944b7 100644 } } #endif - + GrMtlBackendContext backendContext = {}; - backendContext.fDevice.retain((GrMTLHandle)fDevice.get()); - backendContext.fQueue.retain((GrMTLHandle)fQueue.get()); @@ -159,7 +176,7 @@ index d972e321a6..9f576944b7 100644 + + fValid = this->onInitializeContext(); } - + void MetalWindowContext::destroyContext() { - if (fContext) { - // in case we have outstanding refs to this (lua?) @@ -168,10 +185,10 @@ index d972e321a6..9f576944b7 100644 - } - this->onDestroyContext(); - + fMetalLayer = nil; fValid = false; - + + fContext.reset(); + fShared.reset(); + @@ -207,18 +224,18 @@ index d972e321a6..9f576944b7 100644 + + fGlobalShared.reset(); } - + sk_sp<SkSurface> MetalWindowContext::getBackbufferSurface() { -@@ -159,7 +194,7 @@ sk_sp<SkSurface> MetalWindowContext::getBackbufferSurface() { +@@ -161,7 +196,7 @@ void MetalWindowContext::onSwapBuffers() { id<CAMetalDrawable> currentDrawable = (id<CAMetalDrawable>)fDrawableHandle; - + - id<MTLCommandBuffer> commandBuffer([*fQueue commandBuffer]); + id<MTLCommandBuffer> commandBuffer([*fShared->fQueue commandBuffer]); commandBuffer.label = @"Present"; - + [commandBuffer presentDrawable:currentDrawable]; -@@ -180,9 +215,9 @@ void MetalWindowContext::activate(bool isActive) { +@@ -182,9 +217,9 @@ if (!isActive) { #if SKGPU_GRAPHITE_METAL_SDK_VERSION >= 230 if (@available(macOS 11.0, iOS 14.0, *)) { @@ -230,10 +247,10 @@ index d972e321a6..9f576944b7 100644 if (error) { SkDebugf("Error storing MTLBinaryArchive: %s ", error.debugDescription.UTF8String); -@@ -188,4 +223,11 @@ void MetalWindowContext::activate(bool isActive) { +@@ -195,4 +230,11 @@ } } - + +SK_API sk_sp<MetalWindowContext::Shared> MetalWindowContext::fGlobalShared; + +GrDirectContext* getMetalSharedGrDirectContext() @@ -241,14 +258,44 @@ index d972e321a6..9f576944b7 100644 + return MetalWindowContext::getSharedGrDirectContext(); +} + - } //namespace sk_app -diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp -index c9db528ca4..634034da5a 100644 ---- a/tools/sk_app/VulkanWindowContext.cpp -+++ b/tools/sk_app/VulkanWindowContext.cpp + } //namespace skwindow::internal +diff -ur skia.org/tools/window/unix/VulkanWindowContext_unix.cpp skia/tools/window/unix/VulkanWindowContext_unix.cpp +--- skia.org/tools/window/unix/VulkanWindowContext_unix.cpp 2024-10-06 14:30:21.226939096 +0200 ++++ skia/tools/window/unix/VulkanWindowContext_unix.cpp 2024-10-06 14:32:20.232679644 +0200 +@@ -24,7 +24,7 @@ + return nullptr; + } + +- auto createVkSurface = [&info, instProc](VkInstance instance) -> VkSurfaceKHR { ++ internal::VulkanWindowContext::CreateVkSurfaceFn createVkSurface = [&info, instProc](VkInstance instance) -> VkSurfaceKHR { + static PFN_vkCreateXcbSurfaceKHR createXcbSurfaceKHR = nullptr; + if (!createXcbSurfaceKHR) { + createXcbSurfaceKHR = +@@ -48,6 +48,9 @@ + + return surface; + }; ++ // Allow creating just the shared context, without an associated window. ++ if(info.fWindow == None) ++ createVkSurface = nullptr; + + auto canPresent = [&info, instProc](VkInstance instance, VkPhysicalDevice physDev, + uint32_t queueFamilyIndex) { +@@ -73,7 +76,7 @@ + createVkSurface, + canPresent, + instProc)); +- if (!ctx->isValid()) { ++ if (!ctx->isValid() && createVkSurface != nullptr) { + return nullptr; + } + return ctx; +diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanWindowContext.cpp +--- skia.org/tools/window/VulkanWindowContext.cpp 2024-10-06 14:30:21.225939090 +0200 ++++ skia/tools/window/VulkanWindowContext.cpp 2024-10-06 14:32:40.756808630 +0200 @@ -25,9 +25,13 @@ #endif - + #define GET_PROC(F) f ## F = \ - (PFN_vk ## F) backendContext.fGetProc("vk" #F, fInstance, VK_NULL_HANDLE) + (PFN_vk ## F) fGlobalShared->backendContext.fGetProc("vk" #F, fShared->fInstance, VK_NULL_HANDLE) @@ -259,12 +306,12 @@ index c9db528ca4..634034da5a 100644 + (PFN_vk ## F) fGlobalShared->backendContext.fGetProc("vk" #F, fGlobalShared->fInstance, VK_NULL_HANDLE) +#define GET_DEV_PROC_GLOBAL(F) fGlobalShared->f ## F = \ + (PFN_vk ## F) fGlobalShared->backendContext.fGetProc("vk" #F, VK_NULL_HANDLE, fGlobalShared->fDevice) - - namespace sk_app { - -@@ -49,31 +53,39 @@ VulkanWindowContext::VulkanWindowContext(const DisplayParams& params, + + namespace skwindow::internal { + +@@ -49,32 +53,39 @@ } - + void VulkanWindowContext::initializeContext() { + fShared = fGlobalShared; + if( !fShared ) @@ -276,7 +323,7 @@ index c9db528ca4..634034da5a 100644 + SkASSERT(!fContext); // any config code here (particularly for msaa)? - + PFN_vkGetInstanceProcAddr getInstanceProc = fGetInstanceProcAddr; - GrVkBackendContext backendContext; + GrVkBackendContext& backendContext = fGlobalShared->backendContext; @@ -284,7 +331,8 @@ index c9db528ca4..634034da5a 100644 - VkPhysicalDeviceFeatures2 features; - if (!sk_gpu_test::CreateVkBackendContext(getInstanceProc, &backendContext, &extensions, - &features, &fDebugCallback, &fPresentQueueIndex, -- fCanPresentFn)) { +- fCanPresentFn, +- fDisplayParams.fCreateProtectedNativeBackend)) { - sk_gpu_test::FreeVulkanFeaturesStructs(&features); + if (!sk_gpu_test::CreateVkBackendContext(getInstanceProc, &backendContext, &extensions, &d->features, + &d->fDebugCallback, &d->fPresentQueueIndex, fCanPresentFn)) { @@ -292,7 +340,7 @@ index c9db528ca4..634034da5a 100644 + fGlobalShared.reset(); return; } - + if (!extensions.hasExtension(VK_KHR_SURFACE_EXTENSION_NAME, 25) || !extensions.hasExtension(VK_KHR_SWAPCHAIN_EXTENSION_NAME, 68)) { - sk_gpu_test::FreeVulkanFeaturesStructs(&features); @@ -300,7 +348,7 @@ index c9db528ca4..634034da5a 100644 + fGlobalShared.reset(); return; } - + - fInstance = backendContext.fInstance; - fPhysicalDevice = backendContext.fPhysicalDevice; - fDevice = backendContext.fDevice; @@ -311,10 +359,10 @@ index c9db528ca4..634034da5a 100644 + d->fDevice = backendContext.fDevice; + d->fGraphicsQueueIndex = backendContext.fGraphicsQueueIndex; + d->fGraphicsQueue = backendContext.fQueue; - + PFN_vkGetPhysicalDeviceProperties localGetPhysicalDeviceProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceProperties>( -@@ -81,21 +93,30 @@ void VulkanWindowContext::initializeContext() { +@@ -82,21 +93,30 @@ backendContext.fInstance, VK_NULL_HANDLE)); if (!localGetPhysicalDeviceProperties) { @@ -328,12 +376,12 @@ index c9db528ca4..634034da5a 100644 - uint32_t physDevVersion = physDeviceProperties.apiVersion; + localGetPhysicalDeviceProperties(backendContext.fPhysicalDevice, &d->physDeviceProperties); + uint32_t physDevVersion = d->physDeviceProperties.apiVersion; - + - fInterface.reset(new skgpu::VulkanInterface(backendContext.fGetProc, fInstance, fDevice, + d->fInterface.reset(new skgpu::VulkanInterface(backendContext.fGetProc, d->fInstance, d->fDevice, backendContext.fInstanceVersion, physDevVersion, &extensions)); - + - GET_PROC(DestroyInstance); - if (fDebugCallback != VK_NULL_HANDLE) { - GET_PROC(DestroyDebugReportCallbackEXT); @@ -353,7 +401,7 @@ index c9db528ca4..634034da5a 100644 GET_PROC(DestroySurfaceKHR); GET_PROC(GetPhysicalDeviceSurfaceSupportKHR); GET_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR); -@@ -103,7 +124,6 @@ void VulkanWindowContext::initializeContext() { +@@ -104,7 +124,6 @@ GET_PROC(GetPhysicalDeviceSurfacePresentModesKHR); GET_DEV_PROC(DeviceWaitIdle); GET_DEV_PROC(QueueWaitIdle); @@ -361,15 +409,15 @@ index c9db528ca4..634034da5a 100644 GET_DEV_PROC(CreateSwapchainKHR); GET_DEV_PROC(DestroySwapchainKHR); GET_DEV_PROC(GetSwapchainImagesKHR); -@@ -111,46 +131,44 @@ void VulkanWindowContext::initializeContext() { +@@ -112,46 +131,44 @@ GET_DEV_PROC(QueuePresentKHR); GET_DEV_PROC(GetDeviceQueue); - + - fContext = GrDirectContext::MakeVulkan(backendContext, fDisplayParams.fGrContextOptions); + // No actual window, used just to create the shared GrContext. + if(fCreateVkSurfaceFn == nullptr) + return; - + - fSurface = fCreateVkSurfaceFn(fInstance); + fSurface = fCreateVkSurfaceFn(fShared->fInstance); if (VK_NULL_HANDLE == fSurface) { @@ -377,7 +425,7 @@ index c9db528ca4..634034da5a 100644 - sk_gpu_test::FreeVulkanFeaturesStructs(&features); return; } - + + // create presentQueue + fGetDeviceQueue(fShared->fDevice, fShared->fPresentQueueIndex, 0, &fPresentQueue); + @@ -390,7 +438,7 @@ index c9db528ca4..634034da5a 100644 - sk_gpu_test::FreeVulkanFeaturesStructs(&features); return; } - + if (!this->createSwapchain(-1, -1, fDisplayParams)) { this->destroyContext(); - sk_gpu_test::FreeVulkanFeaturesStructs(&features); @@ -401,7 +449,7 @@ index c9db528ca4..634034da5a 100644 - fGetDeviceQueue(fDevice, fPresentQueueIndex, 0, &fPresentQueue); - sk_gpu_test::FreeVulkanFeaturesStructs(&features); } - + bool VulkanWindowContext::createSwapchain(int width, int height, const DisplayParams& params) { // check for capabilities @@ -411,15 +459,15 @@ index c9db528ca4..634034da5a 100644 if (VK_SUCCESS != res) { return false; } - + uint32_t surfaceFormatCount; - res = fGetPhysicalDeviceSurfaceFormatsKHR(fPhysicalDevice, fSurface, &surfaceFormatCount, + res = fGetPhysicalDeviceSurfaceFormatsKHR(fShared->fPhysicalDevice, fSurface, &surfaceFormatCount, nullptr); if (VK_SUCCESS != res) { return false; -@@ -158,14 +176,14 @@ bool VulkanWindowContext::createSwapchain(int width, int height, - +@@ -159,14 +176,14 @@ + SkAutoMalloc surfaceFormatAlloc(surfaceFormatCount * sizeof(VkSurfaceFormatKHR)); VkSurfaceFormatKHR* surfaceFormats = (VkSurfaceFormatKHR*)surfaceFormatAlloc.get(); - res = fGetPhysicalDeviceSurfaceFormatsKHR(fPhysicalDevice, fSurface, &surfaceFormatCount, @@ -428,15 +476,15 @@ index c9db528ca4..634034da5a 100644 if (VK_SUCCESS != res) { return false; } - + uint32_t presentModeCount; - res = fGetPhysicalDeviceSurfacePresentModesKHR(fPhysicalDevice, fSurface, &presentModeCount, + res = fGetPhysicalDeviceSurfacePresentModesKHR(fShared->fPhysicalDevice, fSurface, &presentModeCount, nullptr); if (VK_SUCCESS != res) { return false; -@@ -173,7 +191,7 @@ bool VulkanWindowContext::createSwapchain(int width, int height, - +@@ -174,7 +191,7 @@ + SkAutoMalloc presentModeAlloc(presentModeCount * sizeof(VkPresentModeKHR)); VkPresentModeKHR* presentModes = (VkPresentModeKHR*)presentModeAlloc.get(); - res = fGetPhysicalDeviceSurfacePresentModesKHR(fPhysicalDevice, fSurface, &presentModeCount, @@ -444,10 +492,10 @@ index c9db528ca4..634034da5a 100644 presentModes); if (VK_SUCCESS != res) { return false; -@@ -286,8 +304,8 @@ bool VulkanWindowContext::createSwapchain(int width, int height, +@@ -290,8 +307,8 @@ swapchainCreateInfo.imageArrayLayers = 1; swapchainCreateInfo.imageUsage = usageFlags; - + - uint32_t queueFamilies[] = { fGraphicsQueueIndex, fPresentQueueIndex }; - if (fGraphicsQueueIndex != fPresentQueueIndex) { + uint32_t queueFamilies[] = { fShared->fGraphicsQueueIndex, fShared->fPresentQueueIndex }; @@ -455,62 +503,61 @@ index c9db528ca4..634034da5a 100644 swapchainCreateInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT; swapchainCreateInfo.queueFamilyIndexCount = 2; swapchainCreateInfo.pQueueFamilyIndices = queueFamilies; -@@ -303,27 +321,27 @@ bool VulkanWindowContext::createSwapchain(int width, int height, +@@ -307,27 +324,27 @@ swapchainCreateInfo.clipped = true; swapchainCreateInfo.oldSwapchain = fSwapchain; - + - res = fCreateSwapchainKHR(fDevice, &swapchainCreateInfo, nullptr, &fSwapchain); + res = fCreateSwapchainKHR(fShared->fDevice, &swapchainCreateInfo, nullptr, &fSwapchain); if (VK_SUCCESS != res) { return false; } - + // destroy the old swapchain if (swapchainCreateInfo.oldSwapchain != VK_NULL_HANDLE) { - fDeviceWaitIdle(fDevice); + fDeviceWaitIdle(fShared->fDevice); - + this->destroyBuffers(); - + - fDestroySwapchainKHR(fDevice, swapchainCreateInfo.oldSwapchain, nullptr); + fDestroySwapchainKHR(fShared->fDevice, swapchainCreateInfo.oldSwapchain, nullptr); } - + if (!this->createBuffers(swapchainCreateInfo.imageFormat, usageFlags, colorType, swapchainCreateInfo.imageSharingMode)) { - fDeviceWaitIdle(fDevice); + fDeviceWaitIdle(fShared->fDevice); - + this->destroyBuffers(); - + - fDestroySwapchainKHR(fDevice, swapchainCreateInfo.oldSwapchain, nullptr); + fDestroySwapchainKHR(fShared->fDevice, swapchainCreateInfo.oldSwapchain, nullptr); } - + return true; -@@ -332,10 +350,10 @@ bool VulkanWindowContext::createSwapchain(int width, int height, - bool VulkanWindowContext::createBuffers(VkFormat format, VkImageUsageFlags usageFlags, +@@ -337,10 +354,9 @@ + VkImageUsageFlags usageFlags, SkColorType colorType, VkSharingMode sharingMode) { - fGetSwapchainImagesKHR(fDevice, fSwapchain, &fImageCount, nullptr); -+ fGetSwapchainImagesKHR(fShared->fDevice, fSwapchain, &fImageCount, nullptr); SkASSERT(fImageCount); fImages = new VkImage[fImageCount]; - fGetSwapchainImagesKHR(fDevice, fSwapchain, &fImageCount, fImages); + fGetSwapchainImagesKHR(fShared->fDevice, fSwapchain, &fImageCount, fImages); - + // set up initial image layouts and create surfaces fImageLayouts = new VkImageLayout[fImageCount]; -@@ -351,7 +369,7 @@ bool VulkanWindowContext::createBuffers(VkFormat format, VkImageUsageFlags usage +@@ -356,7 +372,7 @@ info.fFormat = format; info.fImageUsageFlags = usageFlags; info.fLevelCount = 1; - info.fCurrentQueueFamily = fPresentQueueIndex; + info.fCurrentQueueFamily = fShared->fPresentQueueIndex; + info.fProtected = skgpu::Protected(fDisplayParams.fCreateProtectedNativeBackend); info.fSharingMode = sharingMode; - - if (usageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) { -@@ -387,8 +405,8 @@ bool VulkanWindowContext::createBuffers(VkFormat format, VkImageUsageFlags usage + +@@ -398,8 +414,8 @@ fBackbuffers = new BackbufferInfo[fImageCount + 1]; for (uint32_t i = 0; i < fImageCount + 1; ++i) { fBackbuffers[i].fImageIndex = -1; @@ -521,7 +568,7 @@ index c9db528ca4..634034da5a 100644 &fBackbuffers[i].fRenderSemaphore)); SkASSERT(result == VK_SUCCESS); } -@@ -401,8 +419,8 @@ void VulkanWindowContext::destroyBuffers() { +@@ -412,8 +428,8 @@ if (fBackbuffers) { for (uint32_t i = 0; i < fImageCount + 1; ++i) { fBackbuffers[i].fImageIndex = -1; @@ -532,33 +579,36 @@ index c9db528ca4..634034da5a 100644 fBackbuffers[i].fRenderSemaphore, nullptr)); } -@@ -427,42 +445,59 @@ VulkanWindowContext::~VulkanWindowContext() { +@@ -438,42 +454,59 @@ void VulkanWindowContext::destroyContext() { if (this->isValid()) { fQueueWaitIdle(fPresentQueue); - fDeviceWaitIdle(fDevice); + fDeviceWaitIdle(fShared->fDevice); - + this->destroyBuffers(); - + if (VK_NULL_HANDLE != fSwapchain) { - fDestroySwapchainKHR(fDevice, fSwapchain, nullptr); + fDestroySwapchainKHR(fShared->fDevice, fSwapchain, nullptr); fSwapchain = VK_NULL_HANDLE; } - + if (VK_NULL_HANDLE != fSurface) { - fDestroySurfaceKHR(fInstance, fSurface, nullptr); + fDestroySurfaceKHR(fShared->fInstance, fSurface, nullptr); fSurface = VK_NULL_HANDLE; } } - + - SkASSERT(fContext->unique()); fContext.reset(); - fInterface.reset(); + fShared.reset(); -+ + +- if (VK_NULL_HANDLE != fDevice) { +- fDestroyDevice(fDevice, nullptr); +- fDevice = VK_NULL_HANDLE; + checkDestroyShared(); +} + @@ -573,15 +623,12 @@ index c9db528ca4..634034da5a 100644 + SkASSERT(fGlobalShared->fContext->unique()); + fGlobalShared->fContext.reset(); + fGlobalShared->fInterface.reset(); - -- if (VK_NULL_HANDLE != fDevice) { -- fDestroyDevice(fDevice, nullptr); -- fDevice = VK_NULL_HANDLE; ++ + if (VK_NULL_HANDLE != fGlobalShared->fDevice) { + fGlobalShared->fDestroyDevice(fGlobalShared->fDevice, nullptr); + fGlobalShared->fDevice = VK_NULL_HANDLE; } - + #ifdef SK_ENABLE_VK_LAYERS - if (fDebugCallback != VK_NULL_HANDLE) { - fDestroyDebugReportCallbackEXT(fInstance, fDebugCallback, nullptr); @@ -589,10 +636,10 @@ index c9db528ca4..634034da5a 100644 + fGlobalShared->fDestroyDebugReportCallbackEXT(fGlobalShared->fInstance, fDebugCallback, nullptr); } #endif - + - fPhysicalDevice = VK_NULL_HANDLE; + fGlobalShared->fPhysicalDevice = VK_NULL_HANDLE; - + - if (VK_NULL_HANDLE != fInstance) { - fDestroyInstance(fInstance, nullptr); - fInstance = VK_NULL_HANDLE; @@ -604,9 +651,9 @@ index c9db528ca4..634034da5a 100644 + sk_gpu_test::FreeVulkanFeaturesStructs(&fGlobalShared->features); + fGlobalShared.reset(); } - + VulkanWindowContext::BackbufferInfo* VulkanWindowContext::getAvailableBackbuffer() { -@@ -488,35 +523,35 @@ sk_sp<SkSurface> VulkanWindowContext::getBackbufferSurface() { +@@ -499,35 +532,35 @@ semaphoreInfo.pNext = nullptr; semaphoreInfo.flags = 0; VkSemaphore semaphore; @@ -614,7 +661,7 @@ index c9db528ca4..634034da5a 100644 + SkDEBUGCODE(VkResult result = )GR_VK_CALL(fShared->fInterface, CreateSemaphore(fShared->fDevice, &semaphoreInfo, nullptr, &semaphore)); SkASSERT(result == VK_SUCCESS); - + // acquire the image - VkResult res = fAcquireNextImageKHR(fDevice, fSwapchain, UINT64_MAX, + VkResult res = fAcquireNextImageKHR(fShared->fDevice, fSwapchain, UINT64_MAX, @@ -635,20 +682,20 @@ index c9db528ca4..634034da5a 100644 return nullptr; } backbuffer = this->getAvailableBackbuffer(); - + // acquire the image - res = fAcquireNextImageKHR(fDevice, fSwapchain, UINT64_MAX, + res = fAcquireNextImageKHR(fShared->fDevice, fSwapchain, UINT64_MAX, semaphore, VK_NULL_HANDLE, &backbuffer->fImageIndex); - + if (VK_SUCCESS != res) { - GR_VK_CALL(fInterface, DestroySemaphore(fDevice, semaphore, nullptr)); + GR_VK_CALL(fShared->fInterface, DestroySemaphore(fShared->fDevice, semaphore, nullptr)); return nullptr; } } -@@ -547,7 +582,7 @@ void VulkanWindowContext::swapBuffers() { +@@ -553,7 +586,7 @@ GrFlushInfo info; info.fNumSemaphores = 1; info.fSignalSemaphores = &beSemaphore; @@ -657,47 +704,46 @@ index c9db528ca4..634034da5a 100644 auto dContext = surface->recordingContext()->asDirectContext(); dContext->flush(surface, info, &presentState); dContext->submit(); -@@ -562,4 +597,6 @@ void VulkanWindowContext::swapBuffers() { +@@ -574,4 +607,6 @@ fQueuePresentKHR(fPresentQueue, &presentInfo); } - + +SK_API sk_sp<VulkanWindowContext::Shared> VulkanWindowContext::fGlobalShared; + - } //namespace sk_app -diff --git a/tools/sk_app/VulkanWindowContext.h b/tools/sk_app/VulkanWindowContext.h -index 7e1fdd9af5..946bca7522 100644 ---- a/tools/sk_app/VulkanWindowContext.h -+++ b/tools/sk_app/VulkanWindowContext.h -@@ -16,19 +16,23 @@ + } // namespace skwindow::internal +diff -ur skia.org/tools/window/VulkanWindowContext.h skia/tools/window/VulkanWindowContext.h +--- skia.org/tools/window/VulkanWindowContext.h 2024-10-06 14:30:21.225939090 +0200 ++++ skia/tools/window/VulkanWindowContext.h 2024-10-06 14:31:51.352498743 +0200 +@@ -15,19 +15,23 @@ #include "tools/gpu/vk/VkTestUtils.h" - #include "tools/sk_app/WindowContext.h" - + #include "tools/window/WindowContext.h" + +#include <cassert> + class GrRenderTarget; - + namespace skgpu { struct VulkanInterface; } - - namespace sk_app { - + + namespace skwindow::internal { + -class VulkanWindowContext : public WindowContext { +class SK_API VulkanWindowContext : public WindowContext { public: ~VulkanWindowContext() override; - + + static GrDirectContext* getSharedGrDirectContext() { return fGlobalShared ? fGlobalShared->fContext.get() : nullptr; } + sk_sp<SkSurface> getBackbufferSurface() override; - + - 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); -@@ -50,9 +54,15 @@ public: +@@ -47,9 +51,15 @@ VulkanWindowContext(const DisplayParams&, CreateVkSurfaceFn, CanPresentFn, PFN_vkGetInstanceProcAddr); - + + static const VkPhysicalDeviceProperties& getPhysDeviceProperties() { + assert( fGlobalShared != nullptr ); + return fGlobalShared->physDeviceProperties; @@ -707,13 +753,13 @@ index 7e1fdd9af5..946bca7522 100644 void initializeContext(); void destroyContext(); + static void checkDestroyShared(); - + struct BackbufferInfo { uint32_t fImageIndex; // image this is associated with -@@ -64,11 +74,6 @@ private: +@@ -62,11 +72,6 @@ void destroyBuffers(); void onSwapBuffers() override; - + - VkInstance fInstance = VK_NULL_HANDLE; - VkPhysicalDevice fPhysicalDevice = VK_NULL_HANDLE; - VkDevice fDevice = VK_NULL_HANDLE; @@ -722,17 +768,17 @@ index 7e1fdd9af5..946bca7522 100644 // Create functions CreateVkSurfaceFn fCreateVkSurfaceFn; CanPresentFn fCanPresentFn; -@@ -88,20 +93,46 @@ private: +@@ -86,20 +91,46 @@ PFN_vkAcquireNextImageKHR fAcquireNextImageKHR = nullptr; PFN_vkQueuePresentKHR fQueuePresentKHR = nullptr; - + - PFN_vkDestroyInstance fDestroyInstance = nullptr; PFN_vkDeviceWaitIdle fDeviceWaitIdle = nullptr; - PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugReportCallbackEXT = nullptr; PFN_vkQueueWaitIdle fQueueWaitIdle = nullptr; - PFN_vkDestroyDevice fDestroyDevice = nullptr; PFN_vkGetDeviceQueue fGetDeviceQueue = nullptr; - + + // We need to use just one GrDirectContext, so share all the relevant data. + struct Shared : public SkRefCnt + { @@ -746,7 +792,7 @@ index 7e1fdd9af5..946bca7522 100644 + VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE; + sk_sp<const skgpu::VulkanInterface> fInterface; - + - VkSurfaceKHR fSurface; - VkSwapchainKHR fSwapchain; + // Original code had this as a function-local variable, but that seems wrong. @@ -772,104 +818,50 @@ index 7e1fdd9af5..946bca7522 100644 + VkSurfaceKHR fSurface; + VkSwapchainKHR fSwapchain; VkQueue fPresentQueue; - + uint32_t fImageCount; -diff --git a/tools/sk_app/WindowContext.h b/tools/sk_app/WindowContext.h -index 65ab8b9aa4..2d222385a3 100644 ---- a/tools/sk_app/WindowContext.h -+++ b/tools/sk_app/WindowContext.h -@@ -10,9 +10,9 @@ - #include "include/core/SkRefCnt.h" - #include "include/core/SkSurfaceProps.h" - #include "include/gpu/GrTypes.h" -+#include "include/gpu/GrDirectContext.h" - #include "tools/sk_app/DisplayParams.h" - --class GrDirectContext; - class SkSurface; - #if defined(SK_GRAPHITE) - namespace skgpu::graphite { -diff --git a/tools/sk_app/mac/MetalWindowContext_mac.mm b/tools/sk_app/mac/MetalWindowContext_mac.mm -index 5bea8578fa..f7df061af0 100644 ---- a/tools/sk_app/mac/MetalWindowContext_mac.mm -+++ b/tools/sk_app/mac/MetalWindowContext_mac.mm -@@ -49,10 +49,14 @@ MetalWindowContext_mac::~MetalWindowContext_mac() { - } - - bool MetalWindowContext_mac::onInitializeContext() { -+ // Allow creating just the shared context, without an associated window. -+ if(fMainView == nil) -+ return true; -+ - SkASSERT(nil != fMainView); - - fMetalLayer = [CAMetalLayer layer]; -- fMetalLayer.device = fDevice.get(); -+ fMetalLayer.device = fShared->fDevice.get(); - fMetalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm; - - // resize ignores the passed values and uses the fMainView directly. -diff --git a/tools/sk_app/unix/VulkanWindowContext_unix.cpp b/tools/sk_app/unix/VulkanWindowContext_unix.cpp -index 2b31fedc19..0c05fbfc92 100644 ---- a/tools/sk_app/unix/VulkanWindowContext_unix.cpp -+++ b/tools/sk_app/unix/VulkanWindowContext_unix.cpp -@@ -30,7 +30,7 @@ std::unique_ptr<WindowContext> MakeVulkanForXlib(const XlibWindowInfo& info, - return nullptr; - } - -- auto createVkSurface = [&info, instProc](VkInstance instance) -> VkSurfaceKHR { -+ VulkanWindowContext::CreateVkSurfaceFn createVkSurface = [&info, instProc](VkInstance instance) -> VkSurfaceKHR { - static PFN_vkCreateXcbSurfaceKHR createXcbSurfaceKHR = nullptr; - if (!createXcbSurfaceKHR) { - createXcbSurfaceKHR = -@@ -54,6 +54,9 @@ std::unique_ptr<WindowContext> MakeVulkanForXlib(const XlibWindowInfo& info, - - return surface; - }; -+ // Allow creating just the shared context, without an associated window. -+ if(info.fWindow == None) -+ createVkSurface = nullptr; - - auto canPresent = [&info, instProc](VkInstance instance, VkPhysicalDevice physDev, - uint32_t queueFamilyIndex) { -@@ -76,7 +79,7 @@ std::unique_ptr<WindowContext> MakeVulkanForXlib(const XlibWindowInfo& info, - }; - std::unique_ptr<WindowContext> ctx( - new VulkanWindowContext(displayParams, createVkSurface, canPresent, instProc)); -- if (!ctx->isValid()) { -+ if (!ctx->isValid() && createVkSurface != nullptr) { - return nullptr; - } - return ctx; -diff --git a/tools/sk_app/win/VulkanWindowContext_win.cpp b/tools/sk_app/win/VulkanWindowContext_win.cpp -index 976c42556e..c8f6b162bf 100644 ---- a/tools/sk_app/win/VulkanWindowContext_win.cpp -+++ b/tools/sk_app/win/VulkanWindowContext_win.cpp -@@ -29,7 +29,7 @@ std::unique_ptr<WindowContext> MakeVulkanForWin(HWND hwnd, const DisplayParams& +diff -ur skia.org/tools/window/win/VulkanWindowContext_win.cpp skia/tools/window/win/VulkanWindowContext_win.cpp +--- skia.org/tools/window/win/VulkanWindowContext_win.cpp 2024-10-06 14:30:21.225939090 +0200 ++++ skia/tools/window/win/VulkanWindowContext_win.cpp 2024-10-06 14:31:51.352498743 +0200 +@@ -25,7 +25,7 @@ return nullptr; } - + - auto createVkSurface = [hwnd, instProc] (VkInstance instance) -> VkSurfaceKHR { -+ VulkanWindowContext::CreateVkSurfaceFn createVkSurface = [hwnd, instProc] (VkInstance instance) -> VkSurfaceKHR { ++ internal::VulkanWindowContext::CreateVkSurfaceFn createVkSurface = [hwnd, instProc] (VkInstance instance) -> VkSurfaceKHR { static PFN_vkCreateWin32SurfaceKHR createWin32SurfaceKHR = nullptr; if (!createWin32SurfaceKHR) { createWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) -@@ -53,6 +53,9 @@ std::unique_ptr<WindowContext> MakeVulkanForWin(HWND hwnd, const DisplayParams& - +@@ -49,6 +49,9 @@ + return surface; }; + // Allow creating just the shared context, without an associated window. + if(hwnd == nullptr) + createVkSurface = nullptr; - + auto canPresent = [instProc] (VkInstance instance, VkPhysicalDevice physDev, uint32_t queueFamilyIndex) { -@@ -70,7 +73,7 @@ std::unique_ptr<WindowContext> MakeVulkanForWin(HWND hwnd, const DisplayParams& - +@@ -66,7 +69,7 @@ + std::unique_ptr<WindowContext> ctx( - new VulkanWindowContext(params, createVkSurface, canPresent, instProc)); + new internal::VulkanWindowContext(params, createVkSurface, canPresent, instProc)); - if (!ctx->isValid()) { + if (!ctx->isValid() && createVkSurface != nullptr) { return nullptr; } return ctx; +diff -ur skia.org/tools/window/WindowContext.h skia/tools/window/WindowContext.h +--- skia.org/tools/window/WindowContext.h 2024-10-06 14:30:21.225939090 +0200 ++++ skia/tools/window/WindowContext.h 2024-10-06 14:31:51.352498743 +0200 +@@ -10,9 +10,9 @@ + #include "include/core/SkRefCnt.h" + #include "include/core/SkSurfaceProps.h" + #include "include/gpu/GrTypes.h" ++#include "include/gpu/GrDirectContext.h" + #include "tools/window/DisplayParams.h" + +-class GrDirectContext; + class SkSurface; + #if defined(SK_GRAPHITE) + namespace skgpu::graphite { diff --git a/external/skia/sort-comparison-assumption.patch.0 b/external/skia/sort-comparison-assumption.patch.0 deleted file mode 100644 index b23ae0418123..000000000000 --- a/external/skia/sort-comparison-assumption.patch.0 +++ /dev/null @@ -1,16 +0,0 @@ ---- src/sksl/transform/SkSLFindAndDeclareBuiltinVariables.cpp -+++ src/sksl/transform/SkSLFindAndDeclareBuiltinVariables.cpp -@@ -105,11 +105,11 @@ - } - switch (a->kind()) { - case ProgramElement::Kind::kGlobalVar: -- SkASSERT(GlobalVarBuiltinName(*a) != GlobalVarBuiltinName(*b)); -+ SkASSERT(GlobalVarBuiltinName(*a) != GlobalVarBuiltinName(*b) || a == b); - return GlobalVarBuiltinName(*a) < GlobalVarBuiltinName(*b); - - case ProgramElement::Kind::kInterfaceBlock: -- SkASSERT(InterfaceBlockName(*a) != InterfaceBlockName(*b)); -+ SkASSERT(InterfaceBlockName(*a) != InterfaceBlockName(*b) || a == b); - return InterfaceBlockName(*a) < InterfaceBlockName(*b); - - default: diff --git a/external/skia/swap-buffers-rect.patch.1 b/external/skia/swap-buffers-rect.patch.1 index 7ccfaca3d042..82ea48c9bc17 100644 --- a/external/skia/swap-buffers-rect.patch.1 +++ b/external/skia/swap-buffers-rect.patch.1 @@ -1,43 +1,43 @@ -diff -ur skia.org/tools/sk_app/MetalWindowContext.h skia/tools/sk_app/MetalWindowContext.h ---- skia.org/tools/sk_app/MetalWindowContext.h 2023-07-08 21:49:27.179700423 +0200 -+++ skia/tools/sk_app/MetalWindowContext.h 2023-07-08 21:51:53.416328675 +0200 +diff -ur skia.org/tools/window/MetalWindowContext.h skia/tools/window/MetalWindowContext.h +--- skia.org/tools/window/MetalWindowContext.h 2024-10-05 18:16:04.521814026 +0200 ++++ skia/tools/window/MetalWindowContext.h 2024-10-05 18:16:49.459152416 +0200 @@ -51,7 +51,7 @@ - + static void checkDestroyShared(); - + - void onSwapBuffers() override; + void onSwapBuffers(const SkIRect* rect = nullptr) override; - + bool fValid; - -diff -ur skia.org/tools/sk_app/MetalWindowContext.mm skia/tools/sk_app/MetalWindowContext.mm ---- skia.org/tools/sk_app/MetalWindowContext.mm 2023-07-08 21:49:27.179700423 +0200 -+++ skia/tools/sk_app/MetalWindowContext.mm 2023-07-08 21:52:10.064396318 +0200 -@@ -191,7 +191,7 @@ + +diff -ur skia.org/tools/window/MetalWindowContext.mm skia/tools/window/MetalWindowContext.mm +--- skia.org/tools/window/MetalWindowContext.mm 2024-10-05 18:16:04.521814026 +0200 ++++ skia/tools/window/MetalWindowContext.mm 2024-10-05 18:17:31.670443188 +0200 +@@ -193,7 +193,7 @@ return surface; } - + -void MetalWindowContext::onSwapBuffers() { +void MetalWindowContext::onSwapBuffers(const SkIRect*) { id<CAMetalDrawable> currentDrawable = (id<CAMetalDrawable>)fDrawableHandle; - + id<MTLCommandBuffer> commandBuffer([*fShared->fQueue commandBuffer]); -diff -ur skia.org/tools/sk_app/unix/RasterWindowContext_unix.cpp skia/tools/sk_app/unix/RasterWindowContext_unix.cpp ---- skia.org/tools/sk_app/unix/RasterWindowContext_unix.cpp 2023-07-08 21:49:27.183700444 +0200 -+++ skia/tools/sk_app/unix/RasterWindowContext_unix.cpp 2023-07-08 21:54:06.840852252 +0200 +diff -ur skia.org/tools/window/unix/RasterWindowContext_unix.cpp skia/tools/window/unix/RasterWindowContext_unix.cpp +--- 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; - + protected: - void onSwapBuffers() override; + void onSwapBuffers(const SkIRect* rect = nullptr) override; - + sk_sp<SkSurface> fBackbufferSurface; Display* fDisplay; @@ -58,7 +58,7 @@ - + sk_sp<SkSurface> RasterWindowContext_xlib::getBackbufferSurface() { return fBackbufferSurface; } - + -void RasterWindowContext_xlib::onSwapBuffers() { +void RasterWindowContext_xlib::onSwapBuffers(const SkIRect* rect) { SkPixmap pm; @@ -52,48 +52,49 @@ diff -ur skia.org/tools/sk_app/unix/RasterWindowContext_unix.cpp skia/tools/sk_a + XPutImage(fDisplay, fWindow, fGC, &image, update.x(), update.y(), + update.x(), update.y(), update.width(), update.height()); } - + } // anonymous namespace -diff -ur skia.org/tools/sk_app/VulkanWindowContext.cpp skia/tools/sk_app/VulkanWindowContext.cpp ---- skia.org/tools/sk_app/VulkanWindowContext.cpp 2023-07-08 21:49:27.179700423 +0200 -+++ skia/tools/sk_app/VulkanWindowContext.cpp 2023-07-08 21:52:53.676570245 +0200 -@@ -572,7 +572,7 @@ +diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanWindowContext.cpp +--- skia.org/tools/window/VulkanWindowContext.cpp 2024-10-05 18:16:04.521814026 +0200 ++++ skia/tools/window/VulkanWindowContext.cpp 2024-10-05 18:19:23.074028410 +0200 +@@ -542,7 +542,7 @@ return sk_ref_sp(surface); } - + -void VulkanWindowContext::onSwapBuffers() { +void VulkanWindowContext::onSwapBuffers(const SkIRect*) { - + BackbufferInfo* backbuffer = fBackbuffers + fCurrentBackbufferIndex; - sk_sp<SkSurface> surface = fSurfaces[backbuffer->fImageIndex]; -diff -ur skia.org/tools/sk_app/VulkanWindowContext.h skia/tools/sk_app/VulkanWindowContext.h ---- skia.org/tools/sk_app/VulkanWindowContext.h 2023-07-08 21:49:27.179700423 +0200 -+++ skia/tools/sk_app/VulkanWindowContext.h 2023-07-08 21:52:34.580494658 +0200 -@@ -71,7 +71,7 @@ + SkSurface* surface = fSurfaces[backbuffer->fImageIndex].get(); +diff -ur skia.org/tools/window/VulkanWindowContext.h skia/tools/window/VulkanWindowContext.h +--- 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 createBuffers(VkFormat format, VkImageUsageFlags, SkColorType colorType, VkSharingMode); void destroyBuffers(); - void onSwapBuffers() override; + void onSwapBuffers(const SkIRect* rect = nullptr) override; - + // Create functions CreateVkSurfaceFn fCreateVkSurfaceFn; -diff -ur skia.org/tools/sk_app/win/RasterWindowContext_win.cpp skia/tools/sk_app/win/RasterWindowContext_win.cpp ---- skia.org/tools/sk_app/win/RasterWindowContext_win.cpp 2023-07-08 21:49:27.183700444 +0200 -+++ skia/tools/sk_app/win/RasterWindowContext_win.cpp 2023-07-08 21:55:26.169145828 +0200 + CanPresentFn fCanPresentFn; +diff -ur skia.org/tools/window/win/RasterWindowContext_win.cpp skia/tools/window/win/RasterWindowContext_win.cpp +--- 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; - + protected: - void onSwapBuffers() override; + void onSwapBuffers(const SkIRect* rect=nullptr) override; - + SkAutoMalloc fSurfaceMemory; sk_sp<SkSurface> fBackbufferSurface; @@ -73,13 +73,17 @@ - + sk_sp<SkSurface> RasterWindowContext_win::getBackbufferSurface() { return fBackbufferSurface; } - + -void RasterWindowContext_win::onSwapBuffers() { +void RasterWindowContext_win::onSwapBuffers(const SkIRect* rect) { BITMAPINFO* bmpInfo = reinterpret_cast<BITMAPINFO*>(fSurfaceMemory.get()); @@ -110,46 +111,39 @@ diff -ur skia.org/tools/sk_app/win/RasterWindowContext_win.cpp skia/tools/sk_app + pixmap.addr(), bmpInfo, DIB_RGB_COLORS, SRCCOPY); ReleaseDC(fWnd, dc); } - -diff -ur skia.org/tools/sk_app/WindowContext.cpp skia/tools/sk_app/WindowContext.cpp ---- skia.org/tools/sk_app/WindowContext.cpp 2023-07-08 21:49:27.179700423 +0200 -+++ skia/tools/sk_app/WindowContext.cpp 2023-07-08 21:56:23.373350669 +0200 -@@ -20,7 +20,7 @@ - + +diff -ur skia.org/tools/window/WindowContext.cpp skia/tools/window/WindowContext.cpp +--- skia.org/tools/window/WindowContext.cpp 2024-10-05 18:16:04.521814026 +0200 ++++ skia/tools/window/WindowContext.cpp 2024-10-05 18:21:34.482772084 +0200 +@@ -20,8 +20,8 @@ + WindowContext::~WindowContext() {} - + -void WindowContext::swapBuffers() { -+void WindowContext::swapBuffers(const SkIRect* rect) { - #if defined(SK_GRAPHITE) - if (fGraphiteContext) { - SkASSERT(fGraphiteRecorder); -@@ -33,7 +33,7 @@ - } - } - #endif - this->onSwapBuffers(); ++void WindowContext::swapBuffers(const SkIRect* rect) { + this->onSwapBuffers(rect); } - - } //namespace sk_app -diff -ur skia.org/tools/sk_app/WindowContext.h skia/tools/sk_app/WindowContext.h ---- skia.org/tools/sk_app/WindowContext.h 2023-07-08 21:49:27.179700423 +0200 -+++ skia/tools/sk_app/WindowContext.h 2023-07-08 21:51:08.804143750 +0200 + + } // namespace skwindow +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 @@ -31,7 +31,7 @@ - + virtual sk_sp<SkSurface> getBackbufferSurface() = 0; - + - void swapBuffers(); + void swapBuffers(const SkIRect* rect = nullptr); - + virtual bool isValid() = 0; - + @@ -57,7 +57,7 @@ protected: virtual bool isGpuContext() { return true; } - + - virtual void onSwapBuffers() = 0; + virtual void onSwapBuffers(const SkIRect* rect = nullptr) = 0; - + sk_sp<GrDirectContext> fContext; #if defined(SK_GRAPHITE) diff --git a/external/skia/windows-raster-surface-no-copies.patch.1 b/external/skia/windows-raster-surface-no-copies.patch.1 index 3765f70971fd..9c59c252c1f6 100644 --- a/external/skia/windows-raster-surface-no-copies.patch.1 +++ b/external/skia/windows-raster-surface-no-copies.patch.1 @@ -1,7 +1,6 @@ -diff --git a/tools/sk_app/win/RasterWindowContext_win.cpp b/tools/sk_app/win/RasterWindowContext_win.cpp -index 9548220ce6..49f1f9ed17 100644 ---- a/tools/sk_app/win/RasterWindowContext_win.cpp -+++ b/tools/sk_app/win/RasterWindowContext_win.cpp +diff -ur skia.org/tools/window/win/RasterWindowContext_win.cpp skia/tools/window/win/RasterWindowContext_win.cpp +--- skia.org/tools/window/win/RasterWindowContext_win.cpp 2024-10-04 15:36:01.287777189 +0200 ++++ skia/tools/window/win/RasterWindowContext_win.cpp 2024-10-04 15:37:22.221265385 +0200 @@ -53,7 +53,7 @@ fWidth = w; fHeight = h; @@ -18,13 +17,13 @@ index 9548220ce6..49f1f9ed17 100644 - void* pixels = bmpInfo->bmiColors; + // 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); - fBackbufferSurface = SkSurfaces::WrapPixels(info, pixels, sizeof(uint32_t) * w); + fBackbufferSurface = SkSurfaces::Raster(info); } - + sk_sp<SkSurface> RasterWindowContext_win::getBackbufferSurface() { return fBackbufferSurface; } @@ -75,8 +76,10 @@ void RasterWindowContext_win::onSwapBuffers() { @@ -38,4 +37,4 @@ index 9548220ce6..49f1f9ed17 100644 + DIB_RGB_COLORS, SRCCOPY); ReleaseDC(fWnd, dc); } - + diff --git a/external/skia/windows-text-gamma.patch.0 b/external/skia/windows-text-gamma.patch.0 index 624636b7da99..aad89597a447 100644 --- a/external/skia/windows-text-gamma.patch.0 +++ b/external/skia/windows-text-gamma.patch.0 @@ -1,70 +1,72 @@ ---- ./src/ports/SkFontHost_win.cpp.sav 2020-03-18 10:26:52.470184300 +0100 -+++ ./src/ports/SkFontHost_win.cpp 2020-03-18 12:08:04.598406700 +0100 -@@ -1215,17 +1215,23 @@ +--- ./src/ports/SkFontHost_win.cpp 2024-10-04 15:24:40.448100018 +0200 ++++ ./src/ports/SkFontHost_win.cpp 2024-10-04 15:26:22.284624363 +0200 +@@ -1149,18 +1149,24 @@ // since the caller may require A8 for maskfilters, we can't check for BW // ... until we have the caller tell us that explicitly const SkGdiRGB* src = (const SkGdiRGB*)bits; +#if defined(SK_GAMMA_APPLY_TO_A8) if (fPreBlend.isApplicable()) { - RGBToA8<true>(src, srcRB, glyph, fPreBlend.fG); + RGBToA8<true>(src, srcRB, glyph, imageBuffer, fPreBlend.fG); - } else { + } else +#endif + { - RGBToA8<false>(src, srcRB, glyph, fPreBlend.fG); + RGBToA8<false>(src, srcRB, glyph, imageBuffer, fPreBlend.fG); } } else { // LCD16 const SkGdiRGB* src = (const SkGdiRGB*)bits; - SkASSERT(SkMask::kLCD16_Format == glyph.fMaskFormat); + SkASSERT(SkMask::kLCD16_Format == glyph.maskFormat()); +#if defined(SK_GAMMA_APPLY_TO_A8) if (fPreBlend.isApplicable()) { - RGBToLcd16<true>(src, srcRB, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); + RGBToLcd16<true>(src, srcRB, glyph, imageBuffer, + fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); - } else { + } else +#endif + { - RGBToLcd16<false>(src, srcRB, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); + RGBToLcd16<false>(src, srcRB, glyph, imageBuffer, + fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); } - } ---- ./src/ports/SkScalerContext_win_dw.cpp -+++ ./src/ports/SkScalerContext_win_dw.cpp -@@ -1132,27 +1132,36 @@ void SkScalerContext_DW::generateImage(const SkGlyph& glyph) { - BilevelToBW(src, glyph); +--- ./src/ports/SkScalerContext_win_dw.cpp 2024-10-04 15:24:40.448100018 +0200 ++++ ./src/ports/SkScalerContext_win_dw.cpp 2024-10-04 15:29:29.810572073 +0200 +@@ -2127,20 +2127,27 @@ + BilevelToBW(src, glyph, imageBuffer); } else if (!isLCD(fRec)) { if (textureType == DWRITE_TEXTURE_ALIASED_1x1) { +#if defined(SK_GAMMA_APPLY_TO_A8) if (fPreBlend.isApplicable()) { - GrayscaleToA8<true>(src, glyph, fPreBlend.fG); + GrayscaleToA8<true>(src, glyph, imageBuffer, fPreBlend.fG); - } else { + } else +#endif + { - GrayscaleToA8<false>(src, glyph, fPreBlend.fG); + GrayscaleToA8<false>(src, glyph, imageBuffer, fPreBlend.fG); } } else { +#if defined(SK_GAMMA_APPLY_TO_A8) if (fPreBlend.isApplicable()) { - RGBToA8<true>(src, glyph, fPreBlend.fG); + RGBToA8<true>(src, glyph, imageBuffer, fPreBlend.fG); - } else { + } else +#endif + { - RGBToA8<false>(src, glyph, fPreBlend.fG); + RGBToA8<false>(src, glyph, imageBuffer, fPreBlend.fG); } } } else { - SkASSERT(SkMask::kLCD16_Format == glyph.fMaskFormat); + SkASSERT(SkMask::kLCD16_Format == glyph.maskFormat()); +#if defined(SK_GAMMA_APPLY_TO_A8) if (fPreBlend.isApplicable()) { if (fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag) { - RGBToLcd16<true, false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); - } else { - RGBToLcd16<true, true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); + RGBToLcd16<true, false>(src, glyph, imageBuffer, +@@ -2149,7 +2156,9 @@ + RGBToLcd16<true, true>(src, glyph, imageBuffer, + fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); } - } else { + } else +#endif + { if (fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag) { - RGBToLcd16<false, false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); - } else { + RGBToLcd16<false, false>(src, glyph, imageBuffer, + fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx index 0cd1a61b3ced..88d066aaafdb 100644 --- a/vcl/inc/skia/gdiimpl.hxx +++ b/vcl/inc/skia/gdiimpl.hxx @@ -348,7 +348,7 @@ protected: // The Skia surface that is target of all the rendering. sk_sp<SkSurface> mSurface; // Note that mSurface may be a proxy surface and not the one from the window context. - std::unique_ptr<sk_app::WindowContext> mWindowContext; + std::unique_ptr<skwindow::WindowContext> mWindowContext; bool mIsGPU; // whether the surface is GPU-backed // Note that we generally use VCL coordinates, which is not mSurface coordinates if mScaling!=1. SkIRect mDirtyRect; // The area that has been changed since the last performFlush(). diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx index 3ff966114b27..37aedfb2165a 100644 --- a/vcl/inc/skia/utils.hxx +++ b/vcl/inc/skia/utils.hxx @@ -39,7 +39,7 @@ #pragma GCC diagnostic ignored "-Wattributes" #pragma GCC diagnostic ignored "-Wshadow" #endif -#include <tools/sk_app/WindowContext.h> +#include <tools/window/WindowContext.h> #if defined __GNUC__ && !defined __clang__ #pragma GCC diagnostic pop #endif @@ -123,7 +123,7 @@ void setBlenderXor(SkPaint* paint); // Must be called in any VCL backend before any Skia functionality is used. // If not set, Skia will be disabled. VCL_DLLPUBLIC void - prepareSkia(std::unique_ptr<sk_app::WindowContext> (*createGpuWindowContext)(bool)); + prepareSkia(std::unique_ptr<skwindow::WindowContext> (*createGpuWindowContext)(bool)); // Shared cache of images. void addCachedImage(const OString& key, sk_sp<SkImage> image); diff --git a/vcl/inc/skia/x11/gdiimpl.hxx b/vcl/inc/skia/x11/gdiimpl.hxx index 849e81d9858b..f864d51a000a 100644 --- a/vcl/inc/skia/x11/gdiimpl.hxx +++ b/vcl/inc/skia/x11/gdiimpl.hxx @@ -33,10 +33,10 @@ public: private: virtual void createWindowSurfaceInternal(bool forceRaster = false) override; virtual bool avoidRecreateByResize() const override; - static std::unique_ptr<sk_app::WindowContext> + static std::unique_ptr<skwindow::WindowContext> createWindowContext(Display* display, Drawable drawable, const XVisualInfo* visual, int width, int height, SkiaHelper::RenderMethod renderMethod, bool temporary); - friend std::unique_ptr<sk_app::WindowContext> createVulkanWindowContext(bool); + friend std::unique_ptr<skwindow::WindowContext> createVulkanWindowContext(bool); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/osx/salgdiutils.cxx b/vcl/osx/salgdiutils.cxx index 867c579332b6..a125ca98644c 100644 --- a/vcl/osx/salgdiutils.cxx +++ b/vcl/osx/salgdiutils.cxx @@ -37,7 +37,7 @@ #include <osx/saldata.hxx> #if HAVE_FEATURE_SKIA -#include <tools/sk_app/mac/WindowContextFactory_mac.h> +#include <tools/window/mac/WindowContextFactory_mac.h> #include <skia/osx/gdiimpl.hxx> #endif @@ -125,7 +125,7 @@ void resetWindowScaling() // then reconnected. #if HAVE_FEATURE_SKIA if ( SkiaHelper::isVCLSkiaEnabled() ) - sk_app::ResetBackingScaleFactor(); + skwindow::ResetBackingScaleFactor(); #endif bWindowScaling = false; getWindowScaling(); diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx index b9c69a27519d..76f8099000fc 100644 --- a/vcl/skia/SkiaHelper.cxx +++ b/vcl/skia/SkiaHelper.cxx @@ -57,8 +57,8 @@ bool isAlphaMaskBlendingEnabled() { return false; } #if defined(MACOSX) #include <premac.h> #endif -#include <tools/sk_app/VulkanWindowContext.h> -#include <tools/sk_app/MetalWindowContext.h> +#include <tools/window/VulkanWindowContext.h> +#include <tools/window/MetalWindowContext.h> #if defined(MACOSX) #include <postmac.h> #endif @@ -215,7 +215,7 @@ static void writeSkiaRasterInfo() } #if defined(SK_VULKAN) || defined(SK_METAL) -static std::unique_ptr<sk_app::WindowContext> getTemporaryWindowContext(); +static std::unique_ptr<skwindow::WindowContext> getTemporaryWindowContext(); #endif static void checkDeviceDenylisted(bool blockDisable = false) @@ -233,9 +233,9 @@ static void checkDeviceDenylisted(bool blockDisable = false) { #ifdef SK_VULKAN // First try if a GrDirectContext already exists. - std::unique_ptr<sk_app::WindowContext> temporaryWindowContext; + std::unique_ptr<skwindow::WindowContext> temporaryWindowContext; GrDirectContext* grDirectContext - = sk_app::VulkanWindowContext::getSharedGrDirectContext(); + = skwindow::internal::VulkanWindowContext::getSharedGrDirectContext(); if (!grDirectContext) { // This function is called from isVclSkiaEnabled(), which @@ -247,13 +247,14 @@ static void checkDeviceDenylisted(bool blockDisable = false) // for just finding out information about Vulkan) and destroying // the temporary context will clean up again. temporaryWindowContext = getTemporaryWindowContext(); - grDirectContext = sk_app::VulkanWindowContext::getSharedGrDirectContext(); + grDirectContext + = skwindow::internal::VulkanWindowContext::getSharedGrDirectContext(); } bool denylisted = true; // assume the worst if (grDirectContext) // Vulkan was initialized properly { - denylisted - = isVulkanDenylisted(sk_app::VulkanWindowContext::getPhysDeviceProperties()); + denylisted = isVulkanDenylisted( + skwindow::internal::VulkanWindowContext::getPhysDeviceProperties()); SAL_INFO("vcl.skia", "Vulkan denylisted: " << denylisted); } else @@ -274,14 +275,14 @@ static void checkDeviceDenylisted(bool blockDisable = false) { #ifdef SK_METAL // First try if a GrDirectContext already exists. - std::unique_ptr<sk_app::WindowContext> temporaryWindowContext; - GrDirectContext* grDirectContext = sk_app::getMetalSharedGrDirectContext(); + std::unique_ptr<skwindow::WindowContext> temporaryWindowContext; + GrDirectContext* grDirectContext = skwindow::internal::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(); + grDirectContext = skwindow::internal::getMetalSharedGrDirectContext(); } if (grDirectContext) // Metal was initialized properly { @@ -479,10 +480,10 @@ void disableRenderMethod(RenderMethod method) // If needed, we'll allocate one extra window context so that we have a valid GrDirectContext // from Vulkan/MetalWindowContext. -static std::unique_ptr<sk_app::WindowContext> sharedWindowContext; +static std::unique_ptr<skwindow::WindowContext> sharedWindowContext; -static std::unique_ptr<sk_app::WindowContext> (*createGpuWindowContextFunction)(bool) = nullptr; -static void setCreateGpuWindowContext(std::unique_ptr<sk_app::WindowContext> (*function)(bool)) +static std::unique_ptr<skwindow::WindowContext> (*createGpuWindowContextFunction)(bool) = nullptr; +static void setCreateGpuWindowContext(std::unique_ptr<skwindow::WindowContext> (*function)(bool)) { createGpuWindowContextFunction = function; } @@ -500,13 +501,14 @@ GrDirectContext* getSharedGrDirectContext() { case RenderVulkan: #ifdef SK_VULKAN - if (GrDirectContext* context = sk_app::VulkanWindowContext::getSharedGrDirectContext()) + if (GrDirectContext* context + = skwindow::internal::VulkanWindowContext::getSharedGrDirectContext()) return context; #endif break; case RenderMetal: #ifdef SK_METAL - if (GrDirectContext* context = sk_app::getMetalSharedGrDirectContext()) + if (GrDirectContext* context = skwindow::internal::getMetalSharedGrDirectContext()) return context; #endif break; @@ -533,7 +535,7 @@ GrDirectContext* getSharedGrDirectContext() } #if defined(SK_VULKAN) || defined(SK_METAL) -static std::unique_ptr<sk_app::WindowContext> getTemporaryWindowContext() +static std::unique_ptr<skwindow::WindowContext> getTemporaryWindowContext() { if (createGpuWindowContextFunction == nullptr) return nullptr; @@ -853,7 +855,7 @@ void setPixelGeometry(SkPixelGeometry pixelGeometry) // Skia should not be used from VCL backends that do not actually support it, as there will be setup missing. // The code here (that is in the vcl lib) needs a function for creating Vulkan/Metal context that is // usually available only in the backend libs. -void prepareSkia(std::unique_ptr<sk_app::WindowContext> (*createGpuWindowContext)(bool)) +void prepareSkia(std::unique_ptr<skwindow::WindowContext> (*createGpuWindowContext)(bool)) { setCreateGpuWindowContext(createGpuWindowContext); skiaSupportedByBackend = true; @@ -866,7 +868,8 @@ void dump(const SkBitmap& bitmap, const char* file) void dump(const sk_sp<SkSurface>& surface, const char* file) { - surface->getCanvas()->flush(); + if (auto dContext = GrAsDirectContext(surface->getCanvas()->recordingContext())) + dContext->flushAndSubmit(); dump(makeCheckedImageSnapshot(surface), file); } diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index f4e4a2550003..83b9fd6810c6 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -426,7 +426,9 @@ void SkiaSalGraphicsImpl::flushSurfaceToWindowContext() // so no transformation needed. screenSurface->getCanvas()->drawImage(makeCheckedImageSnapshot(mSurface), 0, 0, SkSamplingOptions(), &paint); - screenSurface->flushAndSubmit(); // Otherwise the window is not drawn sometimes. + // Otherwise the window is not drawn sometimes. + if (auto dContext = GrAsDirectContext(screenSurface->getCanvas()->recordingContext())) + dContext->flushAndSubmit(); mWindowContext->swapBuffers(nullptr); // Must swap the entire surface. } else @@ -465,7 +467,8 @@ void SkiaSalGraphicsImpl::postDraw() static int maxOperationsToFlush = 1000; if (pendingOperationsToFlush > maxOperationsToFlush) { - mSurface->flushAndSubmit(); + if (auto dContext = GrAsDirectContext(mSurface->getCanvas()->recordingContext())) + dContext->flushAndSubmit(); pendingOperationsToFlush = 0; } SkiaZone::leave(); // matched in preDraw() diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx index 6afedb2d8025..d7c4194ae5d0 100644 --- a/vcl/skia/osx/gdiimpl.cxx +++ b/vcl/skia/osx/gdiimpl.cxx @@ -23,7 +23,7 @@ #include <skia/utils.hxx> #include <skia/zone.hxx> -#include <tools/sk_app/mac/WindowContextFactory_mac.h> +#include <tools/window/mac/WindowContextFactory_mac.h> #include <quartz/CoreTextFont.hxx> #include <quartz/SystemFontList.hxx> @@ -72,9 +72,9 @@ void AquaSkiaSalGraphicsImpl::createWindowSurfaceInternal(bool forceRaster) assert(!mWindowContext); assert(!mSurface); SkiaZone zone; - sk_app::DisplayParams displayParams; + skwindow::DisplayParams displayParams; displayParams.fColorType = kN32_SkColorType; - sk_app::window_context_factory::MacWindowInfo macWindow; + skwindow::MacWindowInfo macWindow; macWindow.fMainView = mrShared.mpFrame->mpNSView; mScaling = getWindowScaling(); RenderMethod renderMethod = forceRaster ? RenderRaster : renderMethodToUse(); @@ -86,8 +86,7 @@ void AquaSkiaSalGraphicsImpl::createWindowSurfaceInternal(bool forceRaster) mSurface = createSkSurface(GetWidth() * mScaling, GetHeight() * mScaling); break; case RenderMetal: - mWindowContext - = sk_app::window_context_factory::MakeMetalForMac(macWindow, displayParams); + mWindowContext = skwindow::MakeMetalForMac(macWindow, displayParams); // 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 @@ -327,7 +326,8 @@ bool AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n assert(drawRect.width() * mScaling == bitmap.width()); // no scaling should be needed getDrawCanvas()->drawImageRect(bitmap.asImage(), drawRect, SkSamplingOptions()); // Related: tdf#156881 flush the canvas after drawing the pixel buffer - getDrawCanvas()->flush(); + if (auto dContext = GrAsDirectContext(getDrawCanvas()->recordingContext())) + dContext->flushAndSubmit(); ++pendingOperationsToFlush; // tdf#136369 postDraw(); } @@ -398,12 +398,12 @@ void AquaSkiaSalGraphicsImpl::drawTextLayout(const GenericSalLayout& rLayout) namespace { -std::unique_ptr<sk_app::WindowContext> createMetalWindowContext(bool /*temporary*/) +std::unique_ptr<skwindow::WindowContext> createMetalWindowContext(bool /*temporary*/) { - sk_app::DisplayParams displayParams; - sk_app::window_context_factory::MacWindowInfo macWindow; + skwindow::DisplayParams displayParams; + skwindow::MacWindowInfo macWindow; macWindow.fMainView = nullptr; - return sk_app::window_context_factory::MakeMetalForMac(macWindow, displayParams); + return skwindow::MakeMetalForMac(macWindow, displayParams); } } diff --git a/vcl/skia/quartz/salbmp.mm b/vcl/skia/quartz/salbmp.mm index 4e9782daf1d4..630fd1133f36 100644 --- a/vcl/skia/quartz/salbmp.mm +++ b/vcl/skia/quartz/salbmp.mm @@ -56,7 +56,8 @@ CGImageRef SkiaSalBitmap::CreateColorMask(int nX, int nY, int nWidth, int nHeigh SkCanvas canvas(targetBitmap); canvas.concat(matrix); canvas.drawImageRect(GetSkImage(), SkRect::MakeXYWH(nX, nY, nWidth, nHeight), SkRect::MakeXYWH(0, 0, nWidth, nHeight), SkSamplingOptions(), &paint, SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint); - canvas.flush(); + if (auto dContext = GrAsDirectContext(canvas.recordingContext())) + dContext->flushAndSubmit(); const SkColor maskColor = SkiaHelper::toSkColor(nMaskColor); for (int y = 0; y < targetBitmap.height(); y++) @@ -94,7 +95,8 @@ CGImageRef SkiaSalBitmap::CreateCroppedImage(int nX, int nY, int nWidth, int nHe SkCanvas canvas(targetBitmap); canvas.concat(matrix); canvas.drawImageRect(GetSkImage(), SkRect::MakeXYWH(nX, nY, nWidth, nHeight), SkRect::MakeXYWH(0, 0, nWidth, nHeight), SkSamplingOptions(), &paint, SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint); - canvas.flush(); + if (auto dContext = GrAsDirectContext(canvas.recordingContext())) + dContext->flushAndSubmit(); targetBitmap.setImmutable(); CGContextRef xContext = CGBitmapContextCreate(targetBitmap.getAddr32(0, 0), targetBitmap.width(), targetBitmap.height(), 8, targetBitmap.rowBytes(), GetSalData()->mxRGBSpace, SkiaToCGBitmapType(targetBitmap.colorType(), targetBitmap.alphaType())); diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 15a29b89e522..bba67fcbc439 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -1204,7 +1204,8 @@ void SkiaSalBitmap::EnsureBitmapData() SkPaint paint; paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha canvas.drawImage(mAlphaImage, 0, 0, SkSamplingOptions(), &paint); - canvas.flush(); + if (auto dContext = GrAsDirectContext(canvas.recordingContext())) + dContext->flushAndSubmit(); } bitmap.setImmutable(); ResetPendingScaling(); @@ -1281,7 +1282,8 @@ void SkiaSalBitmap::EnsureBitmapData() } else canvas.drawImage(mImage, 0, 0, SkSamplingOptions(), &paint); - canvas.flush(); + if (auto dContext = GrAsDirectContext(canvas.recordingContext())) + dContext->flushAndSubmit(); } bitmap.setImmutable(); ResetPendingScaling(); diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx index 4a8e6266fe63..f95b58eca0fe 100644 --- a/vcl/skia/win/gdiimpl.cxx +++ b/vcl/skia/win/gdiimpl.cxx @@ -27,8 +27,8 @@ #include <SkTypeface_win.h> #include <SkFont.h> #include <SkFontMgr.h> -#include <tools/sk_app/win/WindowContextFactory_win.h> -#include <tools/sk_app/WindowContext.h> +#include <tools/window/win/WindowContextFactory_win.h> +#include <tools/window/WindowContext.h> #include <windows.h> @@ -257,20 +257,18 @@ void WinSkiaSalGraphicsImpl::createWindowSurfaceInternal(bool forceRaster) assert(!mWindowContext); assert(!mSurface); SkiaZone zone; - sk_app::DisplayParams displayParams; + skwindow::DisplayParams displayParams; assert(GetWidth() > 0 && GetHeight() > 0); displayParams.fSurfaceProps = *surfaceProps(); switch (forceRaster ? RenderRaster : renderMethodToUse()) { case RenderRaster: - mWindowContext = sk_app::window_context_factory::MakeRasterForWin(mWinParent.gethWnd(), - displayParams); + mWindowContext = skwindow::MakeRasterForWin(mWinParent.gethWnd(), displayParams); if (mWindowContext) mSurface = mWindowContext->getBackbufferSurface(); break; case RenderVulkan: - mWindowContext = sk_app::window_context_factory::MakeVulkanForWin(mWinParent.gethWnd(), - displayParams); + mWindowContext = skwindow::MakeVulkanForWin(mWinParent.gethWnd(), displayParams); // See flushSurfaceToWindowContext(). if (mWindowContext) mSurface = createSkSurface(GetWidth(), GetHeight()); @@ -568,11 +566,11 @@ SkiaControlCacheType& SkiaControlsCache::get() namespace { -std::unique_ptr<sk_app::WindowContext> createVulkanWindowContext(bool /*temporary*/) +std::unique_ptr<skwindow::WindowContext> createVulkanWindowContext(bool /*temporary*/) { SkiaZone zone; - sk_app::DisplayParams displayParams; - return sk_app::window_context_factory::MakeVulkanForWin(nullptr, displayParams); + skwindow::DisplayParams displayParams; + return skwindow::MakeVulkanForWin(nullptr, displayParams); } } diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx index 6a7cce14dd3f..3f93c5da9c8f 100644 --- a/vcl/skia/x11/gdiimpl.cxx +++ b/vcl/skia/x11/gdiimpl.cxx @@ -18,7 +18,7 @@ #include <skia/x11/gdiimpl.hxx> -#include <tools/sk_app/unix/WindowContextFactory_unix.h> +#include <tools/window/unix/WindowContextFactory_unix.h> #include <skia/utils.hxx> #include <skia/zone.hxx> @@ -60,13 +60,13 @@ void X11SkiaSalGraphicsImpl::createWindowSurfaceInternal(bool forceRaster) } } -std::unique_ptr<sk_app::WindowContext> +std::unique_ptr<skwindow::WindowContext> X11SkiaSalGraphicsImpl::createWindowContext(Display* display, Drawable drawable, const XVisualInfo* visual, int width, int height, RenderMethod renderMethod, bool temporary) { SkiaZone zone; - sk_app::DisplayParams displayParams; + skwindow::DisplayParams displayParams; displayParams.fColorType = kN32_SkColorType; #if defined LINUX // WORKAROUND: VSync causes freezes that can even temporarily freeze the entire desktop. @@ -75,7 +75,7 @@ X11SkiaSalGraphicsImpl::createWindowContext(Display* display, Drawable drawable, if (getVendor() == DriverBlocklist::VendorNVIDIA) displayParams.fDisableVsync = true; #endif - sk_app::window_context_factory::XlibWindowInfo winInfo; + skwindow::XlibWindowInfo winInfo; assert(display); winInfo.fDisplay = display; winInfo.fWindow = drawable; @@ -110,9 +110,9 @@ X11SkiaSalGraphicsImpl::createWindowContext(Display* display, Drawable drawable, displayParams.fColorType = (visual->red_mask > visual->blue_mask ? kBGRA_8888_SkColorType : kRGBA_8888_SkColorType); - return sk_app::window_context_factory::MakeRasterForXlib(winInfo, displayParams); + return skwindow::MakeRasterForXlib(winInfo, displayParams); case RenderVulkan: - return sk_app::window_context_factory::MakeVulkanForXlib(winInfo, displayParams); + return skwindow::MakeVulkanForXlib(winInfo, displayParams); case RenderMetal: abort(); break; @@ -144,7 +144,7 @@ void X11SkiaSalGraphicsImpl::freeResources() {} void X11SkiaSalGraphicsImpl::Flush() { performFlush(); } -std::unique_ptr<sk_app::WindowContext> createVulkanWindowContext(bool temporary) +std::unique_ptr<skwindow::WindowContext> createVulkanWindowContext(bool temporary) { SalDisplay* salDisplay = vcl_sal::getSalDisplay(GetGenericUnixSalData()); const XVisualInfo* visual; @@ -163,7 +163,7 @@ std::unique_ptr<sk_app::WindowContext> createVulkanWindowContext(bool temporary) assert(count == 1); visual = visuals; } - std::unique_ptr<sk_app::WindowContext> ret = X11SkiaSalGraphicsImpl::createWindowContext( + std::unique_ptr<skwindow::WindowContext> ret = X11SkiaSalGraphicsImpl::createWindowContext( salDisplay->GetDisplay(), None, visual, 1, 1, RenderVulkan, temporary); if (temporary) XFree(visuals);