diff options
author | robertphillips <robertphillips@google.com> | 2015-05-26 11:38:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-26 11:38:03 -0700 |
commit | ea4615034498aca2f9ca1753fb9a1ef10508d8cc (patch) | |
tree | 22f0027849de0dd18b199fb13c6c28be812cf229 /src/effects | |
parent | 884e97cb04db7ed053a866567ee9c6e4c01f993a (diff) |
Split drawing functionality out of GrContext and into new GrDrawContext
This is mainly a mechanical CL. There were some fiddly bits in GrContext.cpp where it no longer had access to the GrDrawTarget (and had to use the new GrDrawContext).
I've converted GrAARectRenderer & GrOvalRenderer into static classes so I could stop allocating them.
Review URL: https://codereview.chromium.org/1151283004
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkAlphaThresholdFilter.cpp | 12 | ||||
-rw-r--r-- | src/effects/SkBlurMaskFilter.cpp | 32 | ||||
-rw-r--r-- | src/effects/SkDisplacementMapEffect.cpp | 11 | ||||
-rw-r--r-- | src/effects/SkGpuBlurUtils.cpp | 48 | ||||
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 34 | ||||
-rw-r--r-- | src/effects/SkMorphologyImageFilter.cpp | 34 | ||||
-rw-r--r-- | src/effects/SkXfermodeImageFilter.cpp | 10 |
7 files changed, 120 insertions, 61 deletions
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index d4638779a4..395408c23e 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -10,6 +10,9 @@ #include "SkReadBuffer.h" #include "SkWriteBuffer.h" #include "SkRegion.h" +#if SK_SUPPORT_GPU +#include "GrDrawContext.h" +#endif class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter { public: @@ -284,16 +287,17 @@ bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp, return false; } - { + GrDrawContext* drawContext = context->drawContext(); + if (drawContext) { GrPaint grPaint; grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); SkRegion::Iterator iter(fRegion); - context->clear(NULL, 0x0, true, maskTexture->asRenderTarget()); + drawContext->clear(maskTexture->asRenderTarget(), NULL, 0x0, true); while (!iter.done()) { SkRect rect = SkRect::Make(iter.rect()); - context->drawRect(maskTexture->asRenderTarget(), GrClip::WideOpen(), grPaint, - in_matrix, rect); + drawContext->drawRect(maskTexture->asRenderTarget(), GrClip::WideOpen(), grPaint, + in_matrix, rect); iter.next(); } } diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 556cb4469d..22a9ac62a2 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -19,6 +19,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" +#include "GrDrawContext.h" #include "GrTexture.h" #include "GrFragmentProcessor.h" #include "GrInvariantOutput.h" @@ -870,8 +871,14 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context, if (!viewMatrix.invert(&inverse)) { return false; } - context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse); - return true; + + GrDrawContext* drawContext = context->drawContext(); + if (drawContext) { + drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse); + return true; + } + + return false; } class GrRRectBlurEffect : public GrFragmentProcessor { @@ -1154,8 +1161,15 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context, if (!viewMatrix.invert(&inverse)) { return false; } - context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), proxy_rect, inverse); - return true; + + GrDrawContext* drawContext = context->drawContext(); + if (drawContext) { + drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), + proxy_rect, inverse); + return true; + } + + return false; } bool SkBlurMaskFilterImpl::canFilterMaskGPU(const SkRect& srcBounds, @@ -1236,8 +1250,14 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src, // = 0 * src + (1 - src) * dst paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op); } - context->drawRect((*result)->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(), - clipRect); + + GrDrawContext* drawContext = context->drawContext(); + if (!drawContext) { + return false; + } + + drawContext->drawRect((*result)->asRenderTarget(), GrClip::WideOpen(), + paint, SkMatrix::I(), clipRect); } return true; diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index 23202e2c3f..d7d92c82b9 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -12,6 +12,7 @@ #include "SkColorPriv.h" #if SK_SUPPORT_GPU #include "GrContext.h" +#include "GrDrawContext.h" #include "GrCoordTransform.h" #include "GrInvariantOutput.h" #include "effects/GrTextureDomain.h" @@ -457,8 +458,14 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkMatrix matrix; matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y())); - context->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, matrix, - SkRect::Make(colorBounds)); + + GrDrawContext* drawContext = context->drawContext(); + if (!drawContext) { + return false; + } + + drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, matrix, + SkRect::Make(colorBounds)); offset->fX = bounds.left(); offset->fY = bounds.top(); WrapTexture(dst, bounds.width(), bounds.height(), result); diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp index 6cb349e136..4997afe22f 100644 --- a/src/effects/SkGpuBlurUtils.cpp +++ b/src/effects/SkGpuBlurUtils.cpp @@ -13,6 +13,7 @@ #include "effects/GrConvolutionEffect.h" #include "effects/GrMatrixConvolutionEffect.h" #include "GrContext.h" +#include "GrDrawContext.h" #endif namespace SkGpuBlurUtils { @@ -43,7 +44,7 @@ static float adjust_sigma(float sigma, int maxTextureSize, int *scaleFactor, int return sigma; } -static void convolve_gaussian_1d(GrContext* context, +static void convolve_gaussian_1d(GrDrawContext* drawContext, GrRenderTarget* rt, const GrClip& clip, const SkRect& srcRect, @@ -58,10 +59,10 @@ static void convolve_gaussian_1d(GrContext* context, SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian( texture, direction, radius, sigma, useBounds, bounds)); paint.addColorProcessor(conv); - context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect); + drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect); } -static void convolve_gaussian_2d(GrContext* context, +static void convolve_gaussian_2d(GrDrawContext* drawContext, GrRenderTarget* rt, const GrClip& clip, const SkRect& srcRect, @@ -81,10 +82,10 @@ static void convolve_gaussian_2d(GrContext* context, useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_Mode, true, sigmaX, sigmaY)); paint.addColorProcessor(conv); - context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect); + drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect); } -static void convolve_gaussian(GrContext* context, +static void convolve_gaussian(GrDrawContext* drawContext, GrRenderTarget* rt, const GrClip& clip, const SkRect& srcRect, @@ -96,7 +97,7 @@ static void convolve_gaussian(GrContext* context, bool cropToSrcRect) { float bounds[2] = { 0.0f, 1.0f }; if (!cropToSrcRect) { - convolve_gaussian_1d(context, rt, clip, srcRect, dstRect, texture, + convolve_gaussian_1d(drawContext, rt, clip, srcRect, dstRect, texture, direction, radius, sigma, false, bounds); return; } @@ -128,15 +129,15 @@ static void convolve_gaussian(GrContext* context, } if (radius >= size * SK_ScalarHalf) { // Blur radius covers srcRect; use bounds over entire draw - convolve_gaussian_1d(context, rt, clip, srcRect, dstRect, texture, + convolve_gaussian_1d(drawContext, rt, clip, srcRect, dstRect, texture, direction, radius, sigma, true, bounds); } else { // Draw upper and lower margins with bounds; middle without. - convolve_gaussian_1d(context, rt, clip, lowerSrcRect, lowerDstRect, texture, + convolve_gaussian_1d(drawContext, rt, clip, lowerSrcRect, lowerDstRect, texture, direction, radius, sigma, true, bounds); - convolve_gaussian_1d(context, rt, clip, upperSrcRect, upperDstRect, texture, + convolve_gaussian_1d(drawContext, rt, clip, upperSrcRect, upperDstRect, texture, direction, radius, sigma, true, bounds); - convolve_gaussian_1d(context, rt, clip, middleSrcRect, middleDstRect, texture, + convolve_gaussian_1d(drawContext, rt, clip, middleSrcRect, middleDstRect, texture, direction, radius, sigma, false, bounds); } } @@ -195,6 +196,11 @@ GrTexture* GaussianBlur(GrContext* context, return NULL; } + GrDrawContext* drawContext = context->drawContext(); + if (!drawContext) { + return NULL; + } + for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) { GrPaint paint; SkMatrix matrix; @@ -219,8 +225,8 @@ GrTexture* GaussianBlur(GrContext* context, } scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, i < scaleFactorY ? 0.5f : 1.0f); - context->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint, SkMatrix::I(), - dstRect, srcRect); + drawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint, SkMatrix::I(), + dstRect, srcRect); srcRect = dstRect; srcTexture = dstTexture; SkTSwap(dstTexture, tempTexture); @@ -235,7 +241,7 @@ GrTexture* GaussianBlur(GrContext* context, // We shouldn't be scaling because this is a small size blur SkASSERT((scaleFactorX == scaleFactorY) == 1); SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); - convolve_gaussian_2d(context, dstTexture->asRenderTarget(), clip, srcRect, dstRect, + convolve_gaussian_2d(drawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect, srcTexture, radiusX, radiusY, sigmaX, sigmaY, cropToRect, srcIRect); srcTexture = dstTexture; srcRect = dstRect; @@ -248,10 +254,10 @@ GrTexture* GaussianBlur(GrContext* context, // X convolution from reading garbage. clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop, radiusX, srcIRect.height()); - context->clear(&clearRect, 0x0, false, srcTexture->asRenderTarget()); + drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false); } SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); - convolve_gaussian(context, dstTexture->asRenderTarget(), clip, srcRect, dstRect, + convolve_gaussian(drawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect, srcTexture, Gr1DKernelEffect::kX_Direction, radiusX, sigmaX, cropToRect); srcTexture = dstTexture; @@ -265,11 +271,11 @@ GrTexture* GaussianBlur(GrContext* context, // convolution from reading garbage. clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom, srcIRect.width(), radiusY); - context->clear(&clearRect, 0x0, false, srcTexture->asRenderTarget()); + drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false); } SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); - convolve_gaussian(context, dstTexture->asRenderTarget(), clip, srcRect, + convolve_gaussian(drawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect, srcTexture, Gr1DKernelEffect::kY_Direction, radiusY, sigmaY, cropToRect); srcTexture = dstTexture; @@ -283,10 +289,10 @@ GrTexture* GaussianBlur(GrContext* context, // upsampling. clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom, srcIRect.width() + 1, 1); - context->clear(&clearRect, 0x0, false, srcTexture->asRenderTarget()); + drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false); clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop, 1, srcIRect.height()); - context->clear(&clearRect, 0x0, false, srcTexture->asRenderTarget()); + drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false); SkMatrix matrix; matrix.setIDiv(srcTexture->width(), srcTexture->height()); @@ -297,8 +303,8 @@ GrTexture* GaussianBlur(GrContext* context, SkRect dstRect(srcRect); scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY); - context->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint, - SkMatrix::I(), dstRect, srcRect); + drawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint, + SkMatrix::I(), dstRect, srcRect); srcRect = dstRect; srcTexture = dstTexture; SkTSwap(dstTexture, tempTexture); diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index d281da400b..9d7ce95b07 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -15,6 +15,7 @@ #include "SkTypes.h" #if SK_SUPPORT_GPU +#include "GrDrawContext.h" #include "GrFragmentProcessor.h" #include "GrInvariantOutput.h" #include "effects/GrSingleTextureEffect.h" @@ -310,7 +311,7 @@ protected: #endif private: #if SK_SUPPORT_GPU - void drawRect(GrContext* context, + void drawRect(GrDrawContext* drawContext, GrTexture* src, GrTexture* dst, const SkMatrix& matrix, @@ -323,7 +324,7 @@ private: }; #if SK_SUPPORT_GPU -void SkLightingImageFilterInternal::drawRect(GrContext* context, +void SkLightingImageFilterInternal::drawRect(GrDrawContext* drawContext, GrTexture* src, GrTexture* dst, const SkMatrix& matrix, @@ -335,8 +336,8 @@ void SkLightingImageFilterInternal::drawRect(GrContext* context, GrFragmentProcessor* fp = this->getFragmentProcessor(src, matrix, bounds, boundaryMode); GrPaint paint; paint.addColorProcessor(fp)->unref(); - context->drawNonAARectToRect(dst->asRenderTarget(), clip, paint, SkMatrix::I(), - dstRect, srcRect); + drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint, SkMatrix::I(), + dstRect, srcRect); } bool SkLightingImageFilterInternal::filterImageGPU(Proxy* proxy, @@ -388,19 +389,26 @@ bool SkLightingImageFilterInternal::filterImageGPU(Proxy* proxy, SkRect bottomLeft = SkRect::MakeXYWH(0, dstRect.height() - 1, 1, 1); SkRect bottom = SkRect::MakeXYWH(1, dstRect.height() - 1, dstRect.width() - 2, 1); SkRect bottomRight = SkRect::MakeXYWH(dstRect.width() - 1, dstRect.height() - 1, 1, 1); - this->drawRect(context, srcTexture, dst, matrix, clip, topLeft, kTopLeft_BoundaryMode, bounds); - this->drawRect(context, srcTexture, dst, matrix, clip, top, kTop_BoundaryMode, bounds); - this->drawRect(context, srcTexture, dst, matrix, clip, topRight, kTopRight_BoundaryMode, + + GrDrawContext* drawContext = context->drawContext(); + if (!drawContext) { + return false; + } + + this->drawRect(drawContext, srcTexture, dst, matrix, clip, topLeft, kTopLeft_BoundaryMode, bounds); - this->drawRect(context, srcTexture, dst, matrix, clip, left, kLeft_BoundaryMode, bounds); - this->drawRect(context, srcTexture, dst, matrix, clip, interior, kInterior_BoundaryMode, + this->drawRect(drawContext, srcTexture, dst, matrix, clip, top, kTop_BoundaryMode, bounds); + this->drawRect(drawContext, srcTexture, dst, matrix, clip, topRight, kTopRight_BoundaryMode, bounds); - this->drawRect(context, srcTexture, dst, matrix, clip, right, kRight_BoundaryMode, bounds); - this->drawRect(context, srcTexture, dst, matrix, clip, bottomLeft, kBottomLeft_BoundaryMode, + this->drawRect(drawContext, srcTexture, dst, matrix, clip, left, kLeft_BoundaryMode, bounds); + this->drawRect(drawContext, srcTexture, dst, matrix, clip, interior, kInterior_BoundaryMode, bounds); - this->drawRect(context, srcTexture, dst, matrix, clip, bottom, kBottom_BoundaryMode, bounds); - this->drawRect(context, srcTexture, dst, matrix, clip, bottomRight, kBottomRight_BoundaryMode, + this->drawRect(drawContext, srcTexture, dst, matrix, clip, right, kRight_BoundaryMode, bounds); + this->drawRect(drawContext, srcTexture, dst, matrix, clip, bottomLeft, kBottomLeft_BoundaryMode, bounds); + this->drawRect(drawContext, srcTexture, dst, matrix, clip, bottom, kBottom_BoundaryMode, bounds); + this->drawRect(drawContext, srcTexture, dst, matrix, clip, bottomRight, + kBottomRight_BoundaryMode, bounds); WrapTexture(dst, bounds.width(), bounds.height(), result); return true; } diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index f4bcaf42c0..5eccb0db23 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -14,6 +14,7 @@ #include "SkMorphology_opts.h" #if SK_SUPPORT_GPU #include "GrContext.h" +#include "GrDrawContext.h" #include "GrInvariantOutput.h" #include "GrTexture.h" #include "effects/Gr1DKernelEffect.h" @@ -560,7 +561,7 @@ GrFragmentProcessor* GrMorphologyEffect::TestCreate(SkRandom* random, namespace { -void apply_morphology_rect(GrContext* context, +void apply_morphology_rect(GrDrawContext* drawContext, GrRenderTarget* rt, const GrClip& clip, GrTexture* texture, @@ -576,11 +577,11 @@ void apply_morphology_rect(GrContext* context, radius, morphType, bounds))->unref(); - context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect), - SkRect::Make(srcRect)); + drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect), + SkRect::Make(srcRect)); } -void apply_morphology_rect_no_bounds(GrContext* context, +void apply_morphology_rect_no_bounds(GrDrawContext* drawContext, GrRenderTarget* rt, const GrClip& clip, GrTexture* texture, @@ -594,11 +595,11 @@ void apply_morphology_rect_no_bounds(GrContext* context, direction, radius, morphType))->unref(); - context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect), - SkRect::Make(srcRect)); + drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect), + SkRect::Make(srcRect)); } -void apply_morphology_pass(GrContext* context, +void apply_morphology_pass(GrDrawContext* drawContext, GrRenderTarget* rt, const GrClip& clip, GrTexture* texture, @@ -632,15 +633,15 @@ void apply_morphology_pass(GrContext* context, } if (middleSrcRect.fLeft - middleSrcRect.fRight >= 0) { // radius covers srcRect; use bounds over entire draw - apply_morphology_rect(context, rt, clip, texture, srcRect, dstRect, radius, + apply_morphology_rect(drawContext, rt, clip, texture, srcRect, dstRect, radius, morphType, bounds, direction); } else { // Draw upper and lower margins with bounds; middle without. - apply_morphology_rect(context, rt, clip, texture, lowerSrcRect, lowerDstRect, radius, + apply_morphology_rect(drawContext, rt, clip, texture, lowerSrcRect, lowerDstRect, radius, morphType, bounds, direction); - apply_morphology_rect(context, rt, clip, texture, upperSrcRect, upperDstRect, radius, + apply_morphology_rect(drawContext, rt, clip, texture, upperSrcRect, upperDstRect, radius, morphType, bounds, direction); - apply_morphology_rect_no_bounds(context, rt, clip, texture, middleSrcRect, middleDstRect, + apply_morphology_rect_no_bounds(drawContext, rt, clip, texture, middleSrcRect, middleDstRect, radius, morphType, direction); } } @@ -666,13 +667,18 @@ bool apply_morphology(const SkBitmap& input, desc.fConfig = kSkia8888_GrPixelConfig; SkIRect srcRect = rect; + GrDrawContext* drawContext = context->drawContext(); + if (!drawContext) { + return false; + } + if (radius.fWidth > 0) { GrTexture* texture = context->textureProvider()->refScratchTexture( desc, GrTextureProvider::kApprox_ScratchTexMatch); if (NULL == texture) { return false; } - apply_morphology_pass(context, texture->asRenderTarget(), clip, srcTexture, + apply_morphology_pass(drawContext, texture->asRenderTarget(), clip, srcTexture, srcRect, dstRect, radius.fWidth, morphType, Gr1DKernelEffect::kX_Direction); SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, @@ -680,7 +686,7 @@ bool apply_morphology(const SkBitmap& input, GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ? SK_ColorWHITE : SK_ColorTRANSPARENT; - context->clear(&clearRect, clearColor, false, texture->asRenderTarget()); + drawContext->clear(texture->asRenderTarget(), &clearRect, clearColor, false); srcTexture.reset(texture); srcRect = dstRect; } @@ -690,7 +696,7 @@ bool apply_morphology(const SkBitmap& input, if (NULL == texture) { return false; } - apply_morphology_pass(context, texture->asRenderTarget(), clip, srcTexture, + apply_morphology_pass(drawContext, texture->asRenderTarget(), clip, srcTexture, srcRect, dstRect, radius.fHeight, morphType, Gr1DKernelEffect::kY_Direction); srcTexture.reset(texture); diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index 76c46295a4..f98247a2f4 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -14,6 +14,7 @@ #include "SkXfermode.h" #if SK_SUPPORT_GPU #include "GrContext.h" +#include "GrDrawContext.h" #include "effects/GrTextureDomain.h" #include "SkGr.h" #endif @@ -178,7 +179,14 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, paint.addColorProcessor(foregroundDomain.get()); paint.addColorProcessor(xferProcessor)->unref(); - context->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(), srcRect); + + GrDrawContext* drawContext = context->drawContext(); + if (!drawContext) { + return false; + } + + drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, + SkMatrix::I(), srcRect); offset->fX = backgroundOffset.fX; offset->fY = backgroundOffset.fY; |