aboutsummaryrefslogtreecommitdiff
path: root/src/deps/skia/include/effects
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-04-03 16:34:10 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-04-03 16:34:10 -0700
commita87508008dfa1604baf2d4e39bf44704c00f261c (patch)
tree0be2ade96772037a02803b30e157c367d931e3d9 /src/deps/skia/include/effects
parent4a19a3f07f1887903e5638a3be167f0c7b377ba3 (diff)
downloadbun-jarred/canvas.tar.gz
bun-jarred/canvas.tar.zst
bun-jarred/canvas.zip
Diffstat (limited to 'src/deps/skia/include/effects')
-rw-r--r--src/deps/skia/include/effects/BUILD.bazel219
-rw-r--r--src/deps/skia/include/effects/Sk1DPathEffect.h35
-rw-r--r--src/deps/skia/include/effects/Sk2DPathEffect.h30
-rw-r--r--src/deps/skia/include/effects/SkBlenders.h27
-rw-r--r--src/deps/skia/include/effects/SkBlurDrawLooper.h26
-rw-r--r--src/deps/skia/include/effects/SkBlurMaskFilter.h35
-rw-r--r--src/deps/skia/include/effects/SkColorMatrix.h55
-rw-r--r--src/deps/skia/include/effects/SkColorMatrixFilter.h25
-rw-r--r--src/deps/skia/include/effects/SkCornerPathEffect.h28
-rw-r--r--src/deps/skia/include/effects/SkDashPathEffect.h39
-rw-r--r--src/deps/skia/include/effects/SkDiscretePathEffect.h37
-rw-r--r--src/deps/skia/include/effects/SkGradientShader.h264
-rw-r--r--src/deps/skia/include/effects/SkHighContrastFilter.h80
-rw-r--r--src/deps/skia/include/effects/SkImageFilters.h551
-rw-r--r--src/deps/skia/include/effects/SkLayerDrawLooper.h161
-rw-r--r--src/deps/skia/include/effects/SkLumaColorFilter.h34
-rw-r--r--src/deps/skia/include/effects/SkOpPathEffect.h39
-rw-r--r--src/deps/skia/include/effects/SkOverdrawColorFilter.h29
-rw-r--r--src/deps/skia/include/effects/SkPerlinNoiseShader.h54
-rw-r--r--src/deps/skia/include/effects/SkRuntimeEffect.h518
-rw-r--r--src/deps/skia/include/effects/SkShaderMaskFilter.h24
-rw-r--r--src/deps/skia/include/effects/SkStrokeAndFillPathEffect.h28
-rw-r--r--src/deps/skia/include/effects/SkTableColorFilter.h42
-rw-r--r--src/deps/skia/include/effects/SkTableMaskFilter.h37
-rw-r--r--src/deps/skia/include/effects/SkTrimPathEffect.h41
25 files changed, 2458 insertions, 0 deletions
diff --git a/src/deps/skia/include/effects/BUILD.bazel b/src/deps/skia/include/effects/BUILD.bazel
new file mode 100644
index 000000000..ecb349097
--- /dev/null
+++ b/src/deps/skia/include/effects/BUILD.bazel
@@ -0,0 +1,219 @@
+load("//bazel:macros.bzl", "generated_cc_atom")
+
+generated_cc_atom(
+ name = "Sk1DPathEffect_hdr",
+ hdrs = ["Sk1DPathEffect.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkPathEffect_hdr"],
+)
+
+generated_cc_atom(
+ name = "Sk2DPathEffect_hdr",
+ hdrs = ["Sk2DPathEffect.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkPathEffect_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkBlenders_hdr",
+ hdrs = ["SkBlenders.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkBlender_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkBlurDrawLooper_hdr",
+ hdrs = ["SkBlurDrawLooper.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkDrawLooper_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkBlurMaskFilter_hdr",
+ hdrs = ["SkBlurMaskFilter.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ "//include/core:SkBlurTypes_hdr",
+ "//include/core:SkMaskFilter_hdr",
+ "//include/core:SkRect_hdr",
+ "//include/core:SkScalar_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "SkColorMatrixFilter_hdr",
+ hdrs = ["SkColorMatrixFilter.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ ":SkColorMatrix_hdr",
+ "//include/core:SkColorFilter_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "SkColorMatrix_hdr",
+ hdrs = ["SkColorMatrix.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkImageInfo_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkCornerPathEffect_hdr",
+ hdrs = ["SkCornerPathEffect.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkPathEffect_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkDashPathEffect_hdr",
+ hdrs = ["SkDashPathEffect.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkPathEffect_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkDiscretePathEffect_hdr",
+ hdrs = ["SkDiscretePathEffect.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkPathEffect_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkGradientShader_hdr",
+ hdrs = ["SkGradientShader.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkShader_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkHighContrastFilter_hdr",
+ hdrs = ["SkHighContrastFilter.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkColorFilter_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkImageFilters_hdr",
+ hdrs = ["SkImageFilters.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ ":SkRuntimeEffect_hdr",
+ "//include/core:SkBlendMode_hdr",
+ "//include/core:SkColor_hdr",
+ "//include/core:SkImageFilter_hdr",
+ "//include/core:SkImage_hdr",
+ "//include/core:SkPicture_hdr",
+ "//include/core:SkRect_hdr",
+ "//include/core:SkTileMode_hdr",
+ "//include/core:SkTypes_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "SkLayerDrawLooper_hdr",
+ hdrs = ["SkLayerDrawLooper.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ "//include/core:SkBlendMode_hdr",
+ "//include/core:SkDrawLooper_hdr",
+ "//include/core:SkPaint_hdr",
+ "//include/core:SkPoint_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "SkLumaColorFilter_hdr",
+ hdrs = ["SkLumaColorFilter.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkColorFilter_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkOpPathEffect_hdr",
+ hdrs = ["SkOpPathEffect.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ "//include/core:SkMatrix_hdr",
+ "//include/core:SkPaint_hdr",
+ "//include/core:SkPathEffect_hdr",
+ "//include/pathops:SkPathOps_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "SkOverdrawColorFilter_hdr",
+ hdrs = ["SkOverdrawColorFilter.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ "//include/core:SkColorFilter_hdr",
+ "//include/core:SkFlattenable_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "SkPerlinNoiseShader_hdr",
+ hdrs = ["SkPerlinNoiseShader.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkShader_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkRuntimeEffect_hdr",
+ hdrs = ["SkRuntimeEffect.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ "//include/core:SkBlender_hdr",
+ "//include/core:SkColorFilter_hdr",
+ "//include/core:SkData_hdr",
+ "//include/core:SkImageInfo_hdr",
+ "//include/core:SkMatrix_hdr",
+ "//include/core:SkShader_hdr",
+ "//include/core:SkSpan_hdr",
+ "//include/core:SkString_hdr",
+ "//include/private:SkOnce_hdr",
+ "//include/private:SkSLSampleUsage_hdr",
+ "//include/private:SkTOptional_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "SkShaderMaskFilter_hdr",
+ hdrs = ["SkShaderMaskFilter.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkMaskFilter_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkStrokeAndFillPathEffect_hdr",
+ hdrs = ["SkStrokeAndFillPathEffect.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ "//include/core:SkPaint_hdr",
+ "//include/core:SkPathEffect_hdr",
+ "//include/pathops:SkPathOps_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "SkTableColorFilter_hdr",
+ hdrs = ["SkTableColorFilter.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkColorFilter_hdr"],
+)
+
+generated_cc_atom(
+ name = "SkTableMaskFilter_hdr",
+ hdrs = ["SkTableMaskFilter.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ "//include/core:SkMaskFilter_hdr",
+ "//include/core:SkScalar_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "SkTrimPathEffect_hdr",
+ hdrs = ["SkTrimPathEffect.h"],
+ visibility = ["//:__subpackages__"],
+ deps = ["//include/core:SkPathEffect_hdr"],
+)
diff --git a/src/deps/skia/include/effects/Sk1DPathEffect.h b/src/deps/skia/include/effects/Sk1DPathEffect.h
new file mode 100644
index 000000000..070fc33b5
--- /dev/null
+++ b/src/deps/skia/include/effects/Sk1DPathEffect.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef Sk1DPathEffect_DEFINED
+#define Sk1DPathEffect_DEFINED
+
+#include "include/core/SkPathEffect.h"
+
+class SK_API SkPath1DPathEffect {
+public:
+ enum Style {
+ kTranslate_Style, // translate the shape to each position
+ kRotate_Style, // rotate the shape about its center
+ kMorph_Style, // transform each point, and turn lines into curves
+
+ kLastEnum_Style = kMorph_Style,
+ };
+
+ /** Dash by replicating the specified path.
+ @param path The path to replicate (dash)
+ @param advance The space between instances of path
+ @param phase distance (mod advance) along path for its initial position
+ @param style how to transform path at each point (based on the current
+ position and tangent)
+ */
+ static sk_sp<SkPathEffect> Make(const SkPath& path, SkScalar advance, SkScalar phase, Style);
+
+ static void RegisterFlattenables();
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/Sk2DPathEffect.h b/src/deps/skia/include/effects/Sk2DPathEffect.h
new file mode 100644
index 000000000..96481ca11
--- /dev/null
+++ b/src/deps/skia/include/effects/Sk2DPathEffect.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef Sk2DPathEffect_DEFINED
+#define Sk2DPathEffect_DEFINED
+
+#include "include/core/SkPathEffect.h"
+
+class SkMatrix;
+class SkPath;
+
+class SK_API SkLine2DPathEffect {
+public:
+ static sk_sp<SkPathEffect> Make(SkScalar width, const SkMatrix& matrix);
+
+ static void RegisterFlattenables();
+};
+
+class SK_API SkPath2DPathEffect {
+public:
+ static sk_sp<SkPathEffect> Make(const SkMatrix& matrix, const SkPath& path);
+
+ static void RegisterFlattenables();
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkBlenders.h b/src/deps/skia/include/effects/SkBlenders.h
new file mode 100644
index 000000000..7507071b0
--- /dev/null
+++ b/src/deps/skia/include/effects/SkBlenders.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2021 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkBlenders_DEFINED
+#define SkBlenders_DEFINED
+
+#include "include/core/SkBlender.h"
+
+class SK_API SkBlenders {
+public:
+ /**
+ * Create a blender that implements the following:
+ * k1 * src * dst + k2 * src + k3 * dst + k4
+ * @param k1, k2, k3, k4 The four coefficients.
+ * @param enforcePMColor If true, the RGB channels will be clamped to the calculated alpha.
+ */
+ static sk_sp<SkBlender> Arithmetic(float k1, float k2, float k3, float k4, bool enforcePremul);
+
+private:
+ SkBlenders() = delete;
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkBlurDrawLooper.h b/src/deps/skia/include/effects/SkBlurDrawLooper.h
new file mode 100644
index 000000000..fc766f807
--- /dev/null
+++ b/src/deps/skia/include/effects/SkBlurDrawLooper.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2008 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkBlurDrawLooper_DEFINED
+#define SkBlurDrawLooper_DEFINED
+
+#include "include/core/SkDrawLooper.h"
+
+#ifndef SK_SUPPORT_LEGACY_DRAWLOOPER
+#error "SkDrawLooper is unsupported"
+#endif
+
+/**
+ * DEPRECATED: No longer supported in Skia.
+ */
+namespace SkBlurDrawLooper {
+ sk_sp<SkDrawLooper> SK_API Make(SkColor4f color, SkColorSpace* cs,
+ SkScalar sigma, SkScalar dx, SkScalar dy);
+ sk_sp<SkDrawLooper> SK_API Make(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy);
+} // namespace SkBlurDrawLooper
+
+#endif
diff --git a/src/deps/skia/include/effects/SkBlurMaskFilter.h b/src/deps/skia/include/effects/SkBlurMaskFilter.h
new file mode 100644
index 000000000..1b9319869
--- /dev/null
+++ b/src/deps/skia/include/effects/SkBlurMaskFilter.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkBlurMaskFilter_DEFINED
+#define SkBlurMaskFilter_DEFINED
+
+// we include this since our callers will need to at least be able to ref/unref
+#include "include/core/SkBlurTypes.h"
+#include "include/core/SkMaskFilter.h"
+#include "include/core/SkRect.h"
+#include "include/core/SkScalar.h"
+
+class SkRRect;
+
+class SK_API SkBlurMaskFilter {
+public:
+#ifdef SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
+ /** Create an emboss maskfilter
+ @param blurSigma standard deviation of the Gaussian blur to apply
+ before applying lighting (e.g. 3)
+ @param direction array of 3 scalars [x, y, z] specifying the direction of the light source
+ @param ambient 0...1 amount of ambient light
+ @param specular coefficient for specular highlights (e.g. 8)
+ @return the emboss maskfilter
+ */
+ static sk_sp<SkMaskFilter> MakeEmboss(SkScalar blurSigma, const SkScalar direction[3],
+ SkScalar ambient, SkScalar specular);
+#endif
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkColorMatrix.h b/src/deps/skia/include/effects/SkColorMatrix.h
new file mode 100644
index 000000000..166028214
--- /dev/null
+++ b/src/deps/skia/include/effects/SkColorMatrix.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2007 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkColorMatrix_DEFINED
+#define SkColorMatrix_DEFINED
+
+#include "include/core/SkImageInfo.h"
+
+#include <algorithm>
+#include <array>
+
+class SK_API SkColorMatrix {
+public:
+ constexpr SkColorMatrix() : SkColorMatrix(1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 1, 0) {}
+
+ constexpr SkColorMatrix(float m00, float m01, float m02, float m03, float m04,
+ float m10, float m11, float m12, float m13, float m14,
+ float m20, float m21, float m22, float m23, float m24,
+ float m30, float m31, float m32, float m33, float m34)
+ : fMat { m00, m01, m02, m03, m04,
+ m10, m11, m12, m13, m14,
+ m20, m21, m22, m23, m24,
+ m30, m31, m32, m33, m34 } {}
+
+ static SkColorMatrix RGBtoYUV(SkYUVColorSpace);
+ static SkColorMatrix YUVtoRGB(SkYUVColorSpace);
+
+ void setIdentity();
+ void setScale(float rScale, float gScale, float bScale, float aScale = 1.0f);
+
+ void postTranslate(float dr, float dg, float db, float da);
+
+ void setConcat(const SkColorMatrix& a, const SkColorMatrix& b);
+ void preConcat(const SkColorMatrix& mat) { this->setConcat(*this, mat); }
+ void postConcat(const SkColorMatrix& mat) { this->setConcat(mat, *this); }
+
+ void setSaturation(float sat);
+
+ void setRowMajor(const float src[20]) { std::copy_n(src, 20, fMat.begin()); }
+ void getRowMajor(float dst[20]) const { std::copy_n(fMat.begin(), 20, dst); }
+
+private:
+ std::array<float, 20> fMat;
+
+ friend class SkColorFilters;
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkColorMatrixFilter.h b/src/deps/skia/include/effects/SkColorMatrixFilter.h
new file mode 100644
index 000000000..144c9685f
--- /dev/null
+++ b/src/deps/skia/include/effects/SkColorMatrixFilter.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2007 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkColorMatrixFilter_DEFINED
+#define SkColorMatrixFilter_DEFINED
+
+#include "include/core/SkColorFilter.h"
+#include "include/effects/SkColorMatrix.h"
+
+class SK_API SkColorMatrixFilter : public SkColorFilter {
+public:
+ /**
+ * Create a colorfilter that multiplies the RGB channels by one color, and
+ * then adds a second color, pinning the result for each component to
+ * [0..255]. The alpha components of the mul and add arguments
+ * are ignored.
+ */
+ static sk_sp<SkColorFilter> MakeLightingFilter(SkColor mul, SkColor add);
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkCornerPathEffect.h b/src/deps/skia/include/effects/SkCornerPathEffect.h
new file mode 100644
index 000000000..6017df46a
--- /dev/null
+++ b/src/deps/skia/include/effects/SkCornerPathEffect.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkCornerPathEffect_DEFINED
+#define SkCornerPathEffect_DEFINED
+
+#include "include/core/SkPathEffect.h"
+
+/** \class SkCornerPathEffect
+
+ SkCornerPathEffect is a subclass of SkPathEffect that can turn sharp corners
+ into various treatments (e.g. rounded corners)
+*/
+class SK_API SkCornerPathEffect {
+public:
+ /** radius must be > 0 to have an effect. It specifies the distance from each corner
+ that should be "rounded".
+ */
+ static sk_sp<SkPathEffect> Make(SkScalar radius);
+
+ static void RegisterFlattenables();
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkDashPathEffect.h b/src/deps/skia/include/effects/SkDashPathEffect.h
new file mode 100644
index 000000000..d6ca9122e
--- /dev/null
+++ b/src/deps/skia/include/effects/SkDashPathEffect.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkDashPathEffect_DEFINED
+#define SkDashPathEffect_DEFINED
+
+#include "include/core/SkPathEffect.h"
+
+class SK_API SkDashPathEffect {
+public:
+ /** intervals: array containing an even number of entries (>=2), with
+ the even indices specifying the length of "on" intervals, and the odd
+ indices specifying the length of "off" intervals. This array will be
+ copied in Make, and can be disposed of freely after.
+ count: number of elements in the intervals array
+ phase: offset into the intervals array (mod the sum of all of the
+ intervals).
+
+ For example: if intervals[] = {10, 20}, count = 2, and phase = 25,
+ this will set up a dashed path like so:
+ 5 pixels off
+ 10 pixels on
+ 20 pixels off
+ 10 pixels on
+ 20 pixels off
+ ...
+ A phase of -5, 25, 55, 85, etc. would all result in the same path,
+ because the sum of all the intervals is 30.
+
+ Note: only affects stroked paths.
+ */
+ static sk_sp<SkPathEffect> Make(const SkScalar intervals[], int count, SkScalar phase);
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkDiscretePathEffect.h b/src/deps/skia/include/effects/SkDiscretePathEffect.h
new file mode 100644
index 000000000..6054cbdc9
--- /dev/null
+++ b/src/deps/skia/include/effects/SkDiscretePathEffect.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkDiscretePathEffect_DEFINED
+#define SkDiscretePathEffect_DEFINED
+
+#include "include/core/SkPathEffect.h"
+
+/** \class SkDiscretePathEffect
+
+ This path effect chops a path into discrete segments, and randomly displaces them.
+*/
+class SK_API SkDiscretePathEffect {
+public:
+ /** Break the path into segments of segLength length, and randomly move the endpoints
+ away from the original path by a maximum of deviation.
+ Note: works on filled or framed paths
+
+ @param seedAssist This is a caller-supplied seedAssist that modifies
+ the seed value that is used to randomize the path
+ segments' endpoints. If not supplied it defaults to 0,
+ in which case filtering a path multiple times will
+ result in the same set of segments (this is useful for
+ testing). If a caller does not want this behaviour
+ they can pass in a different seedAssist to get a
+ different set of path segments.
+ */
+ static sk_sp<SkPathEffect> Make(SkScalar segLength, SkScalar dev, uint32_t seedAssist = 0);
+
+ static void RegisterFlattenables();
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkGradientShader.h b/src/deps/skia/include/effects/SkGradientShader.h
new file mode 100644
index 000000000..f8745c3b7
--- /dev/null
+++ b/src/deps/skia/include/effects/SkGradientShader.h
@@ -0,0 +1,264 @@
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkGradientShader_DEFINED
+#define SkGradientShader_DEFINED
+
+#include "include/core/SkShader.h"
+
+/** \class SkGradientShader
+
+ SkGradientShader hosts factories for creating subclasses of SkShader that
+ render linear and radial gradients. In general, degenerate cases should not
+ produce surprising results, but there are several types of degeneracies:
+
+ * A linear gradient made from the same two points.
+ * A radial gradient with a radius of zero.
+ * A sweep gradient where the start and end angle are the same.
+ * A two point conical gradient where the two centers and the two radii are
+ the same.
+
+ For any degenerate gradient with a decal tile mode, it will draw empty since the interpolating
+ region is zero area and the outer region is discarded by the decal mode.
+
+ For any degenerate gradient with a repeat or mirror tile mode, it will draw a solid color that
+ is the average gradient color, since infinitely many repetitions of the gradients will fill the
+ shape.
+
+ For a clamped gradient, every type is well-defined at the limit except for linear gradients. The
+ radial gradient with zero radius becomes the last color. The sweep gradient draws the sector
+ from 0 to the provided angle with the first color, with a hardstop switching to the last color.
+ When the provided angle is 0, this is just the solid last color again. Similarly, the two point
+ conical gradient becomes a circle filled with the first color, sized to the provided radius,
+ with a hardstop switching to the last color. When the two radii are both zero, this is just the
+ solid last color.
+
+ As a linear gradient approaches the degenerate case, its shader will approach the appearance of
+ two half planes, each filled by the first and last colors of the gradient. The planes will be
+ oriented perpendicular to the vector between the two defining points of the gradient. However,
+ once they become the same point, Skia cannot reconstruct what that expected orientation is. To
+ provide a stable and predictable color in this case, Skia just uses the last color as a solid
+ fill to be similar to many of the other degenerate gradients' behaviors in clamp mode.
+*/
+class SK_API SkGradientShader {
+public:
+ enum Flags {
+ /** By default gradients will interpolate their colors in unpremul space
+ * and then premultiply each of the results. By setting this flag, the
+ * gradients will premultiply their colors first, and then interpolate
+ * between them.
+ * example: https://fiddle.skia.org/c/@GradientShader_MakeLinear
+ */
+ kInterpolateColorsInPremul_Flag = 1 << 0,
+ };
+
+ /** Returns a shader that generates a linear gradient between the two specified points.
+ <p />
+ @param pts The start and end points for the gradient.
+ @param colors The array[count] of colors, to be distributed between the two points
+ @param pos May be NULL. array[count] of SkScalars, or NULL, of the relative position of
+ each corresponding color in the colors array. If this is NULL,
+ the the colors are distributed evenly between the start and end point.
+ If this is not null, the values must begin with 0, end with 1.0, and
+ intermediate values must be strictly increasing.
+ @param count Must be >=2. The number of colors (and pos if not NULL) entries.
+ @param mode The tiling mode
+
+ example: https://fiddle.skia.org/c/@GradientShader_MakeLinear
+ */
+ static sk_sp<SkShader> MakeLinear(const SkPoint pts[2],
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkTileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeLinear(const SkPoint pts[2],
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkTileMode mode) {
+ return MakeLinear(pts, colors, pos, count, mode, 0, nullptr);
+ }
+
+ /** Returns a shader that generates a linear gradient between the two specified points.
+ <p />
+ @param pts The start and end points for the gradient.
+ @param colors The array[count] of colors, to be distributed between the two points
+ @param pos May be NULL. array[count] of SkScalars, or NULL, of the relative position of
+ each corresponding color in the colors array. If this is NULL,
+ the the colors are distributed evenly between the start and end point.
+ If this is not null, the values must begin with 0, end with 1.0, and
+ intermediate values must be strictly increasing.
+ @param count Must be >=2. The number of colors (and pos if not NULL) entries.
+ @param mode The tiling mode
+
+ example: https://fiddle.skia.org/c/@GradientShader_MakeLinear
+ */
+ static sk_sp<SkShader> MakeLinear(const SkPoint pts[2],
+ const SkColor4f colors[], sk_sp<SkColorSpace> colorSpace,
+ const SkScalar pos[], int count, SkTileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeLinear(const SkPoint pts[2],
+ const SkColor4f colors[], sk_sp<SkColorSpace> colorSpace,
+ const SkScalar pos[], int count, SkTileMode mode) {
+ return MakeLinear(pts, colors, std::move(colorSpace), pos, count, mode, 0, nullptr);
+ }
+
+ /** Returns a shader that generates a radial gradient given the center and radius.
+ <p />
+ @param center The center of the circle for this gradient
+ @param radius Must be positive. The radius of the circle for this gradient
+ @param colors The array[count] of colors, to be distributed between the center and edge of the circle
+ @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
+ each corresponding color in the colors array. If this is NULL,
+ the the colors are distributed evenly between the center and edge of the circle.
+ If this is not null, the values must begin with 0, end with 1.0, and
+ intermediate values must be strictly increasing.
+ @param count Must be >= 2. The number of colors (and pos if not NULL) entries
+ @param mode The tiling mode
+ */
+ static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius,
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkTileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius,
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkTileMode mode) {
+ return MakeRadial(center, radius, colors, pos, count, mode, 0, nullptr);
+ }
+
+ /** Returns a shader that generates a radial gradient given the center and radius.
+ <p />
+ @param center The center of the circle for this gradient
+ @param radius Must be positive. The radius of the circle for this gradient
+ @param colors The array[count] of colors, to be distributed between the center and edge of the circle
+ @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
+ each corresponding color in the colors array. If this is NULL,
+ the the colors are distributed evenly between the center and edge of the circle.
+ If this is not null, the values must begin with 0, end with 1.0, and
+ intermediate values must be strictly increasing.
+ @param count Must be >= 2. The number of colors (and pos if not NULL) entries
+ @param mode The tiling mode
+ */
+ static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius,
+ const SkColor4f colors[], sk_sp<SkColorSpace> colorSpace,
+ const SkScalar pos[], int count, SkTileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius,
+ const SkColor4f colors[], sk_sp<SkColorSpace> colorSpace,
+ const SkScalar pos[], int count, SkTileMode mode) {
+ return MakeRadial(center, radius, colors, std::move(colorSpace), pos, count, mode,
+ 0, nullptr);
+ }
+
+ /**
+ * Returns a shader that generates a conical gradient given two circles, or
+ * returns NULL if the inputs are invalid. The gradient interprets the
+ * two circles according to the following HTML spec.
+ * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
+ */
+ static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor colors[], const SkScalar pos[],
+ int count, SkTileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor colors[], const SkScalar pos[],
+ int count, SkTileMode mode) {
+ return MakeTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
+ 0, nullptr);
+ }
+
+ /**
+ * Returns a shader that generates a conical gradient given two circles, or
+ * returns NULL if the inputs are invalid. The gradient interprets the
+ * two circles according to the following HTML spec.
+ * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
+ */
+ static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor4f colors[],
+ sk_sp<SkColorSpace> colorSpace, const SkScalar pos[],
+ int count, SkTileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor4f colors[],
+ sk_sp<SkColorSpace> colorSpace, const SkScalar pos[],
+ int count, SkTileMode mode) {
+ return MakeTwoPointConical(start, startRadius, end, endRadius, colors,
+ std::move(colorSpace), pos, count, mode, 0, nullptr);
+ }
+
+ /** Returns a shader that generates a sweep gradient given a center.
+ <p />
+ @param cx The X coordinate of the center of the sweep
+ @param cx The Y coordinate of the center of the sweep
+ @param colors The array[count] of colors, to be distributed around the center, within
+ the gradient angle range.
+ @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative
+ position of each corresponding color in the colors array. If this is
+ NULL, then the colors are distributed evenly within the angular range.
+ If this is not null, the values must begin with 0, end with 1.0, and
+ intermediate values must be strictly increasing.
+ @param count Must be >= 2. The number of colors (and pos if not NULL) entries
+ @param mode Tiling mode: controls drawing outside of the gradient angular range.
+ @param startAngle Start of the angular range, corresponding to pos == 0.
+ @param endAngle End of the angular range, corresponding to pos == 1.
+ */
+ static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkTileMode mode,
+ SkScalar startAngle, SkScalar endAngle,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
+ const SkColor colors[], const SkScalar pos[], int count,
+ uint32_t flags, const SkMatrix* localMatrix) {
+ return MakeSweep(cx, cy, colors, pos, count, SkTileMode::kClamp, 0, 360, flags,
+ localMatrix);
+ }
+ static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
+ const SkColor colors[], const SkScalar pos[], int count) {
+ return MakeSweep(cx, cy, colors, pos, count, 0, nullptr);
+ }
+
+ /** Returns a shader that generates a sweep gradient given a center.
+ <p />
+ @param cx The X coordinate of the center of the sweep
+ @param cx The Y coordinate of the center of the sweep
+ @param colors The array[count] of colors, to be distributed around the center, within
+ the gradient angle range.
+ @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative
+ position of each corresponding color in the colors array. If this is
+ NULL, then the colors are distributed evenly within the angular range.
+ If this is not null, the values must begin with 0, end with 1.0, and
+ intermediate values must be strictly increasing.
+ @param count Must be >= 2. The number of colors (and pos if not NULL) entries
+ @param mode Tiling mode: controls drawing outside of the gradient angular range.
+ @param startAngle Start of the angular range, corresponding to pos == 0.
+ @param endAngle End of the angular range, corresponding to pos == 1.
+ */
+ static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
+ const SkColor4f colors[], sk_sp<SkColorSpace> colorSpace,
+ const SkScalar pos[], int count,
+ SkTileMode mode,
+ SkScalar startAngle, SkScalar endAngle,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
+ const SkColor4f colors[], sk_sp<SkColorSpace> colorSpace,
+ const SkScalar pos[], int count,
+ uint32_t flags, const SkMatrix* localMatrix) {
+ return MakeSweep(cx, cy, colors, std::move(colorSpace), pos, count,
+ SkTileMode::kClamp, 0, 360, flags, localMatrix);
+ }
+ static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
+ const SkColor4f colors[], sk_sp<SkColorSpace> colorSpace,
+ const SkScalar pos[], int count) {
+ return MakeSweep(cx, cy, colors, std::move(colorSpace), pos, count, 0, nullptr);
+ }
+
+ static void RegisterFlattenables();
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkHighContrastFilter.h b/src/deps/skia/include/effects/SkHighContrastFilter.h
new file mode 100644
index 000000000..90acec1cd
--- /dev/null
+++ b/src/deps/skia/include/effects/SkHighContrastFilter.h
@@ -0,0 +1,80 @@
+/*
+* Copyright 2017 Google Inc.
+*
+* Use of this source code is governed by a BSD-style license that can be
+* found in the LICENSE file.
+*/
+
+#ifndef SkHighContrastFilter_DEFINED
+#define SkHighContrastFilter_DEFINED
+
+#include "include/core/SkColorFilter.h"
+
+/**
+ * Configuration struct for SkHighContrastFilter.
+ *
+ * Provides transformations to improve contrast for users with low vision.
+ */
+struct SkHighContrastConfig {
+ enum class InvertStyle {
+ kNoInvert,
+ kInvertBrightness,
+ kInvertLightness,
+
+ kLast = kInvertLightness
+ };
+
+ SkHighContrastConfig() {
+ fGrayscale = false;
+ fInvertStyle = InvertStyle::kNoInvert;
+ fContrast = 0.0f;
+ }
+
+ SkHighContrastConfig(bool grayscale,
+ InvertStyle invertStyle,
+ SkScalar contrast)
+ : fGrayscale(grayscale),
+ fInvertStyle(invertStyle),
+ fContrast(contrast) {}
+
+ // Returns true if all of the fields are set within the valid range.
+ bool isValid() const {
+ return fInvertStyle >= InvertStyle::kNoInvert &&
+ fInvertStyle <= InvertStyle::kInvertLightness &&
+ fContrast >= -1.0 &&
+ fContrast <= 1.0;
+ }
+
+ // If true, the color will be converted to grayscale.
+ bool fGrayscale;
+
+ // Whether to invert brightness, lightness, or neither.
+ InvertStyle fInvertStyle;
+
+ // After grayscale and inverting, the contrast can be adjusted linearly.
+ // The valid range is -1.0 through 1.0, where 0.0 is no adjustment.
+ SkScalar fContrast;
+};
+
+/**
+ * Color filter that provides transformations to improve contrast
+ * for users with low vision.
+ *
+ * Applies the following transformations in this order. Each of these
+ * can be configured using SkHighContrastConfig.
+ *
+ * - Conversion to grayscale
+ * - Color inversion (either in RGB or HSL space)
+ * - Increasing the resulting contrast.
+ *
+ * Calling SkHighContrastFilter::Make will return nullptr if the config is
+ * not valid, e.g. if you try to call it with a contrast outside the range of
+ * -1.0 to 1.0.
+ */
+
+struct SK_API SkHighContrastFilter {
+ // Returns the filter, or nullptr if the config is invalid.
+ static sk_sp<SkColorFilter> Make(const SkHighContrastConfig& config);
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkImageFilters.h b/src/deps/skia/include/effects/SkImageFilters.h
new file mode 100644
index 000000000..144bfb8a6
--- /dev/null
+++ b/src/deps/skia/include/effects/SkImageFilters.h
@@ -0,0 +1,551 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkImageFilters_DEFINED
+#define SkImageFilters_DEFINED
+
+#include "include/core/SkBlendMode.h"
+#include "include/core/SkColor.h"
+#include "include/core/SkImage.h"
+#include "include/core/SkImageFilter.h"
+#include "include/core/SkPicture.h"
+#include "include/core/SkRect.h"
+#include "include/core/SkTileMode.h"
+#include "include/core/SkTypes.h"
+#include "include/effects/SkRuntimeEffect.h"
+
+#include <cstddef>
+
+class SkBlender;
+class SkColorFilter;
+class SkPaint;
+class SkRegion;
+
+namespace skif {
+ static constexpr SkRect kNoCropRect = {SK_ScalarNegativeInfinity, SK_ScalarNegativeInfinity,
+ SK_ScalarInfinity, SK_ScalarInfinity};
+}
+
+// A set of factory functions providing useful SkImageFilter effects. For image filters that take an
+// input filter, providing nullptr means it will automatically use the dynamic source image. This
+// source depends on how the filter is applied, but is either the contents of a saved layer when
+// drawing with SkCanvas, or an explicit SkImage if using SkImage::makeWithFilter.
+class SK_API SkImageFilters {
+public:
+ // This is just a convenience type to allow passing SkIRects, SkRects, and optional pointers
+ // to those types as a crop rect for the image filter factories. It's not intended to be used
+ // directly.
+ struct CropRect {
+ CropRect() : fCropRect(skif::kNoCropRect) {}
+ // Intentionally not explicit so callers don't have to use this type but can use SkIRect or
+ // SkRect as desired.
+ CropRect(std::nullptr_t) : fCropRect(skif::kNoCropRect) {}
+ CropRect(const SkIRect& crop) : fCropRect(SkRect::Make(crop)) {}
+ CropRect(const SkRect& crop) : fCropRect(crop) {}
+ CropRect(const SkIRect* optionalCrop) : fCropRect(optionalCrop ? SkRect::Make(*optionalCrop)
+ : skif::kNoCropRect) {}
+ CropRect(const SkRect* optionalCrop) : fCropRect(optionalCrop ? *optionalCrop
+ : skif::kNoCropRect) {}
+
+ operator const SkRect*() const { return fCropRect == skif::kNoCropRect ? nullptr : &fCropRect; }
+
+ SkRect fCropRect;
+ };
+
+ /**
+ * Create a filter that updates the alpha of the image based on 'region'. Pixels inside the
+ * region are made more opaque and pixels outside are made more transparent.
+ *
+ * Specifically, if a pixel is inside the region, its alpha will be set to
+ * max(innerMin, pixel's alpha). If a pixel is outside the region, its alpha will be updated to
+ * min(outerMax, pixel's alpha).
+ * @param region The geometric region controlling the inner and outer alpha thresholds.
+ * @param innerMin The minimum alpha value for pixels inside 'region'.
+ * @param outerMax The maximum alpha value for pixels outside of 'region'.
+ * @param input The input filter, or uses the source bitmap if this is null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> AlphaThreshold(const SkRegion& region, SkScalar innerMin,
+ SkScalar outerMax, sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+
+ /**
+ * Create a filter that implements a custom blend mode. Each output pixel is the result of
+ * combining the corresponding background and foreground pixels using the 4 coefficients:
+ * k1 * foreground * background + k2 * foreground + k3 * background + k4
+ * @param k1, k2, k3, k4 The four coefficients used to combine the foreground and background.
+ * @param enforcePMColor If true, the RGB channels will be clamped to the calculated alpha.
+ * @param background The background content, using the source bitmap when this is null.
+ * @param foreground The foreground content, using the source bitmap when this is null.
+ * @param cropRect Optional rectangle that crops the inputs and output.
+ */
+ static sk_sp<SkImageFilter> Arithmetic(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
+ bool enforcePMColor, sk_sp<SkImageFilter> background,
+ sk_sp<SkImageFilter> foreground,
+ const CropRect& cropRect = {});
+
+ /**
+ * This filter takes an SkBlendMode and uses it to composite the two filters together.
+ * @param mode The blend mode that defines the compositing operation
+ * @param background The Dst pixels used in blending, if null the source bitmap is used.
+ * @param foreground The Src pixels used in blending, if null the source bitmap is used.
+ * @cropRect Optional rectangle to crop input and output.
+ */
+ static sk_sp<SkImageFilter> Blend(SkBlendMode mode, sk_sp<SkImageFilter> background,
+ sk_sp<SkImageFilter> foreground = nullptr,
+ const CropRect& cropRect = {});
+
+ /**
+ * This filter takes an SkBlendMode and uses it to composite the two filters together.
+ * @param blender The blender that defines the compositing operation
+ * @param background The Dst pixels used in blending, if null the source bitmap is used.
+ * @param foreground The Src pixels used in blending, if null the source bitmap is used.
+ * @cropRect Optional rectangle to crop input and output.
+ */
+ static sk_sp<SkImageFilter> Blend(sk_sp<SkBlender> blender, sk_sp<SkImageFilter> background,
+ sk_sp<SkImageFilter> foreground = nullptr,
+ const CropRect& cropRect = {});
+
+ /**
+ * Create a filter that blurs its input by the separate X and Y sigmas. The provided tile mode
+ * is used when the blur kernel goes outside the input image.
+ * @param sigmaX The Gaussian sigma value for blurring along the X axis.
+ * @param sigmaY The Gaussian sigma value for blurring along the Y axis.
+ * @param tileMode The tile mode applied at edges .
+ * TODO (michaelludwig) - kMirror is not supported yet
+ * @param input The input filter that is blurred, uses source bitmap if this is null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode,
+ sk_sp<SkImageFilter> input, const CropRect& cropRect = {});
+ // As above, but defaults to the decal tile mode.
+ static sk_sp<SkImageFilter> Blur(SkScalar sigmaX, SkScalar sigmaY, sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {}) {
+ return Blur(sigmaX, sigmaY, SkTileMode::kDecal, std::move(input), cropRect);
+ }
+
+ /**
+ * Create a filter that applies the color filter to the input filter results.
+ * @param cf The color filter that transforms the input image.
+ * @param input The input filter, or uses the source bitmap if this is null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> ColorFilter(sk_sp<SkColorFilter> cf, sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+
+ /**
+ * Create a filter that composes 'inner' with 'outer', such that the results of 'inner' are
+ * treated as the source bitmap passed to 'outer', i.e. result = outer(inner(source)).
+ * @param outer The outer filter that evaluates the results of inner.
+ * @param inner The inner filter that produces the input to outer.
+ */
+ static sk_sp<SkImageFilter> Compose(sk_sp<SkImageFilter> outer, sk_sp<SkImageFilter> inner);
+
+ /**
+ * Create a filter that moves each pixel in its color input based on an (x,y) vector encoded
+ * in its displacement input filter. Two color components of the displacement image are
+ * mapped into a vector as scale * (color[xChannel], color[yChannel]), where the channel
+ * selectors are one of R, G, B, or A.
+ * @param xChannelSelector RGBA channel that encodes the x displacement per pixel.
+ * @param yChannelSelector RGBA channel that encodes the y displacement per pixel.
+ * @param scale Scale applied to displacement extracted from image.
+ * @param displacement The filter defining the displacement image, or null to use source.
+ * @param color The filter providing the color pixels to be displaced.
+ * @param cropRect Optional rectangle that crops the color input and output.
+ */
+ static sk_sp<SkImageFilter> DisplacementMap(SkColorChannel xChannelSelector,
+ SkColorChannel yChannelSelector,
+ SkScalar scale, sk_sp<SkImageFilter> displacement,
+ sk_sp<SkImageFilter> color,
+ const CropRect& cropRect = {});
+
+ /**
+ * Create a filter that draws a drop shadow under the input content. This filter produces an
+ * image that includes the inputs' content.
+ * @param dx The X offset of the shadow.
+ * @param dy The Y offset of the shadow.
+ * @param sigmaX The blur radius for the shadow, along the X axis.
+ * @param sigmaY The blur radius for the shadow, along the Y axis.
+ * @param color The color of the drop shadow.
+ * @param input The input filter, or will use the source bitmap if this is null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> DropShadow(SkScalar dx, SkScalar dy,
+ SkScalar sigmaX, SkScalar sigmaY,
+ SkColor color, sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+ /**
+ * Create a filter that renders a drop shadow, in exactly the same manner as ::DropShadow,
+ * except that the resulting image does not include the input content. This allows the shadow
+ * and input to be composed by a filter DAG in a more flexible manner.
+ * @param dx The X offset of the shadow.
+ * @param dy The Y offset of the shadow.
+ * @param sigmaX The blur radius for the shadow, along the X axis.
+ * @param sigmaY The blur radius for the shadow, along the Y axis.
+ * @param color The color of the drop shadow.
+ * @param input The input filter, or will use the source bitmap if this is null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> DropShadowOnly(SkScalar dx, SkScalar dy,
+ SkScalar sigmaX, SkScalar sigmaY,
+ SkColor color, sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+
+ /**
+ * Create a filter that draws the 'srcRect' portion of image into 'dstRect' using the given
+ * filter quality. Similar to SkCanvas::drawImageRect. Returns null if 'image' is null.
+ * @param image The image that is output by the filter, subset by 'srcRect'.
+ * @param srcRect The source pixels sampled into 'dstRect'
+ * @param dstRect The local rectangle to draw the image into.
+ * @param sampling The sampling to use when drawing the image.
+ */
+ static sk_sp<SkImageFilter> Image(sk_sp<SkImage> image, const SkRect& srcRect,
+ const SkRect& dstRect, const SkSamplingOptions& sampling);
+
+ /**
+ * Create a filter that draws the image using the given sampling.
+ * Similar to SkCanvas::drawImage. Returns null if 'image' is null.
+ * @param image The image that is output by the filter.
+ * @param sampling The sampling to use when drawing the image.
+ */
+ static sk_sp<SkImageFilter> Image(sk_sp<SkImage> image, const SkSamplingOptions& sampling) {
+ if (image) {
+ SkRect r = SkRect::Make(image->bounds());
+ return Image(std::move(image), r, r, sampling);
+ } else {
+ return nullptr;
+ }
+ }
+
+ /**
+ * Create a filter that draws the image using Mitchel cubic resampling.
+ * @param image The image that is output by the filter.
+ */
+ static sk_sp<SkImageFilter> Image(sk_sp<SkImage> image) {
+ return Image(std::move(image), SkSamplingOptions({1/3.0f, 1/3.0f}));
+ }
+
+ /**
+ * Create a filter that mimics a zoom/magnifying lens effect.
+ * @param srcRect
+ * @param inset
+ * @param input The input filter that is magnified, if null the source bitmap is used.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> Magnifier(const SkRect& srcRect, SkScalar inset,
+ sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+
+ /**
+ * Create a filter that applies an NxM image processing kernel to the input image. This can be
+ * used to produce effects such as sharpening, blurring, edge detection, etc.
+ * @param kernelSize The kernel size in pixels, in each dimension (N by M).
+ * @param kernel The image processing kernel. Must contain N * M elements, in row order.
+ * @param gain A scale factor applied to each pixel after convolution. This can be
+ * used to normalize the kernel, if it does not already sum to 1.
+ * @param bias A bias factor added to each pixel after convolution.
+ * @param kernelOffset An offset applied to each pixel coordinate before convolution.
+ * This can be used to center the kernel over the image
+ * (e.g., a 3x3 kernel should have an offset of {1, 1}).
+ * @param tileMode How accesses outside the image are treated.
+ * TODO (michaelludwig) - kMirror is not supported yet
+ * @param convolveAlpha If true, all channels are convolved. If false, only the RGB channels
+ * are convolved, and alpha is copied from the source image.
+ * @param input The input image filter, if null the source bitmap is used instead.
+ * @param cropRect Optional rectangle to which the output processing will be limited.
+ */
+ static sk_sp<SkImageFilter> MatrixConvolution(const SkISize& kernelSize,
+ const SkScalar kernel[], SkScalar gain,
+ SkScalar bias, const SkIPoint& kernelOffset,
+ SkTileMode tileMode, bool convolveAlpha,
+ sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+
+ /**
+ * Create a filter that transforms the input image by 'matrix'. This matrix transforms the
+ * local space, which means it effectively happens prior to any transformation coming from the
+ * SkCanvas initiating the filtering.
+ * @param matrix The matrix to apply to the original content.
+ * @param sampling How the image will be sampled when it is transformed
+ * @param input The image filter to transform, or null to use the source image.
+ */
+ static sk_sp<SkImageFilter> MatrixTransform(const SkMatrix& matrix,
+ const SkSamplingOptions& sampling,
+ sk_sp<SkImageFilter> input);
+
+ /**
+ * Create a filter that merges the 'count' filters together by drawing their results in order
+ * with src-over blending.
+ * @param filters The input filter array to merge, which must have 'count' elements. Any null
+ * filter pointers will use the source bitmap instead.
+ * @param count The number of input filters to be merged.
+ * @param cropRect Optional rectangle that crops all input filters and the output.
+ */
+ static sk_sp<SkImageFilter> Merge(sk_sp<SkImageFilter>* const filters, int count,
+ const CropRect& cropRect = {});
+ /**
+ * Create a filter that merges the results of the two filters together with src-over blending.
+ * @param first The first input filter, or the source bitmap if this is null.
+ * @param second The second input filter, or the source bitmap if this null.
+ * @param cropRect Optional rectangle that crops the inputs and output.
+ */
+ static sk_sp<SkImageFilter> Merge(sk_sp<SkImageFilter> first, sk_sp<SkImageFilter> second,
+ const CropRect& cropRect = {}) {
+ sk_sp<SkImageFilter> array[] = { std::move(first), std::move(second) };
+ return Merge(array, 2, cropRect);
+ }
+
+ /**
+ * Create a filter that offsets the input filter by the given vector.
+ * @param dx The x offset in local space that the image is shifted.
+ * @param dy The y offset in local space that the image is shifted.
+ * @param input The input that will be moved, if null the source bitmap is used instead.
+ * @param cropRect Optional rectangle to crop the input and output.
+ */
+ static sk_sp<SkImageFilter> Offset(SkScalar dx, SkScalar dy, sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+
+ /**
+ * Create a filter that fills the output with the given paint.
+ * @param paint The paint to fill
+ * @param cropRect Optional rectangle that will be filled. If null, the source bitmap's bounds
+ * are filled even though the source bitmap itself is not used.
+ *
+ * DEPRECATED: Use Shader() instead, since many features of SkPaint are ignored when filling
+ * the target output, and paint color/alpha can be emulated with SkShaders::Color().
+ */
+ static sk_sp<SkImageFilter> Paint(const SkPaint& paint, const CropRect& cropRect = {});
+
+ /**
+ * Create a filter that produces the SkPicture as its output, drawn into targetRect. Note that
+ * the targetRect is not the same as the SkIRect cropRect that many filters accept. Returns
+ * null if 'pic' is null.
+ * @param pic The picture that is drawn for the filter output.
+ * @param targetRect The drawing region for the picture.
+ */
+ static sk_sp<SkImageFilter> Picture(sk_sp<SkPicture> pic, const SkRect& targetRect);
+ // As above, but uses SkPicture::cullRect for the drawing region.
+ static sk_sp<SkImageFilter> Picture(sk_sp<SkPicture> pic) {
+ SkRect target = pic ? pic->cullRect() : SkRect::MakeEmpty();
+ return Picture(std::move(pic), target);
+ }
+
+#ifdef SK_ENABLE_SKSL
+ /**
+ * Create a filter that fills the output with the per-pixel evaluation of the SkShader produced
+ * by the SkRuntimeShaderBuilder. The shader is defined in the image filter's local coordinate
+ * system, so it will automatically be affected by SkCanvas' transform.
+ *
+ * @param builder The builder used to produce the runtime shader, that will in turn
+ * fill the result image
+ * @param childShaderName The name of the child shader defined in the builder that will be
+ * bound to the input param (or the source image if the input param
+ * is null). If null the builder can have exactly one child shader,
+ * which automatically binds the input param.
+ * @param input The image filter that will be provided as input to the runtime
+ * shader. If null the implicit source image is used instead
+ */
+ static sk_sp<SkImageFilter> RuntimeShader(const SkRuntimeShaderBuilder& builder,
+ const char* childShaderName,
+ sk_sp<SkImageFilter> input);
+
+ /**
+ * Create a filter that fills the output with the per-pixel evaluation of the SkShader produced
+ * by the SkRuntimeShaderBuilder. The shader is defined in the image filter's local coordinate
+ * system, so it will automatically be affected by SkCanvas' transform.
+ *
+ * @param builder The builder used to produce the runtime shader, that will in turn
+ * fill the result image
+ * @param childShaderNames The names of the child shaders defined in the builder that will be
+ * bound to the input params (or the source image if the input param
+ * is null). If any name is null, or appears more than once, factory
+ * fails and returns nullptr.
+ * @param inputs The image filters that will be provided as input to the runtime
+ * shader. If any are null, the implicit source image is used instead.
+ * @param inputCount How many entries are present in 'childShaderNames' and 'inputs'.
+ */
+ static sk_sp<SkImageFilter> RuntimeShader(const SkRuntimeShaderBuilder& builder,
+ const char* childShaderNames[],
+ const sk_sp<SkImageFilter> inputs[],
+ int inputCount);
+#endif // SK_ENABLE_SKSL
+
+ enum class Dither : bool {
+ kNo = false,
+ kYes = true
+ };
+
+ /**
+ * Create a filter that fills the output with the per-pixel evaluation of the SkShader. The
+ * shader is defined in the image filter's local coordinate system, so will automatically
+ * be affected by SkCanvas' transform.
+ *
+ * Like Image() and Picture(), this is a leaf filter that can be used to introduce inputs to
+ * a complex filter graph, but should generally be combined with a filter that as at least
+ * one null input to use the implicit source image.
+ * @param shader The shader that fills the result image
+ */
+ static sk_sp<SkImageFilter> Shader(sk_sp<SkShader> shader, const CropRect& cropRect = {}) {
+ return Shader(std::move(shader), Dither::kNo, cropRect);
+ }
+ static sk_sp<SkImageFilter> Shader(sk_sp<SkShader> shader, Dither dither,
+ const CropRect& cropRect = {});
+
+ /**
+ * Create a tile image filter.
+ * @param src Defines the pixels to tile
+ * @param dst Defines the pixel region that the tiles will be drawn to
+ * @param input The input that will be tiled, if null the source bitmap is used instead.
+ */
+ static sk_sp<SkImageFilter> Tile(const SkRect& src, const SkRect& dst,
+ sk_sp<SkImageFilter> input);
+
+ // Morphology filter effects
+
+ /**
+ * Create a filter that dilates each input pixel's channel values to the max value within the
+ * given radii along the x and y axes.
+ * @param radiusX The distance to dilate along the x axis to either side of each pixel.
+ * @param radiusY The distance to dilate along the y axis to either side of each pixel.
+ * @param input The image filter that is dilated, using source bitmap if this is null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> Dilate(SkScalar radiusX, SkScalar radiusY,
+ sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+
+ /**
+ * Create a filter that erodes each input pixel's channel values to the minimum channel value
+ * within the given radii along the x and y axes.
+ * @param radiusX The distance to erode along the x axis to either side of each pixel.
+ * @param radiusY The distance to erode along the y axis to either side of each pixel.
+ * @param input The image filter that is eroded, using source bitmap if this is null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> Erode(SkScalar radiusX, SkScalar radiusY,
+ sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+
+ // Lighting filter effects
+
+ /**
+ * Create a filter that calculates the diffuse illumination from a distant light source,
+ * interpreting the alpha channel of the input as the height profile of the surface (to
+ * approximate normal vectors).
+ * @param direction The direction to the distance light.
+ * @param lightColor The color of the diffuse light source.
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
+ * @param kd Diffuse reflectance coefficient.
+ * @param input The input filter that defines surface normals (as alpha), or uses the
+ * source bitmap when null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> DistantLitDiffuse(const SkPoint3& direction, SkColor lightColor,
+ SkScalar surfaceScale, SkScalar kd,
+ sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+ /**
+ * Create a filter that calculates the diffuse illumination from a point light source, using
+ * alpha channel of the input as the height profile of the surface (to approximate normal
+ * vectors).
+ * @param location The location of the point light.
+ * @param lightColor The color of the diffuse light source.
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
+ * @param kd Diffuse reflectance coefficient.
+ * @param input The input filter that defines surface normals (as alpha), or uses the
+ * source bitmap when null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> PointLitDiffuse(const SkPoint3& location, SkColor lightColor,
+ SkScalar surfaceScale, SkScalar kd,
+ sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+ /**
+ * Create a filter that calculates the diffuse illumination from a spot light source, using
+ * alpha channel of the input as the height profile of the surface (to approximate normal
+ * vectors). The spot light is restricted to be within 'cutoffAngle' of the vector between
+ * the location and target.
+ * @param location The location of the spot light.
+ * @param target The location that the spot light is point towards
+ * @param falloffExponent Exponential falloff parameter for illumination outside of cutoffAngle
+ * @param cutoffAngle Maximum angle from lighting direction that receives full light
+ * @param lightColor The color of the diffuse light source.
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
+ * @param kd Diffuse reflectance coefficient.
+ * @param input The input filter that defines surface normals (as alpha), or uses the
+ * source bitmap when null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> SpotLitDiffuse(const SkPoint3& location, const SkPoint3& target,
+ SkScalar falloffExponent, SkScalar cutoffAngle,
+ SkColor lightColor, SkScalar surfaceScale,
+ SkScalar kd, sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+
+ /**
+ * Create a filter that calculates the specular illumination from a distant light source,
+ * interpreting the alpha channel of the input as the height profile of the surface (to
+ * approximate normal vectors).
+ * @param direction The direction to the distance light.
+ * @param lightColor The color of the specular light source.
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
+ * @param ks Specular reflectance coefficient.
+ * @param shininess The specular exponent determining how shiny the surface is.
+ * @param input The input filter that defines surface normals (as alpha), or uses the
+ * source bitmap when null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> DistantLitSpecular(const SkPoint3& direction, SkColor lightColor,
+ SkScalar surfaceScale, SkScalar ks,
+ SkScalar shininess, sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+ /**
+ * Create a filter that calculates the specular illumination from a point light source, using
+ * alpha channel of the input as the height profile of the surface (to approximate normal
+ * vectors).
+ * @param location The location of the point light.
+ * @param lightColor The color of the specular light source.
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
+ * @param ks Specular reflectance coefficient.
+ * @param shininess The specular exponent determining how shiny the surface is.
+ * @param input The input filter that defines surface normals (as alpha), or uses the
+ * source bitmap when null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> PointLitSpecular(const SkPoint3& location, SkColor lightColor,
+ SkScalar surfaceScale, SkScalar ks,
+ SkScalar shininess, sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+ /**
+ * Create a filter that calculates the specular illumination from a spot light source, using
+ * alpha channel of the input as the height profile of the surface (to approximate normal
+ * vectors). The spot light is restricted to be within 'cutoffAngle' of the vector between
+ * the location and target.
+ * @param location The location of the spot light.
+ * @param target The location that the spot light is point towards
+ * @param falloffExponent Exponential falloff parameter for illumination outside of cutoffAngle
+ * @param cutoffAngle Maximum angle from lighting direction that receives full light
+ * @param lightColor The color of the specular light source.
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
+ * @param ks Specular reflectance coefficient.
+ * @param shininess The specular exponent determining how shiny the surface is.
+ * @param input The input filter that defines surface normals (as alpha), or uses the
+ * source bitmap when null.
+ * @param cropRect Optional rectangle that crops the input and output.
+ */
+ static sk_sp<SkImageFilter> SpotLitSpecular(const SkPoint3& location, const SkPoint3& target,
+ SkScalar falloffExponent, SkScalar cutoffAngle,
+ SkColor lightColor, SkScalar surfaceScale,
+ SkScalar ks, SkScalar shininess,
+ sk_sp<SkImageFilter> input,
+ const CropRect& cropRect = {});
+
+private:
+ SkImageFilters() = delete;
+};
+
+#endif // SkImageFilters_DEFINED
diff --git a/src/deps/skia/include/effects/SkLayerDrawLooper.h b/src/deps/skia/include/effects/SkLayerDrawLooper.h
new file mode 100644
index 000000000..1e875b58c
--- /dev/null
+++ b/src/deps/skia/include/effects/SkLayerDrawLooper.h
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkLayerDrawLooper_DEFINED
+#define SkLayerDrawLooper_DEFINED
+
+#include "include/core/SkBlendMode.h"
+#include "include/core/SkDrawLooper.h"
+#include "include/core/SkPaint.h"
+#include "include/core/SkPoint.h"
+
+#ifndef SK_SUPPORT_LEGACY_DRAWLOOPER
+#error "SkDrawLooper is unsupported"
+#endif
+
+/**
+ * DEPRECATED: No longer supported by Skia.
+ */
+class SK_API SkLayerDrawLooper : public SkDrawLooper {
+public:
+ ~SkLayerDrawLooper() override;
+
+ /**
+ * Bits specifies which aspects of the layer's paint should replace the
+ * corresponding aspects on the draw's paint.
+ * kEntirePaint_Bits means use the layer's paint completely.
+ * 0 means ignore the layer's paint... except for fColorMode, which is
+ * always applied.
+ */
+ enum Bits {
+ kStyle_Bit = 1 << 0, //!< use this layer's Style/stroke settings
+ kPathEffect_Bit = 1 << 2, //!< use this layer's patheffect
+ kMaskFilter_Bit = 1 << 3, //!< use this layer's maskfilter
+ kShader_Bit = 1 << 4, //!< use this layer's shader
+ kColorFilter_Bit = 1 << 5, //!< use this layer's colorfilter
+ kXfermode_Bit = 1 << 6, //!< use this layer's xfermode
+
+ // unsupported kTextSkewX_Bit = 1 << 1,
+
+ /**
+ * Use the layer's paint entirely, with these exceptions:
+ * - We never override the draw's paint's text_encoding, since that is
+ * used to interpret the text/len parameters in draw[Pos]Text.
+ * - Color is always computed using the LayerInfo's fColorMode.
+ */
+ kEntirePaint_Bits = -1
+
+ };
+ typedef int32_t BitFlags;
+
+ /**
+ * Info for how to apply the layer's paint and offset.
+ *
+ * fColorMode controls how we compute the final color for the layer:
+ * The layer's paint's color is treated as the SRC
+ * The draw's paint's color is treated as the DST
+ * final-color = Mode(layers-color, draws-color);
+ * Any SkBlendMode will work. Two common choices are:
+ * kSrc: to use the layer's color, ignoring the draw's
+ * kDst: to just keep the draw's color, ignoring the layer's
+ */
+ struct SK_API LayerInfo {
+ BitFlags fPaintBits;
+ SkBlendMode fColorMode;
+ SkVector fOffset;
+ bool fPostTranslate; //!< applies to fOffset
+
+ /**
+ * Initial the LayerInfo. Defaults to settings that will draw the
+ * layer with no changes: e.g.
+ * fPaintBits == 0
+ * fColorMode == kDst_Mode
+ * fOffset == (0, 0)
+ */
+ LayerInfo();
+ };
+
+ SkDrawLooper::Context* makeContext(SkArenaAlloc*) const override;
+
+ bool asABlurShadow(BlurShadowRec* rec) const override;
+
+protected:
+ SkLayerDrawLooper();
+
+ void flatten(SkWriteBuffer&) const override;
+
+private:
+ SK_FLATTENABLE_HOOKS(SkLayerDrawLooper)
+
+ struct Rec {
+ Rec* fNext;
+ SkPaint fPaint;
+ LayerInfo fInfo;
+ };
+ Rec* fRecs;
+ int fCount;
+
+ // state-machine during the init/next cycle
+ class LayerDrawLooperContext : public SkDrawLooper::Context {
+ public:
+ explicit LayerDrawLooperContext(const SkLayerDrawLooper* looper);
+
+ protected:
+ bool next(Info*, SkPaint* paint) override;
+
+ private:
+ Rec* fCurrRec;
+
+ static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo&);
+ };
+
+ using INHERITED = SkDrawLooper;
+
+public:
+ class SK_API Builder {
+ public:
+ Builder();
+
+ ~Builder();
+
+ /**
+ * Call for each layer you want to add (from top to bottom).
+ * This returns a paint you can modify, but that ptr is only valid until
+ * the next call made to addLayer().
+ */
+ SkPaint* addLayer(const LayerInfo&);
+
+ /**
+ * This layer will draw with the original paint, at the specified offset
+ */
+ void addLayer(SkScalar dx, SkScalar dy);
+
+ /**
+ * This layer will with the original paint and no offset.
+ */
+ void addLayer() { this->addLayer(0, 0); }
+
+ /// Similar to addLayer, but adds a layer to the top.
+ SkPaint* addLayerOnTop(const LayerInfo&);
+
+ /**
+ * Pass list of layers on to newly built looper and return it. This will
+ * also reset the builder, so it can be used to build another looper.
+ */
+ sk_sp<SkDrawLooper> detach();
+
+ private:
+ Builder(const Builder&) = delete;
+ Builder& operator=(const Builder&) = delete;
+
+ Rec* fRecs;
+ Rec* fTopRec;
+ int fCount;
+ };
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkLumaColorFilter.h b/src/deps/skia/include/effects/SkLumaColorFilter.h
new file mode 100644
index 000000000..c230f524e
--- /dev/null
+++ b/src/deps/skia/include/effects/SkLumaColorFilter.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkLumaColorFilter_DEFINED
+#define SkLumaColorFilter_DEFINED
+
+#include "include/core/SkColorFilter.h"
+
+/**
+ * SkLumaColorFilter multiplies the luma of its input into the alpha channel,
+ * and sets the red, green, and blue channels to zero.
+ *
+ * SkLumaColorFilter(r,g,b,a) = {0,0,0, a * luma(r,g,b)}
+ *
+ * This is similar to a luminanceToAlpha feColorMatrix,
+ * but note how this filter folds in the previous alpha,
+ * something an feColorMatrix cannot do.
+ *
+ * feColorMatrix(luminanceToAlpha; r,g,b,a) = {0,0,0, luma(r,g,b)}
+ *
+ * (Despite its name, an feColorMatrix using luminanceToAlpha does
+ * actually compute luma, a dot-product of gamma-encoded color channels,
+ * not luminance, a dot-product of linear color channels. So at least
+ * SkLumaColorFilter and feColorMatrix+luminanceToAlpha agree there.)
+ */
+struct SK_API SkLumaColorFilter {
+ static sk_sp<SkColorFilter> Make();
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkOpPathEffect.h b/src/deps/skia/include/effects/SkOpPathEffect.h
new file mode 100644
index 000000000..268789ed4
--- /dev/null
+++ b/src/deps/skia/include/effects/SkOpPathEffect.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkOpPathEffect_DEFINED
+#define SkOpPathEffect_DEFINED
+
+#include "include/core/SkMatrix.h"
+#include "include/core/SkPaint.h"
+#include "include/core/SkPathEffect.h"
+#include "include/pathops/SkPathOps.h"
+
+class SK_API SkMergePathEffect {
+public:
+ /* Defers to two other patheffects, and then combines their outputs using the specified op.
+ * e.g.
+ * result = output_one op output_two
+ *
+ * If either one or two is nullptr, then the original path is passed through to the op.
+ */
+ static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> one, sk_sp<SkPathEffect> two, SkPathOp op);
+};
+
+class SK_API SkMatrixPathEffect {
+public:
+ static sk_sp<SkPathEffect> MakeTranslate(SkScalar dx, SkScalar dy);
+ static sk_sp<SkPathEffect> Make(const SkMatrix&);
+};
+
+class SK_API SkStrokePathEffect {
+public:
+ static sk_sp<SkPathEffect> Make(SkScalar width, SkPaint::Join, SkPaint::Cap,
+ SkScalar miter = 4);
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkOverdrawColorFilter.h b/src/deps/skia/include/effects/SkOverdrawColorFilter.h
new file mode 100644
index 000000000..0d6fc9282
--- /dev/null
+++ b/src/deps/skia/include/effects/SkOverdrawColorFilter.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "include/core/SkColorFilter.h"
+#include "include/core/SkFlattenable.h"
+
+#ifndef SkOverdrawColorFilter_DEFINED
+#define SkOverdrawColorFilter_DEFINED
+
+/**
+ * Uses the value in the src alpha channel to set the dst pixel.
+ * 0 -> colors[0]
+ * 1 -> colors[1]
+ * ...
+ * 5 (or larger) -> colors[5]
+ *
+ */
+class SK_API SkOverdrawColorFilter {
+public:
+ static constexpr int kNumColors = 6;
+
+ static sk_sp<SkColorFilter> MakeWithSkColors(const SkColor[kNumColors]);
+};
+
+#endif // SkOverdrawColorFilter_DEFINED
diff --git a/src/deps/skia/include/effects/SkPerlinNoiseShader.h b/src/deps/skia/include/effects/SkPerlinNoiseShader.h
new file mode 100644
index 000000000..f94b3420f
--- /dev/null
+++ b/src/deps/skia/include/effects/SkPerlinNoiseShader.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkPerlinNoiseShader_DEFINED
+#define SkPerlinNoiseShader_DEFINED
+
+#include "include/core/SkShader.h"
+
+/** \class SkPerlinNoiseShader
+
+ SkPerlinNoiseShader creates an image using the Perlin turbulence function.
+
+ It can produce tileable noise if asked to stitch tiles and provided a tile size.
+ In order to fill a large area with repeating noise, set the stitchTiles flag to
+ true, and render exactly a single tile of noise. Without this flag, the result
+ will contain visible seams between tiles.
+
+ The algorithm used is described here :
+ http://www.w3.org/TR/SVG/filters.html#feTurbulenceElement
+*/
+class SK_API SkPerlinNoiseShader {
+public:
+ /**
+ * This will construct Perlin noise of the given type (Fractal Noise or Turbulence).
+ *
+ * Both base frequencies (X and Y) have a usual range of (0..1) and must be non-negative.
+ *
+ * The number of octaves provided should be fairly small, with a limit of 255 enforced.
+ * Each octave doubles the frequency, so 10 octaves would produce noise from
+ * baseFrequency * 1, * 2, * 4, ..., * 512, which quickly yields insignificantly small
+ * periods and resembles regular unstructured noise rather than Perlin noise.
+ *
+ * If tileSize isn't NULL or an empty size, the tileSize parameter will be used to modify
+ * the frequencies so that the noise will be tileable for the given tile size. If tileSize
+ * is NULL or an empty size, the frequencies will be used as is without modification.
+ */
+ static sk_sp<SkShader> MakeFractalNoise(SkScalar baseFrequencyX, SkScalar baseFrequencyY,
+ int numOctaves, SkScalar seed,
+ const SkISize* tileSize = nullptr);
+ static sk_sp<SkShader> MakeTurbulence(SkScalar baseFrequencyX, SkScalar baseFrequencyY,
+ int numOctaves, SkScalar seed,
+ const SkISize* tileSize = nullptr);
+
+ static void RegisterFlattenables();
+
+private:
+ SkPerlinNoiseShader() = delete;
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkRuntimeEffect.h b/src/deps/skia/include/effects/SkRuntimeEffect.h
new file mode 100644
index 000000000..d5002592a
--- /dev/null
+++ b/src/deps/skia/include/effects/SkRuntimeEffect.h
@@ -0,0 +1,518 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkRuntimeEffect_DEFINED
+#define SkRuntimeEffect_DEFINED
+
+#include "include/core/SkBlender.h"
+#include "include/core/SkColorFilter.h"
+#include "include/core/SkData.h"
+#include "include/core/SkImageInfo.h"
+#include "include/core/SkMatrix.h"
+#include "include/core/SkShader.h"
+#include "include/core/SkSpan.h"
+#include "include/core/SkString.h"
+#include "include/private/SkOnce.h"
+#include "include/private/SkSLSampleUsage.h"
+#include "include/private/SkTOptional.h"
+
+#include <string>
+#include <vector>
+
+#ifdef SK_ENABLE_SKSL
+
+class GrRecordingContext;
+class SkFilterColorProgram;
+class SkImage;
+class SkRuntimeImageFilter;
+
+namespace SkSL {
+class DebugTrace;
+class ErrorReporter;
+class FunctionDefinition;
+struct Program;
+enum class ProgramKind : int8_t;
+struct ProgramSettings;
+} // namespace SkSL
+
+namespace skvm {
+class Program;
+} // namespace skvm
+
+/*
+ * SkRuntimeEffect supports creating custom SkShader and SkColorFilter objects using Skia's SkSL
+ * shading language.
+ *
+ * NOTE: This API is experimental and subject to change.
+ */
+class SK_API SkRuntimeEffect : public SkRefCnt {
+public:
+ // Reflected description of a uniform variable in the effect's SkSL
+ struct Uniform {
+ enum class Type {
+ kFloat,
+ kFloat2,
+ kFloat3,
+ kFloat4,
+ kFloat2x2,
+ kFloat3x3,
+ kFloat4x4,
+ kInt,
+ kInt2,
+ kInt3,
+ kInt4,
+ };
+
+ enum Flags {
+ // Uniform is an declared as an array. 'count' contains array length.
+ kArray_Flag = 0x1,
+
+ // Uniform is declared with layout(color). Colors should be supplied as unpremultiplied,
+ // extended-range (unclamped) sRGB (ie SkColor4f). The uniform will be automatically
+ // transformed to unpremultiplied extended-range working-space colors.
+ kColor_Flag = 0x2,
+ };
+
+ SkString name;
+ size_t offset;
+ Type type;
+ int count;
+ uint32_t flags;
+
+ bool isArray() const { return SkToBool(this->flags & kArray_Flag); }
+ bool isColor() const { return SkToBool(this->flags & kColor_Flag); }
+ size_t sizeInBytes() const;
+ };
+
+ // Reflected description of a uniform child (shader or colorFilter) in the effect's SkSL
+ enum class ChildType {
+ kShader,
+ kColorFilter,
+ kBlender,
+ };
+
+ struct Child {
+ SkString name;
+ ChildType type;
+ int index;
+ };
+
+ class Options {
+ public:
+ // For testing purposes, completely disable the inliner. (Normally, Runtime Effects don't
+ // run the inliner directly, but they still get an inlining pass once they are painted.)
+ bool forceNoInline = false;
+
+ private:
+ friend class SkRuntimeEffect;
+ friend class SkRuntimeEffectPriv;
+
+ // This flag lifts the ES2 restrictions on Runtime Effects that are gated by the
+ // `strictES2Mode` check. Be aware that the software renderer and pipeline-stage effect are
+ // still largely ES3-unaware and can still fail or crash if post-ES2 features are used.
+ // This is only intended for use by tests and certain internally created effects.
+ bool enforceES2Restrictions = true;
+
+ // Similarly: Public SkSL does not allow access to sk_FragCoord. The semantics of that
+ // variable are confusing, and expose clients to implementation details of saveLayer and
+ // image filters.
+ bool allowFragCoord = false;
+ };
+
+ // If the effect is compiled successfully, `effect` will be non-null.
+ // Otherwise, `errorText` will contain the reason for failure.
+ struct Result {
+ sk_sp<SkRuntimeEffect> effect;
+ SkString errorText;
+ };
+
+ // MakeForColorFilter and MakeForShader verify that the SkSL code is valid for those stages of
+ // the Skia pipeline. In all of the signatures described below, color parameters and return
+ // values are flexible. They are listed as being 'vec4', but they can also be 'half4' or
+ // 'float4'. ('vec4' is an alias for 'float4').
+
+ // We can't use a default argument for `options` due to a bug in Clang.
+ // https://bugs.llvm.org/show_bug.cgi?id=36684
+
+ // Color filter SkSL requires an entry point that looks like:
+ // vec4 main(vec4 inColor) { ... }
+ static Result MakeForColorFilter(SkString sksl, const Options&);
+ static Result MakeForColorFilter(SkString sksl) {
+ return MakeForColorFilter(std::move(sksl), Options{});
+ }
+
+ // Shader SkSL requires an entry point that looks like:
+ // vec4 main(vec2 inCoords) { ... }
+ // -or-
+ // vec4 main(vec2 inCoords, vec4 inColor) { ... }
+ //
+ // Most shaders don't use the input color, so that parameter is optional.
+ static Result MakeForShader(SkString sksl, const Options&);
+ static Result MakeForShader(SkString sksl) {
+ return MakeForShader(std::move(sksl), Options{});
+ }
+
+ // Blend SkSL requires an entry point that looks like:
+ // vec4 main(vec4 srcColor, vec4 dstColor) { ... }
+ static Result MakeForBlender(SkString sksl, const Options&);
+ static Result MakeForBlender(SkString sksl) {
+ return MakeForBlender(std::move(sksl), Options{});
+ }
+
+ // DSL entry points
+ static Result MakeForColorFilter(std::unique_ptr<SkSL::Program> program, const Options&);
+ static Result MakeForColorFilter(std::unique_ptr<SkSL::Program> program);
+
+ static Result MakeForShader(std::unique_ptr<SkSL::Program> program, const Options&);
+ static Result MakeForShader(std::unique_ptr<SkSL::Program> program);
+ static sk_sp<SkRuntimeEffect> MakeForShader(std::unique_ptr<SkSL::Program> program,
+ const Options&, SkSL::ErrorReporter* errors);
+
+
+ static Result MakeForBlender(std::unique_ptr<SkSL::Program> program, const Options&);
+ static Result MakeForBlender(std::unique_ptr<SkSL::Program> program);
+
+ // Object that allows passing a SkShader, SkColorFilter or SkBlender as a child
+ class ChildPtr {
+ public:
+ ChildPtr() = default;
+ ChildPtr(sk_sp<SkShader> s) : fChild(std::move(s)) {}
+ ChildPtr(sk_sp<SkColorFilter> cf) : fChild(std::move(cf)) {}
+ ChildPtr(sk_sp<SkBlender> b) : fChild(std::move(b)) {}
+
+ skstd::optional<ChildType> type() const;
+
+ SkShader* shader() const;
+ SkColorFilter* colorFilter() const;
+ SkBlender* blender() const;
+ SkFlattenable* flattenable() const { return fChild.get(); }
+
+ private:
+ sk_sp<SkFlattenable> fChild;
+ };
+
+ sk_sp<SkShader> makeShader(sk_sp<SkData> uniforms,
+ sk_sp<SkShader> children[],
+ size_t childCount,
+ const SkMatrix* localMatrix,
+ bool isOpaque) const;
+ sk_sp<SkShader> makeShader(sk_sp<SkData> uniforms,
+ SkSpan<ChildPtr> children,
+ const SkMatrix* localMatrix,
+ bool isOpaque) const;
+
+ sk_sp<SkImage> makeImage(GrRecordingContext*,
+ sk_sp<SkData> uniforms,
+ SkSpan<ChildPtr> children,
+ const SkMatrix* localMatrix,
+ SkImageInfo resultInfo,
+ bool mipmapped) const;
+
+ sk_sp<SkColorFilter> makeColorFilter(sk_sp<SkData> uniforms) const;
+ sk_sp<SkColorFilter> makeColorFilter(sk_sp<SkData> uniforms,
+ sk_sp<SkColorFilter> children[],
+ size_t childCount) const;
+ sk_sp<SkColorFilter> makeColorFilter(sk_sp<SkData> uniforms,
+ SkSpan<ChildPtr> children) const;
+
+ sk_sp<SkBlender> makeBlender(sk_sp<SkData> uniforms, SkSpan<ChildPtr> children = {}) const;
+
+ /**
+ * Creates a new Runtime Effect patterned after an already-existing one. The new shader behaves
+ * like the original, but also creates a debug trace of its execution at the requested
+ * coordinate. After painting with this shader, the associated DebugTrace object will contain a
+ * shader execution trace. Call `writeTrace` on the debug trace object to generate a full trace
+ * suitable for a debugger, or call `dump` to emit a human-readable trace.
+ *
+ * Debug traces are only supported on a raster (non-GPU) canvas.
+
+ * Debug traces are currently only supported on shaders. Color filter and blender tracing is a
+ * work-in-progress.
+ */
+ struct TracedShader {
+ sk_sp<SkShader> shader;
+ sk_sp<SkSL::DebugTrace> debugTrace;
+ };
+ static TracedShader MakeTraced(sk_sp<SkShader> shader, const SkIPoint& traceCoord);
+
+ // Returns the SkSL source of the runtime effect shader.
+ const std::string& source() const;
+
+ // Combined size of all 'uniform' variables. When calling makeColorFilter or makeShader,
+ // provide an SkData of this size, containing values for all of those variables.
+ size_t uniformSize() const;
+
+ SkSpan<const Uniform> uniforms() const { return SkMakeSpan(fUniforms); }
+ SkSpan<const Child> children() const { return SkMakeSpan(fChildren); }
+
+ // Returns pointer to the named uniform variable's description, or nullptr if not found
+ const Uniform* findUniform(const char* name) const;
+
+ // Returns pointer to the named child's description, or nullptr if not found
+ const Child* findChild(const char* name) const;
+
+ static void RegisterFlattenables();
+ ~SkRuntimeEffect() override;
+
+private:
+ enum Flags {
+ kUsesSampleCoords_Flag = 0x01,
+ kAllowColorFilter_Flag = 0x02,
+ kAllowShader_Flag = 0x04,
+ kAllowBlender_Flag = 0x08,
+ kSamplesOutsideMain_Flag = 0x10,
+ kUsesColorTransform_Flag = 0x20,
+ };
+
+ SkRuntimeEffect(std::unique_ptr<SkSL::Program> baseProgram,
+ const Options& options,
+ const SkSL::FunctionDefinition& main,
+ std::vector<Uniform>&& uniforms,
+ std::vector<Child>&& children,
+ std::vector<SkSL::SampleUsage>&& sampleUsages,
+ uint32_t flags);
+
+ sk_sp<SkRuntimeEffect> makeUnoptimizedClone();
+
+ static Result MakeFromSource(SkString sksl, const Options& options, SkSL::ProgramKind kind);
+
+ static Result MakeFromDSL(std::unique_ptr<SkSL::Program> program,
+ const Options& options,
+ SkSL::ProgramKind kind);
+
+ static sk_sp<SkRuntimeEffect> MakeFromDSL(std::unique_ptr<SkSL::Program> program,
+ const Options& options,
+ SkSL::ProgramKind kind,
+ SkSL::ErrorReporter* errors);
+
+ static Result MakeInternal(std::unique_ptr<SkSL::Program> program,
+ const Options& options,
+ SkSL::ProgramKind kind);
+
+ static SkSL::ProgramSettings MakeSettings(const Options& options, bool optimize);
+
+ uint32_t hash() const { return fHash; }
+ bool usesSampleCoords() const { return (fFlags & kUsesSampleCoords_Flag); }
+ bool allowShader() const { return (fFlags & kAllowShader_Flag); }
+ bool allowColorFilter() const { return (fFlags & kAllowColorFilter_Flag); }
+ bool allowBlender() const { return (fFlags & kAllowBlender_Flag); }
+ bool samplesOutsideMain() const { return (fFlags & kSamplesOutsideMain_Flag); }
+ bool usesColorTransform() const { return (fFlags & kUsesColorTransform_Flag); }
+
+ const SkFilterColorProgram* getFilterColorProgram();
+
+#if SK_SUPPORT_GPU
+ friend class GrSkSLFP; // fBaseProgram, fSampleUsages
+ friend class GrGLSLSkSLFP; //
+#endif
+
+ friend class SkRTShader; // fBaseProgram, fMain
+ friend class SkRuntimeBlender; //
+ friend class SkRuntimeColorFilter; //
+
+ friend class SkFilterColorProgram;
+ friend class SkRuntimeEffectPriv;
+
+ uint32_t fHash;
+
+ std::unique_ptr<SkSL::Program> fBaseProgram;
+ const SkSL::FunctionDefinition& fMain;
+ std::vector<Uniform> fUniforms;
+ std::vector<Child> fChildren;
+ std::vector<SkSL::SampleUsage> fSampleUsages;
+
+ std::unique_ptr<SkFilterColorProgram> fFilterColorProgram;
+
+ uint32_t fFlags; // Flags
+};
+
+/** Base class for SkRuntimeShaderBuilder, defined below. */
+class SkRuntimeEffectBuilder {
+public:
+ struct BuilderUniform {
+ // Copy 'val' to this variable. No type conversion is performed - 'val' must be same
+ // size as expected by the effect. Information about the variable can be queried by
+ // looking at fVar. If the size is incorrect, no copy will be performed, and debug
+ // builds will abort. If this is the result of querying a missing variable, fVar will
+ // be nullptr, and assigning will also do nothing (and abort in debug builds).
+ template <typename T>
+ std::enable_if_t<std::is_trivially_copyable<T>::value, BuilderUniform&> operator=(
+ const T& val) {
+ if (!fVar) {
+ SkDEBUGFAIL("Assigning to missing variable");
+ } else if (sizeof(val) != fVar->sizeInBytes()) {
+ SkDEBUGFAIL("Incorrect value size");
+ } else {
+ memcpy(SkTAddOffset<void>(fOwner->writableUniformData(), fVar->offset),
+ &val, sizeof(val));
+ }
+ return *this;
+ }
+
+ BuilderUniform& operator=(const SkMatrix& val) {
+ if (!fVar) {
+ SkDEBUGFAIL("Assigning to missing variable");
+ } else if (fVar->sizeInBytes() != 9 * sizeof(float)) {
+ SkDEBUGFAIL("Incorrect value size");
+ } else {
+ float* data = SkTAddOffset<float>(fOwner->writableUniformData(),
+ (ptrdiff_t)fVar->offset);
+ data[0] = val.get(0); data[1] = val.get(3); data[2] = val.get(6);
+ data[3] = val.get(1); data[4] = val.get(4); data[5] = val.get(7);
+ data[6] = val.get(2); data[7] = val.get(5); data[8] = val.get(8);
+ }
+ return *this;
+ }
+
+ template <typename T>
+ bool set(const T val[], const int count) {
+ static_assert(std::is_trivially_copyable<T>::value, "Value must be trivial copyable");
+ if (!fVar) {
+ SkDEBUGFAIL("Assigning to missing variable");
+ return false;
+ } else if (sizeof(T) * count != fVar->sizeInBytes()) {
+ SkDEBUGFAIL("Incorrect value size");
+ return false;
+ } else {
+ memcpy(SkTAddOffset<void>(fOwner->writableUniformData(), fVar->offset),
+ val, sizeof(T) * count);
+ }
+ return true;
+ }
+
+ SkRuntimeEffectBuilder* fOwner;
+ const SkRuntimeEffect::Uniform* fVar; // nullptr if the variable was not found
+ };
+
+ struct BuilderChild {
+ template <typename T> BuilderChild& operator=(sk_sp<T> val) {
+ if (!fChild) {
+ SkDEBUGFAIL("Assigning to missing child");
+ } else {
+ fOwner->fChildren[(size_t)fChild->index] = std::move(val);
+ }
+ return *this;
+ }
+
+ BuilderChild& operator=(std::nullptr_t) {
+ if (!fChild) {
+ SkDEBUGFAIL("Assigning to missing child");
+ } else {
+ fOwner->fChildren[(size_t)fChild->index] = SkRuntimeEffect::ChildPtr{};
+ }
+ return *this;
+ }
+
+ SkRuntimeEffectBuilder* fOwner;
+ const SkRuntimeEffect::Child* fChild; // nullptr if the child was not found
+ };
+
+ const SkRuntimeEffect* effect() const { return fEffect.get(); }
+
+ BuilderUniform uniform(const char* name) { return { this, fEffect->findUniform(name) }; }
+ BuilderChild child(const char* name) {
+ const SkRuntimeEffect::Child* child = fEffect->findChild(name);
+ return { this, child };
+ }
+
+protected:
+ SkRuntimeEffectBuilder() = delete;
+ explicit SkRuntimeEffectBuilder(sk_sp<SkRuntimeEffect> effect)
+ : fEffect(std::move(effect))
+ , fUniforms(SkData::MakeZeroInitialized(fEffect->uniformSize()))
+ , fChildren(fEffect->children().size()) {}
+ explicit SkRuntimeEffectBuilder(sk_sp<SkRuntimeEffect> effect, sk_sp<SkData> uniforms)
+ : fEffect(std::move(effect))
+ , fUniforms(std::move(uniforms))
+ , fChildren(fEffect->children().size()) {}
+
+ SkRuntimeEffectBuilder(SkRuntimeEffectBuilder&&) = default;
+ SkRuntimeEffectBuilder(const SkRuntimeEffectBuilder&) = default;
+
+ SkRuntimeEffectBuilder& operator=(SkRuntimeEffectBuilder&&) = delete;
+ SkRuntimeEffectBuilder& operator=(const SkRuntimeEffectBuilder&) = delete;
+
+ sk_sp<SkData> uniforms() { return fUniforms; }
+ SkRuntimeEffect::ChildPtr* children() { return fChildren.data(); }
+ size_t numChildren() { return fChildren.size(); }
+
+private:
+ void* writableUniformData() {
+ if (!fUniforms->unique()) {
+ fUniforms = SkData::MakeWithCopy(fUniforms->data(), fUniforms->size());
+ }
+ return fUniforms->writable_data();
+ }
+
+ sk_sp<SkRuntimeEffect> fEffect;
+ sk_sp<SkData> fUniforms;
+ std::vector<SkRuntimeEffect::ChildPtr> fChildren;
+};
+
+/**
+ * SkRuntimeShaderBuilder is a utility to simplify creating SkShader objects from SkRuntimeEffects.
+ *
+ * NOTE: Like SkRuntimeEffect, this API is experimental and subject to change!
+ *
+ * Given an SkRuntimeEffect, the SkRuntimeShaderBuilder manages creating an input data block and
+ * provides named access to the 'uniform' variables in that block, as well as named access
+ * to a list of child shader slots. Usage:
+ *
+ * sk_sp<SkRuntimeEffect> effect = ...;
+ * SkRuntimeShaderBuilder builder(effect);
+ * builder.uniform("some_uniform_float") = 3.14f;
+ * builder.uniform("some_uniform_matrix") = SkM44::Rotate(...);
+ * builder.child("some_child_effect") = mySkImage->makeShader(...);
+ * ...
+ * sk_sp<SkShader> shader = builder.makeShader(nullptr, false);
+ *
+ * Note that SkRuntimeShaderBuilder is built entirely on the public API of SkRuntimeEffect,
+ * so can be used as-is or serve as inspiration for other interfaces or binding techniques.
+ */
+class SK_API SkRuntimeShaderBuilder : public SkRuntimeEffectBuilder {
+public:
+ explicit SkRuntimeShaderBuilder(sk_sp<SkRuntimeEffect>);
+ // This is currently required by Android Framework but may go away if that dependency
+ // can be removed.
+ SkRuntimeShaderBuilder(const SkRuntimeShaderBuilder&) = default;
+ ~SkRuntimeShaderBuilder();
+
+ sk_sp<SkShader> makeShader(const SkMatrix* localMatrix, bool isOpaque);
+ sk_sp<SkImage> makeImage(GrRecordingContext*,
+ const SkMatrix* localMatrix,
+ SkImageInfo resultInfo,
+ bool mipmapped);
+
+private:
+ using INHERITED = SkRuntimeEffectBuilder;
+
+ explicit SkRuntimeShaderBuilder(sk_sp<SkRuntimeEffect> effect, sk_sp<SkData> uniforms)
+ : INHERITED(std::move(effect), std::move(uniforms)) {}
+
+ friend class SkRuntimeImageFilter;
+};
+
+/**
+ * SkRuntimeBlendBuilder is a utility to simplify creation and uniform setup of runtime blenders.
+ */
+class SK_API SkRuntimeBlendBuilder : public SkRuntimeEffectBuilder {
+public:
+ explicit SkRuntimeBlendBuilder(sk_sp<SkRuntimeEffect>);
+ ~SkRuntimeBlendBuilder();
+
+ SkRuntimeBlendBuilder(const SkRuntimeBlendBuilder&) = delete;
+ SkRuntimeBlendBuilder& operator=(const SkRuntimeBlendBuilder&) = delete;
+
+ sk_sp<SkBlender> makeBlender();
+
+private:
+ using INHERITED = SkRuntimeEffectBuilder;
+};
+
+#endif // SK_ENABLE_SKSL
+
+#endif // SkRuntimeEffect_DEFINED
diff --git a/src/deps/skia/include/effects/SkShaderMaskFilter.h b/src/deps/skia/include/effects/SkShaderMaskFilter.h
new file mode 100644
index 000000000..2b25d367a
--- /dev/null
+++ b/src/deps/skia/include/effects/SkShaderMaskFilter.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkShaderMaskFilter_DEFINED
+#define SkShaderMaskFilter_DEFINED
+
+#include "include/core/SkMaskFilter.h"
+
+class SkShader;
+
+class SK_API SkShaderMaskFilter {
+public:
+ static sk_sp<SkMaskFilter> Make(sk_sp<SkShader> shader);
+
+private:
+ static void RegisterFlattenables();
+ friend class SkFlattenable;
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkStrokeAndFillPathEffect.h b/src/deps/skia/include/effects/SkStrokeAndFillPathEffect.h
new file mode 100644
index 000000000..fbde64933
--- /dev/null
+++ b/src/deps/skia/include/effects/SkStrokeAndFillPathEffect.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkStrokeAndFillPathEffect_DEFINED
+#define SkStrokeAndFillPathEffect_DEFINED
+
+#include "include/core/SkPaint.h"
+#include "include/core/SkPathEffect.h"
+#include "include/pathops/SkPathOps.h"
+
+class SK_API SkStrokeAndFillPathEffect {
+public:
+ /* If the paint is set to stroke, this will add the stroke and fill geometries
+ * together (hoping that the winding-direction works out).
+ *
+ * If the paint is set to fill, this effect is ignored.
+ *
+ * Note that if the paint is set to stroke and the stroke-width is 0, then
+ * this will turn the geometry into just a fill.
+ */
+ static sk_sp<SkPathEffect> Make();
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkTableColorFilter.h b/src/deps/skia/include/effects/SkTableColorFilter.h
new file mode 100644
index 000000000..ab964aa20
--- /dev/null
+++ b/src/deps/skia/include/effects/SkTableColorFilter.h
@@ -0,0 +1,42 @@
+/*
+* Copyright 2015 Google Inc.
+*
+* Use of this source code is governed by a BSD-style license that can be
+* found in the LICENSE file.
+*/
+
+#ifndef SkTableColorFilter_DEFINED
+#define SkTableColorFilter_DEFINED
+
+#include "include/core/SkColorFilter.h"
+
+class SK_API SkTableColorFilter {
+public:
+ /**
+ * Create a table colorfilter, copying the table into the filter, and
+ * applying it to all 4 components.
+ * a' = table[a];
+ * r' = table[r];
+ * g' = table[g];
+ * b' = table[b];
+ * Compoents are operated on in unpremultiplied space. If the incomming
+ * colors are premultiplied, they are temporarily unpremultiplied, then
+ * the table is applied, and then the result is remultiplied.
+ */
+ static sk_sp<SkColorFilter> Make(const uint8_t table[256]);
+
+ /**
+ * Create a table colorfilter, with a different table for each
+ * component [A, R, G, B]. If a given table is NULL, then it is
+ * treated as identity, with the component left unchanged. If a table
+ * is not null, then its contents are copied into the filter.
+ */
+ static sk_sp<SkColorFilter> MakeARGB(const uint8_t tableA[256],
+ const uint8_t tableR[256],
+ const uint8_t tableG[256],
+ const uint8_t tableB[256]);
+
+ static void RegisterFlattenables();
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkTableMaskFilter.h b/src/deps/skia/include/effects/SkTableMaskFilter.h
new file mode 100644
index 000000000..03535a6f9
--- /dev/null
+++ b/src/deps/skia/include/effects/SkTableMaskFilter.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkTableMaskFilter_DEFINED
+#define SkTableMaskFilter_DEFINED
+
+#include "include/core/SkMaskFilter.h"
+#include "include/core/SkScalar.h"
+
+/** \class SkTableMaskFilter
+
+ Applies a table lookup on each of the alpha values in the mask.
+ Helper methods create some common tables (e.g. gamma, clipping)
+ */
+class SK_API SkTableMaskFilter {
+public:
+ /** Utility that sets the gamma table
+ */
+ static void MakeGammaTable(uint8_t table[256], SkScalar gamma);
+
+ /** Utility that creates a clipping table: clamps values below min to 0
+ and above max to 255, and rescales the remaining into 0..255
+ */
+ static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max);
+
+ static SkMaskFilter* Create(const uint8_t table[256]);
+ static SkMaskFilter* CreateGamma(SkScalar gamma);
+ static SkMaskFilter* CreateClip(uint8_t min, uint8_t max);
+
+ SkTableMaskFilter() = delete;
+};
+
+#endif
diff --git a/src/deps/skia/include/effects/SkTrimPathEffect.h b/src/deps/skia/include/effects/SkTrimPathEffect.h
new file mode 100644
index 000000000..66de9f44b
--- /dev/null
+++ b/src/deps/skia/include/effects/SkTrimPathEffect.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkTrimPathEffect_DEFINED
+#define SkTrimPathEffect_DEFINED
+
+#include "include/core/SkPathEffect.h"
+
+class SK_API SkTrimPathEffect {
+public:
+ enum class Mode {
+ kNormal, // return the subset path [start,stop]
+ kInverted, // return the complement/subset paths [0,start] + [stop,1]
+ };
+
+ /**
+ * Take start and stop "t" values (values between 0...1), and return a path that is that
+ * subset of the original path.
+ *
+ * e.g.
+ * Make(0.5, 1.0) --> return the 2nd half of the path
+ * Make(0.33333, 0.66667) --> return the middle third of the path
+ *
+ * The trim values apply to the entire path, so if it contains several contours, all of them
+ * are including in the calculation.
+ *
+ * startT and stopT must be 0..1 inclusive. If they are outside of that interval, they will
+ * be pinned to the nearest legal value. If either is NaN, null will be returned.
+ *
+ * Note: for Mode::kNormal, this will return one (logical) segment (even if it is spread
+ * across multiple contours). For Mode::kInverted, this will return 2 logical
+ * segments: stopT..1 and 0...startT, in this order.
+ */
+ static sk_sp<SkPathEffect> Make(SkScalar startT, SkScalar stopT, Mode = Mode::kNormal);
+};
+
+#endif