| reed@google.com | c906204 | 2012-07-30 18:06:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkSurface_Base_DEFINED |
| 9 | #define SkSurface_Base_DEFINED |
| 10 | |
| 11 | #include "SkSurface.h" |
| 12 | |
| 13 | class SkSurface_Base : public SkSurface { |
| 14 | public: |
| 15 | SkSurface_Base(int width, int height) : INHERITED(width, height) {} |
| 16 | |
| 17 | virtual SkCanvas* onNewCanvas() = 0; |
| 18 | virtual SkSurface* onNewSurface(const SkImage::Info&, SkColorSpace*) = 0; |
| 19 | virtual SkImage* onNewImageShapshot() = 0; |
| 20 | |
| 21 | /** |
| 22 | * Default implementation: |
| 23 | * |
| 24 | * image = this->newImageSnapshot(); |
| 25 | * if (image) { |
| 26 | * image->draw(canvas, ...); |
| 27 | * image->unref(); |
| 28 | * } |
| 29 | */ |
| 30 | virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*); |
| 31 | |
| 32 | private: |
| 33 | typedef SkSurface INHERITED; |
| 34 | }; |
| 35 | |
| 36 | #endif |
| 37 | |