add const to SkColorShader's asABitmap
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 8 Mar 2011 14:51:44 +0000 (14:51 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 8 Mar 2011 14:51:44 +0000 (14:51 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@900 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkColorShader.h
src/core/SkShader.cpp

index 1f83355..f7251ff 100644 (file)
@@ -47,10 +47,10 @@ public:
     virtual void shadeSpan16(int x, int y, uint16_t span[], int count);
     virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count);
 
-    virtual BitmapType asABitmap(SkBitmap* outTexture, 
+    virtual BitmapType asABitmap(SkBitmap* outTexture,
                                  SkMatrix* outMatrix,
-                                 TileMode xy[2], 
-                                 SkScalar* twoPointRadialParams);
+                                 TileMode xy[2],
+                                 SkScalar* twoPointRadialParams) const;
 
     virtual GradientType asAGradient(GradientInfo* info) const;
 
@@ -59,8 +59,8 @@ protected:
     virtual void flatten(SkFlattenableWriteBuffer& );
     virtual Factory getFactory() { return CreateProc; }
 private:
-    static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { 
-        return SkNEW_ARGS(SkColorShader, (buffer)); 
+    static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
+        return SkNEW_ARGS(SkColorShader, (buffer));
     }
     SkColor     fColor;         // ignored if fInheritColor is true
     SkPMColor   fPMColor;       // cached after setContext()
@@ -69,7 +69,7 @@ private:
     SkBool8     fInheritColor;
 
     // deferred allocation, used for asABitmap()
-    SkPixelRef* fAsABitmapPixelRef;
+    mutable SkPixelRef* fAsABitmapPixelRef;
 
     typedef SkShader INHERITED;
 };
index 015389e..8e469f2 100644 (file)
@@ -312,7 +312,7 @@ void SkColorShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) {
 // if we had a asAColor method, that would be more efficient...
 SkShader::BitmapType SkColorShader::asABitmap(SkBitmap* bitmap, SkMatrix* matrix,
                                               TileMode modes[],
-                                              SkScalar* twoPointRadialParams) {
+                                      SkScalar* twoPointRadialParams) const {
     // we cache the pixelref, since its generateID is used in the texture cache
     if (NULL == fAsABitmapPixelRef) {
         SkPMColor* storage = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor));