diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-15 21:17:03 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-15 21:17:03 +0000 |
commit | 86b2e43a33c486a0b150aa14fadf7af8323a11f5 (patch) | |
tree | cb6435b8fe64c2de1865254558c246de9c8b4573 | |
parent | c329641248c4cfb7b67fdb4bfae69985a7bc892c (diff) |
add getBounds() helper
git-svn-id: http://skia.googlecode.com/svn/trunk@3409 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/core/SkBitmap.h | 5 | ||||
-rw-r--r-- | src/core/SkBitmap.cpp | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index 57b80e5f82..36d7013397 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -218,6 +218,11 @@ public: static Sk64 ComputeSize64(Config, int width, int height); static size_t ComputeSize(Config, int width, int height); + /** + * Return the bitmap's bounds [0, 0, width, height] as an SkRect + */ + void getBounds(SkRect* bounds) const; + /** Set the bitmap's config and dimensions. If rowBytes is 0, then ComputeRowBytes() is called to compute the optimal value. This resets any pixel/colortable ownership, just like reset(). diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index 58d0bd868f..3d586e40da 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -252,6 +252,14 @@ size_t SkBitmap::ComputeSafeSize(Config config, return (safeSize.is32() ? safeSize.get32() : 0); } +void SkBitmap::getBounds(SkRect* bounds) const { + SkASSERT(bounds); + bounds->set(0, 0, + SkIntToScalar(fWidth), SkIntToScalar(fHeight)); +} + +/////////////////////////////////////////////////////////////////////////////// + void SkBitmap::setConfig(Config c, int width, int height, int rowBytes) { this->freePixels(); |