aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-02-25 11:21:21 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-25 11:21:21 -0800
commit586d5d640b19860dfbbd903a5188da1bbbe87336 (patch)
treeab3fde1525edf311a9c384404a847757251108be /src/effects
parent63d0024cde57eba4f7802fdc4fe49467867f52ba (diff)
I'd really like to land this before the branch so speedy reviews are appreciated.
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkAlphaThresholdFilter.cpp3
-rw-r--r--src/effects/SkBlurMaskFilter.cpp13
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp3
-rw-r--r--src/effects/SkGpuBlurUtils.cpp42
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp32
-rw-r--r--src/effects/SkXfermodeImageFilter.cpp2
6 files changed, 56 insertions, 39 deletions
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index f78c9c0b8c..09dc7427e5 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -292,7 +292,8 @@ bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
while (!iter.done()) {
SkRect rect = SkRect::Make(iter.rect());
- context->drawRect(maskTexture->asRenderTarget(), grPaint, in_matrix, rect);
+ context->drawRect(maskTexture->asRenderTarget(), GrClip::WideOpen(), grPaint,
+ in_matrix, rect);
iter.next();
}
}
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index ae4f756b25..d7c874cfda 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -50,12 +50,14 @@ public:
virtual bool directFilterMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
+ const GrClip&,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkPath& path) const SK_OVERRIDE;
virtual bool directFilterRRectMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
+ const GrClip&,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkRRect& rrect) const SK_OVERRIDE;
@@ -830,6 +832,7 @@ GrFragmentProcessor* GrRectBlurEffect::TestCreate(SkRandom* random,
bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
+ const GrClip& clip,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkPath& path) const {
@@ -863,7 +866,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
if (!viewMatrix.invert(&inverse)) {
return false;
}
- context->drawNonAARectWithLocalMatrix(rt, *grp, SkMatrix::I(), rect, inverse);
+ context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse);
return true;
}
@@ -1120,6 +1123,7 @@ GrGLFragmentProcessor* GrRRectBlurEffect::createGLInstance() const {
bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
+ const GrClip& clip,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkRRect& rrect) const {
@@ -1148,7 +1152,7 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
if (!viewMatrix.invert(&inverse)) {
return false;
}
- context->drawNonAARectWithLocalMatrix(rt, *grp, SkMatrix::I(), proxy_rect, inverse);
+ context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), proxy_rect, inverse);
return true;
}
@@ -1200,8 +1204,6 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
GrContext* context = src->getContext();
- GrContext::AutoWideOpenIdentityDraw awo(context);
-
SkScalar xformedSigma = this->computeXformedSigma(ctm);
SkASSERT(xformedSigma > 0);
@@ -1232,7 +1234,8 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
// = 0 * src + (1 - src) * dst
paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
}
- context->drawRect((*result)->asRenderTarget(), paint, SkMatrix::I(), clipRect);
+ context->drawRect((*result)->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(),
+ clipRect);
}
return true;
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 0463fb08b8..25339e613c 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -449,7 +449,8 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(colorBounds.x()),
-SkIntToScalar(colorBounds.y()));
- context->drawRect(dst->asRenderTarget(), paint, matrix, SkRect::Make(colorBounds));
+ context->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 77e225888c..832e48a4e0 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -45,6 +45,7 @@ static float adjust_sigma(float sigma, int maxTextureSize, int *scaleFactor, int
static void convolve_gaussian_1d(GrContext* context,
GrRenderTarget* rt,
+ const GrClip& clip,
const SkRect& srcRect,
const SkRect& dstRect,
GrTexture* texture,
@@ -57,11 +58,12 @@ static void convolve_gaussian_1d(GrContext* context,
SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
texture, direction, radius, sigma, useBounds, bounds));
paint.addColorProcessor(conv);
- context->drawNonAARectToRect(rt, paint, SkMatrix::I(), dstRect, srcRect);
+ context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect);
}
static void convolve_gaussian_2d(GrContext* context,
GrRenderTarget* rt,
+ const GrClip& clip,
const SkRect& srcRect,
const SkRect& dstRect,
GrTexture* texture,
@@ -79,11 +81,12 @@ static void convolve_gaussian_2d(GrContext* context,
useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY));
paint.addColorProcessor(conv);
- context->drawNonAARectToRect(rt, paint, SkMatrix::I(), dstRect, srcRect);
+ context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect);
}
static void convolve_gaussian(GrContext* context,
GrRenderTarget* rt,
+ const GrClip& clip,
const SkRect& srcRect,
const SkRect& dstRect,
GrTexture* texture,
@@ -93,7 +96,7 @@ static void convolve_gaussian(GrContext* context,
bool cropToSrcRect) {
float bounds[2] = { 0.0f, 1.0f };
if (!cropToSrcRect) {
- convolve_gaussian_1d(context, rt, srcRect, dstRect, texture,
+ convolve_gaussian_1d(context, rt, clip, srcRect, dstRect, texture,
direction, radius, sigma, false, bounds);
return;
}
@@ -125,15 +128,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, srcRect, dstRect, texture,
+ convolve_gaussian_1d(context, 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, lowerSrcRect, lowerDstRect, texture,
+ convolve_gaussian_1d(context, rt, clip, lowerSrcRect, lowerDstRect, texture,
direction, radius, sigma, true, bounds);
- convolve_gaussian_1d(context, rt, upperSrcRect, upperDstRect, texture,
+ convolve_gaussian_1d(context, rt, clip, upperSrcRect, upperDstRect, texture,
direction, radius, sigma, true, bounds);
- convolve_gaussian_1d(context, rt, middleSrcRect, middleDstRect, texture,
+ convolve_gaussian_1d(context, rt, clip, middleSrcRect, middleDstRect, texture,
direction, radius, sigma, false, bounds);
}
}
@@ -160,7 +163,8 @@ GrTexture* GaussianBlur(GrContext* context,
scale_rect(&srcRect, static_cast<float>(scaleFactorX),
static_cast<float>(scaleFactorY));
- GrContext::AutoClip acs(context, SkRect::MakeWH(srcRect.width(), srcRect.height()));
+ // setup new clip
+ GrClip clip(SkRect::MakeWH(srcRect.width(), srcRect.height()));
SkASSERT(kBGRA_8888_GrPixelConfig == srcTexture->config() ||
kRGBA_8888_GrPixelConfig == srcTexture->config() ||
@@ -213,8 +217,8 @@ GrTexture* GaussianBlur(GrContext* context,
}
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
i < scaleFactorY ? 0.5f : 1.0f);
- context->drawNonAARectToRect(dstTexture->asRenderTarget(), paint, SkMatrix::I(), dstRect,
- srcRect);
+ context->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint, SkMatrix::I(),
+ dstRect, srcRect);
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
@@ -229,8 +233,8 @@ 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(), srcRect, dstRect, srcTexture,
- radiusX, radiusY, sigmaX, sigmaY, cropToRect, srcIRect);
+ convolve_gaussian_2d(context, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
+ srcTexture, radiusX, radiusY, sigmaX, sigmaY, cropToRect, srcIRect);
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
@@ -245,8 +249,9 @@ GrTexture* GaussianBlur(GrContext* context,
context->clear(&clearRect, 0x0, false, srcTexture->asRenderTarget());
}
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian(context, dstTexture->asRenderTarget(), srcRect, dstRect, srcTexture,
- Gr1DKernelEffect::kX_Direction, radiusX, sigmaX, cropToRect);
+ convolve_gaussian(context, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
+ srcTexture, Gr1DKernelEffect::kX_Direction, radiusX, sigmaX,
+ cropToRect);
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
@@ -262,8 +267,9 @@ GrTexture* GaussianBlur(GrContext* context,
}
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian(context, dstTexture->asRenderTarget(), srcRect, dstRect, srcTexture,
- Gr1DKernelEffect::kY_Direction, radiusY, sigmaY, cropToRect);
+ convolve_gaussian(context, dstTexture->asRenderTarget(), clip, srcRect,
+ dstRect, srcTexture, Gr1DKernelEffect::kY_Direction, radiusY, sigmaY,
+ cropToRect);
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
@@ -289,8 +295,8 @@ GrTexture* GaussianBlur(GrContext* context,
SkRect dstRect(srcRect);
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
- context->drawNonAARectToRect(dstTexture->asRenderTarget(), paint, SkMatrix::I(), dstRect,
- srcRect);
+ context->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
+ SkMatrix::I(), dstRect, srcRect);
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 8c46aae757..d2ec036ba7 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -563,6 +563,7 @@ namespace {
void apply_morphology_rect(GrContext* context,
GrRenderTarget* rt,
+ const GrClip& clip,
GrTexture* texture,
const SkIRect& srcRect,
const SkIRect& dstRect,
@@ -576,12 +577,13 @@ void apply_morphology_rect(GrContext* context,
radius,
morphType,
bounds))->unref();
- context->drawNonAARectToRect(rt, paint, SkMatrix::I(), SkRect::Make(dstRect),
+ context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
}
void apply_morphology_rect_no_bounds(GrContext* context,
GrRenderTarget* rt,
+ const GrClip& clip,
GrTexture* texture,
const SkIRect& srcRect,
const SkIRect& dstRect,
@@ -593,12 +595,13 @@ void apply_morphology_rect_no_bounds(GrContext* context,
direction,
radius,
morphType))->unref();
- context->drawNonAARectToRect(rt, paint, SkMatrix::I(), SkRect::Make(dstRect),
+ context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
}
void apply_morphology_pass(GrContext* context,
GrRenderTarget* rt,
+ const GrClip& clip,
GrTexture* texture,
const SkIRect& srcRect,
const SkIRect& dstRect,
@@ -630,16 +633,16 @@ 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, texture, srcRect, dstRect, radius,
+ apply_morphology_rect(context, rt, clip, texture, srcRect, dstRect, radius,
morphType, bounds, direction);
} else {
// Draw upper and lower margins with bounds; middle without.
- apply_morphology_rect(context, rt,texture, lowerSrcRect, lowerDstRect, radius,
+ apply_morphology_rect(context, rt, clip, texture, lowerSrcRect, lowerDstRect, radius,
morphType, bounds, direction);
- apply_morphology_rect(context, rt, texture, upperSrcRect, upperDstRect, radius,
+ apply_morphology_rect(context, rt, clip, texture, upperSrcRect, upperDstRect, radius,
morphType, bounds, direction);
- apply_morphology_rect_no_bounds(context, rt, texture, middleSrcRect, middleDstRect, radius,
- morphType, direction);
+ apply_morphology_rect_no_bounds(context, rt, clip, texture, middleSrcRect, middleDstRect,
+ radius, morphType, direction);
}
}
@@ -652,8 +655,9 @@ bool apply_morphology(const SkBitmap& input,
SkASSERT(srcTexture);
GrContext* context = srcTexture->getContext();
- GrContext::AutoClip acs(context, SkRect::MakeWH(SkIntToScalar(srcTexture->width()),
- SkIntToScalar(srcTexture->height())));
+ // setup new clip
+ GrClip clip(SkRect::MakeWH(SkIntToScalar(srcTexture->width()),
+ SkIntToScalar(srcTexture->height())));
SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height());
GrSurfaceDesc desc;
@@ -668,8 +672,9 @@ bool apply_morphology(const SkBitmap& input,
if (NULL == texture) {
return false;
}
- apply_morphology_pass(context, texture->asRenderTarget(), srcTexture, srcRect, dstRect,
- radius.fWidth, morphType, Gr1DKernelEffect::kX_Direction);
+ apply_morphology_pass(context, texture->asRenderTarget(), clip, srcTexture,
+ srcRect, dstRect, radius.fWidth, morphType,
+ Gr1DKernelEffect::kX_Direction);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
dstRect.width(), radius.fHeight);
GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ?
@@ -684,8 +689,9 @@ bool apply_morphology(const SkBitmap& input,
if (NULL == texture) {
return false;
}
- apply_morphology_pass(context, texture->asRenderTarget(), srcTexture, srcRect, dstRect,
- radius.fHeight, morphType, Gr1DKernelEffect::kY_Direction);
+ apply_morphology_pass(context, texture->asRenderTarget(), clip, srcTexture,
+ srcRect, dstRect, radius.fHeight, morphType,
+ Gr1DKernelEffect::kY_Direction);
srcTexture.reset(texture);
}
SkImageFilter::WrapTexture(srcTexture, rect.width(), rect.height(), dst);
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index ce6e790250..2ba5ec5160 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -172,7 +172,7 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
GrPaint paint;
paint.addColorTextureProcessor(foregroundTex, foregroundMatrix);
paint.addColorProcessor(xferProcessor)->unref();
- context->drawRect(dst->asRenderTarget(), paint, SkMatrix::I(), srcRect);
+ context->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(), srcRect);
offset->fX = backgroundOffset.fX;
offset->fY = backgroundOffset.fY;