aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-12-13 14:36:14 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-13 20:01:40 +0000
commit2d5f9b3d58e07ac8a8df17f4c0321cb65f255e69 (patch)
tree8422c1a8b0d73cd3cc15e9c1a4ac2fda2e66fa20 /src/gpu
parentdf9a7e11c2656a555579de40e9dd39927ffa9bce (diff)
converted GrMagnifierEffect to SkSL
Bug: skia: Change-Id: I6dc14ac66d5b911117e71fa23fef49a897082781 Reviewed-on: https://skia-review.googlesource.com/71342 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/effects/GrAARectEffect.cpp1
-rw-r--r--src/gpu/effects/GrArithmeticFP.cpp1
-rw-r--r--src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp1
-rw-r--r--src/gpu/effects/GrCircleEffect.cpp1
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp1
-rw-r--r--src/gpu/effects/GrConstColorProcessor.cpp1
-rw-r--r--src/gpu/effects/GrDitherEffect.cpp1
-rw-r--r--src/gpu/effects/GrEllipseEffect.cpp1
-rw-r--r--src/gpu/effects/GrLumaColorFilterEffect.cpp1
-rw-r--r--src/gpu/effects/GrMagnifierEffect.cpp197
-rw-r--r--src/gpu/effects/GrMagnifierEffect.fp85
-rw-r--r--src/gpu/effects/GrMagnifierEffect.h65
-rw-r--r--src/gpu/effects/GrOverdrawFragmentProcessor.cpp1
-rw-r--r--src/gpu/effects/GrPremulInputFragmentProcessor.cpp1
-rw-r--r--src/gpu/effects/GrRectBlurEffect.cpp4
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.cpp1
-rw-r--r--src/gpu/effects/GrUnpremulInputFragmentProcessor.cpp1
17 files changed, 363 insertions, 1 deletions
diff --git a/src/gpu/effects/GrAARectEffect.cpp b/src/gpu/effects/GrAARectEffect.cpp
index 0e49e0fad8..48ed6447a1 100644
--- a/src/gpu/effects/GrAARectEffect.cpp
+++ b/src/gpu/effects/GrAARectEffect.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLAARectEffect : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrArithmeticFP.cpp b/src/gpu/effects/GrArithmeticFP.cpp
index 41de6432ef..a9057059b7 100644
--- a/src/gpu/effects/GrArithmeticFP.cpp
+++ b/src/gpu/effects/GrArithmeticFP.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLArithmeticFP : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
index 6dfb6c5216..a531d42116 100644
--- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLBlurredEdgeFragmentProcessor : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrCircleEffect.cpp b/src/gpu/effects/GrCircleEffect.cpp
index a5adf1cc88..ed3ad518b9 100644
--- a/src/gpu/effects/GrCircleEffect.cpp
+++ b/src/gpu/effects/GrCircleEffect.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLCircleEffect : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 9887cac6b0..b1e4aa758f 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLConfigConversionEffect : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrConstColorProcessor.cpp b/src/gpu/effects/GrConstColorProcessor.cpp
index b2ac82568b..cfc910ab57 100644
--- a/src/gpu/effects/GrConstColorProcessor.cpp
+++ b/src/gpu/effects/GrConstColorProcessor.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLConstColorProcessor : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp
index d3fdc4fa5d..a66a40d2b7 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLDitherEffect : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrEllipseEffect.cpp b/src/gpu/effects/GrEllipseEffect.cpp
index 88a07f9bed..7ea975ffde 100644
--- a/src/gpu/effects/GrEllipseEffect.cpp
+++ b/src/gpu/effects/GrEllipseEffect.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLEllipseEffect : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrLumaColorFilterEffect.cpp b/src/gpu/effects/GrLumaColorFilterEffect.cpp
index e09751d9b6..6cd103086f 100644
--- a/src/gpu/effects/GrLumaColorFilterEffect.cpp
+++ b/src/gpu/effects/GrLumaColorFilterEffect.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLLumaColorFilterEffect : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrMagnifierEffect.cpp b/src/gpu/effects/GrMagnifierEffect.cpp
new file mode 100644
index 0000000000..ac00270fef
--- /dev/null
+++ b/src/gpu/effects/GrMagnifierEffect.cpp
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * This file was autogenerated from GrMagnifierEffect.fp; do not modify.
+ */
+#include "GrMagnifierEffect.h"
+#if SK_SUPPORT_GPU
+#include "glsl/GrGLSLFragmentProcessor.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
+#include "SkSLCPP.h"
+#include "SkSLUtil.h"
+class GrGLSLMagnifierEffect : public GrGLSLFragmentProcessor {
+public:
+ GrGLSLMagnifierEffect() {}
+ void emitCode(EmitArgs& args) override {
+ GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
+ const GrMagnifierEffect& _outer = args.fFp.cast<GrMagnifierEffect>();
+ (void)_outer;
+ auto bounds = _outer.bounds();
+ (void)bounds;
+ auto srcRect = _outer.srcRect();
+ (void)srcRect;
+ auto xInvZoom = _outer.xInvZoom();
+ (void)xInvZoom;
+ auto yInvZoom = _outer.yInvZoom();
+ (void)yInvZoom;
+ auto xInvInset = _outer.xInvInset();
+ (void)xInvInset;
+ auto yInvInset = _outer.yInvInset();
+ (void)yInvInset;
+ fBoundsUniformVar = args.fUniformHandler->addUniform(
+ kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "boundsUniform");
+ fXInvZoomVar = args.fUniformHandler->addUniform(
+ kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "xInvZoom");
+ fYInvZoomVar = args.fUniformHandler->addUniform(
+ kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "yInvZoom");
+ fXInvInsetVar = args.fUniformHandler->addUniform(
+ kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "xInvInset");
+ fYInvInsetVar = args.fUniformHandler->addUniform(
+ kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "yInvInset");
+ fOffsetVar = args.fUniformHandler->addUniform(
+ kFragment_GrShaderFlag, kHalf2_GrSLType, kDefault_GrSLPrecision, "offset");
+ SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
+ fragBuilder->codeAppendf(
+ "float2 coord = %s;\nfloat2 zoom_coord = float2(%s + half2(coord * "
+ "float2(half2(half(%s), half(%s)))));\nfloat2 delta = (coord - %s.xy) * "
+ "%s.zw;\ndelta = min(delta, float2(half2(1.0, 1.0) - half2(delta)));\ndelta *= "
+ "float2(half2(half(%s), half(%s)));\nhalf weight = 0.0;\nif (delta.x < 2.0 && "
+ "delta.y < 2.0) {\n delta = float2(half2(2.0, 2.0) - half2(delta));\n half "
+ "dist = half(length(delta));\n dist = half(max(2.0 - float(dist), 0.0));\n "
+ "weight = half(min(float(dist * dist), 1.0));\n} else {\n ",
+ sk_TransformedCoords2D_0.c_str(),
+ args.fUniformHandler->getUniformCStr(fOffsetVar),
+ args.fUniformHandler->getUniformCStr(fXInvZoomVar),
+ args.fUniformHandler->getUniformCStr(fYInvZoomVar),
+ args.fUniformHandler->getUniformCStr(fBoundsUniformVar),
+ args.fUniformHandler->getUniformCStr(fBoundsUniformVar),
+ args.fUniformHandler->getUniformCStr(fXInvInsetVar),
+ args.fUniformHandler->getUniformCStr(fYInvInsetVar));
+ fragBuilder->codeAppendf(
+ "float2 delta_squared = delta * delta;\n weight = half(min(min(delta_squared.x, "
+ "delta_squared.y), 1.0));\n}\n%s = texture(%s, mix(coord, zoom_coord, "
+ "float(weight))).%s;\n",
+ args.fOutputColor,
+ fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
+ fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());
+ }
+
+private:
+ void onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrFragmentProcessor& _proc) override {
+ const GrMagnifierEffect& _outer = _proc.cast<GrMagnifierEffect>();
+ {
+ pdman.set1f(fXInvZoomVar, _outer.xInvZoom());
+ pdman.set1f(fYInvZoomVar, _outer.yInvZoom());
+ pdman.set1f(fXInvInsetVar, _outer.xInvInset());
+ pdman.set1f(fYInvInsetVar, _outer.yInvInset());
+ }
+ GrSurfaceProxy& srcProxy = *_outer.textureSampler(0).proxy();
+ GrTexture& src = *srcProxy.priv().peekTexture();
+ (void)src;
+ auto bounds = _outer.bounds();
+ (void)bounds;
+ UniformHandle& boundsUniform = fBoundsUniformVar;
+ (void)boundsUniform;
+ auto srcRect = _outer.srcRect();
+ (void)srcRect;
+ UniformHandle& xInvZoom = fXInvZoomVar;
+ (void)xInvZoom;
+ UniformHandle& yInvZoom = fYInvZoomVar;
+ (void)yInvZoom;
+ UniformHandle& xInvInset = fXInvInsetVar;
+ (void)xInvInset;
+ UniformHandle& yInvInset = fYInvInsetVar;
+ (void)yInvInset;
+ UniformHandle& offset = fOffsetVar;
+ (void)offset;
+
+ SkScalar invW = 1.0f / src.width();
+ SkScalar invH = 1.0f / src.height();
+
+ {
+ SkScalar y = srcRect.y() * invH;
+ if (srcProxy.origin() != kTopLeft_GrSurfaceOrigin) {
+ y = 1.0f - (srcRect.height() / bounds.height()) - y;
+ }
+
+ pdman.set2f(offset, srcRect.x() * invW, y);
+ }
+
+ {
+ SkScalar y = bounds.y() * invH;
+ if (srcProxy.origin() != kTopLeft_GrSurfaceOrigin) {
+ y = 1.0f - bounds.height() * invH;
+ }
+
+ pdman.set4f(boundsUniform,
+ bounds.x() * invW,
+ y,
+ SkIntToScalar(src.width()) / bounds.width(),
+ SkIntToScalar(src.height()) / bounds.height());
+ }
+ }
+ UniformHandle fBoundsUniformVar;
+ UniformHandle fOffsetVar;
+ UniformHandle fSrcVar;
+ UniformHandle fXInvZoomVar;
+ UniformHandle fYInvZoomVar;
+ UniformHandle fXInvInsetVar;
+ UniformHandle fYInvInsetVar;
+};
+GrGLSLFragmentProcessor* GrMagnifierEffect::onCreateGLSLInstance() const {
+ return new GrGLSLMagnifierEffect();
+}
+void GrMagnifierEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
+ GrProcessorKeyBuilder* b) const {}
+bool GrMagnifierEffect::onIsEqual(const GrFragmentProcessor& other) const {
+ const GrMagnifierEffect& that = other.cast<GrMagnifierEffect>();
+ (void)that;
+ if (fSrc != that.fSrc) return false;
+ if (fBounds != that.fBounds) return false;
+ if (fSrcRect != that.fSrcRect) return false;
+ if (fXInvZoom != that.fXInvZoom) return false;
+ if (fYInvZoom != that.fYInvZoom) return false;
+ if (fXInvInset != that.fXInvInset) return false;
+ if (fYInvInset != that.fYInvInset) return false;
+ return true;
+}
+GrMagnifierEffect::GrMagnifierEffect(const GrMagnifierEffect& src)
+ : INHERITED(kGrMagnifierEffect_ClassID, src.optimizationFlags())
+ , fSrc(src.fSrc)
+ , fBounds(src.fBounds)
+ , fSrcRect(src.fSrcRect)
+ , fXInvZoom(src.fXInvZoom)
+ , fYInvZoom(src.fYInvZoom)
+ , fXInvInset(src.fXInvInset)
+ , fYInvInset(src.fYInvInset)
+ , fSrcCoordTransform(src.fSrcCoordTransform) {
+ this->addTextureSampler(&fSrc);
+ this->addCoordTransform(&fSrcCoordTransform);
+}
+std::unique_ptr<GrFragmentProcessor> GrMagnifierEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrMagnifierEffect(*this));
+}
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
+#if GR_TEST_UTILS
+std::unique_ptr<GrFragmentProcessor> GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
+ sk_sp<GrTextureProxy> proxy = d->textureProxy(0);
+ const int kMaxWidth = 200;
+ const int kMaxHeight = 200;
+ const SkScalar kMaxInset = 20.0f;
+ uint32_t width = d->fRandom->nextULessThan(kMaxWidth);
+ uint32_t height = d->fRandom->nextULessThan(kMaxHeight);
+ SkScalar inset = d->fRandom->nextRangeScalar(1.0f, kMaxInset);
+
+ SkIRect bounds = SkIRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight));
+ SkRect srcRect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
+
+ auto effect = GrMagnifierEffect::Make(std::move(proxy),
+ bounds,
+ srcRect,
+ srcRect.width() / bounds.width(),
+ srcRect.height() / bounds.height(),
+ bounds.width() / inset,
+ bounds.height() / inset);
+ SkASSERT(effect);
+ return effect;
+}
+#endif
+#endif
diff --git a/src/gpu/effects/GrMagnifierEffect.fp b/src/gpu/effects/GrMagnifierEffect.fp
new file mode 100644
index 0000000000..962c1a0160
--- /dev/null
+++ b/src/gpu/effects/GrMagnifierEffect.fp
@@ -0,0 +1,85 @@
+in uniform sampler2D src;
+layout(ctype=SkIRect) in int4 bounds;
+uniform float4 boundsUniform;
+layout(ctype=SkRect) in float4 srcRect;
+in uniform float xInvZoom;
+in uniform float yInvZoom;
+in uniform float xInvInset;
+in uniform float yInvInset;
+
+uniform half2 offset;
+
+@coordTransform(src) {
+ SkMatrix::I()
+}
+
+void main() {
+ float2 coord = sk_TransformedCoords2D[0];
+ float2 zoom_coord = offset + coord * half2(xInvZoom, yInvZoom);
+ float2 delta = (coord - boundsUniform.xy) * boundsUniform.zw;
+ delta = min(delta, half2(1.0, 1.0) - delta);
+ delta *= half2(xInvInset, yInvInset);
+
+ half weight = 0.0;
+ if (delta.s < 2.0 && delta.t < 2.0) {
+ delta = half2(2.0, 2.0) - delta;
+ half dist = length(delta);
+ dist = max(2.0 - dist, 0.0);
+ weight = min(dist * dist, 1.0);
+ } else {
+ float2 delta_squared = delta * delta;
+ weight = min(min(delta_squared.x, delta_squared.y), 1.0);
+ }
+
+ sk_OutColor = texture(src, mix(coord, zoom_coord, weight));
+}
+
+@setData(pdman) {
+ SkScalar invW = 1.0f / src.width();
+ SkScalar invH = 1.0f / src.height();
+
+ {
+ SkScalar y = srcRect.y() * invH;
+ if (srcProxy.origin() != kTopLeft_GrSurfaceOrigin) {
+ y = 1.0f - (srcRect.height() / bounds.height()) - y;
+ }
+
+ pdman.set2f(offset, srcRect.x() * invW, y);
+ }
+
+ {
+ SkScalar y = bounds.y() * invH;
+ if (srcProxy.origin() != kTopLeft_GrSurfaceOrigin) {
+ y = 1.0f - bounds.height() * invH;
+ }
+
+ pdman.set4f(boundsUniform,
+ bounds.x() * invW,
+ y,
+ SkIntToScalar(src.width()) / bounds.width(),
+ SkIntToScalar(src.height()) / bounds.height());
+ }
+}
+
+@test(d) {
+ sk_sp<GrTextureProxy> proxy = d->textureProxy(0);
+ const int kMaxWidth = 200;
+ const int kMaxHeight = 200;
+ const SkScalar kMaxInset = 20.0f;
+ uint32_t width = d->fRandom->nextULessThan(kMaxWidth);
+ uint32_t height = d->fRandom->nextULessThan(kMaxHeight);
+ SkScalar inset = d->fRandom->nextRangeScalar(1.0f, kMaxInset);
+
+ SkIRect bounds = SkIRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight));
+ SkRect srcRect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
+
+ auto effect = GrMagnifierEffect::Make(std::move(proxy),
+ bounds,
+ srcRect,
+ srcRect.width() / bounds.width(),
+ srcRect.height() / bounds.height(),
+ bounds.width() / inset,
+ bounds.height() / inset);
+ SkASSERT(effect);
+ return effect;
+}
diff --git a/src/gpu/effects/GrMagnifierEffect.h b/src/gpu/effects/GrMagnifierEffect.h
new file mode 100644
index 0000000000..13904f983f
--- /dev/null
+++ b/src/gpu/effects/GrMagnifierEffect.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * This file was autogenerated from GrMagnifierEffect.fp; do not modify.
+ */
+#ifndef GrMagnifierEffect_DEFINED
+#define GrMagnifierEffect_DEFINED
+#include "SkTypes.h"
+#if SK_SUPPORT_GPU
+#include "GrFragmentProcessor.h"
+#include "GrCoordTransform.h"
+class GrMagnifierEffect : public GrFragmentProcessor {
+public:
+ SkIRect bounds() const { return fBounds; }
+ SkRect srcRect() const { return fSrcRect; }
+ float xInvZoom() const { return fXInvZoom; }
+ float yInvZoom() const { return fYInvZoom; }
+ float xInvInset() const { return fXInvInset; }
+ float yInvInset() const { return fYInvInset; }
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> src, SkIRect bounds,
+ SkRect srcRect, float xInvZoom, float yInvZoom,
+ float xInvInset, float yInvInset) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrMagnifierEffect(
+ src, bounds, srcRect, xInvZoom, yInvZoom, xInvInset, yInvInset));
+ }
+ GrMagnifierEffect(const GrMagnifierEffect& src);
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
+ const char* name() const override { return "MagnifierEffect"; }
+
+private:
+ GrMagnifierEffect(sk_sp<GrTextureProxy> src, SkIRect bounds, SkRect srcRect, float xInvZoom,
+ float yInvZoom, float xInvInset, float yInvInset)
+ : INHERITED(kGrMagnifierEffect_ClassID, kNone_OptimizationFlags)
+ , fSrc(std::move(src))
+ , fBounds(bounds)
+ , fSrcRect(srcRect)
+ , fXInvZoom(xInvZoom)
+ , fYInvZoom(yInvZoom)
+ , fXInvInset(xInvInset)
+ , fYInvInset(yInvInset)
+ , fSrcCoordTransform(SkMatrix::I(), fSrc.proxy()) {
+ this->addTextureSampler(&fSrc);
+ this->addCoordTransform(&fSrcCoordTransform);
+ }
+ GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
+ bool onIsEqual(const GrFragmentProcessor&) const override;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST
+ TextureSampler fSrc;
+ SkIRect fBounds;
+ SkRect fSrcRect;
+ float fXInvZoom;
+ float fYInvZoom;
+ float fXInvInset;
+ float fYInvInset;
+ GrCoordTransform fSrcCoordTransform;
+ typedef GrFragmentProcessor INHERITED;
+};
+#endif
+#endif
diff --git a/src/gpu/effects/GrOverdrawFragmentProcessor.cpp b/src/gpu/effects/GrOverdrawFragmentProcessor.cpp
index 31ab53d397..9d9e4fecc3 100644
--- a/src/gpu/effects/GrOverdrawFragmentProcessor.cpp
+++ b/src/gpu/effects/GrOverdrawFragmentProcessor.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLOverdrawFragmentProcessor : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrPremulInputFragmentProcessor.cpp b/src/gpu/effects/GrPremulInputFragmentProcessor.cpp
index a90f52944e..2e3beceec3 100644
--- a/src/gpu/effects/GrPremulInputFragmentProcessor.cpp
+++ b/src/gpu/effects/GrPremulInputFragmentProcessor.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLPremulInputFragmentProcessor : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrRectBlurEffect.cpp b/src/gpu/effects/GrRectBlurEffect.cpp
index 573c1313a0..e656d848de 100644
--- a/src/gpu/effects/GrRectBlurEffect.cpp
+++ b/src/gpu/effects/GrRectBlurEffect.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLRectBlurEffect : public GrGLSLFragmentProcessor {
@@ -113,7 +114,8 @@ private:
(void)rect;
auto sigma = _outer.sigma();
(void)sigma;
- UniformHandle& blurProfile = fBlurProfileVar;
+ GrSurfaceProxy& blurProfileProxy = *_outer.textureSampler(0).proxy();
+ GrTexture& blurProfile = *blurProfileProxy.priv().peekTexture();
(void)blurProfile;
UniformHandle& proxyRectHalf = fProxyRectHalfVar;
(void)proxyRectHalf;
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index 387731e956..d1efc8520e 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLSimpleTextureEffect : public GrGLSLFragmentProcessor {
diff --git a/src/gpu/effects/GrUnpremulInputFragmentProcessor.cpp b/src/gpu/effects/GrUnpremulInputFragmentProcessor.cpp
index 273643f78d..6e33763f9d 100644
--- a/src/gpu/effects/GrUnpremulInputFragmentProcessor.cpp
+++ b/src/gpu/effects/GrUnpremulInputFragmentProcessor.cpp
@@ -13,6 +13,7 @@
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrTexture.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLUnpremulInputFragmentProcessor : public GrGLSLFragmentProcessor {