diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-08-18 19:26:45 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-08-24 12:52:39 +0200 |
commit | ddcdc2077fab2b6d9c4def4e4615185411cbe80a (patch) | |
tree | b5a6ae5cc158def6c52e02f9448ee3ec1fac6c37 | |
parent | 4efd9f8a4bebe88841b5c3e27d2f7ef3ff10a8d0 (diff) |
build Skia with Metal support
Change-Id: I7a9abde4101164af8c47433acfa35f4f9d3b3d04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120907
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r-- | config_host.mk.in | 1 | ||||
-rw-r--r-- | config_host/config_skia.h.in | 9 | ||||
-rw-r--r-- | configure.ac | 12 | ||||
-rw-r--r-- | external/skia/Library_skia.mk | 65 | ||||
-rw-r--r-- | external/skia/make-api-visible.patch.1 | 13 | ||||
-rw-r--r-- | external/skia/swap-buffers-rect.patch.1 | 26 | ||||
-rw-r--r-- | vcl/inc/skia/gdiimpl.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/skia/utils.hxx | 2 | ||||
-rw-r--r-- | vcl/skia/salbmp.cxx | 6 |
9 files changed, 122 insertions, 14 deletions
diff --git a/config_host.mk.in b/config_host.mk.in index 6810660067b0..abda7d688540 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -550,6 +550,7 @@ export SERF_LIBS=$(gb_SPACE)@SERF_LIBS@ export SHA256SUM=@SHA256SUM@ export SHOWINCLUDES_PREFIX=@SHOWINCLUDES_PREFIX@ export SKIA_DISABLE_VMA_USE_STL_SHARED_MUTEX=@SKIA_DISABLE_VMA_USE_STL_SHARED_MUTEX@ +export SKIA_GPU=@SKIA_GPU@ export SOLARINC=@SOLARINC@ export SORT=@SORT@ export SPLIT_APP_MODULES=@SPLIT_APP_MODULES@ diff --git a/config_host/config_skia.h.in b/config_host/config_skia.h.in index 10fd4374b9c5..1e003179291b 100644 --- a/config_host/config_skia.h.in +++ b/config_host/config_skia.h.in @@ -30,10 +30,13 @@ are the same. #define SKIA_USE_BITMAP32 0 - -#define SK_SUPPORT_GPU 1 - +// GPU support (set by configure). +#undef SK_SUPPORT_GPU +// Vulkan support enabled (set by configure). +// temporary override #define SK_VULKAN 1 +// Metal support enabled (set by configure). +#undef SK_METAL // Memory allocator for Vulkan. #define SK_USE_VMA 1 diff --git a/configure.ac b/configure.ac index bd2157edb00e..9e5708cd49d4 100644 --- a/configure.ac +++ b/configure.ac @@ -11983,6 +11983,18 @@ if test "$enable_skia" != "no" -a "$build_skia" = "yes" -a -z "$DISABLE_GUI"; th AC_DEFINE(HAVE_FEATURE_SKIA) BUILD_TYPE="$BUILD_TYPE SKIA" + if test "$OS" = "MACOSX"; then + AC_DEFINE(SK_SUPPORT_GPU,1) + AC_DEFINE(SK_METAL,1) + SKIA_GPU=METAL + AC_SUBST(SKIA_GPU) + else + AC_DEFINE(SK_SUPPORT_GPU,1) + AC_DEFINE(SK_VULKAN,1) + SKIA_GPU=VULKAN + AC_SUBST(SKIA_GPU) + fi + if test -n "$MAC_OS_X_VERSION_MIN_REQUIRED" -a "$MAC_OS_X_VERSION_MIN_REQUIRED" -lt "101200"; then SKIA_DISABLE_VMA_USE_STL_SHARED_MUTEX=1 AC_SUBST(SKIA_DISABLE_VMA_USE_STL_SHARED_MUTEX) diff --git a/external/skia/Library_skia.mk b/external/skia/Library_skia.mk index 517b5585496e..65006ca5db61 100644 --- a/external/skia/Library_skia.mk +++ b/external/skia/Library_skia.mk @@ -63,6 +63,8 @@ else ifeq ($(OS),MACOSX) $(eval $(call gb_Library_use_system_darwin_frameworks,skia,\ Cocoa \ + Metal \ + QuartzCore \ )) ifneq ($(SKIA_DISABLE_VMA_USE_STL_SHARED_MUTEX),) @@ -527,6 +529,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/xps/SkXPSDocument \ )) +ifneq ($(SKIA_GPU),) $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/core/SkGpuBlurUtils \ UnpackedTarball/skia/src/gpu/ccpr/GrCCAtlas \ @@ -791,6 +794,10 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/image/SkImage_Gpu \ UnpackedTarball/skia/src/image/SkImage_GpuYUVA \ UnpackedTarball/skia/src/image/SkSurface_Gpu \ +)) + +#ifeq ($(SKIA_GPU),VULKAN) +$(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/gpu/vk/GrVkAMDMemoryAllocator \ UnpackedTarball/skia/src/gpu/vk/GrVkAttachment \ UnpackedTarball/skia/src/gpu/vk/GrVkBuffer \ @@ -830,6 +837,15 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ )) $(eval $(call gb_Library_add_generated_exception_objects,skia,\ + UnpackedTarball/skia/tools/gpu/vk/VkTestUtils \ + UnpackedTarball/skia/tools/sk_app/VulkanWindowContext \ + UnpackedTarball/skia/third_party/vulkanmemoryallocator/GrVulkanMemoryAllocator \ +)) + +#endif +endif + +$(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/ports/SkGlobalInitialization_default \ UnpackedTarball/skia/src/ports/SkImageGenerator_none \ UnpackedTarball/skia/src/ports/SkOSFile_stdio \ @@ -861,8 +877,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ )) $(eval $(call gb_Library_add_generated_exception_objects,skia,\ - UnpackedTarball/skia/tools/gpu/vk/VkTestUtils \ - UnpackedTarball/skia/tools/sk_app/VulkanWindowContext \ UnpackedTarball/skia/tools/sk_app/WindowContext \ )) @@ -887,8 +901,13 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/tools/sk_app/win/RasterWindowContext_win \ +)) + +#ifeq ($(SKIA_GPU),VULKAN) +$(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/tools/sk_app/win/VulkanWindowContext_win \ )) +#endif else ifeq ($(OS),MACOSX) $(eval $(call gb_Library_add_generated_exception_objects,skia,\ @@ -905,10 +924,39 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/utils/mac/SkCreateCGImageRef \ )) +ifeq ($(SKIA_GPU),METAL) +$(eval $(call gb_Library_add_generated_objcxxobjects,skia,\ + UnpackedTarball/skia/tools/sk_app/MetalWindowContext \ + UnpackedTarball/skia/tools/sk_app/mac/MetalWindowContext_mac \ +)) + # Not used, uses OpenGL - UnpackedTarball/skia/tools/sk_app/mac/RasterWindowContext_mac -# UnpackedTarball/skia/tools/sk_app/mac/VulkanWindowContext_mac \ -# UnpackedTarball/skia/tools/sk_app/mac/MetalWindowContext_mac \ +$(eval $(call gb_Library_add_generated_objcxxobjects,skia,\ + UnpackedTarball/skia/src/gpu/mtl/GrMtlAttachment \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlBuffer \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlCaps \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlCommandBuffer \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlDepthStencil \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlGpu \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlOpsRenderPass \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlPipelineState \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlPipelineStateBuilder \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlPipelineStateDataManager \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlRenderTarget \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlResourceProvider \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlSampler \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlSemaphore \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlTexture \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlTextureRenderTarget \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlTrampoline \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlUniformHandler \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlUtil \ + UnpackedTarball/skia/src/gpu/mtl/GrMtlVaryingHandler \ + UnpackedTarball/skia/src/image/SkSurface_GpuMtl \ + , -fobjc-arc \ +)) +endif else $(eval $(call gb_Library_add_generated_exception_objects,skia,\ @@ -927,13 +975,14 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/tools/sk_app/unix/RasterWindowContext_unix \ - UnpackedTarball/skia/tools/sk_app/unix/VulkanWindowContext_unix \ )) -endif - +#ifeq ($(SKIA_GPU),VULKAN) $(eval $(call gb_Library_add_generated_exception_objects,skia,\ - UnpackedTarball/skia/third_party/vulkanmemoryallocator/GrVulkanMemoryAllocator \ + UnpackedTarball/skia/tools/sk_app/unix/VulkanWindowContext_unix \ )) +#endif + +endif # 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 diff --git a/external/skia/make-api-visible.patch.1 b/external/skia/make-api-visible.patch.1 index 822313006dc6..6dbaf82b13bd 100644 --- a/external/skia/make-api-visible.patch.1 +++ b/external/skia/make-api-visible.patch.1 @@ -65,3 +65,16 @@ index c05a4f0acf..fc27cd2afb 100644 } // namespace window_context_factory +diff --git a/tools/sk_app/mac/WindowContextFactory_mac.h b/tools/sk_app/mac/WindowContextFactory_mac.h +index acf860ae4b..cdb2ee8027 100644 +--- a/tools/sk_app/mac/WindowContextFactory_mac.h ++++ b/tools/sk_app/mac/WindowContextFactory_mac.h +@@ -48,7 +48,7 @@ std::unique_ptr<WindowContext> MakeDawnMTLForMac(const MacWindowInfo&, const Dis + + std::unique_ptr<WindowContext> MakeRasterForMac(const MacWindowInfo&, const DisplayParams&); + #ifdef SK_METAL +-std::unique_ptr<WindowContext> MakeMetalForMac(const MacWindowInfo&, const DisplayParams&); ++SK_API std::unique_ptr<WindowContext> MakeMetalForMac(const MacWindowInfo&, const DisplayParams&); + #endif + + } // namespace window_context_factory diff --git a/external/skia/swap-buffers-rect.patch.1 b/external/skia/swap-buffers-rect.patch.1 index 7673a358ebc4..a6e6fd4904a7 100644 --- a/external/skia/swap-buffers-rect.patch.1 +++ b/external/skia/swap-buffers-rect.patch.1 @@ -11,6 +11,32 @@ index c519903006..5dc5bcd180 100644 void setDisplayParams(const DisplayParams& params) override; +diff --git a/tools/sk_app/MetalWindowContext.h b/tools/sk_app/MetalWindowContext.h +index e8c8392a15..0d8fd1df6e 100644 +--- a/tools/sk_app/MetalWindowContext.h ++++ b/tools/sk_app/MetalWindowContext.h +@@ -24,7 +24,7 @@ public: + + bool isValid() override { return fValid; } + +- void swapBuffers() override; ++ void swapBuffers(const SkIRect* rect = nullptr) override; + + void setDisplayParams(const DisplayParams& params) override; + +diff --git a/tools/sk_app/MetalWindowContext.mm b/tools/sk_app/MetalWindowContext.mm +index 5b623811ed..bae6b24138 100644 +--- a/tools/sk_app/MetalWindowContext.mm ++++ b/tools/sk_app/MetalWindowContext.mm +@@ -152,7 +152,7 @@ GrBackendRenderTarget backendRT(fWidth, + return surface; + } + +-void MetalWindowContext::swapBuffers() { ++void MetalWindowContext::swapBuffers(const SkIRect*) { + id<CAMetalDrawable> currentDrawable = (id<CAMetalDrawable>)fDrawableHandle; + + id<MTLCommandBuffer> commandBuffer([*fQueue commandBuffer]); diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp index 2b36d60076..d73978c9e4 100644 --- a/tools/sk_app/VulkanWindowContext.cpp diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx index 14fa5df6012b..1d5bfd071ea5 100644 --- a/vcl/inc/skia/gdiimpl.hxx +++ b/vcl/inc/skia/gdiimpl.hxx @@ -25,8 +25,10 @@ #include <salgdiimpl.hxx> #include <salgeom.hxx> +#include <premac.h> #include <SkSurface.h> #include <SkRegion.h> +#include <postmac.h> #include <prewin.h> #include <tools/sk_app/WindowContext.h> diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx index e53a17c7d934..b1987024c616 100644 --- a/vcl/inc/skia/utils.hxx +++ b/vcl/inc/skia/utils.hxx @@ -27,9 +27,11 @@ #include <vcl/bitmap.hxx> #include <vcl/salgtype.hxx> +#include <premac.h> #include <SkRegion.h> #include <SkSurface.h> #include <tools/sk_app/VulkanWindowContext.h> +#include <postmac.h> namespace SkiaHelper { diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 3c0c9d32ed99..abcfb0326e3a 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -30,6 +30,9 @@ #include <bitmap/bmpfast.hxx> #include <vcl/BitmapReadAccess.hxx> +#include <skia/utils.hxx> +#include <skia/zone.hxx> + #include <SkCanvas.h> #include <SkImage.h> #include <SkPixelRef.h> @@ -39,9 +42,6 @@ #include <SkColorMatrix.h> #include <skia_opts.hxx> -#include <skia/utils.hxx> -#include <skia/zone.hxx> - #ifdef DBG_UTIL #include <fstream> #define CANARY "skia-canary" |