Add createNewCompatibleDevice. Allow devices to have a NULL factory and saveLayer will fall back on createNewCompatibleDevice.

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



git-svn-id: http://skia.googlecode.com/svn/trunk@1625 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index 4d0efeb..3a675be 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -37,11 +37,12 @@
      *  New device that will create an offscreen renderTarget based on the
      *  config, width, height.
      *
-     *  isForSaveLayer is a special flag that should only be set by SkCanvas
+     *  usage is a special flag that should only be set by SkCanvas
      *  internally.
      */
-    SkGpuDevice(GrContext*, SkBitmap::Config, int width, int height,
-                bool isForSaveLayer = false);
+    SkGpuDevice(GrContext*, SkBitmap::Config,
+                int width, int height, 
+                SkDevice::Usage usage = SkDevice::kGeneral_Usage);
 
     /**
      *  New device that will render to the specified renderTarget.
@@ -132,11 +133,15 @@
     virtual SkDeviceFactory* onNewDeviceFactory();
 
     class TexCache;
+    enum TexType {
+        kBitmap_TexType,
+        kDeviceRenderTarget_TexType,
+        kSaveLayerDeviceRenderTarget_TexType
+    };
     TexCache* lockCachedTexture(const SkBitmap& bitmap,
                                 const GrSamplerState& sampler,
                                 GrTexture** texture,
-                                bool forDeviceRenderTarget = false,
-                                bool isSaveLayer = false);
+                                TexType type = kBitmap_TexType);
     void unlockCachedTexture(TexCache*);
 
     class SkAutoCachedTexture {
@@ -192,6 +197,12 @@
                                GrPaint* grPaint,
                                bool constantColor);
 
+    // override from SkDevice
+    virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config, 
+                                               int width, int height, 
+                                               bool isOpaque,
+                                               Usage usage);
+
     SkDrawProcs* initDrawForText(GrTextContext*);
     bool bindDeviceAsTexture(GrPaint* paint);