diff options
author | 2011-07-19 21:22:13 +0000 | |
---|---|---|
committer | 2011-07-19 21:22:13 +0000 | |
commit | 422b67d745afc6e3b02c489dc6f0cd3ae856dd32 (patch) | |
tree | 4678a24a5ea133fca374cd1a8ac27738a9b1cdc1 /src | |
parent | 6c858246f5cd4d99fa5d754ed9175ec4cc7094ab (diff) |
Fix GPU blur cacheing bug. Sometimes, the texture cache serves us textures of
different sizes for srcTexture and dstTexture (this is fair; they're supposed
to be approximate). Code was assuming otherwise while downsampling; fix is to
reapply the scale on each downsample. (Yes, I could cache these reciprocals
if and when they prove to be a hot spot).
Also, use setIDiv(w,h) everywhere for conciseness.
Review URL: http://codereview.appspot.com/4798041/
git-svn-id: http://skia.googlecode.com/svn/trunk@1907 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index cc669fe311..c4e0ebecd1 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -936,8 +936,7 @@ static bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path, SkTSwap(srcTexture, dstTexture); GrMatrix sampleM; - sampleM.setScale(GR_Scalar1 / srcTexture->width(), - GR_Scalar1 / srcTexture->height()); + sampleM.setIDiv(srcTexture->width(), srcTexture->height()); GrPaint paint; paint.reset(); paint.getTextureSampler(0)->setFilter(GrSamplerState::kBilinear_Filter); @@ -955,6 +954,8 @@ static bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path, } GrAutoUnlockTextureEntry origLock(context, origEntry); for (int i = 1; i < scaleFactor; i *= 2) { + sampleM.setIDiv(srcTexture->width(), srcTexture->height()); + paint.getTextureSampler(0)->setMatrix(sampleM); context->setRenderTarget(dstTexture->asRenderTarget()); SkRect dstRect(srcRect); scaleRect(&dstRect, 0.5f); @@ -984,8 +985,7 @@ static bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path, if (scaleFactor > 1) { // FIXME: This should be mitchell, not bilinear. paint.getTextureSampler(0)->setFilter(GrSamplerState::kBilinear_Filter); - sampleM.setScale(GR_Scalar1 / srcTexture->width(), - GR_Scalar1 / srcTexture->height()); + sampleM.setIDiv(srcTexture->width(), srcTexture->height()); paint.getTextureSampler(0)->setMatrix(sampleM); context->setRenderTarget(dstTexture->asRenderTarget()); // Clear out 2 pixel border for bicubic filtering. @@ -1002,8 +1002,7 @@ static bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path, if (blurType != SkMaskFilter::kNormal_BlurType) { GrTexture* origTexture = origEntry->texture(); paint.getTextureSampler(0)->setFilter(GrSamplerState::kNearest_Filter); - sampleM.setScale(GR_Scalar1 / origTexture->width(), - GR_Scalar1 / origTexture->height()); + sampleM.setIDiv(origTexture->width(), origTexture->height()); paint.getTextureSampler(0)->setMatrix(sampleM); // Blend origTexture over srcTexture. context->setRenderTarget(srcTexture->asRenderTarget()); |