Add a src rect to drawImageLattice() API
This will allow us to draw ninepatches directly from an asset
texture without having to upload them individually.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2382893002
Review-Url: https://codereview.chromium.org/2382893002
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 6a0d5e6..7597c7a 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1999,8 +1999,16 @@
if (dst.isEmpty()) {
return;
}
- if (SkLatticeIter::Valid(image->width(), image->height(), lattice)) {
- this->onDrawImageLattice(image, lattice, dst, paint);
+
+ SkIRect bounds;
+ Lattice latticePlusBounds = lattice;
+ if (!latticePlusBounds.fBounds) {
+ bounds = SkIRect::MakeWH(image->width(), image->height());
+ latticePlusBounds.fBounds = &bounds;
+ }
+
+ if (SkLatticeIter::Valid(image->width(), image->height(), latticePlusBounds)) {
+ this->onDrawImageLattice(image, latticePlusBounds, dst, paint);
} else {
this->drawImageRect(image, dst, paint);
}
@@ -2049,8 +2057,16 @@
if (bitmap.drawsNothing() || dst.isEmpty()) {
return;
}
- if (SkLatticeIter::Valid(bitmap.width(), bitmap.height(), lattice)) {
- this->onDrawBitmapLattice(bitmap, lattice, dst, paint);
+
+ SkIRect bounds;
+ Lattice latticePlusBounds = lattice;
+ if (!latticePlusBounds.fBounds) {
+ bounds = SkIRect::MakeWH(bitmap.width(), bitmap.height());
+ latticePlusBounds.fBounds = &bounds;
+ }
+
+ if (SkLatticeIter::Valid(bitmap.width(), bitmap.height(), latticePlusBounds)) {
+ this->onDrawBitmapLattice(bitmap, latticePlusBounds, dst, paint);
} else {
this->drawBitmapRect(bitmap, dst, paint);
}