use surface in SkView/SampleApp

BUG=skia:
R=bsalomon@google.com, robertphillips@google.com

Author: reed@google.com

Review URL: https://codereview.chromium.org/580073003
diff --git a/include/views/SkWindow.h b/include/views/SkWindow.h
index 2a9315d..40cc5ec 100644
--- a/include/views/SkWindow.h
+++ b/include/views/SkWindow.h
@@ -21,8 +21,7 @@
 #endif
 //#define USE_GX_SCREEN
 
-class SkCanvas;
-
+class SkSurface;
 class SkOSMenu;
 
 class SkWindow : public SkView {
@@ -59,7 +58,7 @@
     void    preConcat(const SkMatrix&);
     void    postConcat(const SkMatrix&);
 
-    virtual SkCanvas* createCanvas();
+    virtual SkSurface* createSurface();
 
     virtual void onPDFSaved(const char title[], const char desc[],
         const char path[]) {}
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 9d7e727..08e7240 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -271,17 +271,14 @@
         fBackend = kNone_BackEndType;
     }
 
-    virtual SkCanvas* createCanvas(SampleWindow::DeviceType dType,
-                                   SampleWindow* win) {
+    virtual SkSurface* createSurface(SampleWindow::DeviceType dType,
+                                     SampleWindow* win) SK_OVERRIDE {
 #if SK_SUPPORT_GPU
         if (IsGpuDeviceType(dType) && fCurContext) {
-            SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(fCurRenderTarget));
-            return new SkCanvas(device);
-        } else
-#endif
-        {
-            return NULL;
+            return SkSurface::NewRenderTargetDirect(fCurRenderTarget);
         }
+#endif
+        return NULL;
     }
 
     virtual void publishCanvas(SampleWindow::DeviceType dType,
diff --git a/samplecode/SampleApp.h b/samplecode/SampleApp.h
index e08ff8a..abb1f24 100644
--- a/samplecode/SampleApp.h
+++ b/samplecode/SampleApp.h
@@ -76,7 +76,7 @@
 
         // called before drawing. should install correct device
         // type on the canvas. Will skip drawing if returns false.
-        virtual SkCanvas* createCanvas(DeviceType dType, SampleWindow* win) = 0;
+        virtual SkSurface* createSurface(DeviceType dType, SampleWindow* win) = 0;
 
         // called after drawing, should get the results onto the
         // screen.
@@ -100,18 +100,18 @@
     SampleWindow(void* hwnd, int argc, char** argv, DeviceManager*);
     virtual ~SampleWindow();
 
-    virtual SkCanvas* createCanvas() SK_OVERRIDE {
-        SkCanvas* canvas = NULL;
+    virtual SkSurface* createSurface() SK_OVERRIDE {
+        SkSurface* surface = NULL;
         if (fDevManager) {
-            canvas = fDevManager->createCanvas(fDeviceType, this);
+            surface = fDevManager->createSurface(fDeviceType, this);
         }
-        if (NULL == canvas) {
-            canvas = this->INHERITED::createCanvas();
+        if (NULL == surface) {
+            surface = this->INHERITED::createSurface();
         }
-        return canvas;
+        return surface;
     }
 
-    virtual void draw(SkCanvas* canvas);
+    virtual void draw(SkCanvas*) SK_OVERRIDE;
 
     void setDeviceType(DeviceType type);
     void toggleRendering();
diff --git a/samplecode/SampleBitmapRect.cpp b/samplecode/SampleBitmapRect.cpp
index cf1196c..006b919 100644
--- a/samplecode/SampleBitmapRect.cpp
+++ b/samplecode/SampleBitmapRect.cpp
@@ -24,12 +24,6 @@
 #include "SkOSFile.h"
 #include "SkStream.h"
 
-#if SK_SUPPORT_GPU
-#include "SkGpuDevice.h"
-#else
-class GrContext;
-#endif
-
 #define INT_SIZE        64
 #define SCALAR_SIZE     SkIntToScalar(INT_SIZE)
 
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index 99c2d30..90ef280 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -1,14 +1,14 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "SkWindow.h"
 #include "SkCanvas.h"
-#include "SkDevice.h"
 #include "SkOSMenu.h"
+#include "SkSurface.h"
 #include "SkSystemEventTypes.h"
 #include "SkTime.h"
 
@@ -32,8 +32,9 @@
     fMenus.deleteAll();
 }
 
-SkCanvas* SkWindow::createCanvas() {
-    return new SkCanvas(this->getBitmap());
+SkSurface* SkWindow::createSurface() {
+    const SkBitmap& bm = this->getBitmap();
+    return SkSurface::NewRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes());
 }
 
 void SkWindow::setMatrix(const SkMatrix& matrix) {
@@ -126,7 +127,8 @@
         bm.setPixels(buffer);
 #endif
 
-        SkAutoTUnref<SkCanvas> canvas(this->createCanvas());
+        SkAutoTUnref<SkSurface> surface(this->createSurface());
+        SkCanvas* canvas = surface->getCanvas();
 
         canvas->clipRegion(fDirtyRgn);
         if (updateArea)
diff --git a/src/views/mac/SkNSView.mm b/src/views/mac/SkNSView.mm
index 6347d46..6714167 100644
--- a/src/views/mac/SkNSView.mm
+++ b/src/views/mac/SkNSView.mm
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
@@ -8,6 +7,7 @@
 
 #import "SkNSView.h"
 #include "SkCanvas.h"
+#include "SkSurface.h"
 #include "SkCGUtils.h"
 #include "SkEvent.h"
 SK_COMPILE_ASSERT(SK_SUPPORT_GPU, not_implemented_for_non_gpu_build);
@@ -129,8 +129,8 @@
 - (void)drawSkia {
     fRedrawRequestPending = false;
     if (fWind) {
-        SkAutoTUnref<SkCanvas> canvas(fWind->createCanvas());
-        fWind->draw(canvas);
+        SkAutoTUnref<SkSurface> surface(fWind->createSurface());
+        fWind->draw(surface->getCanvas());
 #ifdef FORCE_REDRAW
         fWind->inval(NULL);
 #endif