#endif
//#define USE_GX_SCREEN
-class SkCanvas;
-
+class SkSurface;
class SkOSMenu;
class SkWindow : public SkView {
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[]) {}
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,
// 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.
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();
#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)
-
/*
* 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"
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) {
bm.setPixels(buffer);
#endif
- SkAutoTUnref<SkCanvas> canvas(this->createCanvas());
+ SkAutoTUnref<SkSurface> surface(this->createSurface());
+ SkCanvas* canvas = surface->getCanvas();
canvas->clipRegion(fDirtyRgn);
if (updateArea)
-
/*
* Copyright 2011 Google Inc.
*
#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);
- (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