add getBounds() helper
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 15 Mar 2012 21:17:03 +0000 (21:17 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 15 Mar 2012 21:17:03 +0000 (21:17 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@3409 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkBitmap.h
src/core/SkBitmap.cpp

index 57b80e5..36d7013 100644 (file)
@@ -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().
index 58d0bd8..3d586e4 100644 (file)
@@ -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();