Allow SkGpuDevice::drawSprite to handle subset SkBitmaps
With the upcoming switch to SkSpecialImage in the blur image filter, it is possible for drawSprite calls to use an SkBitmap with an offset (e.g., a blur image filter with a cropRect and 0 blur radii). This simply updates the drawSprite code path to be origin aware.
This is calved off of: https://codereview.chromium.org/1785643003/ (Switch SkBlurImageFilter over to new onFilterImage interface)
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1808743003
Review URL: https://codereview.chromium.org/1808743003
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 173fe30..c2d8bda 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1142,6 +1142,8 @@
return;
}
+ int offX = bitmap.pixelRefOrigin().fX;
+ int offY = bitmap.pixelRefOrigin().fY;
int w = bitmap.width();
int h = bitmap.height();
@@ -1170,6 +1172,8 @@
if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredBitmap,
&offset)) {
texture = (GrTexture*) filteredBitmap.getTexture();
+ offX = filteredBitmap.pixelRefOrigin().fX;
+ offY = filteredBitmap.pixelRefOrigin().fY;
w = filteredBitmap.width();
h = filteredBitmap.height();
left += offset.x();
@@ -1200,10 +1204,10 @@
SkIntToScalar(top),
SkIntToScalar(w),
SkIntToScalar(h)),
- SkRect::MakeXYWH(0,
- 0,
- SK_Scalar1 * w / texture->width(),
- SK_Scalar1 * h / texture->height()));
+ SkRect::MakeXYWH(SkIntToScalar(offX) / texture->width(),
+ SkIntToScalar(offY) / texture->height(),
+ SkIntToScalar(w) / texture->width(),
+ SkIntToScalar(h) / texture->height()));
}
void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,