Adding a new SkSurface factory for generating surfaces from the scratch texture pool.

TEST=Surface unit test
BUG=crbug.com/351798
R=bsalomon@google.com, robertphillips@google.com, reed@google.com

Author: junov@chromium.org

Review URL: https://codereview.chromium.org/201153023

git-svn-id: http://skia.googlecode.com/svn/trunk@13864 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index ad4ebd7..3e20e16 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -29,12 +29,18 @@
  */
 class SK_API SkGpuDevice : public SkBitmapDevice {
 public:
+    enum Flags {
+        kNeedClear_Flag = 1 << 0,  //!< Surface requires an initial clear 
+        kCached_Flag    = 1 << 1,  //!< Surface is cached and needs to be unlocked when released
+    };
 
     /**
      * Creates an SkGpuDevice from a GrSurface. This will fail if the surface is not a render
-     * target. The caller owns a ref on the returned device.
+     * target. The caller owns a ref on the returned device. If the surface is cached, 
+     * the kCached_Flag should be specified to make the device responsible for unlocking
+     * the surface when it is released.
      */
-    static SkGpuDevice* Create(GrSurface* surface);
+    static SkGpuDevice* Create(GrSurface* surface, unsigned flags = 0);
 
     /**
      *  New device that will create an offscreen renderTarget based on the
@@ -58,7 +64,7 @@
      *  DEPRECATED -- need to make this private, call Create(surface)
      *  New device that will render to the specified renderTarget.
      */
-    SkGpuDevice(GrContext*, GrRenderTarget*);
+    SkGpuDevice(GrContext*, GrRenderTarget*, unsigned flags = 0);
 
     /**
      *  DEPRECATED -- need to make this private, call Create(surface)
@@ -66,7 +72,7 @@
      *  The GrTexture's asRenderTarget() must be non-NULL or device will not
      *  function.
      */
-    SkGpuDevice(GrContext*, GrTexture*);
+    SkGpuDevice(GrContext*, GrTexture*, unsigned flags = 0);
 
     virtual ~SkGpuDevice();
 
@@ -173,10 +179,7 @@
     bool                fNeedClear;
 
     // called from rt and tex cons
-    void initFromRenderTarget(GrContext*, GrRenderTarget*, bool cached);
-
-    // used by createCompatibleDevice
-    SkGpuDevice(GrContext*, GrTexture* texture, bool needClear);
+    void initFromRenderTarget(GrContext*, GrRenderTarget*, unsigned flags);
 
     virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE;