From b902658a1a2e4e3d1f359b40891e95282be2202b Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Wed, 23 Feb 2022 11:50:43 -0500 Subject: [PATCH] [bazel] Fix Bazel build by guarding addToKey PS1 is the automatic regenerated changes. PS2-3 adds an #ifdef guard to the addToKey method on shaders. The SkShaderCodeDictionary class helps generate SkSL and is only necessary when we are building with SkSL (gpu builds and cpu builds with SkVM). Suggested Review order: - Use Gerrit to diff PS 1 and the last PS - src/core/BUILD.bazel adds some sources to the "only necessary if sksl is enabled" bucket - All the .cpp and .h files to see the #ifdef is added correctly. Change-Id: I4d4ce61a4957ef1e0840204acff08ce7e616f9cb Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512157 Reviewed-by: Michael Ludwig Commit-Queue: Kevin Lubick --- experimental/graphite/src/BUILD.bazel | 19 +++++- gm/BUILD.bazel | 28 ++++++++- include/core/BUILD.bazel | 1 + include/private/BUILD.bazel | 5 +- include/private/chromium/BUILD.bazel | 1 + src/core/BUILD.bazel | 9 ++- src/core/SkBlendModeBlender.cpp | 7 ++- src/core/SkBlenderBase.h | 2 + src/gpu/BUILD.bazel | 60 ++++++++++--------- src/gpu/gl/BUILD.bazel | 4 +- src/gpu/gl/builders/BUILD.bazel | 2 +- src/gpu/glsl/BUILD.bazel | 4 +- src/gpu/text/BUILD.bazel | 5 ++ src/gpu/v1/BUILD.bazel | 3 +- src/shaders/SkColorShader.cpp | 7 ++- src/shaders/SkColorShader.h | 7 +++ src/shaders/SkComposeShader.cpp | 7 ++- src/shaders/SkComposeShader.h | 4 ++ src/shaders/SkImageShader.cpp | 7 ++- src/shaders/SkImageShader.h | 6 +- src/shaders/SkShader.cpp | 7 ++- src/shaders/SkShaderBase.h | 2 + src/shaders/gradients/SkLinearGradient.cpp | 8 ++- src/shaders/gradients/SkLinearGradient.h | 4 ++ src/shaders/gradients/SkRadialGradient.cpp | 7 ++- src/shaders/gradients/SkRadialGradient.h | 5 +- src/shaders/gradients/SkSweepGradient.cpp | 7 ++- src/shaders/gradients/SkSweepGradient.h | 4 ++ .../gradients/SkTwoPointConicalGradient.cpp | 7 ++- .../gradients/SkTwoPointConicalGradient.h | 5 +- src/sksl/BUILD.bazel | 5 +- tests/BUILD.bazel | 17 +++++- tests/graphite/BUILD.bazel | 27 ++++----- 33 files changed, 216 insertions(+), 77 deletions(-) diff --git a/experimental/graphite/src/BUILD.bazel b/experimental/graphite/src/BUILD.bazel index ea757157b8..4eb6e61eb1 100644 --- a/experimental/graphite/src/BUILD.bazel +++ b/experimental/graphite/src/BUILD.bazel @@ -100,6 +100,7 @@ generated_cc_atom( visibility = ["//:__subpackages__"], deps = [ ":ContextPriv_hdr", + ":GlobalCache_hdr", ":Gpu_hdr", ], ) @@ -366,6 +367,7 @@ generated_cc_atom( "//experimental/graphite/include:Recorder_hdr", "//experimental/graphite/src/geom:BoundsManager_hdr", "//src/core:SkMathPriv_hdr", + "//src/core:SkPaintParamsKey_hdr", "//src/core:SkTBlockList_hdr", "//src/core:SkUniformData_hdr", "//src/gpu:BufferWriter_hdr", @@ -482,7 +484,10 @@ generated_cc_atom( name = "Image_Graphite_hdr", hdrs = ["Image_Graphite.h"], visibility = ["//:__subpackages__"], - deps = ["//src/image:SkImage_Base_hdr"], + deps = [ + ":TextureProxyView_hdr", + "//src/image:SkImage_Base_hdr", + ], ) generated_cc_atom( @@ -944,3 +949,15 @@ generated_cc_atom( "//src/core:SkConvertPixels_hdr", ], ) + +generated_cc_atom( + name = "TextureProxyView_hdr", + hdrs = ["TextureProxyView.h"], + visibility = ["//:__subpackages__"], + deps = [ + ":TextureProxy_hdr", + "//experimental/graphite/include:GraphiteTypes_hdr", + "//include/core:SkRefCnt_hdr", + "//src/gpu:Swizzle_hdr", + ], +) diff --git a/gm/BUILD.bazel b/gm/BUILD.bazel index 98519b22ab..48b854f29a 100644 --- a/gm/BUILD.bazel +++ b/gm/BUILD.bazel @@ -1927,8 +1927,8 @@ generated_cc_atom( "//include/private:SkColorData_hdr", "//src/core:SkCanvasPriv_hdr", "//src/gpu:GrRecordingContextPriv_hdr", - "//src/gpu:GrSwizzle_hdr", "//src/gpu:SurfaceFillContext_hdr", + "//src/gpu:Swizzle_hdr", ], ) @@ -5755,6 +5755,7 @@ generated_cc_atom( deps = [ ":gm_hdr", "//include/core:SkCanvas_hdr", + "//include/core:SkMaskFilter_hdr", "//include/core:SkPaint_hdr", "//include/core:SkPathEffect_hdr", "//include/core:SkPath_hdr", @@ -5763,6 +5764,7 @@ generated_cc_atom( "//include/core:SkScalar_hdr", "//include/core:SkTypes_hdr", "//include/effects:SkDashPathEffect_hdr", + "//include/effects:SkImageFilters_hdr", ], ) @@ -9381,6 +9383,7 @@ generated_cc_atom( "//include/gpu:GrRecordingContext_hdr", "//include/gpu:GrTypes_hdr", "//include/private:GrTypesPriv_hdr", + "//include/private:SkHalf_hdr", "//include/private:SkTArray_hdr", "//include/private:SkTDArray_hdr", "//include/private:SkTPin_hdr", @@ -9616,3 +9619,26 @@ generated_cc_atom( "//src/gpu/v1:SurfaceDrawContext_v1_hdr", ], ) + +generated_cc_atom( + name = "palette_src", + srcs = ["palette.cpp"], + visibility = ["//:__subpackages__"], + deps = [ + ":gm_hdr", + "//include/core:SkCanvas_hdr", + "//include/core:SkColor_hdr", + "//include/core:SkFontMetrics_hdr", + "//include/core:SkFontMgr_hdr", + "//include/core:SkFont_hdr", + "//include/core:SkPaint_hdr", + "//include/core:SkRefCnt_hdr", + "//include/core:SkScalar_hdr", + "//include/core:SkSize_hdr", + "//include/core:SkString_hdr", + "//include/core:SkTypeface_hdr", + "//include/core:SkTypes_hdr", + "//tools:Resources_hdr", + "//tools:ToolUtils_hdr", + ], +) diff --git a/include/core/BUILD.bazel b/include/core/BUILD.bazel index e7ee356e21..b246ed59b7 100644 --- a/include/core/BUILD.bazel +++ b/include/core/BUILD.bazel @@ -274,6 +274,7 @@ generated_cc_atom( hdrs = ["SkFontArguments.h"], visibility = ["//:__subpackages__"], deps = [ + ":SkColor_hdr", ":SkScalar_hdr", ":SkTypes_hdr", ], diff --git a/include/private/BUILD.bazel b/include/private/BUILD.bazel index 134b7322c8..1dcb415c88 100644 --- a/include/private/BUILD.bazel +++ b/include/private/BUILD.bazel @@ -367,10 +367,7 @@ generated_cc_atom( name = "SkSLString_hdr", hdrs = ["SkSLString.h"], visibility = ["//:__subpackages__"], - deps = [ - ":SkSLDefines_hdr", - "//include/core:SkString_hdr", - ], + deps = [":SkSLDefines_hdr"], ) generated_cc_atom( diff --git a/include/private/chromium/BUILD.bazel b/include/private/chromium/BUILD.bazel index 8633eae549..2ec7409abc 100644 --- a/include/private/chromium/BUILD.bazel +++ b/include/private/chromium/BUILD.bazel @@ -5,6 +5,7 @@ generated_cc_atom( hdrs = ["GrSlug.h"], visibility = ["//:__subpackages__"], deps = [ + "//include/core:SkData_hdr", "//include/core:SkRect_hdr", "//include/core:SkRefCnt_hdr", ], diff --git a/src/core/BUILD.bazel b/src/core/BUILD.bazel index a9f343e5cc..592911b913 100644 --- a/src/core/BUILD.bazel +++ b/src/core/BUILD.bazel @@ -94,7 +94,6 @@ cc_library( ":SkImageFilter_src", ":SkImageGenerator_src", ":SkImageInfo_src", - ":SkKeyHelpers_src", ":SkLatticeIter_src", ":SkLineClipper_src", ":SkLocalMatrixImageFilter_src", @@ -210,10 +209,14 @@ cc_library( ], ) +# These are sources that are only needed if SkSL is enabled (GPU backend or SkVM). cc_library( name = "sksl_srcs", deps = [ + ":SkKeyHelpers_src", + ":SkPaintParamsKey_src", ":SkRuntimeEffect_src", + ":SkShaderCodeDictionary_src", ], ) @@ -3126,8 +3129,6 @@ generated_cc_atom( ":SkBlenderBase_hdr", ":SkColorFilterBase_hdr", ":SkColorSpacePriv_hdr", - ":SkKeyHelpers_hdr", - ":SkPaintParamsKey_hdr", ":SkPaintPriv_hdr", ":SkXfermodePriv_hdr", "//include/core:SkPaint_hdr", @@ -5656,7 +5657,9 @@ generated_cc_atom( visibility = ["//:__subpackages__"], deps = [ ":SkBuiltInCodeSnippetID_hdr", + "//include/core:SkSpan_hdr", "//include/core:SkTypes_hdr", + "//include/private:SkTArray_hdr", ], ) diff --git a/src/core/SkBlendModeBlender.cpp b/src/core/SkBlendModeBlender.cpp index 49272b1425..de9f2cfd3d 100644 --- a/src/core/SkBlendModeBlender.cpp +++ b/src/core/SkBlendModeBlender.cpp @@ -6,7 +6,6 @@ */ #include "src/core/SkBlendModeBlender.h" -#include "src/core/SkKeyHelpers.h" #include "src/core/SkReadBuffer.h" #include "src/core/SkWriteBuffer.h" @@ -15,6 +14,10 @@ #include "src/gpu/effects/GrBlendFragmentProcessor.h" #endif +#ifdef SK_ENABLE_SKSL +#include "src/core/SkKeyHelpers.h" +#endif + sk_sp SkBlender::Mode(SkBlendMode mode) { #define RETURN_SINGLETON_BLENDER(m) \ case m: { \ @@ -60,6 +63,7 @@ sk_sp SkBlender::Mode(SkBlendMode mode) { #undef RETURN_SINGLETON_BLENDER } +#ifdef SK_ENABLE_SKSL void SkBlenderBase::addToKey(SkShaderCodeDictionary* dict, SkPaintParamsKeyBuilder* builder, SkUniformBlock* uniformBlock) const { @@ -70,6 +74,7 @@ void SkBlenderBase::addToKey(SkShaderCodeDictionary* dict, BlendModeBlock::AddToKey(dict, builder, uniformBlock, SkBlendMode::kSrcOver); } } +#endif sk_sp SkBlendModeBlender::CreateProc(SkReadBuffer& buffer) { SkBlendMode mode = buffer.read32LE(SkBlendMode::kLastMode); diff --git a/src/core/SkBlenderBase.h b/src/core/SkBlenderBase.h index f2896db8f6..1bc2222be0 100644 --- a/src/core/SkBlenderBase.h +++ b/src/core/SkBlenderBase.h @@ -57,10 +57,12 @@ public: virtual SkRuntimeEffect* asRuntimeEffect() const { return nullptr; } +#ifdef SK_ENABLE_SKSL // TODO: make pure virtual virtual void addToKey(SkShaderCodeDictionary*, SkPaintParamsKeyBuilder*, SkUniformBlock*) const; +#endif static SkFlattenable::Type GetFlattenableType() { return kSkBlender_Type; } Type getFlattenableType() const override { return GetFlattenableType(); } diff --git a/src/gpu/BUILD.bazel b/src/gpu/BUILD.bazel index 32dd1c193b..464abfe082 100644 --- a/src/gpu/BUILD.bazel +++ b/src/gpu/BUILD.bazel @@ -85,7 +85,6 @@ cc_library( ":GrSurfaceInfo_src", ":GrSurfaceProxy_src", ":GrSurface_src", - ":GrSwizzle_src", ":GrTestUtils_src", ":GrTextureProxy_src", ":GrTextureRenderTargetProxy_src", @@ -107,6 +106,7 @@ cc_library( ":SkGr_src", ":SurfaceContext_src", ":SurfaceFillContext_src", + ":Swizzle_src", "//src/gpu/effects:GrBezierEffect_src", "//src/gpu/effects:GrBicubicEffect_src", "//src/gpu/effects:GrBitmapTextGeoProc_src", @@ -701,7 +701,7 @@ generated_cc_atom( ":GrSamplerState_hdr", ":GrShaderCaps_hdr", ":GrSurfaceProxy_hdr", - ":GrSwizzle_hdr", + ":Swizzle_hdr", "//include/core:SkImageInfo_hdr", "//include/core:SkRefCnt_hdr", "//include/core:SkString_hdr", @@ -957,7 +957,7 @@ generated_cc_atom( ":GrDataUtils_hdr", ":GrImageInfo_hdr", ":GrPixmap_hdr", - ":GrSwizzle_hdr", + ":Swizzle_hdr", "//include/private:SkTPin_hdr", "//include/third_party/skcms:skcms_hdr", "//src/core:SkColorSpaceXformSteps_hdr", @@ -1311,7 +1311,10 @@ generated_cc_atom( name = "GrEagerVertexAllocator_hdr", hdrs = ["GrEagerVertexAllocator.h"], visibility = ["//:__subpackages__"], - deps = [":GrThreadSafeCache_hdr"], + deps = [ + ":BufferWriter_hdr", + ":GrThreadSafeCache_hdr", + ], ) generated_cc_atom( @@ -1416,7 +1419,7 @@ generated_cc_atom( ":GrProcessor_hdr", ":GrShaderCaps_hdr", ":GrShaderVar_hdr", - ":GrSwizzle_hdr", + ":Swizzle_hdr", "//src/gpu/glsl:GrGLSLProgramDataManager_hdr", "//src/gpu/glsl:GrGLSLUniformHandler_hdr", "//src/gpu/glsl:GrGLSLVarying_hdr", @@ -1524,8 +1527,8 @@ generated_cc_atom( ":GrCaps_hdr", ":GrOpsRenderPass_hdr", ":GrPixmap_hdr", - ":GrSwizzle_hdr", ":GrXferProcessor_hdr", + ":Swizzle_hdr", "//include/core:SkPath_hdr", "//include/core:SkSpan_hdr", "//include/core:SkSurface_hdr", @@ -2246,7 +2249,7 @@ generated_cc_atom( ":GrNativeRect_hdr", ":GrSubRunAllocator_hdr", ":GrSurfaceProxy_hdr", - ":GrSwizzle_hdr", + ":Swizzle_hdr", "//include/private:GrTypesPriv_hdr", "//src/core:SkArenaAlloc_hdr", ], @@ -2750,8 +2753,8 @@ generated_cc_atom( deps = [ ":GrRenderTargetProxy_hdr", ":GrSurfaceProxy_hdr", - ":GrSwizzle_hdr", ":GrTextureProxy_hdr", + ":Swizzle_hdr", "//include/core:SkRefCnt_hdr", "//include/gpu:GrTypes_hdr", ], @@ -2825,27 +2828,6 @@ generated_cc_atom( ], ) -generated_cc_atom( - name = "GrSwizzle_hdr", - hdrs = ["GrSwizzle.h"], - visibility = ["//:__subpackages__"], - deps = [ - ":GrColor_hdr", - "//include/core:SkString_hdr", - "//include/private:SkColorData_hdr", - ], -) - -generated_cc_atom( - name = "GrSwizzle_src", - srcs = ["GrSwizzle.cpp"], - visibility = ["//:__subpackages__"], - deps = [ - ":GrSwizzle_hdr", - "//src/core:SkRasterPipeline_hdr", - ], -) - generated_cc_atom( name = "GrTTopoSort_hdr", hdrs = ["GrTTopoSort.h"], @@ -3492,3 +3474,23 @@ generated_cc_atom( visibility = ["//:__subpackages__"], deps = ["//include/core:SkTypes_hdr"], ) + +generated_cc_atom( + name = "Swizzle_hdr", + hdrs = ["Swizzle.h"], + visibility = ["//:__subpackages__"], + deps = [ + "//include/core:SkString_hdr", + "//include/private:SkColorData_hdr", + ], +) + +generated_cc_atom( + name = "Swizzle_src", + srcs = ["Swizzle.cpp"], + visibility = ["//:__subpackages__"], + deps = [ + ":Swizzle_hdr", + "//src/core:SkRasterPipeline_hdr", + ], +) diff --git a/src/gpu/gl/BUILD.bazel b/src/gpu/gl/BUILD.bazel index f3f0d7a9f1..612cae10cb 100644 --- a/src/gpu/gl/BUILD.bazel +++ b/src/gpu/gl/BUILD.bazel @@ -111,7 +111,7 @@ generated_cc_atom( "//include/private:SkTArray_hdr", "//include/private:SkTHash_hdr", "//src/gpu:GrCaps_hdr", - "//src/gpu:GrSwizzle_hdr", + "//src/gpu:Swizzle_hdr", ], ) @@ -495,7 +495,7 @@ generated_cc_atom( ":GrGLDefines_hdr", "//include/core:SkScalar_hdr", "//include/private:GrGLTypesPriv_hdr", - "//src/gpu:GrSwizzle_hdr", + "//src/gpu:Swizzle_hdr", ], ) diff --git a/src/gpu/gl/builders/BUILD.bazel b/src/gpu/gl/builders/BUILD.bazel index 82deeecde4..b53a43da18 100644 --- a/src/gpu/gl/builders/BUILD.bazel +++ b/src/gpu/gl/builders/BUILD.bazel @@ -36,8 +36,8 @@ generated_cc_atom( "//src/gpu:GrPersistentCacheUtils_hdr", "//src/gpu:GrProgramDesc_hdr", "//src/gpu:GrShaderCaps_hdr", - "//src/gpu:GrSwizzle_hdr", "//src/gpu:GrXferProcessor_hdr", + "//src/gpu:Swizzle_hdr", "//src/gpu/gl:GrGLGpu_hdr", "//src/gpu/gl:GrGLProgram_hdr", "//src/gpu/glsl:GrGLSLProgramDataManager_hdr", diff --git a/src/gpu/glsl/BUILD.bazel b/src/gpu/glsl/BUILD.bazel index 5b29468297..bb5589cb2b 100644 --- a/src/gpu/glsl/BUILD.bazel +++ b/src/gpu/glsl/BUILD.bazel @@ -145,7 +145,7 @@ generated_cc_atom( "//include/sksl:DSL_hdr", "//src/gpu:GrShaderCaps_hdr", "//src/gpu:GrShaderVar_hdr", - "//src/gpu:GrSwizzle_hdr", + "//src/gpu:Swizzle_hdr", "//src/sksl:SkSLThreadContext_hdr", "//src/sksl/ir:SkSLVarDeclarations_hdr", ], @@ -158,7 +158,7 @@ generated_cc_atom( deps = [ ":GrGLSLProgramDataManager_hdr", "//src/gpu:GrShaderVar_hdr", - "//src/gpu:GrSwizzle_hdr", + "//src/gpu:Swizzle_hdr", ], ) diff --git a/src/gpu/text/BUILD.bazel b/src/gpu/text/BUILD.bazel index aa7346a790..0a1bf1ca67 100644 --- a/src/gpu/text/BUILD.bazel +++ b/src/gpu/text/BUILD.bazel @@ -106,6 +106,8 @@ generated_cc_atom( deps = [ "//include/core:SkCanvas_hdr", "//include/private/chromium:GrSlug_hdr", + "//src/core:SkReadBuffer_hdr", + "//src/core:SkWriteBuffer_hdr", ], ) @@ -167,10 +169,12 @@ generated_cc_atom( "//include/gpu:GrRecordingContext_hdr", "//include/private:SkTemplates_hdr", "//include/private/chromium:GrSlug_hdr", + "//include/private/chromium:SkChromeRemoteGlyphCache_hdr", "//src/core:SkFontPriv_hdr", "//src/core:SkMaskFilterBase_hdr", "//src/core:SkMatrixProvider_hdr", "//src/core:SkPaintPriv_hdr", + "//src/core:SkReadBuffer_hdr", "//src/core:SkStrikeCache_hdr", "//src/core:SkStrikeSpec_hdr", "//src/gpu:GrBlurUtils_hdr", @@ -235,6 +239,7 @@ generated_cc_atom( deps = [ ":GrAtlasManager_hdr", ":GrGlyphVector_hdr", + "//include/private/chromium:SkChromeRemoteGlyphCache_hdr", "//src/core:SkReadBuffer_hdr", "//src/core:SkStrikeCache_hdr", "//src/core:SkStrikeSpec_hdr", diff --git a/src/gpu/v1/BUILD.bazel b/src/gpu/v1/BUILD.bazel index 615edbf855..ec17491158 100644 --- a/src/gpu/v1/BUILD.bazel +++ b/src/gpu/v1/BUILD.bazel @@ -110,6 +110,7 @@ generated_cc_atom( "//src/core:SkStroke_hdr", "//src/core:SkTLazy_hdr", "//src/core:SkVerticesPriv_hdr", + "//src/core:SkWriteBuffer_hdr", "//src/gpu:GrBlurUtils_hdr", "//src/gpu:GrDirectContextPriv_hdr", "//src/gpu:GrGpu_hdr", @@ -350,8 +351,8 @@ generated_cc_atom( "//include/core:SkSize_hdr", "//include/private:GrTypesPriv_hdr", "//src/gpu:GrImageInfo_hdr", - "//src/gpu:GrSwizzle_hdr", "//src/gpu:SurfaceFillContext_hdr", + "//src/gpu:Swizzle_hdr", "//src/gpu/ops:OpsTask_hdr", ], ) diff --git a/src/shaders/SkColorShader.cpp b/src/shaders/SkColorShader.cpp index c0bb2eb476..04fdfce017 100644 --- a/src/shaders/SkColorShader.cpp +++ b/src/shaders/SkColorShader.cpp @@ -11,12 +11,15 @@ #include "src/core/SkArenaAlloc.h" #include "src/core/SkColorSpacePriv.h" #include "src/core/SkColorSpaceXformSteps.h" -#include "src/core/SkKeyHelpers.h" #include "src/core/SkRasterPipeline.h" #include "src/core/SkReadBuffer.h" #include "src/core/SkUtils.h" #include "src/core/SkVM.h" +#ifdef SK_ENABLE_SKSL +#include "src/core/SkKeyHelpers.h" +#endif + SkColorShader::SkColorShader(SkColor c) : fColor(c) {} bool SkColorShader::isOpaque() const { @@ -137,6 +140,7 @@ std::unique_ptr SkColor4Shader::asFragmentProcessor( #endif +#ifdef SK_ENABLE_SKSL void SkColorShader::addToKey(SkShaderCodeDictionary* dict, SkPaintParamsKeyBuilder* builder, SkUniformBlock* uniformBlock) const { @@ -149,3 +153,4 @@ void SkColor4Shader::addToKey(SkShaderCodeDictionary* dict, SkUniformBlock* uniformBlock) const { SolidColorShaderBlock::AddToKey(dict, builder, uniformBlock, fColor); } +#endif diff --git a/src/shaders/SkColorShader.h b/src/shaders/SkColorShader.h index 1a8864bbe9..6d59903865 100644 --- a/src/shaders/SkColorShader.h +++ b/src/shaders/SkColorShader.h @@ -10,6 +10,8 @@ #include "src/shaders/SkShaderBase.h" +class SkShaderCodeDictionary; + /** \class SkColorShader A Shader that represents a single color. In general, this effect can be accomplished by just using the color field on the paint, but if an @@ -31,9 +33,12 @@ public: #if SK_SUPPORT_GPU std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif + +#ifdef SK_ENABLE_SKSL void addToKey(SkShaderCodeDictionary*, SkPaintParamsKeyBuilder*, SkUniformBlock*) const override; +#endif private: SK_FLATTENABLE_HOOKS(SkColorShader) @@ -64,9 +69,11 @@ public: #if SK_SUPPORT_GPU std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif +#ifdef SK_ENABLE_SKSL void addToKey(SkShaderCodeDictionary*, SkPaintParamsKeyBuilder*, SkUniformBlock*) const override; +#endif private: SK_FLATTENABLE_HOOKS(SkColor4Shader) diff --git a/src/shaders/SkComposeShader.cpp b/src/shaders/SkComposeShader.cpp index df076a25d3..76cbf738ea 100644 --- a/src/shaders/SkComposeShader.cpp +++ b/src/shaders/SkComposeShader.cpp @@ -11,7 +11,6 @@ #include "src/core/SkArenaAlloc.h" #include "src/core/SkBlendModePriv.h" #include "src/core/SkBlenderBase.h" -#include "src/core/SkKeyHelpers.h" #include "src/core/SkRasterPipeline.h" #include "src/core/SkReadBuffer.h" #include "src/core/SkRuntimeEffectPriv.h" @@ -20,6 +19,10 @@ #include "src/shaders/SkColorShader.h" #include "src/shaders/SkComposeShader.h" +#ifdef SK_ENABLE_SKSL +#include "src/core/SkKeyHelpers.h" +#endif + namespace { struct LocalMatrixStageRec final : public SkStageRec { @@ -189,6 +192,7 @@ std::unique_ptr SkShader_Blend::asFragmentProcessor( } #endif +#ifdef SK_ENABLE_SKSL void SkShader_Blend::addToKey(SkShaderCodeDictionary* dict, SkPaintParamsKeyBuilder* builder, SkUniformBlock* uniformBlock) const { @@ -197,3 +201,4 @@ void SkShader_Blend::addToKey(SkShaderCodeDictionary* dict, BlendShaderBlock::AddToKey(dict, builder, uniformBlock, { fDst.get(), fSrc.get(), fMode }); } +#endif diff --git a/src/shaders/SkComposeShader.h b/src/shaders/SkComposeShader.h index d8ff823b2c..87e9595a80 100644 --- a/src/shaders/SkComposeShader.h +++ b/src/shaders/SkComposeShader.h @@ -13,6 +13,8 @@ #include "src/core/SkBlenderBase.h" #include "src/shaders/SkShaderBase.h" +class SkShaderCodeDictionary; + class SkShader_Blend final : public SkShaderBase { public: SkShader_Blend(SkBlendMode mode, sk_sp dst, sk_sp src) @@ -28,9 +30,11 @@ public: std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif +#ifdef SK_ENABLE_SKSL void addToKey(SkShaderCodeDictionary*, SkPaintParamsKeyBuilder*, SkUniformBlock*) const override; +#endif protected: SkShader_Blend(SkReadBuffer&); diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp index 087e08bc70..d8f026cf23 100755 --- a/src/shaders/SkImageShader.cpp +++ b/src/shaders/SkImageShader.cpp @@ -11,7 +11,6 @@ #include "src/core/SkArenaAlloc.h" #include "src/core/SkColorSpacePriv.h" #include "src/core/SkColorSpaceXformSteps.h" -#include "src/core/SkKeyHelpers.h" #include "src/core/SkMatrixPriv.h" #include "src/core/SkMatrixProvider.h" #include "src/core/SkMipmapAccessor.h" @@ -27,6 +26,10 @@ #include "src/shaders/SkEmptyShader.h" #include "src/shaders/SkTransformShader.h" +#ifdef SK_ENABLE_SKSL +#include "src/core/SkKeyHelpers.h" +#endif + SkM44 SkImageShader::CubicResamplerMatrix(float B, float C) { #if 0 constexpr SkM44 kMitchell = SkM44( 1.f/18.f, -9.f/18.f, 15.f/18.f, -7.f/18.f, @@ -373,11 +376,13 @@ std::unique_ptr SkImageShader::asFragmentProcessor( #endif +#ifdef SK_ENABLE_SKSL void SkImageShader::addToKey(SkShaderCodeDictionary* dict, SkPaintParamsKeyBuilder* builder, SkUniformBlock* uniformBlock) const { ImageShaderBlock::AddToKey(dict, builder, uniformBlock, { fTileModeX, fTileModeY }); } +#endif /////////////////////////////////////////////////////////////////////////////////////////////////// #include "src/core/SkImagePriv.h" diff --git a/src/shaders/SkImageShader.h b/src/shaders/SkImageShader.h index 7733884fac..9316925b91 100644 --- a/src/shaders/SkImageShader.h +++ b/src/shaders/SkImageShader.h @@ -13,6 +13,8 @@ #include "src/shaders/SkBitmapProcShader.h" #include "src/shaders/SkShaderBase.h" +class SkShaderCodeDictionary; + class SkImageShader : public SkShaderBase { public: static sk_sp Make(sk_sp, @@ -43,11 +45,11 @@ public: #if SK_SUPPORT_GPU std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif - +#ifdef SK_ENABLE_SKSL void addToKey(SkShaderCodeDictionary*, SkPaintParamsKeyBuilder*, SkUniformBlock*) const override; - +#endif static SkM44 CubicResamplerMatrix(float B, float C); private: diff --git a/src/shaders/SkShader.cpp b/src/shaders/SkShader.cpp index 895158aa67..98dc592290 100644 --- a/src/shaders/SkShader.cpp +++ b/src/shaders/SkShader.cpp @@ -12,7 +12,6 @@ #include "src/core/SkArenaAlloc.h" #include "src/core/SkColorSpacePriv.h" #include "src/core/SkColorSpaceXformSteps.h" -#include "src/core/SkKeyHelpers.h" #include "src/core/SkMatrixProvider.h" #include "src/core/SkRasterPipeline.h" #include "src/core/SkReadBuffer.h" @@ -31,6 +30,10 @@ #include "src/gpu/GrFragmentProcessor.h" #endif +#ifdef SK_ENABLE_SKSL +#include "src/core/SkKeyHelpers.h" +#endif + SkShaderBase::SkShaderBase(const SkMatrix* localMatrix) : fLocalMatrix(localMatrix ? *localMatrix : SkMatrix::I()) { // Pre-cache so future calls to fLocalMatrix.getType() are threadsafe. @@ -149,12 +152,14 @@ SkUpdatableShader* SkShaderBase::onUpdatableShader(SkArenaAlloc* alloc) const { return nullptr; } +#ifdef SK_ENABLE_SKSL // TODO: add implementations for derived classes void SkShaderBase::addToKey(SkShaderCodeDictionary* dict, SkPaintParamsKeyBuilder* builder, SkUniformBlock* uniformBlock) const { SolidColorShaderBlock::AddToKey(dict, builder, uniformBlock, SkColors::kRed); } +#endif sk_sp SkShaders::Empty() { return sk_make_sp(); } sk_sp SkShaders::Color(SkColor color) { return sk_make_sp(color); } diff --git a/src/shaders/SkShaderBase.h b/src/shaders/SkShaderBase.h index 1fb4e0f5b8..5d0cf03238 100644 --- a/src/shaders/SkShaderBase.h +++ b/src/shaders/SkShaderBase.h @@ -214,6 +214,7 @@ public: skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const; +#ifdef SK_ENABLE_SKSL /** Add implementation details, for the specified backend, of this SkShader to the provided key. @@ -225,6 +226,7 @@ public: virtual void addToKey(SkShaderCodeDictionary* dictionary, SkPaintParamsKeyBuilder* builder, SkUniformBlock* uniformBlock) const; +#endif protected: SkShaderBase(const SkMatrix* localMatrix = nullptr); diff --git a/src/shaders/gradients/SkLinearGradient.cpp b/src/shaders/gradients/SkLinearGradient.cpp index 607bd39c5b..d14bd4d8a2 100644 --- a/src/shaders/gradients/SkLinearGradient.cpp +++ b/src/shaders/gradients/SkLinearGradient.cpp @@ -7,11 +7,15 @@ #include "src/shaders/gradients/SkLinearGradient.h" -#include "src/core/SkKeyHelpers.h" + #include "src/core/SkReadBuffer.h" #include "src/core/SkWriteBuffer.h" #include "src/shaders/gradients/Sk4fLinearGradient.h" +#ifdef SK_ENABLE_SKSL +#include "src/core/SkKeyHelpers.h" +#endif + static SkMatrix pts_to_unit_matrix(const SkPoint pts[2]) { SkVector vec = pts[1] - pts[0]; SkScalar mag = vec.length(); @@ -104,6 +108,7 @@ std::unique_ptr SkLinearGradient::asFragmentProcessor( #endif +#ifdef SK_ENABLE_SKSL void SkLinearGradient::addToKey(SkShaderCodeDictionary* dict, SkPaintParamsKeyBuilder* builder, SkUniformBlock* uniformBlock) const { @@ -117,3 +122,4 @@ void SkLinearGradient::addToKey(SkShaderCodeDictionary* dict, GradientShaderBlocks::AddToKey(dict, builder, uniformBlock, data); } +#endif diff --git a/src/shaders/gradients/SkLinearGradient.h b/src/shaders/gradients/SkLinearGradient.h index 5c4662b15c..e804c7f259 100644 --- a/src/shaders/gradients/SkLinearGradient.h +++ b/src/shaders/gradients/SkLinearGradient.h @@ -10,6 +10,8 @@ #include "src/shaders/gradients/SkGradientShaderPriv.h" +class SkShaderCodeDictionary; + class SkLinearGradient : public SkGradientShaderBase { public: SkLinearGradient(const SkPoint pts[2], const Descriptor&); @@ -18,9 +20,11 @@ public: #if SK_SUPPORT_GPU std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif +#ifdef SK_ENABLE_SKSL void addToKey(SkShaderCodeDictionary*, SkPaintParamsKeyBuilder*, SkUniformBlock*) const override; +#endif protected: SkLinearGradient(SkReadBuffer& buffer); diff --git a/src/shaders/gradients/SkRadialGradient.cpp b/src/shaders/gradients/SkRadialGradient.cpp index cb940678ac..5d02ab7fa3 100644 --- a/src/shaders/gradients/SkRadialGradient.cpp +++ b/src/shaders/gradients/SkRadialGradient.cpp @@ -7,11 +7,14 @@ #include "src/shaders/gradients/SkRadialGradient.h" -#include "src/core/SkKeyHelpers.h" #include "src/core/SkRasterPipeline.h" #include "src/core/SkReadBuffer.h" #include "src/core/SkWriteBuffer.h" +#ifdef SK_ENABLE_SKSL +#include "src/core/SkKeyHelpers.h" +#endif + namespace { SkMatrix rad_to_unit_matrix(const SkPoint& center, SkScalar radius) { @@ -83,6 +86,7 @@ std::unique_ptr SkRadialGradient::asFragmentProcessor( #endif +#ifdef SK_ENABLE_SKSL void SkRadialGradient::addToKey(SkShaderCodeDictionary* dict, SkPaintParamsKeyBuilder* builder, SkUniformBlock* uniformBlock) const { @@ -96,3 +100,4 @@ void SkRadialGradient::addToKey(SkShaderCodeDictionary* dict, GradientShaderBlocks::AddToKey(dict, builder, uniformBlock, data); } +#endif diff --git a/src/shaders/gradients/SkRadialGradient.h b/src/shaders/gradients/SkRadialGradient.h index e7cca4a077..63eaab893c 100644 --- a/src/shaders/gradients/SkRadialGradient.h +++ b/src/shaders/gradients/SkRadialGradient.h @@ -10,6 +10,8 @@ #include "src/shaders/gradients/SkGradientShaderPriv.h" +class SkShaderCodeDictionary; + class SkRadialGradient final : public SkGradientShaderBase { public: SkRadialGradient(const SkPoint& center, SkScalar radius, const Descriptor&); @@ -18,10 +20,11 @@ public: #if SK_SUPPORT_GPU std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif +#ifdef SK_ENABLE_SKSL void addToKey(SkShaderCodeDictionary*, SkPaintParamsKeyBuilder*, SkUniformBlock*) const override; - +#endif protected: SkRadialGradient(SkReadBuffer& buffer); void flatten(SkWriteBuffer& buffer) const override; diff --git a/src/shaders/gradients/SkSweepGradient.cpp b/src/shaders/gradients/SkSweepGradient.cpp index 2b22874ac8..659c85f6f3 100644 --- a/src/shaders/gradients/SkSweepGradient.cpp +++ b/src/shaders/gradients/SkSweepGradient.cpp @@ -8,11 +8,14 @@ #include "src/shaders/gradients/SkSweepGradient.h" #include "include/private/SkFloatingPoint.h" -#include "src/core/SkKeyHelpers.h" #include "src/core/SkRasterPipeline.h" #include "src/core/SkReadBuffer.h" #include "src/core/SkWriteBuffer.h" +#ifdef SK_ENABLE_SKSL +#include "src/core/SkKeyHelpers.h" +#endif + SkSweepGradient::SkSweepGradient(const SkPoint& center, SkScalar t0, SkScalar t1, const Descriptor& desc) : SkGradientShaderBase(desc, SkMatrix::Translate(-center.x(), -center.y())) @@ -107,6 +110,7 @@ std::unique_ptr SkSweepGradient::asFragmentProcessor( #endif +#ifdef SK_ENABLE_SKSL void SkSweepGradient::addToKey(SkShaderCodeDictionary* dict, SkPaintParamsKeyBuilder* builder, SkUniformBlock* uniformBlock) const { @@ -120,3 +124,4 @@ void SkSweepGradient::addToKey(SkShaderCodeDictionary* dict, GradientShaderBlocks::AddToKey(dict, builder, uniformBlock, data); } +#endif diff --git a/src/shaders/gradients/SkSweepGradient.h b/src/shaders/gradients/SkSweepGradient.h index be3897d68f..b14062696a 100644 --- a/src/shaders/gradients/SkSweepGradient.h +++ b/src/shaders/gradients/SkSweepGradient.h @@ -10,6 +10,8 @@ #include "src/shaders/gradients/SkGradientShaderPriv.h" +class SkShaderCodeDictionary; + class SkSweepGradient final : public SkGradientShaderBase { public: SkSweepGradient(const SkPoint& center, SkScalar t0, SkScalar t1, const Descriptor&); @@ -19,9 +21,11 @@ public: #if SK_SUPPORT_GPU std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif +#ifdef SK_ENABLE_SKSL void addToKey(SkShaderCodeDictionary*, SkPaintParamsKeyBuilder*, SkUniformBlock*) const override; +#endif SkScalar getTBias() const { return fTBias; } diff --git a/src/shaders/gradients/SkTwoPointConicalGradient.cpp b/src/shaders/gradients/SkTwoPointConicalGradient.cpp index e7d9b729d6..9da6c5022e 100644 --- a/src/shaders/gradients/SkTwoPointConicalGradient.cpp +++ b/src/shaders/gradients/SkTwoPointConicalGradient.cpp @@ -8,13 +8,16 @@ #include "src/shaders/gradients/SkTwoPointConicalGradient.h" #include "include/private/SkFloatingPoint.h" -#include "src/core/SkKeyHelpers.h" #include "src/core/SkRasterPipeline.h" #include "src/core/SkReadBuffer.h" #include "src/core/SkWriteBuffer.h" #include +#ifdef SK_ENABLE_SKSL +#include "src/core/SkKeyHelpers.h" +#endif + // Please see https://skia.org/dev/design/conical for how our shader works. bool SkTwoPointConicalGradient::FocalData::set(SkScalar r0, SkScalar r1, SkMatrix* matrix) { @@ -277,6 +280,7 @@ std::unique_ptr SkTwoPointConicalGradient::asFragmentProces #endif +#ifdef SK_ENABLE_SKSL void SkTwoPointConicalGradient::addToKey(SkShaderCodeDictionary* dict, SkPaintParamsKeyBuilder* builder, SkUniformBlock* uniformBlock) const { @@ -290,3 +294,4 @@ void SkTwoPointConicalGradient::addToKey(SkShaderCodeDictionary* dict, GradientShaderBlocks::AddToKey(dict, builder, uniformBlock, data); } +#endif diff --git a/src/shaders/gradients/SkTwoPointConicalGradient.h b/src/shaders/gradients/SkTwoPointConicalGradient.h index bfe603ecad..54fed43af2 100644 --- a/src/shaders/gradients/SkTwoPointConicalGradient.h +++ b/src/shaders/gradients/SkTwoPointConicalGradient.h @@ -10,6 +10,8 @@ #include "src/shaders/gradients/SkGradientShaderPriv.h" +class SkShaderCodeDictionary; + class SkTwoPointConicalGradient final : public SkGradientShaderBase { public: // See https://skia.org/dev/design/conical for what focal data means and how our shader works. @@ -51,10 +53,11 @@ public: #if SK_SUPPORT_GPU std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif +#ifdef SK_ENABLE_SKSL void addToKey(SkShaderCodeDictionary*, SkPaintParamsKeyBuilder*, SkUniformBlock*) const override; - +#endif bool isOpaque() const override; SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); } diff --git a/src/sksl/BUILD.bazel b/src/sksl/BUILD.bazel index a7584d2057..c8f0ef70dc 100644 --- a/src/sksl/BUILD.bazel +++ b/src/sksl/BUILD.bazel @@ -769,10 +769,7 @@ generated_cc_atom( name = "SkSLString_src", srcs = ["SkSLString.cpp"], visibility = ["//:__subpackages__"], - deps = [ - ":SkSLUtil_hdr", - "//include/private:SkSLString_hdr", - ], + deps = ["//include/private:SkSLString_hdr"], ) generated_cc_atom( diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 1c4add0709..6e3250399c 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -2875,6 +2875,7 @@ generated_cc_atom( "//src/core:SkSpecialSurface_hdr", "//src/gpu:GrCaps_hdr", "//src/gpu:GrRecordingContextPriv_hdr", + "//src/image:SkImage_Base_hdr", "//tools:Resources_hdr", "//tools:ToolUtils_hdr", ], @@ -5572,7 +5573,7 @@ generated_cc_atom( "//include/private:SkHalf_hdr", "//include/private:SkTo_hdr", "//src/core:SkRasterPipeline_hdr", - "//src/gpu:GrSwizzle_hdr", + "//src/gpu:Swizzle_hdr", ], ) @@ -5592,6 +5593,7 @@ generated_cc_atom( "//include/private/chromium:SkChromeRemoteGlyphCache_hdr", "//src/core:SkDraw_hdr", "//src/core:SkFontPriv_hdr", + "//src/core:SkReadBuffer_hdr", "//src/core:SkScalerCache_hdr", "//src/core:SkStrikeCache_hdr", "//src/core:SkStrikeSpec_hdr", @@ -7031,3 +7033,16 @@ generated_cc_atom( "//src/gpu/text:GrGlyphVector_hdr", ], ) + +generated_cc_atom( + name = "SaveLayerOriginTest_src", + srcs = ["SaveLayerOriginTest.cpp"], + visibility = ["//:__subpackages__"], + deps = [ + ":TestUtils_hdr", + ":Test_hdr", + "//include/core:SkCanvas_hdr", + "//include/core:SkSurface_hdr", + "//include/gpu:GrDirectContext_hdr", + ], +) diff --git a/tests/graphite/BUILD.bazel b/tests/graphite/BUILD.bazel index 86f7e12e9a..4a5be57e2f 100644 --- a/tests/graphite/BUILD.bazel +++ b/tests/graphite/BUILD.bazel @@ -18,21 +18,6 @@ generated_cc_atom( ], ) -generated_cc_atom( - name = "ComboTest_src", - srcs = ["ComboTest.cpp"], - visibility = ["//:__subpackages__"], - deps = [ - "//include/core:SkCanvas_hdr", - "//include/core:SkSurface_hdr", - "//include/effects:SkGradientShader_hdr", - "//src/core:SkPaintParamsKey_hdr", - "//src/core:SkPaintPriv_hdr", - "//src/core:SkShaderCodeDictionary_hdr", - "//tests:Test_hdr", - ], -) - generated_cc_atom( name = "CommandBufferTest_src", srcs = ["CommandBufferTest.cpp"], @@ -165,3 +150,15 @@ generated_cc_atom( "//tests:Test_hdr", ], ) + +generated_cc_atom( + name = "KeyTest_src", + srcs = ["KeyTest.cpp"], + visibility = ["//:__subpackages__"], + deps = [ + "//experimental/graphite/src:ContextPriv_hdr", + "//src/core:SkPaintParamsKey_hdr", + "//src/core:SkShaderCodeDictionary_hdr", + "//tests:Test_hdr", + ], +)