(Relanding r7275 with assert fix, plus fixes from r7276, r7280, r7283.)
Implement a bicubic resampling image filter, with raster and GPU backends.
In order to get this to work on the GPU side, I had to modify the width and height of the drawn texture in drawSprite() and drawDevice() to use the filtered texture's dimensions, instead of the source texture. (This wasn't a problem before since all other image filters produce results the same dimensions as their input texture.)
For now, this implementation only does axis-aligned scaling (same as the Lanczos-3 implementation in Chrome). It's also done for correctness and clarity, not speed, so there are lots of opportunities for speedups.
Committed: https://code.google.com/p/skia/source/detail?r=7275
Review URL: https://codereview.appspot.com/7033049
git-svn-id: http://skia.googlecode.com/svn/trunk@7287 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 0cf3b35..8390164 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1428,6 +1428,8 @@
if (filteredTexture) {
grPaint.colorStage(kBitmapTextureIdx)->setEffect(
GrSimpleTextureEffect::Create(filteredTexture, SkMatrix::I()))->unref();
+ w = filteredTexture->width();
+ h = filteredTexture->height();
texture = filteredTexture;
filteredTexture->unref();
}
@@ -1491,6 +1493,10 @@
return;
}
+ const SkBitmap& bm = dev->accessBitmap(false);
+ int w = bm.width();
+ int h = bm.height();
+
GrTexture* devTex = grPaint.getColorStage(kBitmapTextureIdx).getEffect()->texture(0);
SkASSERT(NULL != devTex);
@@ -1503,14 +1509,12 @@
grPaint.colorStage(kBitmapTextureIdx)->setEffect(
GrSimpleTextureEffect::Create(filteredTexture, SkMatrix::I()))->unref();
devTex = filteredTexture;
+ w = devTex->width();
+ h = devTex->height();
filteredTexture->unref();
}
}
- const SkBitmap& bm = dev->accessBitmap(false);
- int w = bm.width();
- int h = bm.height();
-
GrRect dstRect = GrRect::MakeXYWH(SkIntToScalar(x),
SkIntToScalar(y),
SkIntToScalar(w),