aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-07-12 13:51:34 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-12 13:51:46 +0000
commitbaf981f71614e7a2fbe6af2726e65126d431ed8e (patch)
tree1efed95d65f841bbbe8006165f37d9f03a0c0972 /src/gpu
parent46b654df9e70bbfacf6dc45d3a2a7ceb13a61edb (diff)
Revert "converted GrSimpleTextureEffect to sksl"
This reverts commit 46b654df9e70bbfacf6dc45d3a2a7ceb13a61edb. Reason for revert: making Vulkan mad Original change's description: > converted GrSimpleTextureEffect to sksl > > Bug: skia: > Change-Id: If556c6baad75f22135f429759feabaaec095b900 > Reviewed-on: https://skia-review.googlesource.com/21720 > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> TBR=egdaniel@google.com,ethannicholas@google.com Change-Id: I06fac3d106435e1d58e19cc54a919c5d84784d92 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/22266 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/effects/GrDitherEffect.h1
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.cpp130
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.fp82
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.h97
4 files changed, 126 insertions, 184 deletions
diff --git a/src/gpu/effects/GrDitherEffect.h b/src/gpu/effects/GrDitherEffect.h
index a996ad94c2..d0bf9a9f9c 100644
--- a/src/gpu/effects/GrDitherEffect.h
+++ b/src/gpu/effects/GrDitherEffect.h
@@ -14,7 +14,6 @@
#if SK_SUPPORT_GPU
#include "GrFragmentProcessor.h"
#include "GrCoordTransform.h"
-#include "GrColorSpaceXform.h"
#include "effects/GrProxyMove.h"
class GrDitherEffect : public GrFragmentProcessor {
public:
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index ce713b7d41..938fb04ab9 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -1,81 +1,111 @@
/*
- * Copyright 2017 Google Inc.
+ * Copyright 2012 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 GrSimpleTextureEffect.fp; do not modify.
- */
#include "GrSimpleTextureEffect.h"
-#if SK_SUPPORT_GPU
+#include "GrProxyMove.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
-#include "SkSLCPP.h"
-#include "SkSLUtil.h"
-class GrGLSLSimpleTextureEffect : public GrGLSLFragmentProcessor {
+
+GrSimpleTextureEffect::GrSimpleTextureEffect(sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform> colorSpaceXform,
+ const SkMatrix& matrix,
+ GrSamplerParams::FilterMode filterMode)
+ : INHERITED{ModulationFlags(proxy->config()),
+ GR_PROXY_MOVE(proxy),
+ std::move(colorSpaceXform),
+ matrix,
+ filterMode} {
+ this->initClassID<GrSimpleTextureEffect>();
+}
+
+GrSimpleTextureEffect::GrSimpleTextureEffect(sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform> colorSpaceXform,
+ const SkMatrix& matrix,
+ const GrSamplerParams& params)
+ : INHERITED{ModulationFlags(proxy->config()),
+ GR_PROXY_MOVE(proxy),
+ std::move(colorSpaceXform),
+ matrix,
+ params} {
+ this->initClassID<GrSimpleTextureEffect>();
+}
+
+class GrGLSimpleTextureEffect : public GrGLSLFragmentProcessor {
public:
- GrGLSLSimpleTextureEffect() {}
void emitCode(EmitArgs& args) override {
+ const GrSimpleTextureEffect& textureEffect = args.fFp.cast<GrSimpleTextureEffect>();
+ fColorSpaceHelper.emitCode(args.fUniformHandler, textureEffect.colorSpaceXform());
+
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- const GrSimpleTextureEffect& _outer = args.fFp.cast<GrSimpleTextureEffect>();
- (void) _outer;
- fColorSpaceHelper.emitCode(args.fUniformHandler, _outer.colorXform().get());
- SkSL::String sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
- fragBuilder->codeAppendf("vec4 _tmp0;\n%s = %s * (_tmp0 = texture(%s, %s).%s , %s != mat4(1.0) ? vec4(clamp((%s * vec4(_tmp0.xyz, 1.0)).xyz, 0.0, _tmp0.w), _tmp0.w) : _tmp0);\n", args.fOutputColor, args.fInputColor ? args.fInputColor : "vec4(1)", fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(), sk_TransformedCoords2D_0.c_str(), fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(), fColorSpaceHelper.isValid() ? args.fUniformHandler->getUniformCStr(fColorSpaceHelper.gamutXformUniform()) : "mat4(1.0)", fColorSpaceHelper.isValid() ? args.fUniformHandler->getUniformCStr(fColorSpaceHelper.gamutXformUniform()) : "mat4(1.0)");
+ fragBuilder->codeAppendf("%s = ", args.fOutputColor);
+ fragBuilder->appendTextureLookupAndModulate(args.fInputColor,
+ args.fTexSamplers[0],
+ args.fTransformedCoords[0].c_str(),
+ args.fTransformedCoords[0].getType(),
+ &fColorSpaceHelper);
+ fragBuilder->codeAppend(";");
}
-private:
- void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
- const GrSimpleTextureEffect& _outer = _proc.cast<GrSimpleTextureEffect>();
- {
- if (fColorSpaceHelper.isValid()) {
- fColorSpaceHelper.setData(pdman, _outer.colorXform().get());
- }
+
+ static inline void GenKey(const GrProcessor& effect, const GrShaderCaps&,
+ GrProcessorKeyBuilder* b) {
+ const GrSimpleTextureEffect& textureEffect = effect.cast<GrSimpleTextureEffect>();
+ b->add32(GrColorSpaceXform::XformKey(textureEffect.colorSpaceXform()));
+ }
+
+protected:
+ void onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrFragmentProcessor& processor) override {
+ const GrSimpleTextureEffect& textureEffect = processor.cast<GrSimpleTextureEffect>();
+ if (SkToBool(textureEffect.colorSpaceXform())) {
+ fColorSpaceHelper.setData(pdman, textureEffect.colorSpaceXform());
}
}
- UniformHandle fImageVar;
+
+private:
+ typedef GrGLSLFragmentProcessor INHERITED;
+
GrGLSLColorSpaceXformHelper fColorSpaceHelper;
};
-GrGLSLFragmentProcessor* GrSimpleTextureEffect::onCreateGLSLInstance() const {
- return new GrGLSLSimpleTextureEffect();
-}
-void GrSimpleTextureEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
- b->add32(GrColorSpaceXform::XformKey(fColorXform.get()));
+
+///////////////////////////////////////////////////////////////////////////////
+
+void GrSimpleTextureEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
+ GrProcessorKeyBuilder* b) const {
+ GrGLSimpleTextureEffect::GenKey(*this, caps, b);
}
-bool GrSimpleTextureEffect::onIsEqual(const GrFragmentProcessor& other) const {
- const GrSimpleTextureEffect& that = other.cast<GrSimpleTextureEffect>();
- (void) that;
- if (fImage != that.fImage) return false;
- if (fColorXform != that.fColorXform) return false;
- if (fMatrix != that.fMatrix) return false;
- return true;
+
+GrGLSLFragmentProcessor* GrSimpleTextureEffect::onCreateGLSLInstance() const {
+ return new GrGLSimpleTextureEffect;
}
+
+///////////////////////////////////////////////////////////////////////////////
+
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect);
-#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(GrProcessorTestData* testData) {
- int texIdx = testData->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
- : GrProcessorUnitTest::kAlphaTextureIdx;
+#if GR_TEST_UTILS
+sk_sp<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(GrProcessorTestData* d) {
+ int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
+ : GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
SkShader::kClamp_TileMode,
SkShader::kRepeat_TileMode,
SkShader::kMirror_TileMode,
};
SkShader::TileMode tileModes[] = {
- kTileModes[testData->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- kTileModes[testData->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
+ kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
+ kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
};
- GrSamplerParams params(tileModes, testData->fRandom->nextBool()
- ? GrSamplerParams::kBilerp_FilterMode
- : GrSamplerParams::kNone_FilterMode);
-
- const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
- sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(testData->fRandom);
- return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), std::move(colorSpaceXform),
- matrix);
+ GrSamplerParams params(tileModes, d->fRandom->nextBool() ? GrSamplerParams::kBilerp_FilterMode
+ : GrSamplerParams::kNone_FilterMode);
+
+ const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
+ sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(d->fRandom);
+ return GrSimpleTextureEffect::Make(d->textureProxy(texIdx),
+ std::move(colorSpaceXform), matrix);
}
#endif
-#endif
diff --git a/src/gpu/effects/GrSimpleTextureEffect.fp b/src/gpu/effects/GrSimpleTextureEffect.fp
deleted file mode 100644
index 20944447ce..0000000000
--- a/src/gpu/effects/GrSimpleTextureEffect.fp
+++ /dev/null
@@ -1,82 +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.
- */
-
-in uniform sampler2D image;
-in uniform colorSpaceXform colorXform;
-in mat4 matrix;
-
-@constructorParams {
- GrSamplerParams samplerParams
-}
-
-@coordTransform(image) {
- matrix
-}
-
-@samplerParams(image) {
- samplerParams
-}
-
-@make {
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix) {
- return sk_sp<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
- GrSamplerParams(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode)));
- }
-
- /* clamp mode */
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix,
- GrSamplerParams::FilterMode filterMode) {
- return sk_sp<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
- GrSamplerParams(SkShader::kClamp_TileMode, filterMode)));
- }
-
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix,
- const GrSamplerParams& p) {
- return sk_sp<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, p));
- }
-}
-
-@optimizationFlags {
- kCompatibleWithCoverageAsAlpha_OptimizationFlag |
- (GrPixelConfigIsOpaque(image->config()) ? kPreservesOpaqueInput_OptimizationFlag :
- kNone_OptimizationFlags)
-}
-
-void main() {
- sk_OutColor = sk_InColor * texture(image, sk_TransformedCoords2D[0], colorXform);
-}
-
-@test(testData) {
- int texIdx = testData->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
- : GrProcessorUnitTest::kAlphaTextureIdx;
- static const SkShader::TileMode kTileModes[] = {
- SkShader::kClamp_TileMode,
- SkShader::kRepeat_TileMode,
- SkShader::kMirror_TileMode,
- };
- SkShader::TileMode tileModes[] = {
- kTileModes[testData->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- kTileModes[testData->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- };
- GrSamplerParams params(tileModes, testData->fRandom->nextBool()
- ? GrSamplerParams::kBilerp_FilterMode
- : GrSamplerParams::kNone_FilterMode);
-
- const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
- sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(testData->fRandom);
- return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), std::move(colorSpaceXform),
- matrix);
-}
diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h
index aed91d7c10..5013e3dce8 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.h
+++ b/src/gpu/effects/GrSimpleTextureEffect.h
@@ -1,82 +1,77 @@
/*
- * Copyright 2017 Google Inc.
+ * Copyright 2013 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 GrSimpleTextureEffect.fp; do not modify.
- */
#ifndef GrSimpleTextureEffect_DEFINED
#define GrSimpleTextureEffect_DEFINED
-#include "SkTypes.h"
-#if SK_SUPPORT_GPU
-#include "GrFragmentProcessor.h"
-#include "GrCoordTransform.h"
-#include "GrColorSpaceXform.h"
-#include "effects/GrProxyMove.h"
-class GrSimpleTextureEffect : public GrFragmentProcessor {
-public:
- sk_sp<GrColorSpaceXform> colorXform() const { return fColorXform; }
- SkMatrix44 matrix() const { return fMatrix; }
+#include "GrSingleTextureEffect.h"
+#include "GrTextureProxy.h"
+
+class GrInvariantOutput;
+
+/**
+ * The output color of this effect is a modulation of the input color and a sample from a texture.
+ * It allows explicit specification of the filtering and wrap modes (GrSamplerParams) and accepts
+ * a matrix that is used to compute texture coordinates from local coordinates.
+ */
+class GrSimpleTextureEffect : public GrSingleTextureEffect {
+public:
+ /* unfiltered, clamp mode */
static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix) {
return sk_sp<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
- GrSamplerParams(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode)));
+ new GrSimpleTextureEffect(std::move(proxy),
+ std::move(colorSpaceXform), matrix,
+ GrSamplerParams::kNone_FilterMode));
}
-
+ /* clamp mode */
static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
GrSamplerParams::FilterMode filterMode) {
return sk_sp<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
- GrSamplerParams(SkShader::kClamp_TileMode, filterMode)));
- }
+ new GrSimpleTextureEffect(std::move(proxy),
+ std::move(colorSpaceXform),
+ matrix, filterMode));
+ }
static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
const GrSamplerParams& p) {
- return sk_sp<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, p));
+ return sk_sp<GrFragmentProcessor>(new GrSimpleTextureEffect(std::move(proxy),
+ std::move(colorSpaceXform),
+ matrix, p));
}
- const char* name() const override { return "SimpleTextureEffect"; }
+
+ ~GrSimpleTextureEffect() override {}
+
+ const char* name() const override { return "SimpleTexture"; }
+
private:
- GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, sk_sp<GrColorSpaceXform> colorXform, SkMatrix44 matrix,
- GrSamplerParams samplerParams
-)
- : INHERITED((OptimizationFlags)
- kCompatibleWithCoverageAsAlpha_OptimizationFlag |
- (GrPixelConfigIsOpaque(image->config()) ? kPreservesOpaqueInput_OptimizationFlag :
- kNone_OptimizationFlags)
-)
- , fImage(std::move(image),
- samplerParams
-)
- , fColorXform(colorXform)
- , fMatrix(matrix)
- , fImageCoordTransform(
- matrix
-, fImage.proxy()) {
- this->addTextureSampler(&fImage);
- this->addCoordTransform(&fImageCoordTransform);
- this->initClassID<GrSimpleTextureEffect>();
- }
+ GrSimpleTextureEffect(sk_sp<GrTextureProxy>,
+ sk_sp<GrColorSpaceXform>, const SkMatrix& matrix,
+ GrSamplerParams::FilterMode);
+
+ GrSimpleTextureEffect(sk_sp<GrTextureProxy>,
+ sk_sp<GrColorSpaceXform>, const SkMatrix& matrix,
+ const GrSamplerParams&);
+
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrShaderCaps&,GrProcessorKeyBuilder*) const override;
- bool onIsEqual(const GrFragmentProcessor&) const override;
+
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
+
+ bool onIsEqual(const GrFragmentProcessor& other) const override { return true; }
+
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
- TextureSampler fImage;
- sk_sp<GrColorSpaceXform> fColorXform;
- SkMatrix44 fMatrix;
- GrCoordTransform fImageCoordTransform;
- typedef GrFragmentProcessor INHERITED;
+
+ typedef GrSingleTextureEffect INHERITED;
};
-#endif
+
#endif