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/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)