Add `SkIRect bounds()` convenience method to SkImageInfo and SkBitmap.
Review URL: https://codereview.chromium.org/646213003
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 2f7fcf4..bb6d1ba 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1260,7 +1260,7 @@
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix = *iter.fMatrix;
matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()));
- SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height());
+ const SkIRect clipBounds = bitmap.bounds();
SkAutoTUnref<SkImageFilter::Cache> cache(iter.fDevice->getImageFilterCache());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) {
diff --git a/src/lazy/SkCachingPixelRef.cpp b/src/lazy/SkCachingPixelRef.cpp
index 1459567..5ab9656 100644
--- a/src/lazy/SkCachingPixelRef.cpp
+++ b/src/lazy/SkCachingPixelRef.cpp
@@ -45,9 +45,8 @@
}
const SkImageInfo& info = this->info();
- if (!SkBitmapCache::Find(this->getGenerationID(),
- SkIRect::MakeWH(info.width(), info.height()),
- &fLockedBitmap)) {
+ if (!SkBitmapCache::Find(
+ this->getGenerationID(), info.bounds(), &fLockedBitmap)) {
// Cache has been purged, must re-decode.
if (!fLockedBitmap.tryAllocPixels(info, fRowBytes)) {
fErrorInDecoding = true;
@@ -58,9 +57,8 @@
return false;
}
fLockedBitmap.setImmutable();
- SkBitmapCache::Add(this->getGenerationID(),
- SkIRect::MakeWH(info.width(), info.height()),
- fLockedBitmap);
+ SkBitmapCache::Add(
+ this->getGenerationID(), info.bounds(), fLockedBitmap);
}
// Now bitmap should contain a concrete PixelRef of the decoded image.
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 8509de8..b14ca72 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -745,7 +745,7 @@
fInitialTransform.preConcat(initialTransform);
fLegacyBitmap.setInfo(info);
- SkIRect existingClip = SkIRect::MakeWH(info.width(), info.height());
+ SkIRect existingClip = info.bounds();
fExistingClipRegion.setRect(existingClip);
this->init();
}
@@ -2181,7 +2181,7 @@
scaled.setScale(SK_Scalar1, -SK_Scalar1);
scaled.postTranslate(0, SK_Scalar1);
// Scale the image up from 1x1 to WxH.
- SkIRect subset = SkIRect::MakeWH(bitmap->width(), bitmap->height());
+ SkIRect subset = bitmap->bounds();
scaled.postScale(SkIntToScalar(subset.width()),
SkIntToScalar(subset.height()));
scaled.postConcat(matrix);