Reapply r1951.



git-svn-id: http://skia.googlecode.com/svn/trunk@1959 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrTexture.h b/gpu/include/GrTexture.h
index 50ed35d..cadf0f2 100644
--- a/gpu/include/GrTexture.h
+++ b/gpu/include/GrTexture.h
@@ -44,6 +44,13 @@
     int height() const { return fHeight; }
 
     /**
+     * @return the pixel config. Can be kUnknown_GrPixelConfig
+     * if client asked us to render to a target that has a pixel
+     * config that isn't equivalent with one of our configs.
+     */
+    int config() const { return fConfig; }
+
+    /**
      * @return the number of stencil bits in the rendertarget
      */
     int stencilBits() const { return fStencilBits; }
@@ -105,6 +112,9 @@
      */
     const GrIRect& getResolveRect() const { return fResolveRect; }
 
+    // GrResource overrides
+    virtual size_t sizeInBytes() const;
+
     /**
      * Reads a rectangle of pixels from the render target.
      * @param left          left edge of the rectangle to read (inclusive)
@@ -135,12 +145,14 @@
                    GrTexture* texture,
                    int width,
                    int height,
+                   GrPixelConfig config,
                    int stencilBits,
                    bool isMultisampled)
         : INHERITED(gpu)
         , fTexture(texture)
         , fWidth(width)
         , fHeight(height)
+        , fConfig(config)
         , fStencilBits(stencilBits)
         , fIsMultisampled(isMultisampled)
     {
@@ -160,11 +172,12 @@
 
 private:
     GrTexture* fTexture; // not ref'ed
-    int        fWidth;
-    int        fHeight;
-    int        fStencilBits;
-    bool       fIsMultisampled;
-    GrIRect    fResolveRect;
+    int             fWidth;
+    int             fHeight;
+    GrPixelConfig   fConfig;
+    int             fStencilBits;
+    bool            fIsMultisampled;
+    GrIRect         fResolveRect;
 
     // GrGpu keeps a cached clip in the render target to avoid redundantly
     // rendering the clip into the same stencil buffer.
@@ -208,7 +221,7 @@
     /**
      *  Approximate number of bytes used by the texture
      */
-    size_t sizeInBytes() const {
+    virtual size_t sizeInBytes() const {
         return fWidth * fHeight * GrBytesPerPixel(fConfig);
     }
 
@@ -273,7 +286,7 @@
      *  Return the native ID or handle to the texture, depending on the
      *  platform. e.g. on opengl, return the texture ID.
      */
-    virtual intptr_t getTextureHandle() = 0;
+    virtual intptr_t getTextureHandle() const = 0;
 
 #if GR_DEBUG
     void validate() const {
@@ -301,7 +314,7 @@
         fShiftFixedX = 31 - Gr_clz(fWidth);
         fShiftFixedY = 31 - Gr_clz(fHeight);
     }
-    
+
     // GrResource overrides
     virtual void onRelease() {
         releaseRenderTarget();