Switch SkBlurImageFilter over to new onFilterImage interface
This CL relies on:
https://codereview.chromium.org/1787883002/ (Add SkSpecialImage::extractSubset & NewFromPixmap)
https://codereview.chromium.org/1808743003/ (Allow SkGpuDevice::drawSprite to handle subset SkBitmaps)
https://codereview.chromium.org/1813813002/ (Add SkSpecialImage::makeTextureImage entry point)
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1785643003
Committed: https://skia.googlesource.com/skia/+/3c935bc87020bfd19a08922f7394db3a801d168b
Review URL: https://codereview.chromium.org/1785643003
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index f4a1d4e..dc1edd4 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -221,6 +221,38 @@
return texture->asRenderTarget();
}
+// This method ensures that we always have a texture-backed "bitmap" when we finally
+// call through to the base impl so that the image filtering code will take the
+// gpu-specific paths. This mirrors SkCanvas::internalDrawDevice (the other
+// use of SkImageFilter::filterImage) in that the source and dest will have
+// homogenous backing (e.g., raster or gpu).
+void SkGpuDevice::drawBitmapAsSpriteWithImageFilter(const SkDraw& draw, const SkBitmap& bitmap,
+ int x, int y, const SkPaint& paint) {
+ if (bitmap.getTexture()) {
+ INHERITED::drawBitmapAsSpriteWithImageFilter(draw, bitmap, x, y, paint);
+ return;
+ }
+
+ SkAutoLockPixels alp(bitmap, !bitmap.getTexture());
+ if (!bitmap.getTexture() && !bitmap.readyToDraw()) {
+ return;
+ }
+
+ GrTexture* texture;
+ // draw sprite neither filters nor tiles.
+ AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), &texture);
+ if (!texture) {
+ return;
+ }
+
+ SkBitmap newBitmap;
+
+ GrWrapTextureInBitmap(texture, texture->width(), texture->height(),
+ bitmap.isOpaque(), &newBitmap);
+
+ INHERITED::drawBitmapAsSpriteWithImageFilter(draw, newBitmap, x, y, paint);
+}
+
///////////////////////////////////////////////////////////////////////////////
bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,