Make RT & TEX base classes aware of NPOT/min-RT bloated size

Review URL: http://codereview.appspot.com/4849045/


git-svn-id: http://skia.googlecode.com/svn/trunk@2057 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrTexture.h b/gpu/include/GrTexture.h
index 9bdd340..77f88fa 100644
--- a/gpu/include/GrTexture.h
+++ b/gpu/include/GrTexture.h
@@ -33,6 +33,20 @@
     int height() const { return fHeight; }
 
     /**
+     * Retrieves the allocated width. It may differ from width for
+     * NPOT or min-RT size reasons.
+     * @return allocated width in texels
+     */
+    int allocatedWidth() const { return fAllocatedWidth; }
+
+    /**
+     * Retrieves the allocated height. It may differ from height for
+     * NPOT or min-RT size reasons.
+     * @return allocated height in texels
+     */
+    int allocatedHeight() const { return fAllocatedHeight; }
+
+    /**
      * Convert from texels to normalized texture coords for POT textures
      * only.
      */
@@ -50,7 +64,7 @@
      *  Approximate number of bytes used by the texture
      */
     virtual size_t sizeInBytes() const {
-        return fWidth * fHeight * GrBytesPerPixel(fConfig);
+        return fAllocatedWidth * fAllocatedHeight * GrBytesPerPixel(fConfig);
     }
 
     /**
@@ -125,11 +139,15 @@
     GrTexture(GrGpu* gpu,
               int width,
               int height,
+              int allocatedWidth,
+              int allocatedHeight,
               GrPixelConfig config)
     : INHERITED(gpu)
     , fRenderTarget(NULL)
     , fWidth(width)
     , fHeight(height)
+    , fAllocatedWidth(allocatedWidth)
+    , fAllocatedHeight(allocatedHeight)
     , fConfig(config) {
         // only make sense if alloc size is pow2
         fShiftFixedX = 31 - Gr_clz(fWidth);
@@ -146,6 +164,9 @@
 private:
     int fWidth;
     int fHeight;
+    int fAllocatedWidth;
+    int fAllocatedHeight;
+
     // these two shift a fixed-point value into normalized coordinates
     // for this texture if the texture is power of two sized.
     int      fShiftFixedX;