aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-07-22 11:54:44 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-22 11:54:44 -0700
commitff0ca5ed825d9106edc2df6ab3865e1c17c326bf (patch)
tree43c617a6914e3255d77242cd0142b4609d68994d /src
parent425535f1626932e4e22f61a2571f9c3c2b1c5977 (diff)
Misc cleanup
This is split off of https://codereview.chromium.org/1225923010/ (Start tightening correspondence betweeen GrDrawContext and GrRenderTarget). It: fixes some style nits replaces some passing of GrContext with GrTextureProvider & GrDrawContext does a bit of the finer grained creation of GrDrawContexts Review URL: https://codereview.chromium.org/1245183002
Diffstat (limited to 'src')
-rw-r--r--src/core/SkMaskFilter.cpp6
-rw-r--r--src/effects/SkBlurImageFilter.cpp12
-rw-r--r--src/effects/SkBlurMaskFilter.cpp125
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp22
-rw-r--r--src/effects/SkGpuBlurUtils.cpp89
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp53
-rw-r--r--src/effects/SkXfermodeImageFilter.cpp18
-rw-r--r--src/gpu/GrBlurUtils.cpp4
-rw-r--r--src/gpu/SkGpuDevice.cpp3
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp62
10 files changed, 235 insertions, 159 deletions
diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp
index 5e20c151f6..bb700cd4b9 100644
--- a/src/core/SkMaskFilter.cpp
+++ b/src/core/SkMaskFilter.cpp
@@ -315,7 +315,8 @@ bool SkMaskFilter::canFilterMaskGPU(const SkRect& devBounds,
return false;
}
- bool SkMaskFilter::directFilterMaskGPU(GrContext* context,
+ bool SkMaskFilter::directFilterMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
@@ -326,7 +327,8 @@ bool SkMaskFilter::canFilterMaskGPU(const SkRect& devBounds,
}
-bool SkMaskFilter::directFilterRRectMaskGPU(GrContext* context,
+bool SkMaskFilter::directFilterRRectMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
index 38d3d9d12d..17f8d3a337 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -149,7 +149,8 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
SkBitmap* dst, SkIPoint* offset) const {
SkBitmap src = source;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
+ if (this->getInput(0) &&
+ !this->getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
return false;
}
@@ -231,8 +232,8 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
void SkBlurImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (getInput(0)) {
- getInput(0)->computeFastBounds(src, dst);
+ if (this->getInput(0)) {
+ this->getInput(0)->computeFastBounds(src, dst);
} else {
*dst = src;
}
@@ -247,7 +248,7 @@ bool SkBlurImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
SkVector sigma = mapSigma(fSigma, ctm);
bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
- if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) {
+ if (this->getInput(0) && !this->getInput(0)->filterBounds(bounds, ctm, &bounds)) {
return false;
}
*dst = bounds;
@@ -259,7 +260,8 @@ bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
#if SK_SUPPORT_GPU
SkBitmap input = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
+ if (this->getInput(0) &&
+ !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
return false;
}
SkIRect rect;
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 402641c980..5ae03e4a2f 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -40,34 +40,35 @@ public:
// overrides from SkMaskFilter
SkMask::Format getFormat() const override;
- virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
- SkIPoint* margin) const override;
+ bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
+ SkIPoint* margin) const override;
#if SK_SUPPORT_GPU
- virtual bool canFilterMaskGPU(const SkRect& devBounds,
- const SkIRect& clipBounds,
- const SkMatrix& ctm,
- SkRect* maskRect) const override;
- virtual bool directFilterMaskGPU(GrContext* context,
- GrRenderTarget* rt,
- GrPaint* grp,
- const GrClip&,
- const SkMatrix& viewMatrix,
- const SkStrokeRec& strokeRec,
- const SkPath& path) const override;
- virtual bool directFilterRRectMaskGPU(GrContext* context,
- GrRenderTarget* rt,
- GrPaint* grp,
- const GrClip&,
- const SkMatrix& viewMatrix,
- const SkStrokeRec& strokeRec,
- const SkRRect& rrect) const override;
-
- virtual bool filterMaskGPU(GrTexture* src,
- const SkMatrix& ctm,
- const SkRect& maskRect,
- GrTexture** result,
- bool canOverwriteSrc) const override;
+ bool canFilterMaskGPU(const SkRect& devBounds,
+ const SkIRect& clipBounds,
+ const SkMatrix& ctm,
+ SkRect* maskRect) const override;
+ bool directFilterMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
+ GrRenderTarget* rt,
+ GrPaint* grp,
+ const GrClip&,
+ const SkMatrix& viewMatrix,
+ const SkStrokeRec& strokeRec,
+ const SkPath& path) const override;
+ bool directFilterRRectMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
+ GrRenderTarget* rt,
+ GrPaint* grp,
+ const GrClip&,
+ const SkMatrix& viewMatrix,
+ const SkStrokeRec& strokeRec,
+ const SkRRect& rrect) const override;
+ bool filterMaskGPU(GrTexture* src,
+ const SkMatrix& ctm,
+ const SkRect& maskRect,
+ GrTexture** result,
+ bool canOverwriteSrc) const override;
#endif
void computeFastBounds(const SkRect&, SkRect*) const override;
@@ -77,13 +78,13 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl)
protected:
- virtual FilterReturn filterRectsToNine(const SkRect[], int count, const SkMatrix&,
- const SkIRect& clipBounds,
- NinePatch*) const override;
+ FilterReturn filterRectsToNine(const SkRect[], int count, const SkMatrix&,
+ const SkIRect& clipBounds,
+ NinePatch*) const override;
- virtual FilterReturn filterRRectToNine(const SkRRect&, const SkMatrix&,
- const SkIRect& clipBounds,
- NinePatch*) const override;
+ FilterReturn filterRRectToNine(const SkRRect&, const SkMatrix&,
+ const SkIRect& clipBounds,
+ NinePatch*) const override;
bool filterRectMask(SkMask* dstM, const SkRect& r, const SkMatrix& matrix,
SkIPoint* margin, SkMask::CreateMode createMode) const;
@@ -830,13 +831,16 @@ GrFragmentProcessor* GrRectBlurEffect::TestCreate(GrProcessorTestData* d) {
}
-bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
+bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkPath& path) const {
+ SkASSERT(drawContext);
+
if (fBlurStyle != kNormal_SkBlurStyle) {
return false;
}
@@ -850,14 +854,13 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
return false;
}
- SkMatrix ctm = viewMatrix;
- SkScalar xformedSigma = this->computeXformedSigma(ctm);
+ SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
- int pad=SkScalarCeilToInt(6*xformedSigma)/2;
+ int pad = SkScalarCeilToInt(6*xformedSigma)/2;
rect.outset(SkIntToScalar(pad), SkIntToScalar(pad));
SkAutoTUnref<GrFragmentProcessor> fp(GrRectBlurEffect::Create(
- context->textureProvider(), rect, xformedSigma));
+ texProvider, rect, xformedSigma));
if (!fp) {
return false;
}
@@ -869,19 +872,14 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
return false;
}
- GrDrawContext* drawContext = context->drawContext();
- if (drawContext) {
- drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse);
- return true;
- }
-
- return false;
+ drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse);
+ return true;
}
class GrRRectBlurEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(GrContext* context, float sigma, const SkRRect&);
+ static GrFragmentProcessor* Create(GrTextureProvider*, float sigma, const SkRRect&);
virtual ~GrRRectBlurEffect() {};
const char* name() const override { return "GrRRectBlur"; }
@@ -911,7 +909,7 @@ private:
};
-GrFragmentProcessor* GrRRectBlurEffect::Create(GrContext* context, float sigma,
+GrFragmentProcessor* GrRRectBlurEffect::Create(GrTextureProvider* texProvider, float sigma,
const SkRRect& rrect) {
if (!rrect.isSimpleCircular()) {
return NULL;
@@ -935,8 +933,7 @@ GrFragmentProcessor* GrRRectBlurEffect::Create(GrContext* context, float sigma,
builder[1] = cornerRadius;
builder.finish();
- SkAutoTUnref<GrTexture> blurNinePatchTexture(
- context->textureProvider()->findAndRefTextureByUniqueKey(key));
+ SkAutoTUnref<GrTexture> blurNinePatchTexture(texProvider->findAndRefTextureByUniqueKey(key));
if (!blurNinePatchTexture) {
SkMask mask;
@@ -974,12 +971,12 @@ GrFragmentProcessor* GrRRectBlurEffect::Create(GrContext* context, float sigma,
texDesc.fConfig = kAlpha_8_GrPixelConfig;
blurNinePatchTexture.reset(
- context->textureProvider()->createTexture(texDesc, true, blurredMask.fImage, 0));
+ texProvider->createTexture(texDesc, true, blurredMask.fImage, 0));
SkMask::FreeImage(blurredMask.fImage);
if (!blurNinePatchTexture) {
return NULL;
}
- context->textureProvider()->assignUniqueKeyToTexture(key, blurNinePatchTexture);
+ texProvider->assignUniqueKeyToTexture(key, blurNinePatchTexture);
}
return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture));
}
@@ -1013,7 +1010,7 @@ GrFragmentProcessor* GrRRectBlurEffect::TestCreate(GrProcessorTestData* d) {
SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
- return GrRRectBlurEffect::Create(d->fContext, sigma, rrect);
+ return GrRRectBlurEffect::Create(d->fContext->textureProvider(), sigma, rrect);
}
//////////////////////////////////////////////////////////////////////////////
@@ -1123,13 +1120,16 @@ GrGLFragmentProcessor* GrRRectBlurEffect::createGLInstance() const {
return SkNEW_ARGS(GrGLRRectBlurEffect, (*this));
}
-bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
+bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkRRect& rrect) const {
+ SkASSERT(drawContext);
+
if (fBlurStyle != kNormal_SkBlurStyle) {
return false;
}
@@ -1138,13 +1138,14 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
return false;
}
- SkRect proxy_rect = rrect.rect();
- SkMatrix ctm = viewMatrix;
- SkScalar xformedSigma = this->computeXformedSigma(ctm);
+ SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
float extra=3.f*SkScalarCeilToScalar(xformedSigma-1/6.0f);
- proxy_rect.outset(extra, extra);
- SkAutoTUnref<GrFragmentProcessor> fp(GrRRectBlurEffect::Create(context, xformedSigma, rrect));
+ SkRect proxyRect = rrect.rect();
+ proxyRect.outset(extra, extra);
+
+ SkAutoTUnref<GrFragmentProcessor> fp(GrRRectBlurEffect::Create(texProvider,
+ xformedSigma, rrect));
if (!fp) {
return false;
}
@@ -1156,14 +1157,8 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
return false;
}
- GrDrawContext* drawContext = context->drawContext();
- if (drawContext) {
- drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(),
- proxy_rect, inverse);
- return true;
- }
-
- return false;
+ drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), proxyRect, inverse);
+ return true;
}
bool SkBlurMaskFilterImpl::canFilterMaskGPU(const SkRect& srcBounds,
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 27509dc55b..45137d5159 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -213,8 +213,8 @@ bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
SkBitmap* dst,
SkIPoint* offset) const {
SkBitmap displ = src, color = src;
- const SkImageFilter* colorInput = getColorInput();
- const SkImageFilter* displInput = getDisplacementInput();
+ const SkImageFilter* colorInput = this->getColorInput();
+ const SkImageFilter* displInput = this->getDisplacementInput();
SkIPoint colorOffset = SkIPoint::Make(0, 0), displOffset = SkIPoint::Make(0, 0);
if ((colorInput && !colorInput->filterImage(proxy, src, ctx, &color, &colorOffset)) ||
(displInput && !displInput->filterImage(proxy, src, ctx, &displ, &displOffset))) {
@@ -260,8 +260,8 @@ bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
}
void SkDisplacementMapEffect::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (getColorInput()) {
- getColorInput()->computeFastBounds(src, dst);
+ if (this->getColorInput()) {
+ this->getColorInput()->computeFastBounds(src, dst);
} else {
*dst = src;
}
@@ -275,8 +275,8 @@ bool SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix&
ctm.mapVectors(&scale, 1);
bounds.outset(SkScalarCeilToInt(scale.fX * SK_ScalarHalf),
SkScalarCeilToInt(scale.fY * SK_ScalarHalf));
- if (getColorInput()) {
- return getColorInput()->filterBounds(bounds, ctm, dst);
+ if (this->getColorInput()) {
+ return this->getColorInput()->filterBounds(bounds, ctm, dst);
}
*dst = bounds;
return true;
@@ -398,15 +398,15 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
SkBitmap* result, SkIPoint* offset) const {
SkBitmap colorBM = src;
SkIPoint colorOffset = SkIPoint::Make(0, 0);
- if (getColorInput() && !getColorInput()->getInputResultGPU(proxy, src, ctx, &colorBM,
- &colorOffset)) {
+ if (this->getColorInput() &&
+ !this->getColorInput()->getInputResultGPU(proxy, src, ctx, &colorBM, &colorOffset)) {
return false;
}
SkBitmap displacementBM = src;
SkIPoint displacementOffset = SkIPoint::Make(0, 0);
- if (getDisplacementInput() &&
- !getDisplacementInput()->getInputResultGPU(proxy, src, ctx, &displacementBM,
- &displacementOffset)) {
+ if (this->getDisplacementInput() &&
+ !this->getDisplacementInput()->getInputResultGPU(proxy, src, ctx, &displacementBM,
+ &displacementOffset)) {
return false;
}
SkIRect bounds;
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index a6aa4085f0..401057b24b 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -198,10 +198,7 @@ GrTexture* GaussianBlur(GrContext* context,
return NULL;
}
- GrDrawContext* drawContext = context->drawContext();
- if (!drawContext) {
- return NULL;
- }
+ GrDrawContext* srcDrawContext = NULL;
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
GrPaint paint;
@@ -228,8 +225,15 @@ GrTexture* GaussianBlur(GrContext* context,
}
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
i < scaleFactorY ? 0.5f : 1.0f);
- drawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint, SkMatrix::I(),
- dstRect, srcRect);
+
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return NULL;
+ }
+ dstDrawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
+ SkMatrix::I(), dstRect, srcRect);
+
+ srcDrawContext = dstDrawContext;
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
@@ -237,32 +241,54 @@ GrTexture* GaussianBlur(GrContext* context,
const SkIRect srcIRect = srcRect.roundOut();
- // For really small blurs(Certainly no wider than 5x5 on desktop gpus) it is faster to just
+ // For really small blurs (certainly no wider than 5x5 on desktop gpus) it is faster to just
// launch a single non separable kernel vs two launches
- if (sigmaX > 0.0f && sigmaY > 0 &&
+ if (sigmaX > 0.0f && sigmaY > 0.0f &&
(2 * radiusX + 1) * (2 * radiusY + 1) <= MAX_KERNEL_SIZE) {
// We shouldn't be scaling because this is a small size blur
- SkASSERT((scaleFactorX == scaleFactorY) == 1);
+ SkASSERT((1 == scaleFactorX) && (1 == scaleFactorY));
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian_2d(drawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
+
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return NULL;
+ }
+ convolve_gaussian_2d(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
srcTexture, radiusX, radiusY, sigmaX, sigmaY, cropToRect, srcIRect);
- srcTexture = dstTexture;
+
+ srcDrawContext = dstDrawContext;
srcRect = dstRect;
+ srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
} else {
if (sigmaX > 0.0f) {
if (scaleFactorX > 1) {
+ // TODO: if we pass in the source draw context we don't need this here
+ if (!srcDrawContext) {
+ srcDrawContext = context->drawContext();
+ if (!srcDrawContext) {
+ return NULL;
+ }
+ }
+
// Clear out a radius to the right of the srcRect to prevent the
// X convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
radiusX, srcIRect.height());
- drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
}
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian(drawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
+
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return NULL;
+ }
+ convolve_gaussian(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
srcTexture, Gr1DKernelEffect::kX_Direction, radiusX, sigmaX,
cropToRect);
+
+ srcDrawContext = dstDrawContext;
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
@@ -270,17 +296,32 @@ GrTexture* GaussianBlur(GrContext* context,
if (sigmaY > 0.0f) {
if (scaleFactorY > 1 || sigmaX > 0.0f) {
+ // TODO: if we pass in the source draw context we don't need this here
+ if (!srcDrawContext) {
+ srcDrawContext = context->drawContext();
+ if (!srcDrawContext) {
+ return NULL;
+ }
+ }
+
// Clear out a radius below the srcRect to prevent the Y
// convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width(), radiusY);
- drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
}
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian(drawContext, dstTexture->asRenderTarget(), clip, srcRect,
+
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return NULL;
+ }
+ convolve_gaussian(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect,
dstRect, srcTexture, Gr1DKernelEffect::kY_Direction, radiusY, sigmaY,
cropToRect);
+
+ srcDrawContext = dstDrawContext;
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
@@ -288,14 +329,16 @@ GrTexture* GaussianBlur(GrContext* context,
}
if (scaleFactorX > 1 || scaleFactorY > 1) {
+ SkASSERT(srcDrawContext);
+
// Clear one pixel to the right and below, to accommodate bilinear
// upsampling.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width() + 1, 1);
- drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
1, srcIRect.height());
- drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
SkMatrix matrix;
matrix.setIDiv(srcTexture->width(), srcTexture->height());
@@ -306,12 +349,20 @@ GrTexture* GaussianBlur(GrContext* context,
SkRect dstRect(srcRect);
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
- drawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
- SkMatrix::I(), dstRect, srcRect);
+
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return NULL;
+ }
+ dstDrawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
+ SkMatrix::I(), dstRect, srcRect);
+
+ srcDrawContext = dstDrawContext;
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
}
+
return SkRef(srcTexture);
}
#endif
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index b5c3700da0..b156186990 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -138,7 +138,8 @@ bool SkMorphologyImageFilter::filterImageGeneric(SkMorphologyImageFilter::Proc p
SkIPoint* offset) const {
SkBitmap src = source;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
+ if (this->getInput(0) &&
+ !this->getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
return false;
}
@@ -228,8 +229,8 @@ bool SkDilateImageFilter::onFilterImage(Proxy* proxy,
}
void SkMorphologyImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (getInput(0)) {
- getInput(0)->computeFastBounds(src, dst);
+ if (this->getInput(0)) {
+ this->getInput(0)->computeFastBounds(src, dst);
} else {
*dst = src;
}
@@ -243,7 +244,7 @@ bool SkMorphologyImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix&
SkIntToScalar(this->radius().height()));
ctm.mapVectors(&radius, 1);
bounds.outset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y()));
- if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) {
+ if (this->getInput(0) && !this->getInput(0)->filterBounds(bounds, ctm, &bounds)) {
return false;
}
*dst = bounds;
@@ -670,18 +671,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(
+ GrTexture* dst = context->textureProvider()->refScratchTexture(
desc, GrTextureProvider::kApprox_ScratchTexMatch);
- if (NULL == texture) {
+ if (NULL == dst) {
return false;
}
- apply_morphology_pass(drawContext, texture->asRenderTarget(), clip, srcTexture,
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return false;
+ }
+
+ apply_morphology_pass(dstDrawContext, dst->asRenderTarget(), clip, srcTexture,
srcRect, dstRect, radius.fWidth, morphType,
Gr1DKernelEffect::kX_Direction);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
@@ -689,20 +690,27 @@ bool apply_morphology(const SkBitmap& input,
GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ?
SK_ColorWHITE :
SK_ColorTRANSPARENT;
- drawContext->clear(texture->asRenderTarget(), &clearRect, clearColor, false);
- srcTexture.reset(texture);
+ dstDrawContext->clear(dst->asRenderTarget(), &clearRect, clearColor, false);
+
+ srcTexture.reset(dst);
srcRect = dstRect;
}
if (radius.fHeight > 0) {
- GrTexture* texture = context->textureProvider()->refScratchTexture(desc,
+ GrTexture* dst = context->textureProvider()->refScratchTexture(desc,
GrTextureProvider::kApprox_ScratchTexMatch);
- if (NULL == texture) {
+ if (NULL == dst) {
+ return false;
+ }
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
return false;
}
- apply_morphology_pass(drawContext, texture->asRenderTarget(), clip, srcTexture,
+
+ apply_morphology_pass(dstDrawContext, dst->asRenderTarget(), clip, srcTexture,
srcRect, dstRect, radius.fHeight, morphType,
Gr1DKernelEffect::kY_Direction);
- srcTexture.reset(texture);
+
+ srcTexture.reset(dst);
}
SkImageFilter::WrapTexture(srcTexture, rect.width(), rect.height(), dst);
return true;
@@ -718,7 +726,8 @@ bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate,
SkIPoint* offset) const {
SkBitmap input = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
+ if (this->getInput(0) &&
+ !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
return false;
}
SkIRect bounds;
@@ -744,9 +753,9 @@ bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate,
return true;
}
- GrMorphologyEffect::MorphologyType type = dilate ? GrMorphologyEffect::kDilate_MorphologyType : GrMorphologyEffect::kErode_MorphologyType;
- if (!apply_morphology(input, srcBounds, type,
- SkISize::Make(width, height), result)) {
+ GrMorphologyEffect::MorphologyType type = dilate ? GrMorphologyEffect::kDilate_MorphologyType
+ : GrMorphologyEffect::kErode_MorphologyType;
+ if (!apply_morphology(input, srcBounds, type, SkISize::Make(width, height), result)) {
return false;
}
offset->fX = bounds.left();
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index f1334a2c94..b45a4225d1 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -49,8 +49,8 @@ bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy,
SkBitmap* dst,
SkIPoint* offset) const {
SkBitmap background = src, foreground = src;
- SkImageFilter* backgroundInput = getInput(0);
- SkImageFilter* foregroundInput = getInput(1);
+ SkImageFilter* backgroundInput = this->getInput(0);
+ SkImageFilter* foregroundInput = this->getInput(1);
SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
if (backgroundInput &&
!backgroundInput->filterImage(proxy, src, ctx, &background, &backgroundOffset)) {
@@ -133,12 +133,12 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
SkIPoint* offset) const {
SkBitmap background = src;
SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &background,
- &backgroundOffset)) {
- return onFilterImage(proxy, src, ctx, result, offset);
+ if (this->getInput(0) &&
+ !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &background, &backgroundOffset)) {
+ return this->onFilterImage(proxy, src, ctx, result, offset);
}
- GrTexture* backgroundTex = background.getTexture();
+ GrTexture* backgroundTex = background.getTexture();
if (NULL == backgroundTex) {
SkASSERT(false);
return false;
@@ -146,9 +146,9 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
SkBitmap foreground = src;
SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
- if (getInput(1) && !getInput(1)->getInputResultGPU(proxy, src, ctx, &foreground,
- &foregroundOffset)) {
- return onFilterImage(proxy, src, ctx, result, offset);
+ if (this->getInput(1) &&
+ !this->getInput(1)->getInputResultGPU(proxy, src, ctx, &foreground, &foregroundOffset)) {
+ return this->onFilterImage(proxy, src, ctx, result, offset);
}
GrTexture* foregroundTex = foreground.getTexture();
GrContext* context = foregroundTex->getContext();
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index d273371c10..733d1e6ece 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -242,7 +242,8 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
return;
}
- if (paint.getMaskFilter()->directFilterMaskGPU(context,
+ if (paint.getMaskFilter()->directFilterMaskGPU(context->textureProvider(),
+ drawContext,
renderTarget,
&grPaint,
clip,
@@ -254,7 +255,6 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
return;
}
-
SkAutoTUnref<GrTexture> mask(create_mask_GPU(context,
maskRect,
*devPathPtr,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index ea2b537520..a4394589bb 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -564,7 +564,8 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
// clipped out
return;
}
- if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext,
+ if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext->textureProvider(),
+ fDrawContext,
fRenderTarget,
&grPaint,
fClip,
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index fa97f324be..82ac5df081 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -207,11 +207,6 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
bool failed = true;
- GrDrawContext* drawContext = context->drawContext();
- if (!drawContext) {
- return;
- }
-
for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) {
*pmToUPMRule = kConversionRules[i][0];
*upmToPMRule = kConversionRules[i][1];
@@ -239,30 +234,51 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
SkMatrix::I())));
paint1.addColorProcessor(pmToUPM1);
- drawContext->drawNonAARectToRect(readTex->asRenderTarget(),
- GrClip::WideOpen(),
- paint1,
- SkMatrix::I(),
- kDstRect,
- kSrcRect);
+
+
+ GrDrawContext* readDrawContext = context->drawContext();
+ if (!readDrawContext) {
+ failed = true;
+ break;
+ }
+
+ readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(),
+ GrClip::WideOpen(),
+ paint1,
+ SkMatrix::I(),
+ kDstRect,
+ kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
paint2.addColorProcessor(upmToPM);
- drawContext->drawNonAARectToRect(tempTex->asRenderTarget(),
- GrClip::WideOpen(),
- paint2,
- SkMatrix::I(),
- kDstRect,
- kSrcRect);
+
+ GrDrawContext* tempDrawContext = context->drawContext();
+ if (!tempDrawContext) {
+ failed = true;
+ break;
+ }
+ tempDrawContext->drawNonAARectToRect(tempTex->asRenderTarget(),
+ GrClip::WideOpen(),
+ paint2,
+ SkMatrix::I(),
+ kDstRect,
+ kSrcRect);
paint3.addColorProcessor(pmToUPM2);
- drawContext->drawNonAARectToRect(readTex->asRenderTarget(),
- GrClip::WideOpen(),
- paint3,
- SkMatrix::I(),
- kDstRect,
- kSrcRect);
+
+ readDrawContext = context->drawContext();
+ if (!readDrawContext) {
+ failed = true;
+ break;
+ }
+
+ readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(),
+ GrClip::WideOpen(),
+ paint3,
+ SkMatrix::I(),
+ kDstRect,
+ kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead);