Revert "Rename GrSimpleTextureEffect->GrTextureEffect"
This reverts commit 90673ec66510f70f1d4b0f29d0b9c155aaac3532.
Reason for revert: Causes metal bot failures
Original change's description:
> Rename GrSimpleTextureEffect->GrTextureEffect
>
> It will become less simple.
>
> Change-Id: I409d0faba386597ae05738273d5ff773501eb358
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262383
> Auto-Submit: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
TBR=bsalomon@google.com,brianosman@google.com
Change-Id: Id25c9cde3c2048149409745f163e42c588de70c1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262514
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index f7fae02..1267d2f 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -17,7 +17,7 @@
#include "src/gpu/GrSoftwarePathRenderer.h"
#include "src/gpu/GrStyle.h"
#include "src/gpu/GrTextureProxy.h"
-#include "src/gpu/effects/GrTextureEffect.h"
+#include "src/gpu/effects/GrSimpleTextureEffect.h"
#include "src/gpu/geometry/GrShape.h"
#include "include/core/SkPaint.h"
@@ -48,7 +48,7 @@
-SkIntToScalar(maskRect.fTop));
matrix.preConcat(viewMatrix);
paint.addCoverageFragmentProcessor(
- GrTextureEffect::Make(std::move(mask), kUnknown_SkAlphaType, matrix));
+ GrSimpleTextureEffect::Make(std::move(mask), kUnknown_SkAlphaType, matrix));
renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(maskRect), inverse);
diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp
index 0a651ed..3dd8779 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -9,7 +9,7 @@
#include "src/gpu/GrXferProcessor.h"
#include "src/gpu/effects/GrCoverageSetOpXP.h"
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
-#include "src/gpu/effects/GrTextureEffect.h"
+#include "src/gpu/effects/GrSimpleTextureEffect.h"
GrPaint::GrPaint(const GrPaint& that)
: fXPFactory(that.fXPFactory)
@@ -38,7 +38,7 @@
void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, SkAlphaType alphaType,
const SkMatrix& matrix, const GrSamplerState& samplerState) {
this->addColorFragmentProcessor(
- GrTextureEffect::Make(std::move(proxy), alphaType, matrix, samplerState));
+ GrSimpleTextureEffect::Make(std::move(proxy), alphaType, matrix, samplerState));
}
bool GrPaint::isConstantBlendedColor(SkPMColor4f* constantColor) const {
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index 7bad0e5..f13264f 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -21,7 +21,7 @@
#include "src/gpu/effects/GrCoverageSetOpXP.h"
#include "src/gpu/effects/GrDisableColorXP.h"
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
-#include "src/gpu/effects/GrTextureEffect.h"
+#include "src/gpu/effects/GrSimpleTextureEffect.h"
#include "src/gpu/geometry/GrRect.h"
class GrAppliedClip;
diff --git a/src/gpu/GrProcessor.h b/src/gpu/GrProcessor.h
index 3fffc8a..ae1dcf1 100644
--- a/src/gpu/GrProcessor.h
+++ b/src/gpu/GrProcessor.h
@@ -131,6 +131,7 @@
kGrRGBToHSLFilterEffect_ClassID,
kGrRRectBlurEffect_ClassID,
kGrRRectShadowGeoProc_ClassID,
+ kGrSimpleTextureEffect_ClassID,
kGrSingleIntervalGradientColorizer_ClassID,
kGrSkSLFP_ClassID,
kGrSpecularLightingEffect_ClassID,
@@ -138,7 +139,6 @@
kGrSampleMaskProcessor_ClassID,
kGrSaturateProcessor_ClassID,
kGrSweepGradientLayout_ClassID,
- kGrTextureEffect_ClassID,
kGrTextureGradientColorizer_ClassID,
kGrTiledGradientEffect_ClassID,
kGrTwoPointConicalGradientLayout_ClassID,
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 00fb78f..36a82e4 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -2371,7 +2371,7 @@
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- auto fp = GrTextureEffect::Make(sk_ref_sp(src), kUnknown_SkAlphaType, SkMatrix::I());
+ auto fp = GrSimpleTextureEffect::Make(sk_ref_sp(src), kUnknown_SkAlphaType, SkMatrix::I());
if (!fp) {
return false;
}
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index ba75657..26ba0da 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -163,7 +163,7 @@
SkMatrix maskMatrix = SkMatrix::MakeTrans(SkIntToScalar(-textureOriginInDeviceSpace.fX),
SkIntToScalar(-textureOriginInDeviceSpace.fY));
maskMatrix.preConcat(viewMatrix);
- paint.addCoverageFragmentProcessor(GrTextureEffect::Make(
+ paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(
std::move(proxy), kPremul_SkAlphaType, maskMatrix, GrSamplerState::Filter::kNearest));
DrawNonAARect(renderTargetContext, std::move(paint), userStencilSettings, clip, SkMatrix::I(),
dstRect, invert);
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index ca04239..848eee3 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -203,8 +203,8 @@
std::unique_ptr<GrFragmentProcessor> fp;
if (canvas2DFastPath) {
fp = direct->priv().createPMToUPMEffect(
- GrTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()),
- this->colorInfo().alphaType(), SkMatrix::I()));
+ GrSimpleTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()),
+ this->colorInfo().alphaType(), SkMatrix::I()));
if (dstInfo.colorType() == GrColorType::kBGRA_8888) {
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
dstInfo = dstInfo.makeColorType(GrColorType::kRGBA_8888);
@@ -214,8 +214,8 @@
// double unpremul.
dstInfo = dstInfo.makeAlphaType(kPremul_SkAlphaType);
} else {
- fp = GrTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()),
- this->colorInfo().alphaType(), SkMatrix::I());
+ fp = GrSimpleTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()),
+ this->colorInfo().alphaType(), SkMatrix::I());
}
if (!fp) {
return false;
@@ -394,14 +394,14 @@
if (this->asRenderTargetContext()) {
std::unique_ptr<GrFragmentProcessor> fp;
if (canvas2DFastPath) {
- fp = direct->priv().createUPMToPMEffect(
- GrTextureEffect::Make(std::move(tempProxy), alphaType, SkMatrix::I()));
+ fp = direct->priv().createUPMToPMEffect(GrSimpleTextureEffect::Make(
+ std::move(tempProxy), alphaType, SkMatrix::I()));
// Important: check the original src color type here!
if (origSrcInfo.colorType() == GrColorType::kBGRA_8888) {
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
}
} else {
- fp = GrTextureEffect::Make(std::move(tempProxy), alphaType, SkMatrix::I());
+ fp = GrSimpleTextureEffect::Make(std::move(tempProxy), alphaType, SkMatrix::I());
}
if (!fp) {
return false;
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 1bf649d..36e38ea 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -5,8 +5,6 @@
* found in the LICENSE file.
*/
-#include "src/gpu/GrTextureProducer.h"
-
#include "include/private/GrRecordingContext.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkRectPriv.h"
@@ -15,11 +13,12 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetContext.h"
+#include "src/gpu/GrTextureProducer.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/effects/GrBicubicEffect.h"
+#include "src/gpu/effects/GrSimpleTextureEffect.h"
#include "src/gpu/effects/GrTextureDomain.h"
-#include "src/gpu/effects/GrTextureEffect.h"
sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrRecordingContext* context,
sk_sp<GrTextureProxy> inputProxy,
@@ -59,8 +58,8 @@
GrPaint paint;
- auto fp = GrTextureEffect::Make(std::move(inputProxy), kUnknown_SkAlphaType, SkMatrix::I(),
- copyParams.fFilter);
+ auto fp = GrSimpleTextureEffect::Make(std::move(inputProxy), kUnknown_SkAlphaType,
+ SkMatrix::I(), copyParams.fFilter);
if (needsDomain) {
const SkRect domain = localRect.makeInset(0.5f, 0.5f);
// This would cause us to read values from outside the subset. Surely, the caller knows
@@ -206,8 +205,8 @@
? GrSamplerState::WrapMode::kClampToBorder
: GrSamplerState::WrapMode::kClamp;
GrSamplerState samplerState(wrapMode, *filterOrNullForBicubic);
- auto fp =
- GrTextureEffect::Make(std::move(proxy), srcAlphaType, textureMatrix, samplerState);
+ auto fp = GrSimpleTextureEffect::Make(std::move(proxy), srcAlphaType, textureMatrix,
+ samplerState);
if (kDomain_DomainMode == domainMode || (fDomainNeedsDecal && !clampToBorderSupport)) {
GrTextureDomain::Mode wrapMode = fDomainNeedsDecal ? GrTextureDomain::kDecal_Mode
: GrTextureDomain::kClamp_Mode;
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 9e114f3..1280b8d 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -955,7 +955,8 @@
static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, domain, kDir, srcAlphaType);
} else {
- fp = GrTextureEffect::Make(std::move(proxy), srcAlphaType, texMatrix, samplerState);
+ fp = GrSimpleTextureEffect::Make(std::move(proxy), srcAlphaType, texMatrix,
+ samplerState);
fp = GrDomainEffect::Make(std::move(fp), domain, GrTextureDomain::kClamp_Mode,
samplerState.filter());
}
@@ -965,7 +966,7 @@
static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, wrapMode, kDir, srcAlphaType);
} else {
- fp = GrTextureEffect::Make(std::move(proxy), srcAlphaType, texMatrix, samplerState);
+ fp = GrSimpleTextureEffect::Make(std::move(proxy), srcAlphaType, texMatrix, samplerState);
}
fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), bitmap.alphaType(),
@@ -1036,7 +1037,7 @@
tmpUnfiltered.setImageFilter(nullptr);
- auto fp = GrTextureEffect::Make(std::move(proxy), special->alphaType(), SkMatrix::I());
+ auto fp = GrSimpleTextureEffect::Make(std::move(proxy), special->alphaType(), SkMatrix::I());
fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), result->alphaType(),
fRenderTargetContext->colorInfo().colorSpace());
if (GrColorTypeIsAlphaOnly(SkColorTypeToGrColorType(result->colorType()))) {
@@ -1074,8 +1075,8 @@
std::unique_ptr<GrFragmentProcessor> cfp;
if (clipProxy && ctm.invert(&inverseClipMatrix)) {
GrColorType srcColorType = SkColorTypeToGrColorType(clipImage->colorType());
- cfp = GrTextureEffect::Make(std::move(clipProxy), clipImage->alphaType(),
- inverseClipMatrix, sampler);
+ cfp = GrSimpleTextureEffect::Make(std::move(clipProxy), clipImage->alphaType(),
+ inverseClipMatrix, sampler);
if (srcColorType != GrColorType::kAlpha_8) {
cfp = GrFragmentProcessor::SwizzleOutput(std::move(cfp), GrSwizzle::AAAA());
}
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index fc32c27..96a6fd4 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -21,8 +21,8 @@
#include "src/gpu/GrTextureMaker.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/effects/GrBicubicEffect.h"
+#include "src/gpu/effects/GrSimpleTextureEffect.h"
#include "src/gpu/effects/GrTextureDomain.h"
-#include "src/gpu/effects/GrTextureEffect.h"
#include "src/gpu/geometry/GrShape.h"
#include "src/image/SkImage_Base.h"
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
new file mode 100644
index 0000000..389c8de
--- /dev/null
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "src/gpu/effects/GrSimpleTextureEffect.h"
+
+#include "include/gpu/GrTexture.h"
+#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
+#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
+#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
+#include "src/sksl/SkSLCPP.h"
+#include "src/sksl/SkSLUtil.h"
+
+std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::Make(sk_sp<GrSurfaceProxy> proxy,
+ SkAlphaType alphaType,
+ const SkMatrix& matrix,
+ GrSamplerState::Filter filter) {
+ return std::unique_ptr<GrFragmentProcessor>(
+ new GrSimpleTextureEffect(std::move(proxy), alphaType, matrix,
+ GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
+}
+
+std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::Make(sk_sp<GrSurfaceProxy> proxy,
+ SkAlphaType alphaType,
+ const SkMatrix& matrix,
+ GrSamplerState sampler) {
+ return std::unique_ptr<GrFragmentProcessor>(
+ new GrSimpleTextureEffect(std::move(proxy), alphaType, matrix, sampler));
+}
+
+GrGLSLFragmentProcessor* GrSimpleTextureEffect::onCreateGLSLInstance() const {
+ class Impl : public GrGLSLFragmentProcessor {
+ public:
+ void emitCode(EmitArgs& args) override {
+ const char* coords;
+ if (args.fFp.coordTransformsApplyToLocalCoords()) {
+ coords = args.fTransformedCoords[0].fVaryingPoint.c_str();
+ } else {
+ coords = "_coords";
+ }
+ auto* fb = args.fFragBuilder;
+ fb->codeAppendf("%s = ", args.fOutputColor);
+ fb->appendTextureLookupAndBlend(args.fInputColor, SkBlendMode::kModulate,
+ args.fTexSamplers[0], coords);
+ fb->codeAppendf(";");
+ }
+ };
+ return new Impl;
+}
+
+void GrSimpleTextureEffect::onGetGLSLProcessorKey(const GrShaderCaps&,
+ GrProcessorKeyBuilder*) const {}
+
+bool GrSimpleTextureEffect::onIsEqual(const GrFragmentProcessor&) const { return true; }
+
+static inline bool uses_border(const GrSamplerState s) {
+ return s.wrapModeX() == GrSamplerState::WrapMode::kClampToBorder ||
+ s.wrapModeY() == GrSamplerState::WrapMode::kClampToBorder;
+}
+
+GrSimpleTextureEffect::GrSimpleTextureEffect(sk_sp<GrSurfaceProxy> texture, SkAlphaType alphaType,
+ const SkMatrix& matrix, GrSamplerState sampler)
+ : GrFragmentProcessor(kGrSimpleTextureEffect_ClassID,
+ ModulateForSamplerOptFlags(alphaType, uses_border(sampler)))
+ , fCoordTransform(matrix, texture.get())
+ , fSampler(std::move(texture), sampler) {
+ this->setTextureSamplerCnt(1);
+ this->addCoordTransform(&fCoordTransform);
+}
+
+GrSimpleTextureEffect::GrSimpleTextureEffect(const GrSimpleTextureEffect& src)
+ : INHERITED(kGrSimpleTextureEffect_ClassID, src.optimizationFlags())
+ , fCoordTransform(src.fCoordTransform)
+ , fSampler(src.fSampler) {
+ this->setTextureSamplerCnt(1);
+ this->addCoordTransform(&fCoordTransform);
+}
+
+std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(*this));
+}
+
+const GrFragmentProcessor::TextureSampler& GrSimpleTextureEffect::onTextureSampler(int) const {
+ return fSampler;
+}
+
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect);
+#if GR_TEST_UTILS
+std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(
+ GrProcessorTestData* testData) {
+ auto [proxy, ct, at] = testData->randomProxy();
+ GrSamplerState::WrapMode wrapModes[2];
+ GrTest::TestWrapModes(testData->fRandom, wrapModes);
+ if (!testData->caps()->npotTextureTileSupport()) {
+ // Performing repeat sampling on npot textures will cause asserts on HW
+ // that lacks support.
+ wrapModes[0] = GrSamplerState::WrapMode::kClamp;
+ wrapModes[1] = GrSamplerState::WrapMode::kClamp;
+ }
+
+ GrSamplerState params(wrapModes, testData->fRandom->nextBool()
+ ? GrSamplerState::Filter::kBilerp
+ : GrSamplerState::Filter::kNearest);
+
+ const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
+ return GrSimpleTextureEffect::Make(std::move(proxy), at, matrix, params);
+}
+#endif
diff --git a/src/gpu/effects/GrTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h
similarity index 82%
rename from src/gpu/effects/GrTextureEffect.h
rename to src/gpu/effects/GrSimpleTextureEffect.h
index 8f1d7ac..f5cb9dc 100644
--- a/src/gpu/effects/GrTextureEffect.h
+++ b/src/gpu/effects/GrSimpleTextureEffect.h
@@ -5,15 +5,15 @@
* found in the LICENSE file.
*/
-#ifndef GrTextureEffect_DEFINED
-#define GrTextureEffect_DEFINED
+#ifndef GrSimpleTextureEffect_DEFINED
+#define GrSimpleTextureEffect_DEFINED
#include "include/core/SkImageInfo.h"
#include "include/core/SkMatrix.h"
#include "src/gpu/GrCoordTransform.h"
#include "src/gpu/GrFragmentProcessor.h"
-class GrTextureEffect : public GrFragmentProcessor {
+class GrSimpleTextureEffect : public GrFragmentProcessor {
public:
/** Uses kClamp wrap mode in both dimensions. */
static std::unique_ptr<GrFragmentProcessor> Make(
@@ -36,9 +36,10 @@
GrCoordTransform fCoordTransform;
TextureSampler fSampler;
- GrTextureEffect(const GrTextureEffect& src);
+ GrSimpleTextureEffect(const GrSimpleTextureEffect& src);
- inline GrTextureEffect(sk_sp<GrSurfaceProxy>, SkAlphaType, const SkMatrix&, GrSamplerState);
+ inline GrSimpleTextureEffect(sk_sp<GrSurfaceProxy>, SkAlphaType, const SkMatrix&,
+ GrSamplerState);
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index d26c4bf..dfd606c 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -12,7 +12,7 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrShaderCaps.h"
#include "src/gpu/GrSurfaceProxyPriv.h"
-#include "src/gpu/effects/GrTextureEffect.h"
+#include "src/gpu/effects/GrSimpleTextureEffect.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramDataManager.h"
diff --git a/src/gpu/effects/GrTextureEffect.cpp b/src/gpu/effects/GrTextureEffect.cpp
deleted file mode 100644
index 0e9f8cf..0000000
--- a/src/gpu/effects/GrTextureEffect.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "src/gpu/effects/GrTextureEffect.h"
-
-#include "include/gpu/GrTexture.h"
-#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
-#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
-#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
-#include "src/sksl/SkSLCPP.h"
-#include "src/sksl/SkSLUtil.h"
-
-std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(sk_sp<GrSurfaceProxy> proxy,
- SkAlphaType alphaType,
- const SkMatrix& matrix,
- GrSamplerState::Filter filter) {
- return std::unique_ptr<GrFragmentProcessor>(
- new GrTextureEffect(std::move(proxy), alphaType, matrix,
- GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
-}
-
-std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(sk_sp<GrSurfaceProxy> proxy,
- SkAlphaType alphaType,
- const SkMatrix& matrix,
- GrSamplerState sampler) {
- return std::unique_ptr<GrFragmentProcessor>(
- new GrTextureEffect(std::move(proxy), alphaType, matrix, sampler));
-}
-
-GrGLSLFragmentProcessor* GrTextureEffect::onCreateGLSLInstance() const {
- class Impl : public GrGLSLFragmentProcessor {
- public:
- void emitCode(EmitArgs& args) override {
- const char* coords;
- if (args.fFp.coordTransformsApplyToLocalCoords()) {
- coords = args.fTransformedCoords[0].fVaryingPoint.c_str();
- } else {
- coords = "_coords";
- }
- auto* fb = args.fFragBuilder;
- fb->codeAppendf("%s = ", args.fOutputColor);
- fb->appendTextureLookupAndBlend(args.fInputColor, SkBlendMode::kModulate,
- args.fTexSamplers[0], coords);
- fb->codeAppendf(";");
- }
- };
- return new Impl;
-}
-
-void GrTextureEffect::onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const {}
-
-bool GrTextureEffect::onIsEqual(const GrFragmentProcessor&) const { return true; }
-
-static inline bool uses_border(const GrSamplerState s) {
- return s.wrapModeX() == GrSamplerState::WrapMode::kClampToBorder ||
- s.wrapModeY() == GrSamplerState::WrapMode::kClampToBorder;
-}
-
-GrTextureEffect::GrTextureEffect(sk_sp<GrSurfaceProxy> texture, SkAlphaType alphaType,
- const SkMatrix& matrix, GrSamplerState sampler)
- : GrFragmentProcessor(kGrTextureEffect_ClassID,
- ModulateForSamplerOptFlags(alphaType, uses_border(sampler)))
- , fCoordTransform(matrix, texture.get())
- , fSampler(std::move(texture), sampler) {
- this->setTextureSamplerCnt(1);
- this->addCoordTransform(&fCoordTransform);
-}
-
-GrTextureEffect::GrTextureEffect(const GrTextureEffect& src)
- : INHERITED(kGrTextureEffect_ClassID, src.optimizationFlags())
- , fCoordTransform(src.fCoordTransform)
- , fSampler(src.fSampler) {
- this->setTextureSamplerCnt(1);
- this->addCoordTransform(&fCoordTransform);
-}
-
-std::unique_ptr<GrFragmentProcessor> GrTextureEffect::clone() const {
- return std::unique_ptr<GrFragmentProcessor>(new GrTextureEffect(*this));
-}
-
-const GrFragmentProcessor::TextureSampler& GrTextureEffect::onTextureSampler(int) const {
- return fSampler;
-}
-
-GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureEffect);
-#if GR_TEST_UTILS
-std::unique_ptr<GrFragmentProcessor> GrTextureEffect::TestCreate(GrProcessorTestData* testData) {
- auto [proxy, ct, at] = testData->randomProxy();
- GrSamplerState::WrapMode wrapModes[2];
- GrTest::TestWrapModes(testData->fRandom, wrapModes);
- if (!testData->caps()->npotTextureTileSupport()) {
- // Performing repeat sampling on npot textures will cause asserts on HW
- // that lacks support.
- wrapModes[0] = GrSamplerState::WrapMode::kClamp;
- wrapModes[1] = GrSamplerState::WrapMode::kClamp;
- }
-
- GrSamplerState params(wrapModes, testData->fRandom->nextBool()
- ? GrSamplerState::Filter::kBilerp
- : GrSamplerState::Filter::kNearest);
-
- const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
- return GrTextureEffect::Make(std::move(proxy), at, matrix, params);
-}
-#endif
diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp
index 987db7e..4d2d732 100644
--- a/src/gpu/effects/GrYUVtoRGBEffect.cpp
+++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp
@@ -63,8 +63,8 @@
} else if (domain) {
planeDomain = *domain;
}
- planeFPs[i] =
- GrTextureEffect::Make(proxies[i], kUnknown_SkAlphaType, *planeMatrix, planeFilter);
+ planeFPs[i] = GrSimpleTextureEffect::Make(proxies[i], kUnknown_SkAlphaType, *planeMatrix,
+ planeFilter);
if (domain) {
SkASSERT(planeFilter != GrSamplerState::Filter::kMipMap);
if (planeFilter != GrSamplerState::Filter::kNearest) {
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 1425a4f..61ee5a3 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -1073,7 +1073,7 @@
GrSurfaceProxy* proxy = proxyView.proxy();
std::unique_ptr<GrFragmentProcessor> fp;
- fp = GrTextureEffect::Make(sk_ref_sp(proxy), alphaType, SkMatrix::I(), filter);
+ fp = GrSimpleTextureEffect::Make(sk_ref_sp(proxy), alphaType, SkMatrix::I(), filter);
if (domain) {
// Update domain to match what GrTextureOp would do for bilerp, but don't do any
// normalization since GrTextureDomainEffect handles that and the origin.