make SkDevice constructors explicit between offscreen and on/direct

http://codereview.appspot.com/4632044/



git-svn-id: http://skia.googlecode.com/svn/trunk@1620 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 273153f..d5032a7 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -101,13 +101,13 @@
         is raster, the pixels will be allocated automatically.
      */
     virtual SkDevice* createDevice(SkBitmap::Config, int width, int height,
-                                   bool isOpaque, bool forLayer = false);
+                                   bool isOpaque);
 
     /**
      *  Create a new raster device and make it current. This also returns
      *  the new device.
      */
-    SkDevice* setBitmapDevice(const SkBitmap& bitmap, bool forLayer = false);
+    SkDevice* setBitmapDevice(const SkBitmap& bitmap);
 
     /**
      *  Return the current device factory, or NULL. The reference count of
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index d9a4fde..ff9c4d1 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -52,18 +52,30 @@
 
 class SK_API SkDevice : public SkRefCnt {
 public:
-    SkDevice(SkCanvas*);
-    /** Construct a new device, extracting the width/height/config/isOpaque values from
-        the bitmap. If transferPixelOwnership is true, and the bitmap claims to own its
-        own pixels (getOwnsPixels() == true), then transfer this responsibility to the
-        device, and call setOwnsPixels(false) on the bitmap.
+//    SkDevice();
 
-        Subclasses may override the destructor, which is virtual, even though this class
-        doesn't have one. SkRefCnt does.
-
-        @param bitmap   A copy of this bitmap is made and stored in the device
+    /**
+     *  Construct a new device with the specified bitmap as its backend. It is
+     *  valid for the bitmap to have no pixels associated with it. In that case,
+     *  any drawing to this device will have no effect.
     */
-    SkDevice(SkCanvas*, const SkBitmap& bitmap, bool forOffscreen);
+    SkDevice(const SkBitmap& bitmap);
+
+    /**
+     *  Create a new raster device and have the pixels be automatically
+     *  allocated. The rowBytes of the device will be computed automatically
+     *  based on the config and the width.
+     *
+     *  @param config   The desired config for the pixels. If the request cannot
+     *                  be met, the closest matching support config will be used.
+     *  @param width    width (in pixels) of the device
+     *  @param height   height (in pixels) of the device
+     *  @param isOpaque Set to true if it is known that all of the pixels will
+     *                  be drawn to opaquely. Used as an accelerator when drawing
+     *                  these pixels to another device.
+     */
+    SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque = false);
+
     virtual ~SkDevice();
 
     /**
@@ -276,7 +288,6 @@
     // just called by SkCanvas when built as a layer
     void setOrigin(int x, int y) { fOrigin.set(x, y); }
 
-    SkCanvas*   fCanvas;
     SkBitmap    fBitmap;
     SkIPoint    fOrigin;
     SkMetaData* fMetaData;
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index 96afa08..4d0efeb 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -19,6 +19,7 @@
 #define SkGpuDevice_DEFINED
 
 #include "SkGr.h"
+#include "SkBitmap.h"
 #include "SkDevice.h"
 #include "SkRegion.h"
 
@@ -33,15 +34,19 @@
 class SK_API SkGpuDevice : public SkDevice {
 public:
     /**
-     * The SkGpuDevice will render to the GrRenderTarget, or if the paremeter is
-     * null it will create its own render target and manage that target's
-     * lifetime. Setting isSaveLayer to true is for internal use and may cause 
-     * problems when using the device's bitmap as a src if used externally.
+     *  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
+     *  internally.
      */
-    SkGpuDevice(GrContext*,
-                const SkBitmap& bitmap,
-                GrRenderTarget* renderTargetOrNull,
-                bool isSaveLayer = false);
+    SkGpuDevice(GrContext*, SkBitmap::Config, int width, int height,
+                bool isForSaveLayer = false);
+
+    /**
+     *  New device that will render to the specified renderTarget.
+     */
+    SkGpuDevice(GrContext*, GrRenderTarget*);
 
     /**
      * Magic value that can be passed to constructor. Causes
diff --git a/include/utils/SkProxyCanvas.h b/include/utils/SkProxyCanvas.h
index 6e55aa6..5d03c07 100644
--- a/include/utils/SkProxyCanvas.h
+++ b/include/utils/SkProxyCanvas.h
@@ -76,7 +76,7 @@
     virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter);
 
     virtual SkDevice* createDevice(SkBitmap::Config, int width, int height,
-                                   bool isOpaque, bool isForLayer);
+                                   bool isOpaque);
 
 private:
     SkCanvas*   fProxy;