diff options
author | Robert Phillips <robertphillips@google.com> | 2017-01-24 16:24:41 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-24 22:03:40 +0000 |
commit | 901f29ad3e38b7072a2abef5ff1665cd755d21a2 (patch) | |
tree | 8b231c4cf579b0c591014c5287790b40d38e8868 /src/gpu | |
parent | c8c901fc36816b9a2603a8c129cdca1d2b4d7fe2 (diff) |
Allow GrSingleTextureEffect to take GrTextureProxies
Change-Id: I1dd441a5838f665c6815a5c629f5763f43f66e09
Reviewed-on: https://skia-review.googlesource.com/7429
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrPaint.cpp | 31 | ||||
-rw-r--r-- | src/gpu/GrProcessor.cpp | 10 | ||||
-rw-r--r-- | src/gpu/effects/GrSimpleTextureEffect.h | 44 | ||||
-rw-r--r-- | src/gpu/effects/GrSingleTextureEffect.cpp | 35 | ||||
-rw-r--r-- | src/gpu/effects/GrSingleTextureEffect.h | 12 |
5 files changed, 131 insertions, 1 deletions
diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp index 5bcd28a69e..c68b4b1089 100644 --- a/src/gpu/GrPaint.cpp +++ b/src/gpu/GrPaint.cpp @@ -44,6 +44,37 @@ void GrPaint::addCoverageTextureProcessor(GrTexture* texture, params)); } +void GrPaint::addColorTextureProcessor(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& matrix) { + this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(ctx, std::move(proxy), + std::move(colorSpaceXform), + matrix)); +} + +void GrPaint::addColorTextureProcessor(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& matrix, + const GrSamplerParams& params) { + this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(ctx, + std::move(proxy), + std::move(colorSpaceXform), + matrix, params)); +} + +void GrPaint::addCoverageTextureProcessor(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + const SkMatrix& matrix) { + this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(ctx, std::move(proxy), + nullptr, matrix)); +} + +void GrPaint::addCoverageTextureProcessor(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + const SkMatrix& matrix, + const GrSamplerParams& params) { + this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(ctx, std::move(proxy), + nullptr, matrix, params)); +} + bool GrPaint::internalIsConstantBlendedColor(GrColor paintColor, GrColor* color) const { GrProcOptInfo colorProcInfo(paintColor, kRGBA_GrColorComponentFlags); colorProcInfo.analyzeProcessors( diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp index 3e1346482f..56d3e7f1a4 100644 --- a/src/gpu/GrProcessor.cpp +++ b/src/gpu/GrProcessor.cpp @@ -210,12 +210,20 @@ GrProcessor::TextureSampler::TextureSampler(GrTexture* texture, GrProcessor::TextureSampler::TextureSampler(GrTextureProvider* texProvider, sk_sp<GrTextureProxy> proxy, + const GrSamplerParams& params) { + // For now, end the deferral at this time. Once all the TextureSamplers are swapped over + // to taking a GrSurfaceProxy just use the IORefs on the proxy + this->reset(proxy->instantiate(texProvider), params); +} + +GrProcessor::TextureSampler::TextureSampler(GrTextureProvider* texProvider, + sk_sp<GrTextureProxy> proxy, GrSamplerParams::FilterMode filterMode, SkShader::TileMode tileXAndY, GrShaderFlags visibility) { // For now, end the deferral at this time. Once all the TextureSamplers are swapped over // to taking a GrSurfaceProxy just use the IORefs on the proxy - this->reset( proxy->instantiate(texProvider), filterMode, tileXAndY, visibility); + this->reset(proxy->instantiate(texProvider), filterMode, tileXAndY, visibility); } void GrProcessor::TextureSampler::reset(GrTexture* texture, diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h index 90f39acba0..bf013e9c83 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.h +++ b/src/gpu/effects/GrSimpleTextureEffect.h @@ -9,6 +9,7 @@ #define GrSimpleTextureEffect_DEFINED #include "GrSingleTextureEffect.h" +#include "GrTextureProxy.h" class GrInvariantOutput; @@ -28,6 +29,14 @@ public: GrSamplerParams::kNone_FilterMode)); } + static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& matrix) { + return sk_sp<GrFragmentProcessor>( + new GrSimpleTextureEffect(ctx, std::move(proxy), std::move(colorSpaceXform), matrix, + GrSamplerParams::kNone_FilterMode)); + } + /* clamp mode */ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, sk_sp<GrColorSpaceXform> colorSpaceXform, @@ -37,6 +46,15 @@ public: new GrSimpleTextureEffect(tex, std::move(colorSpaceXform), matrix, filterMode)); } + static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& matrix, + GrSamplerParams::FilterMode filterMode) { + return sk_sp<GrFragmentProcessor>( + new GrSimpleTextureEffect(ctx, std::move(proxy), std::move(colorSpaceXform), + matrix, filterMode)); + } + static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, sk_sp<GrColorSpaceXform> colorSpaceXform, const SkMatrix& matrix, @@ -45,6 +63,15 @@ public: matrix, p)); } + static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& matrix, + const GrSamplerParams& p) { + return sk_sp<GrFragmentProcessor>(new GrSimpleTextureEffect(ctx, std::move(proxy), + std::move(colorSpaceXform), + matrix, p)); + } + virtual ~GrSimpleTextureEffect() {} const char* name() const override { return "SimpleTexture"; } @@ -58,6 +85,15 @@ private: this->initClassID<GrSimpleTextureEffect>(); } + GrSimpleTextureEffect(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& matrix, + GrSamplerParams::FilterMode filterMode) + : GrSingleTextureEffect(ctx, std::move(proxy), std::move(colorSpaceXform), + matrix, filterMode) { + this->initClassID<GrSimpleTextureEffect>(); + } + GrSimpleTextureEffect(GrTexture* texture, sk_sp<GrColorSpaceXform> colorSpaceXform, const SkMatrix& matrix, @@ -66,6 +102,14 @@ private: this->initClassID<GrSimpleTextureEffect>(); } + GrSimpleTextureEffect(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& matrix, + const GrSamplerParams& params) + : GrSingleTextureEffect(ctx, std::move(proxy), std::move(colorSpaceXform), matrix, params) { + this->initClassID<GrSimpleTextureEffect>(); + } + GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp index 425e367178..c493920d3d 100644 --- a/src/gpu/effects/GrSingleTextureEffect.cpp +++ b/src/gpu/effects/GrSingleTextureEffect.cpp @@ -7,6 +7,9 @@ #include "effects/GrSingleTextureEffect.h" +#include "GrContext.h" +#include "GrTextureProxy.h" + GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, sk_sp<GrColorSpaceXform> colorSpaceXform, const SkMatrix& m) @@ -39,5 +42,37 @@ GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, this->addTextureSampler(&fTextureSampler); } +GrSingleTextureEffect::GrSingleTextureEffect(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& m) + : fCoordTransform(ctx, m, proxy.get(), GrSamplerParams::kNone_FilterMode) + , fTextureSampler(ctx->textureProvider(), std::move(proxy)) + , fColorSpaceXform(std::move(colorSpaceXform)) { + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); +} + +GrSingleTextureEffect::GrSingleTextureEffect(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& m, + GrSamplerParams::FilterMode filterMode) + : fCoordTransform(ctx, m, proxy.get(), filterMode) + , fTextureSampler(ctx->textureProvider(), std::move(proxy), filterMode) + , fColorSpaceXform(std::move(colorSpaceXform)) { + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); +} + +GrSingleTextureEffect::GrSingleTextureEffect(GrContext* ctx, sk_sp<GrTextureProxy> proxy, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& m, + const GrSamplerParams& params) + : fCoordTransform(ctx, m, proxy.get(), params.filterMode()) + , fTextureSampler(ctx->textureProvider(), std::move(proxy), params) + , fColorSpaceXform(std::move(colorSpaceXform)) { + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); +} + GrSingleTextureEffect::~GrSingleTextureEffect() { } diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h index 716ad2f294..1d0f27a4ff 100644 --- a/src/gpu/effects/GrSingleTextureEffect.h +++ b/src/gpu/effects/GrSingleTextureEffect.h @@ -15,6 +15,7 @@ #include "SkMatrix.h" class GrTexture; +class GrTextureProxy; /** * A base class for effects that draw a single texture with a texture matrix. This effect has no @@ -43,6 +44,17 @@ protected: const SkMatrix&, const GrSamplerParams&); + /** unfiltered, clamp mode */ + GrSingleTextureEffect(GrContext*, + sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>, const SkMatrix&); + /** clamp mode */ + GrSingleTextureEffect(GrContext*, + sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>, const SkMatrix&, + GrSamplerParams::FilterMode filterMode); + GrSingleTextureEffect(GrContext*, + sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>, const SkMatrix&, + const GrSamplerParams&); + /** * Can be used as a helper to implement subclass onComputeInvariantOutput(). It assumes that * the subclass output color will be a modulation of the input color with a value read from the |