expose gpu-device-factory
use that factory in gpucanvas, rather than overriding createDevice

note: I think we now don't need the canvas parameter in device-factory



git-svn-id: http://skia.googlecode.com/svn/trunk@684 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 2d5634c..a4fb986 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -18,8 +18,8 @@
 #include "GrContext.h"
 #include "GrTextContext.h"
 
-#include "SkGpuCanvas.h"
 #include "SkGpuDevice.h"
+#include "SkGpuDeviceFactory.h"
 #include "SkGrTexturePixelRef.h"
 
 #include "SkDrawProcs.h"
@@ -109,13 +109,14 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-SkGpuDevice::SkGpuDevice(SkGpuCanvas* canvas, const SkBitmap& bitmap, bool isLayer)
-        : SkDevice(canvas, bitmap, false) {
+SkGpuDevice::SkGpuDevice(GrContext* context, const SkBitmap& bitmap, bool isLayer)
+        : SkDevice(NULL, bitmap, false) {
 
     fNeedPrepareRenderTarget = false;
     fDrawProcs = NULL;
 
-    fContext = canvas->context();
+    // should I ref() this, and then unref in destructor? <mrr>
+    fContext = context;
 
     fCache = NULL;
     fTexture = NULL;
@@ -1046,4 +1047,22 @@
     this->context()->unlockTexture((GrTextureEntry*)cache);
 }
 
+///////////////////////////////////////////////////////////////////////////////
+
+SkGpuDeviceFactory::SkGpuDeviceFactory(GrContext* context) : fContext(context) {
+    context->ref();
+}
+
+SkGpuDeviceFactory::~SkGpuDeviceFactory() {
+    fContext->unref();
+}
+
+SkDevice* SkGpuDeviceFactory::newDevice(SkCanvas*, SkBitmap::Config config,
+                                        int width, int height,
+                                        bool isOpaque, bool isLayer) {
+    SkBitmap bm;
+    bm.setConfig(config, width, height);
+    bm.setIsOpaque(isOpaque);
+    return new SkGpuDevice(fContext, bm, isLayer);
+}