From 85ff25e8d905502ec09d057ecc6245f487bf94ce Mon Sep 17 00:00:00 2001 From: joshualitt Date: Wed, 8 Jul 2015 09:10:03 -0700 Subject: [PATCH] Thread GrShaderDataManager through Image filters TBR=bsalomon@google.com BUG=skia: Review URL: https://codereview.chromium.org/1229613002 --- include/core/SkImageFilter.h | 5 +++-- include/effects/SkMagnifierImageFilter.h | 8 ++++---- include/effects/SkMatrixConvolutionImageFilter.h | 8 ++++---- src/core/SkImageFilter.cpp | 10 +++++----- src/effects/SkAlphaThresholdFilter.cpp | 5 +++-- src/effects/SkMagnifierImageFilter.cpp | 5 +++-- src/effects/SkMatrixConvolutionImageFilter.cpp | 1 + 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h index 4125db3734..ea0bd22f1a 100644 --- a/include/core/SkImageFilter.h +++ b/include/core/SkImageFilter.h @@ -16,6 +16,7 @@ #include "SkTemplates.h" class GrFragmentProcessor; +class GrShaderDataManager; class GrTexture; class SkBaseDevice; class SkBitmap; @@ -340,8 +341,8 @@ protected: * will be called with (NULL, NULL, SkMatrix::I()) to query for support, * so returning "true" indicates support for all possible matrices. */ - virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, - const SkIRect& bounds) const; + virtual bool asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManager*, GrTexture*, + const SkMatrix&, const SkIRect& bounds) const; private: friend class SkGraphics; diff --git a/include/effects/SkMagnifierImageFilter.h b/include/effects/SkMagnifierImageFilter.h index 6df95b233a..4371456de3 100644 --- a/include/effects/SkMagnifierImageFilter.h +++ b/include/effects/SkMagnifierImageFilter.h @@ -23,11 +23,11 @@ protected: SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset, SkImageFilter* input); void flatten(SkWriteBuffer&) const override; - virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, - SkBitmap* result, SkIPoint* offset) const override; + bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, + SkBitmap* result, SkIPoint* offset) const override; #if SK_SUPPORT_GPU - virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, - const SkIRect& bounds) const override; + bool asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManager*, GrTexture*, + const SkMatrix&, const SkIRect& bounds) const override; #endif private: diff --git a/include/effects/SkMatrixConvolutionImageFilter.h b/include/effects/SkMatrixConvolutionImageFilter.h index 3bbfc4f09b..62c69357eb 100644 --- a/include/effects/SkMatrixConvolutionImageFilter.h +++ b/include/effects/SkMatrixConvolutionImageFilter.h @@ -77,14 +77,14 @@ protected: const CropRect* cropRect); void flatten(SkWriteBuffer&) const override; - virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, - SkBitmap* result, SkIPoint* loc) const override; + bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, + SkBitmap* result, SkIPoint* loc) const override; bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const override; #if SK_SUPPORT_GPU - virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, - const SkIRect& bounds) const override; + bool asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManager*, GrTexture*, + const SkMatrix&, const SkIRect& bounds) const override; #endif private: diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index 394d8b20e7..1586a3fb27 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -232,7 +232,7 @@ bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&, } bool SkImageFilter::canFilterImageGPU() const { - return this->asFragmentProcessor(NULL, NULL, SkMatrix::I(), SkIRect()); + return this->asFragmentProcessor(NULL, NULL, NULL, SkMatrix::I(), SkIRect()); } bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, @@ -275,9 +275,9 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont bounds.offset(-srcOffset); SkMatrix matrix(ctx.ctm()); matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top())); - if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) { + GrPaint paint; + if (this->asFragmentProcessor(&fp, paint.getShaderDataManager(), srcTexture, matrix, bounds)) { SkASSERT(fp); - GrPaint paint; paint.addColorProcessor(fp)->unref(); GrDrawContext* drawContext = context->drawContext(); @@ -374,8 +374,8 @@ bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, return true; } -bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, - const SkIRect&) const { +bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManager*, GrTexture*, + const SkMatrix&, const SkIRect&) const { return false; } diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index 82f6ea43bb..774092c2df 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -28,8 +28,8 @@ protected: bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* offset) const override; #if SK_SUPPORT_GPU - bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, - const SkIRect& bounds) const override; + bool asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManager*, GrTexture*, + const SkMatrix&, const SkIRect& bounds) const override; #endif private: @@ -265,6 +265,7 @@ SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region, #if SK_SUPPORT_GPU bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp, + GrShaderDataManager*, GrTexture* texture, const SkMatrix& in_matrix, const SkIRect&) const { diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index 542a5a9569..96d04e2786 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -276,8 +276,9 @@ SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i } #if SK_SUPPORT_GPU -bool SkMagnifierImageFilter::asFragmentProcessor(GrFragmentProcessor** fp, GrTexture* texture, - const SkMatrix&, const SkIRect&bounds) const { +bool SkMagnifierImageFilter::asFragmentProcessor(GrFragmentProcessor** fp, GrShaderDataManager*, + GrTexture* texture, const SkMatrix&, + const SkIRect&bounds) const { if (fp) { SkScalar yOffset = texture->origin() == kTopLeft_GrSurfaceOrigin ? fSrcRect.y() : texture->height() - fSrcRect.height() * texture->height() / bounds.height() diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp index 4cba043e99..8855e3c6fe 100644 --- a/src/effects/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/SkMatrixConvolutionImageFilter.cpp @@ -348,6 +348,7 @@ static GrTextureDomain::Mode convert_tilemodes( } bool SkMatrixConvolutionImageFilter::asFragmentProcessor(GrFragmentProcessor** fp, + GrShaderDataManager*, GrTexture* texture, const SkMatrix&, const SkIRect& bounds) const {