aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/SkGpuBlurUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/effects/SkGpuBlurUtils.cpp')
-rw-r--r--src/effects/SkGpuBlurUtils.cpp47
1 files changed, 8 insertions, 39 deletions
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index 5b52ad3cea..479648850c 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -11,7 +11,6 @@
#if SK_SUPPORT_GPU
#include "effects/GrConvolutionEffect.h"
-#include "effects/GrTextureDomainEffect.h"
#include "GrContext.h"
#endif
@@ -41,29 +40,18 @@ static float adjust_sigma(float sigma, int *scaleFactor, int *radius) {
static void convolve_gaussian(GrContext* context,
GrTexture* texture,
- const SkRect& srcRect,
- const SkRect& dstRect,
+ const SkRect& rect,
float sigma,
int radius,
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
- paint.reset();
- float cropRect[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
- if (direction == Gr1DKernelEffect::kX_Direction) {
- cropRect[0] = SkScalarToFloat(srcRect.left()) / texture->width();
- cropRect[1] = SkScalarToFloat(srcRect.right()) / texture->width();
- } else {
- cropRect[2] = SkScalarToFloat(srcRect.top()) / texture->height();
- cropRect[3] = SkScalarToFloat(srcRect.bottom()) / texture->height();
- }
SkAutoTUnref<GrEffectRef> conv(GrConvolutionEffect::CreateGaussian(texture,
direction,
radius,
- sigma,
- cropRect));
+ sigma));
paint.addColorEffect(conv);
- context->drawRectToRect(paint, dstRect, srcRect);
+ context->drawRect(paint, rect);
}
GrTexture* GaussianBlur(GrContext* context,
@@ -91,7 +79,7 @@ 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()));
+ GrContext::AutoClip acs(context, srcRect);
GrAssert(kBGRA_8888_GrPixelConfig == srcTexture->config() ||
kRGBA_8888_GrPixelConfig == srcTexture->config() ||
@@ -116,25 +104,10 @@ GrTexture* GaussianBlur(GrContext* context,
matrix.setIDiv(srcTexture->width(), srcTexture->height());
context->setRenderTarget(dstTexture->asRenderTarget());
SkRect dstRect(srcRect);
- if (i == 1) {
- dstRect.offset(-dstRect.fLeft, -dstRect.fTop);
- SkRect domain;
- matrix.mapRect(&domain, rect);
- domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width() : 0.0f,
- i < scaleFactorY ? SK_ScalarHalf / srcTexture->height() : 0.0f);
- SkAutoTUnref<GrEffectRef> effect(GrTextureDomainEffect::Create(
- srcTexture,
- matrix,
- domain,
- GrTextureDomainEffect::kDecal_WrapMode,
- true));
- paint.addColorEffect(effect);
- } else {
- GrTextureParams params(SkShader::kClamp_TileMode, true);
- paint.addColorTextureEffect(srcTexture, matrix, params);
- }
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
i < scaleFactorY ? 0.5f : 1.0f);
+ GrTextureParams params(SkShader::kClamp_TileMode, true);
+ paint.addColorTextureEffect(srcTexture, matrix, params);
context->drawRectToRect(paint, dstRect, srcRect);
srcRect = dstRect;
srcTexture = dstTexture;
@@ -153,11 +126,9 @@ GrTexture* GaussianBlur(GrContext* context,
context->clear(&clearRect, 0x0);
}
context->setRenderTarget(dstTexture->asRenderTarget());
- SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian(context, srcTexture, srcRect, dstRect, sigmaX, radiusX,
+ convolve_gaussian(context, srcTexture, srcRect, sigmaX, radiusX,
Gr1DKernelEffect::kX_Direction);
srcTexture = dstTexture;
- srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
}
@@ -171,11 +142,9 @@ GrTexture* GaussianBlur(GrContext* context,
}
context->setRenderTarget(dstTexture->asRenderTarget());
- SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian(context, srcTexture, srcRect, dstRect, sigmaY, radiusY,
+ convolve_gaussian(context, srcTexture, srcRect, sigmaY, radiusY,
Gr1DKernelEffect::kY_Direction);
srcTexture = dstTexture;
- srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
}