diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-12-06 12:26:00 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2019-12-12 11:01:41 +0100 |
commit | 23b3de0b9a6cb69ed258905effa096ce5d5f1f13 (patch) | |
tree | efcd2dba24db226c27c16ed338e7919e782f2df5 /external | |
parent | d32be257ca011316281edf2752564a421e3747a3 (diff) |
update Skia to chrome/m80
Change-Id: I26782c8bd3d8ce34cbf7ce5a00b884436d37cb85
Reviewed-on: https://gerrit.libreoffice.org/84617
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/skia/Library_skia.mk | 9 | ||||
-rw-r--r-- | external/skia/README | 4 | ||||
-rw-r--r-- | external/skia/UnpackedTarball_skia.mk | 4 | ||||
-rw-r--r-- | external/skia/fix-alpha-difference-copy.patch.1 | 6 | ||||
-rw-r--r-- | external/skia/fix-msvc.patch.1 | 22 | ||||
-rw-r--r-- | external/skia/fix-pch.patch.1 (renamed from external/skia/fix-pch.patch) | 120 | ||||
-rw-r--r-- | external/skia/fix-shader-locale.patch.1 | 40 | ||||
-rw-r--r-- | external/skia/inc/pch/precompiled_skia.hxx | 16 | ||||
-rw-r--r-- | external/skia/share-grcontext.patch.1 | 387 |
9 files changed, 309 insertions, 299 deletions
diff --git a/external/skia/Library_skia.mk b/external/skia/Library_skia.mk index 2fe24876b499..ecebc4a4fe14 100644 --- a/external/skia/Library_skia.mk +++ b/external/skia/Library_skia.mk @@ -90,7 +90,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/codec/SkCodecImageGenerator \ UnpackedTarball/skia/src/codec/SkColorTable \ UnpackedTarball/skia/src/codec/SkEncodedInfo \ - UnpackedTarball/skia/src/codec/SkGifCodec \ UnpackedTarball/skia/src/codec/SkIcoCodec \ UnpackedTarball/skia/src/codec/SkJpegCodec \ UnpackedTarball/skia/src/codec/SkJpegDecoderMgr \ @@ -167,6 +166,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/core/SkExecutor \ UnpackedTarball/skia/src/core/SkFlattenable \ UnpackedTarball/skia/src/core/SkFont \ + UnpackedTarball/skia/src/core/SkFont_serial \ UnpackedTarball/skia/src/core/SkFontDescriptor \ UnpackedTarball/skia/src/core/SkFontLCDConfig \ UnpackedTarball/skia/src/core/SkFontMgr \ @@ -190,6 +190,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/core/SkLatticeIter \ UnpackedTarball/skia/src/core/SkLineClipper \ UnpackedTarball/skia/src/core/SkLocalMatrixImageFilter \ + UnpackedTarball/skia/src/core/SkMalloc \ UnpackedTarball/skia/src/core/SkMallocPixelRef \ UnpackedTarball/skia/src/core/SkMaskBlurFilter \ UnpackedTarball/skia/src/core/SkMaskCache \ @@ -204,7 +205,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/core/SkMiniRecorder \ UnpackedTarball/skia/src/core/SkMipMap \ UnpackedTarball/skia/src/core/SkModeColorFilter \ - UnpackedTarball/skia/src/core/SkMultiPictureDraw \ UnpackedTarball/skia/src/core/SkNormalFlatSource \ UnpackedTarball/skia/src/core/SkNormalMapSource \ UnpackedTarball/skia/src/core/SkNormalSource \ @@ -277,6 +277,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/core/SkSwizzle \ UnpackedTarball/skia/src/core/SkTaskGroup \ UnpackedTarball/skia/src/core/SkTextBlob \ + UnpackedTarball/skia/src/core/SkTextBlobTrace \ UnpackedTarball/skia/src/core/SkThreadID \ UnpackedTarball/skia/src/core/SkTime \ UnpackedTarball/skia/src/core/SkTLS \ @@ -520,12 +521,14 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/gpu/effects/generated/GrConfigConversionEffect \ UnpackedTarball/skia/src/gpu/effects/generated/GrConstColorProcessor \ UnpackedTarball/skia/src/gpu/effects/generated/GrEllipseEffect \ + UnpackedTarball/skia/src/gpu/effects/generated/GrHSLToRGBFilterEffect \ UnpackedTarball/skia/src/gpu/effects/generated/GrLumaColorFilterEffect \ UnpackedTarball/skia/src/gpu/effects/generated/GrMagnifierEffect \ UnpackedTarball/skia/src/gpu/effects/generated/GrMixerEffect \ UnpackedTarball/skia/src/gpu/effects/generated/GrOverrideInputFragmentProcessor \ UnpackedTarball/skia/src/gpu/effects/generated/GrPremulInputFragmentProcessor \ UnpackedTarball/skia/src/gpu/effects/generated/GrRectBlurEffect \ + UnpackedTarball/skia/src/gpu/effects/generated/GrRGBToHSLFilterEffect \ UnpackedTarball/skia/src/gpu/effects/generated/GrRRectBlurEffect \ UnpackedTarball/skia/src/gpu/effects/generated/GrSaturateProcessor \ UnpackedTarball/skia/src/gpu/effects/generated/GrSimpleTextureEffect \ @@ -750,7 +753,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ UnpackedTarball/skia/src/image/SkSurface_Gpu \ UnpackedTarball/skia/src/gpu/vk/GrVkAMDMemoryAllocator \ UnpackedTarball/skia/src/gpu/vk/GrVkBuffer \ - UnpackedTarball/skia/src/gpu/vk/GrVkBufferView \ UnpackedTarball/skia/src/gpu/vk/GrVkCaps \ UnpackedTarball/skia/src/gpu/vk/GrVkCommandBuffer \ UnpackedTarball/skia/src/gpu/vk/GrVkCommandPool \ @@ -970,7 +972,6 @@ endif # UnpackedTarball/skia/src/atlastext/SkInternalAtlasTextContext \ $(eval $(call gb_Library_add_generated_exception_objects,skia,\ - UnpackedTarball/skia/third_party/gif/SkGifImageReader \ UnpackedTarball/skia/third_party/skcms/skcms \ UnpackedTarball/skia/third_party/vulkanmemoryallocator/GrVulkanMemoryAllocator \ )) diff --git a/external/skia/README b/external/skia/README index 95be1561d4fb..79cb3334a12a 100644 --- a/external/skia/README +++ b/external/skia/README @@ -10,13 +10,15 @@ git clone https://skia.googlesource.com/skia.git cd skia git checkout chrome/mXX id=$(git rev-parse chrome/mXX) +git clean -idx rm -rf .git gitignore cd .. tar cvJf skia-mXX-$id.tar.xz skia (where XX refers to the branch version) -And review differences for BUILD.gn and relevant files in gn/ . +And review differences for BUILD.gn and relevant files in gn/ +(git diff chrome/mYY..chrome/mXX ./file). GrContext sharing diff --git a/external/skia/UnpackedTarball_skia.mk b/external/skia/UnpackedTarball_skia.mk index 84178749caed..64bfe5e2e76e 100644 --- a/external/skia/UnpackedTarball_skia.mk +++ b/external/skia/UnpackedTarball_skia.mk @@ -14,10 +14,9 @@ $(eval $(call gb_UnpackedTarball_set_tarball,skia,$(SKIA_TARBALL))) # TODO skia_patches := \ lerp.patch \ - fix-pch.patch \ + fix-pch.patch.1 \ fix-ddi.patch \ make-api-visible.patch.1 \ - fix-shader-locale.patch.1 \ no-trace-resources-on-exit.patch.1 \ fix-alpha-difference-copy.patch.1 \ libvulkan-name.patch.1 \ @@ -25,6 +24,7 @@ skia_patches := \ c++20-comparison.patch.0 \ Wdeprecated-copy.patch.0 \ Wdeprecated-copy-dtor.patch.0 \ + fix-msvc.patch.1 \ $(eval $(call gb_UnpackedTarball_set_patchlevel,skia,1)) diff --git a/external/skia/fix-alpha-difference-copy.patch.1 b/external/skia/fix-alpha-difference-copy.patch.1 index d9e992a770a7..a691f8f57334 100644 --- a/external/skia/fix-alpha-difference-copy.patch.1 +++ b/external/skia/fix-alpha-difference-copy.patch.1 @@ -1,11 +1,11 @@ diff --git a/src/core/SkBlitter_Sprite.cpp b/src/core/SkBlitter_Sprite.cpp -index 89b107b939..042d8e65aa 100644 +index 6ae7893681..3878eb3b81 100644 --- a/src/core/SkBlitter_Sprite.cpp +++ b/src/core/SkBlitter_Sprite.cpp -@@ -178,7 +178,7 @@ SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint, - */ +@@ -179,7 +179,7 @@ SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint, SkASSERT(allocator != nullptr); + // TODO: in principle SkRasterPipelineSpriteBlitter could be made to handle this. - if (source.alphaType() == kUnpremul_SkAlphaType) { + if (source.alphaType() != dst.alphaType()) { return nullptr; diff --git a/external/skia/fix-msvc.patch.1 b/external/skia/fix-msvc.patch.1 new file mode 100644 index 000000000000..807d0adfcfb2 --- /dev/null +++ b/external/skia/fix-msvc.patch.1 @@ -0,0 +1,22 @@ +diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h +index 03d22aeaae..0f91f6f73c 100644 +--- a/src/gpu/GrFragmentProcessor.h ++++ b/src/gpu/GrFragmentProcessor.h +@@ -531,7 +531,7 @@ public: + bool operator!=(const EndIter&) { return (bool)*this; } + + // Because each iterator carries a stack we want to avoid copies. +- IterBase(const IterBase&) = delete; ++ IterBase(const IterBase&) = default; + IterBase& operator=(const IterBase&) = delete; + + protected: +@@ -603,7 +603,7 @@ public: + operator bool() const { return fFPIter; } + bool operator!=(const FPItemEndIter&) { return (bool)*this; } + +- FPItemIter(const FPItemIter&) = delete; ++ FPItemIter(const FPItemIter&) = default; + FPItemIter& operator=(const FPItemIter&) = delete; + + private: diff --git a/external/skia/fix-pch.patch b/external/skia/fix-pch.patch.1 index a991e80970e9..d884c151a869 100644 --- a/external/skia/fix-pch.patch +++ b/external/skia/fix-pch.patch.1 @@ -1,17 +1,41 @@ ---- skia/src/utils/Sk3D.cpp.sav 2019-08-15 21:59:46.324369467 +0200 -+++ skia/src/utils/Sk3D.cpp 2019-09-26 13:13:34.153647165 +0200 -@@ -38,6 +38,9 @@ void Sk3LookAt(SkMatrix44* dst, const Sk - dst->invert(dst); - } +diff --git a/include/core/SkColor.h b/include/core/SkColor.h +index 53df435e46..ce74db8b27 100644 +--- a/include/core/SkColor.h ++++ b/include/core/SkColor.h +@@ -400,6 +400,7 @@ using SkColor4f = SkRGBA4f<kUnpremul_SkAlphaType>; -+#undef far -+#undef near + template <> SK_API SkColor4f SkColor4f::FromColor(SkColor); + template <> SK_API SkColor SkColor4f::toSkColor() const; ++template <> uint32_t SkColor4f::toBytes_RGBA() const; + + namespace SkColors { + constexpr SkColor4f kTransparent = {0, 0, 0, 0}; +diff --git a/include/private/SkColorData.h b/include/private/SkColorData.h +index 2090ab4b7e..801511586f 100644 +--- a/include/private/SkColorData.h ++++ b/include/private/SkColorData.h +@@ -441,4 +441,6 @@ constexpr SkPMColor4f SK_PMColor4fILLEGAL = { SK_FloatNegativeInfinity, + SK_FloatNegativeInfinity, + SK_FloatNegativeInfinity }; + ++template <> uint32_t SkPMColor4f::toBytes_RGBA() const; + - bool Sk3Perspective(SkMatrix44* dst, float near, float far, float angle) { - SkASSERT(far > near); + #endif +diff --git a/src/gpu/text/GrTextBlobCache.h b/src/gpu/text/GrTextBlobCache.h +index 1484cee527..dcb53b20a1 100644 +--- a/src/gpu/text/GrTextBlobCache.h ++++ b/src/gpu/text/GrTextBlobCache.h +@@ -197,4 +197,6 @@ private: + SkMessageBus<PurgeBlobMessage>::Inbox fPurgeBlobInbox; + }; ---- skia/src/gpu/vk/GrVkSemaphore.cpp.sav 2019-08-15 21:59:46.292369407 +0200 -+++ skia/src/gpu/vk/GrVkSemaphore.cpp 2019-09-26 13:12:56.041647516 +0200 ++template<> SkMessageBus<GrTextBlobCache::PurgeBlobMessage>* SkMessageBus<GrTextBlobCache::PurgeBlobMessage>::Get(); ++ + #endif +diff --git a/src/gpu/vk/GrVkSemaphore.cpp b/src/gpu/vk/GrVkSemaphore.cpp +index 191b6a3ce5..26754acccd 100644 +--- a/src/gpu/vk/GrVkSemaphore.cpp ++++ b/src/gpu/vk/GrVkSemaphore.cpp @@ -10,6 +10,7 @@ #include "include/gpu/GrBackendSemaphore.h" #include "src/gpu/vk/GrVkGpu.h" @@ -20,8 +44,37 @@ #ifdef VK_USE_PLATFORM_WIN32_KHR // windows wants to define this as CreateSemaphoreA or CreateSemaphoreW ---- skia/third_party/skcms/skcms.cc.sav 2019-09-26 13:03:33.997652697 +0200 -+++ skia/third_party/skcms/skcms.cc 2019-09-26 13:13:19.185647303 +0200 +diff --git a/src/utils/Sk3D.cpp b/src/utils/Sk3D.cpp +index 0df42b5fa9..97b85233b3 100644 +--- a/src/utils/Sk3D.cpp ++++ b/src/utils/Sk3D.cpp +@@ -38,6 +38,9 @@ void Sk3LookAt(SkMatrix44* dst, const SkPoint3& eye, const SkPoint3& center, con + dst->invert(dst); + } + ++#undef far ++#undef near ++ + bool Sk3Perspective(SkMatrix44* dst, float near, float far, float angle) { + SkASSERT(far > near); + +diff --git a/src/utils/win/SkDWriteGeometrySink.h b/src/utils/win/SkDWriteGeometrySink.h +index 019539b191..5dd7bef353 100644 +--- a/src/utils/win/SkDWriteGeometrySink.h ++++ b/src/utils/win/SkDWriteGeometrySink.h +@@ -13,6 +13,8 @@ + + class SkPath; + ++#define CONST const ++ + #include <dwrite.h> + #include <d2d1.h> + +diff --git a/third_party/skcms/skcms.cc b/third_party/skcms/skcms.cc +index cc5738d977..c67310f6cc 100644 +--- a/third_party/skcms/skcms.cc ++++ b/third_party/skcms/skcms.cc @@ -124,7 +124,8 @@ static float minus_1_ulp(float x) { // Most transfer functions we work with are sRGBish. // For exotic HDR transfer functions, we encode them using a tf.g that makes no sense, @@ -32,7 +85,7 @@ struct TF_PQish { float A,B,C,D,E,F; }; struct TF_HLGish { float R,G,a,b,c; }; -@@ -1817,7 +1817,9 @@ typedef enum { +@@ -2011,7 +2012,9 @@ typedef enum { Op_store_hhhh, Op_store_fff, Op_store_ffff, @@ -43,42 +96,3 @@ #if defined(__clang__) template <int N, typename T> using Vec = T __attribute__((ext_vector_type(N))); ---- skia/src/utils/win/SkDWriteGeometrySink.h.sav 2019-08-15 22:00:07.552409373 +0200 -+++ skia/src/utils/win/SkDWriteGeometrySink.h 2019-09-26 13:54:17.725624642 +0200 -@@ -12,6 +12,8 @@ - - class SkPath; - -+#define CONST const -+ - #include <dwrite.h> - #include <d2d1.h> - ---- skia/include/core/SkColor.h -+++ skia/include/core/SkColor.h -@@ -396,6 +396,7 @@ using SkColor4f = SkRGBA4f<kUnpremul_SkAlphaType>; - - template <> SK_API SkColor4f SkColor4f::FromColor(SkColor); - template <> SK_API SkColor SkColor4f::toSkColor() const; -+template <> uint32_t SkColor4f::toBytes_RGBA() const; - - namespace SkColors { - constexpr SkColor4f kTransparent = {0, 0, 0, 0}; ---- skia/include/private/SkColorData.h -+++ skia/include/private/SkColorData.h -@@ -441,4 +441,6 @@ constexpr SkPMColor4f SK_PMColor4fILLEGAL = { SK_FloatNegativeInfinity, - SK_FloatNegativeInfinity, - SK_FloatNegativeInfinity }; - -+template <> uint32_t SkPMColor4f::toBytes_RGBA() const; -+ - #endif ---- skia/src/gpu/text/GrTextBlobCache.h -+++ skia/src/gpu/text/GrTextBlobCache.h -@@ -188,4 +188,6 @@ private: - SkMessageBus<PurgeBlobMessage>::Inbox fPurgeBlobInbox; - }; - -+template<> SkMessageBus<GrTextBlobCache::PurgeBlobMessage>* SkMessageBus<GrTextBlobCache::PurgeBlobMessage>::Get(); -+ - #endif diff --git a/external/skia/fix-shader-locale.patch.1 b/external/skia/fix-shader-locale.patch.1 deleted file mode 100644 index af6405fe517c..000000000000 --- a/external/skia/fix-shader-locale.patch.1 +++ /dev/null @@ -1,40 +0,0 @@ -From b653813d58146fb41cd1852e5f24cdfc0ad9532a Mon Sep 17 00:00:00 2001 -From: Ethan Nicholas <ethannicholas@google.com> -Date: Tue, 22 Oct 2019 16:00:18 -0400 -Subject: [PATCH 1/7] Vulkan SkSL code now works in locales which use ',' as - the decimal separator. - -Bug: skia:9550 -Change-Id: Ib844971bd1daebdf7a0f93388ad40e4977822233 -Reviewed-on: https://skia-review.googlesource.com/c/skia/+/250076 -Reviewed-by: Greg Daniel <egdaniel@google.com> -Commit-Queue: Ethan Nicholas <ethannicholas@google.com> ---- - src/gpu/vk/GrVkPipelineStateBuilder.cpp | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/src/gpu/vk/GrVkPipelineStateBuilder.cpp b/src/gpu/vk/GrVkPipelineStateBuilder.cpp -index 4d595e7eca..dbe16f6e7f 100644 ---- a/src/gpu/vk/GrVkPipelineStateBuilder.cpp -+++ b/src/gpu/vk/GrVkPipelineStateBuilder.cpp -@@ -6,6 +6,7 @@ - */ - - #include "include/gpu/GrContext.h" -+#include "src/gpu/GrAutoLocaleSetter.h" - #include "src/gpu/GrContextPriv.h" - #include "src/gpu/GrPersistentCacheUtils.h" - #include "src/gpu/GrShaderCaps.h" -@@ -27,6 +28,9 @@ GrVkPipelineState* GrVkPipelineStateBuilder::CreatePipelineState( - GrPrimitiveType primitiveType, - Desc* desc, - VkRenderPass compatibleRenderPass) { -+ // ensure that we use "." as a decimal separator when creating SkSL code -+ GrAutoLocaleSetter als("C"); -+ - // create a builder. This will be handed off to effects so they can use it to add - // uniforms, varyings, textures, etc - GrVkPipelineStateBuilder builder(gpu, renderTarget, programInfo, desc); --- -2.16.4 - diff --git a/external/skia/inc/pch/precompiled_skia.hxx b/external/skia/inc/pch/precompiled_skia.hxx index 34adcad39af2..8a0b7f0a6014 100644 --- a/external/skia/inc/pch/precompiled_skia.hxx +++ b/external/skia/inc/pch/precompiled_skia.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2019-10-21 16:31:00 using: + Generated on 2019-12-06 12:13:34 using: ./bin/update_pch external/skia skia --cutoff=1 --exclude:system --include:module --include:local If after updating build fails, use the following command to locate conflicting headers: @@ -24,6 +24,7 @@ #include <algorithm> #include <assert.h> #include <atomic> +#include <bitset> #include <cctype> #include <cfloat> #include <chrono> @@ -83,7 +84,6 @@ #include <include/c/sk_surface.h> #include <include/codec/SkAndroidCodec.h> #include <include/codec/SkCodec.h> -#include <include/codec/SkCodecAnimation.h> #include <include/core/SkAnnotation.h> #include <include/core/SkBBHFactory.h> #include <include/core/SkBitmap.h> @@ -122,8 +122,6 @@ #include <include/core/SkMath.h> #include <include/core/SkMatrix.h> #include <include/core/SkMatrix44.h> -#include <include/core/SkMilestone.h> -#include <include/core/SkMultiPictureDraw.h> #include <include/core/SkOverdrawCanvas.h> #include <include/core/SkPaint.h> #include <include/core/SkPath.h> @@ -262,6 +260,7 @@ #include <include/private/SkTFitsIn.h> #include <include/private/SkTHash.h> #include <include/private/SkTemplates.h> +#include <include/private/SkThreadAnnotations.h> #include <include/private/SkThreadID.h> #include <include/private/SkTo.h> #include <include/private/SkVx.h> @@ -292,7 +291,6 @@ #include <src/codec/SkCodecPriv.h> #include <src/codec/SkColorTable.h> #include <src/codec/SkFrameHolder.h> -#include <src/codec/SkGifCodec.h> #include <src/codec/SkIcoCodec.h> #include <src/codec/SkJpegCodec.h> #include <src/codec/SkJpegDecoderMgr.h> @@ -445,6 +443,7 @@ #include <src/core/SkScanPriv.h> #include <src/core/SkScopeExit.h> #include <src/core/SkSharedMutex.h> +#include <src/core/SkSpan.h> #include <src/core/SkSpecialImage.h> #include <src/core/SkSpecialSurface.h> #include <src/core/SkSpriteBlitter.h> @@ -468,6 +467,7 @@ #include <src/core/SkTTopoSort.h> #include <src/core/SkTaskGroup.h> #include <src/core/SkTextBlobPriv.h> +#include <src/core/SkTextBlobTrace.h> #include <src/core/SkTextFormatParams.h> #include <src/core/SkTraceEvent.h> #include <src/core/SkTraceEventCommon.h> @@ -475,6 +475,7 @@ #include <src/core/SkTypeface_remote.h> #include <src/core/SkUtils.h> #include <src/core/SkVM.h> +#include <src/core/SkVMBlitter.h> #include <src/core/SkValidationUtils.h> #include <src/core/SkVertState.h> #include <src/core/SkWriteBuffer.h> @@ -484,6 +485,7 @@ #include <src/core/SkXfermodePriv.h> #include <src/core/SkYUVMath.h> #include <src/core/SkYUVPlanesCache.h> +#include <src/core/SkZip.h> #include <src/effects/SkDashImpl.h> #include <src/effects/SkEmbossMask.h> #include <src/effects/SkEmbossMaskFilter.h> @@ -666,11 +668,13 @@ #include <src/gpu/effects/generated/GrConfigConversionEffect.h> #include <src/gpu/effects/generated/GrConstColorProcessor.h> #include <src/gpu/effects/generated/GrEllipseEffect.h> +#include <src/gpu/effects/generated/GrHSLToRGBFilterEffect.h> #include <src/gpu/effects/generated/GrLumaColorFilterEffect.h> #include <src/gpu/effects/generated/GrMagnifierEffect.h> #include <src/gpu/effects/generated/GrMixerEffect.h> #include <src/gpu/effects/generated/GrOverrideInputFragmentProcessor.h> #include <src/gpu/effects/generated/GrPremulInputFragmentProcessor.h> +#include <src/gpu/effects/generated/GrRGBToHSLFilterEffect.h> #include <src/gpu/effects/generated/GrRRectBlurEffect.h> #include <src/gpu/effects/generated/GrRectBlurEffect.h> #include <src/gpu/effects/generated/GrSaturateProcessor.h> @@ -777,7 +781,6 @@ #include <src/gpu/text/GrTextContext.h> #include <src/gpu/text/GrTextTarget.h> #include <src/gpu/vk/GrVkBuffer.h> -#include <src/gpu/vk/GrVkBufferView.h> #include <src/gpu/vk/GrVkCaps.h> #include <src/gpu/vk/GrVkCommandBuffer.h> #include <src/gpu/vk/GrVkCommandPool.h> @@ -983,7 +986,6 @@ #include <src/utils/SkShadowTessellator.h> #include <src/utils/SkShaperJSONWriter.h> #include <src/utils/SkUTF.h> -#include <third_party/gif/SkGifImageReader.h> #include <tools/gpu/vk/GrVulkanDefines.h> #include <tools/gpu/vk/VkTestUtils.h> #include <tools/sk_app/GLWindowContext.h> diff --git a/external/skia/share-grcontext.patch.1 b/external/skia/share-grcontext.patch.1 index ed81e772aa20..ea5952eeac1d 100644 --- a/external/skia/share-grcontext.patch.1 +++ b/external/skia/share-grcontext.patch.1 @@ -1,167 +1,7 @@ ---- ./tools/sk_app/VulkanWindowContext.h.sav 2019-11-14 16:46:31.218722399 +0100 -+++ ./tools/sk_app/VulkanWindowContext.h 2019-11-15 11:58:46.656455921 +0100 -@@ -23,14 +23,30 @@ class GrRenderTarget; - - namespace sk_app { - --class VulkanWindowContext : public WindowContext { -+class SK_API VulkanWindowContext : public WindowContext { -+ struct Shared; - public: - ~VulkanWindowContext() override; - -+ class SharedGrContext { -+ public: -+ SharedGrContext() {} -+ GrContext* getGrContext() { return shared ? shared->fContext.get() : nullptr; } -+ ~SharedGrContext() { shared.reset(); checkDestroyShared(); } -+ bool operator!() const { return !shared; } -+ void reset() { shared.reset(); } -+ private: -+ friend class VulkanWindowContext; -+ SharedGrContext(sk_sp<Shared>& sh ) : shared( sh ) {} -+ sk_sp<Shared> shared; -+ }; -+ -+ static SharedGrContext getSharedGrContext() { return SharedGrContext( fGlobalShared ); } -+ - sk_sp<SkSurface> getBackbufferSurface() override; - void swapBuffers() 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); -@@ -53,6 +69,7 @@ public: - private: - void initializeContext(); - void destroyContext(); -+ static void checkDestroyShared(); - - struct BackbufferInfo { - uint32_t fImageIndex; // image this is associated with -@@ -64,11 +81,6 @@ private: - void createBuffers(VkFormat format, SkColorType colorType); - void destroyBuffers(); - -- VkInstance fInstance = VK_NULL_HANDLE; -- VkPhysicalDevice fPhysicalDevice = VK_NULL_HANDLE; -- VkDevice fDevice = VK_NULL_HANDLE; -- VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE; -- - // Create functions - CreateVkSurfaceFn fCreateVkSurfaceFn; - CanPresentFn fCanPresentFn; -@@ -90,20 +102,41 @@ private: - 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 GrContext, so share all the relevant data. -+ struct Shared : public SkRefCnt -+ { -+ PFN_vkDestroyInstance fDestroyInstance = nullptr; -+ PFN_vkDestroyDevice fDestroyDevice = nullptr; -+ PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugReportCallbackEXT = nullptr; -+ -+ VkInstance fInstance = VK_NULL_HANDLE; -+ VkPhysicalDevice fPhysicalDevice = VK_NULL_HANDLE; -+ VkDevice fDevice = VK_NULL_HANDLE; -+ VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE; -+ - sk_sp<const GrVkInterface> fInterface; - -- VkSurfaceKHR fSurface; -- VkSwapchainKHR fSwapchain; -+ // Original code had this as a function-local variable, but that seems wrong. -+ // It should exist as long as the context exists. -+ VkPhysicalDeviceFeatures2 features; -+ - uint32_t fGraphicsQueueIndex; - VkQueue fGraphicsQueue; - uint32_t fPresentQueueIndex; -+ -+ sk_sp<GrContext> fContext; -+ }; -+ -+ sk_sp<Shared> fShared; -+ -+ static sk_sp<Shared> fGlobalShared; -+ -+ VkSurfaceKHR fSurface; -+ VkSwapchainKHR fSwapchain; - VkQueue fPresentQueue; - - uint32_t fImageCount; ---- ./tools/sk_app/unix/VulkanWindowContext_unix.cpp.sav 2019-10-21 12:03:51.753745188 +0200 -+++ ./tools/sk_app/unix/VulkanWindowContext_unix.cpp 2019-11-15 12:08:01.605967642 +0100 -@@ -30,7 +30,7 @@ std::unique_ptr<WindowContext> MakeVulka - 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> MakeVulka - - 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> MakeVulka - }; - std::unique_ptr<WindowContext> ctx( - new VulkanWindowContext(displayParams, createVkSurface, canPresent, instProc, devProc)); -- if (!ctx->isValid()) { -+ if (!ctx->isValid() && createVkSurface != nullptr) { - return nullptr; - } - return ctx; ---- ./tools/sk_app/win/VulkanWindowContext_win.cpp.sav 2019-10-21 12:03:51.753745188 +0200 -+++ ./tools/sk_app/win/VulkanWindowContext_win.cpp 2019-11-15 12:08:21.466022257 +0100 -@@ -30,7 +30,7 @@ std::unique_ptr<WindowContext> MakeVulka - return nullptr; - } - -- auto createVkSurface = [hwnd, instProc] (VkInstance instance) -> VkSurfaceKHR { -+ VulkanWindowContext::CreateVkSurfaceFn createVkSurface = [hwnd, instProc] (VkInstance instance) -> VkSurfaceKHR { - static PFN_vkCreateWin32SurfaceKHR createWin32SurfaceKHR = nullptr; - if (!createWin32SurfaceKHR) { - createWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) -@@ -54,6 +54,9 @@ std::unique_ptr<WindowContext> MakeVulka - - 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) { -@@ -71,7 +74,7 @@ std::unique_ptr<WindowContext> MakeVulka - - std::unique_ptr<WindowContext> ctx( - new VulkanWindowContext(params, createVkSurface, canPresent, instProc, devProc)); -- if (!ctx->isValid()) { -+ if (!ctx->isValid() && createVkSurface != nullptr) { - return nullptr; - } - return ctx; ---- ./tools/sk_app/VulkanWindowContext.cpp.sav 2019-11-14 16:46:31.218722399 +0100 -+++ ./tools/sk_app/VulkanWindowContext.cpp 2019-11-15 11:58:46.656455921 +0100 +diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp +index c2b26b4254..ef84f7902a 100644 +--- a/tools/sk_app/VulkanWindowContext.cpp ++++ b/tools/sk_app/VulkanWindowContext.cpp @@ -24,8 +24,10 @@ #undef CreateSemaphore #endif @@ -175,7 +15,7 @@ namespace sk_app { -@@ -49,6 +51,14 @@ VulkanWindowContext::VulkanWindowContext +@@ -49,6 +51,14 @@ VulkanWindowContext::VulkanWindowContext(const DisplayParams& params, } void VulkanWindowContext::initializeContext() { @@ -190,7 +30,7 @@ // any config code here (particularly for msaa)? PFN_vkGetInstanceProcAddr getInstanceProc = fGetInstanceProcAddr; -@@ -62,24 +72,25 @@ void VulkanWindowContext::initializeCont +@@ -62,24 +72,25 @@ void VulkanWindowContext::initializeContext() { }; GrVkBackendContext backendContext; GrVkExtensions extensions; @@ -226,7 +66,7 @@ PFN_vkGetPhysicalDeviceProperties localGetPhysicalDeviceProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceProperties>( -@@ -87,21 +98,31 @@ void VulkanWindowContext::initializeCont +@@ -87,21 +98,31 @@ void VulkanWindowContext::initializeContext() { backendContext.fInstance, VK_NULL_HANDLE)); if (!localGetPhysicalDeviceProperties) { @@ -263,7 +103,7 @@ GET_PROC(DestroySurfaceKHR); GET_PROC(GetPhysicalDeviceSurfaceSupportKHR); GET_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR); -@@ -109,7 +130,6 @@ void VulkanWindowContext::initializeCont +@@ -109,7 +130,6 @@ void VulkanWindowContext::initializeContext() { GET_PROC(GetPhysicalDeviceSurfacePresentModesKHR); GET_DEV_PROC(DeviceWaitIdle); GET_DEV_PROC(QueueWaitIdle); @@ -271,7 +111,7 @@ GET_DEV_PROC(CreateSwapchainKHR); GET_DEV_PROC(DestroySwapchainKHR); GET_DEV_PROC(GetSwapchainImagesKHR); -@@ -117,46 +137,44 @@ void VulkanWindowContext::initializeCont +@@ -117,46 +137,44 @@ void VulkanWindowContext::initializeContext() { GET_DEV_PROC(QueuePresentKHR); GET_DEV_PROC(GetDeviceQueue); @@ -328,7 +168,7 @@ nullptr); if (VK_SUCCESS != res) { return false; -@@ -164,14 +182,14 @@ bool VulkanWindowContext::createSwapchai +@@ -164,14 +182,14 @@ bool VulkanWindowContext::createSwapchain(int width, int height, SkAutoMalloc surfaceFormatAlloc(surfaceFormatCount * sizeof(VkSurfaceFormatKHR)); VkSurfaceFormatKHR* surfaceFormats = (VkSurfaceFormatKHR*)surfaceFormatAlloc.get(); @@ -345,7 +185,7 @@ nullptr); if (VK_SUCCESS != res) { return false; -@@ -179,7 +197,7 @@ bool VulkanWindowContext::createSwapchai +@@ -179,7 +197,7 @@ bool VulkanWindowContext::createSwapchain(int width, int height, SkAutoMalloc presentModeAlloc(presentModeCount * sizeof(VkPresentModeKHR)); VkPresentModeKHR* presentModes = (VkPresentModeKHR*)presentModeAlloc.get(); @@ -354,7 +194,7 @@ presentModes); if (VK_SUCCESS != res) { return false; -@@ -286,8 +304,8 @@ bool VulkanWindowContext::createSwapchai +@@ -286,8 +304,8 @@ bool VulkanWindowContext::createSwapchain(int width, int height, swapchainCreateInfo.imageArrayLayers = 1; swapchainCreateInfo.imageUsage = usageFlags; @@ -365,7 +205,7 @@ swapchainCreateInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT; swapchainCreateInfo.queueFamilyIndexCount = 2; swapchainCreateInfo.pQueueFamilyIndices = queueFamilies; -@@ -303,18 +321,18 @@ bool VulkanWindowContext::createSwapchai +@@ -303,18 +321,18 @@ bool VulkanWindowContext::createSwapchain(int width, int height, swapchainCreateInfo.clipped = true; swapchainCreateInfo.oldSwapchain = fSwapchain; @@ -387,7 +227,7 @@ } this->createBuffers(swapchainCreateInfo.imageFormat, colorType); -@@ -323,10 +341,10 @@ bool VulkanWindowContext::createSwapchai +@@ -323,10 +341,10 @@ bool VulkanWindowContext::createSwapchain(int width, int height, } void VulkanWindowContext::createBuffers(VkFormat format, SkColorType colorType) { @@ -400,7 +240,7 @@ // set up initial image layouts and create surfaces fImageLayouts = new VkImageLayout[fImageCount]; -@@ -341,7 +359,7 @@ void VulkanWindowContext::createBuffers( +@@ -341,7 +359,7 @@ void VulkanWindowContext::createBuffers(VkFormat format, SkColorType colorType) info.fImageTiling = VK_IMAGE_TILING_OPTIMAL; info.fFormat = format; info.fLevelCount = 1; @@ -409,18 +249,18 @@ if (fSampleCount == 1) { GrBackendRenderTarget backendRT(fWidth, fHeight, fSampleCount, info); -@@ -372,8 +390,8 @@ void VulkanWindowContext::createBuffers( +@@ -372,8 +390,8 @@ void VulkanWindowContext::createBuffers(VkFormat format, SkColorType colorType) fBackbuffers = new BackbufferInfo[fImageCount + 1]; for (uint32_t i = 0; i < fImageCount + 1; ++i) { fBackbuffers[i].fImageIndex = -1; -- GR_VK_CALL_ERRCHECK(fInterface, -- CreateSemaphore(fDevice, &semaphoreInfo, -+ GR_VK_CALL_ERRCHECK(fShared->fInterface, -+ CreateSemaphore(fShared->fDevice, &semaphoreInfo, - nullptr, &fBackbuffers[i].fRenderSemaphore)); +- SkDEBUGCODE(VkResult result = )GR_VK_CALL(fInterface, +- CreateSemaphore(fDevice, &semaphoreInfo, nullptr, ++ SkDEBUGCODE(VkResult result = )GR_VK_CALL(fShared->fInterface, ++ CreateSemaphore(fShared->fDevice, &semaphoreInfo, nullptr, + &fBackbuffers[i].fRenderSemaphore)); + SkASSERT(result == VK_SUCCESS); } - fCurrentBackbufferIndex = fImageCount; -@@ -384,8 +402,8 @@ void VulkanWindowContext::destroyBuffers +@@ -385,8 +403,8 @@ void VulkanWindowContext::destroyBuffers() { if (fBackbuffers) { for (uint32_t i = 0; i < fImageCount + 1; ++i) { fBackbuffers[i].fImageIndex = -1; @@ -431,7 +271,7 @@ fBackbuffers[i].fRenderSemaphore, nullptr)); } -@@ -410,41 +428,55 @@ VulkanWindowContext::~VulkanWindowContex +@@ -411,41 +429,55 @@ VulkanWindowContext::~VulkanWindowContext() { void VulkanWindowContext::destroyContext() { if (this->isValid()) { fQueueWaitIdle(fPresentQueue); @@ -500,13 +340,14 @@ } VulkanWindowContext::BackbufferInfo* VulkanWindowContext::getAvailableBackbuffer() { -@@ -470,34 +502,34 @@ sk_sp<SkSurface> VulkanWindowContext::ge +@@ -471,35 +503,35 @@ sk_sp<SkSurface> VulkanWindowContext::getBackbufferSurface() { semaphoreInfo.pNext = nullptr; semaphoreInfo.flags = 0; VkSemaphore semaphore; -- GR_VK_CALL_ERRCHECK(fInterface, CreateSemaphore(fDevice, &semaphoreInfo, -+ GR_VK_CALL_ERRCHECK(fShared->fInterface, CreateSemaphore(fShared->fDevice, &semaphoreInfo, - nullptr, &semaphore)); +- SkDEBUGCODE(VkResult result = )GR_VK_CALL(fInterface, CreateSemaphore(fDevice, &semaphoreInfo, ++ 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, @@ -541,10 +382,178 @@ return nullptr; } } -@@ -541,4 +573,6 @@ void VulkanWindowContext::swapBuffers() +@@ -543,4 +575,6 @@ void VulkanWindowContext::swapBuffers() { 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 2db9e79ae6..11e94aae31 100644 +--- a/tools/sk_app/VulkanWindowContext.h ++++ b/tools/sk_app/VulkanWindowContext.h +@@ -23,14 +23,30 @@ class GrRenderTarget; + + namespace sk_app { + +-class VulkanWindowContext : public WindowContext { ++class SK_API VulkanWindowContext : public WindowContext { ++ struct Shared; + public: + ~VulkanWindowContext() override; + ++ class SharedGrContext { ++ public: ++ SharedGrContext() {} ++ GrContext* getGrContext() { return shared ? shared->fContext.get() : nullptr; } ++ ~SharedGrContext() { shared.reset(); checkDestroyShared(); } ++ bool operator!() const { return !shared; } ++ void reset() { shared.reset(); } ++ private: ++ friend class VulkanWindowContext; ++ SharedGrContext(sk_sp<Shared>& sh ) : shared( sh ) {} ++ sk_sp<Shared> shared; ++ }; ++ ++ static SharedGrContext getSharedGrContext() { return SharedGrContext( fGlobalShared ); } ++ + sk_sp<SkSurface> getBackbufferSurface() override; + void swapBuffers() 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); +@@ -53,6 +69,7 @@ public: + private: + void initializeContext(); + void destroyContext(); ++ static void checkDestroyShared(); + + struct BackbufferInfo { + uint32_t fImageIndex; // image this is associated with +@@ -64,11 +81,6 @@ private: + void createBuffers(VkFormat format, SkColorType colorType); + void destroyBuffers(); + +- VkInstance fInstance = VK_NULL_HANDLE; +- VkPhysicalDevice fPhysicalDevice = VK_NULL_HANDLE; +- VkDevice fDevice = VK_NULL_HANDLE; +- VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE; +- + // Create functions + CreateVkSurfaceFn fCreateVkSurfaceFn; + CanPresentFn fCanPresentFn; +@@ -90,20 +102,41 @@ private: + 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 GrContext, so share all the relevant data. ++ struct Shared : public SkRefCnt ++ { ++ PFN_vkDestroyInstance fDestroyInstance = nullptr; ++ PFN_vkDestroyDevice fDestroyDevice = nullptr; ++ PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugReportCallbackEXT = nullptr; ++ ++ VkInstance fInstance = VK_NULL_HANDLE; ++ VkPhysicalDevice fPhysicalDevice = VK_NULL_HANDLE; ++ VkDevice fDevice = VK_NULL_HANDLE; ++ VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE; ++ + sk_sp<const GrVkInterface> fInterface; + +- VkSurfaceKHR fSurface; +- VkSwapchainKHR fSwapchain; ++ // Original code had this as a function-local variable, but that seems wrong. ++ // It should exist as long as the context exists. ++ VkPhysicalDeviceFeatures2 features; ++ + uint32_t fGraphicsQueueIndex; + VkQueue fGraphicsQueue; + uint32_t fPresentQueueIndex; ++ ++ sk_sp<GrContext> fContext; ++ }; ++ ++ sk_sp<Shared> fShared; ++ ++ static sk_sp<Shared> fGlobalShared; ++ ++ VkSurfaceKHR fSurface; ++ VkSwapchainKHR fSwapchain; + VkQueue fPresentQueue; + + uint32_t fImageCount; +diff --git a/tools/sk_app/unix/VulkanWindowContext_unix.cpp b/tools/sk_app/unix/VulkanWindowContext_unix.cpp +index 6f0ce0aceb..877578cede 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, devProc)); +- 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 909c96127b..35e063ae28 100644 +--- a/tools/sk_app/win/VulkanWindowContext_win.cpp ++++ b/tools/sk_app/win/VulkanWindowContext_win.cpp +@@ -30,7 +30,7 @@ std::unique_ptr<WindowContext> MakeVulkanForWin(HWND hwnd, const DisplayParams& + return nullptr; + } + +- auto createVkSurface = [hwnd, instProc] (VkInstance instance) -> VkSurfaceKHR { ++ VulkanWindowContext::CreateVkSurfaceFn createVkSurface = [hwnd, instProc] (VkInstance instance) -> VkSurfaceKHR { + static PFN_vkCreateWin32SurfaceKHR createWin32SurfaceKHR = nullptr; + if (!createWin32SurfaceKHR) { + createWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) +@@ -54,6 +54,9 @@ std::unique_ptr<WindowContext> MakeVulkanForWin(HWND hwnd, const DisplayParams& + + 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) { +@@ -71,7 +74,7 @@ std::unique_ptr<WindowContext> MakeVulkanForWin(HWND hwnd, const DisplayParams& + + std::unique_ptr<WindowContext> ctx( + new VulkanWindowContext(params, createVkSurface, canPresent, instProc, devProc)); +- if (!ctx->isValid()) { ++ if (!ctx->isValid() && createVkSurface != nullptr) { + return nullptr; + } + return ctx; |