diff options
author | Mike Reed <reed@google.com> | 2017-06-28 19:57:21 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-29 12:14:53 +0000 |
commit | 44d04bd7ed3be8c39cc7ea02e3789cccf083bb55 (patch) | |
tree | 9fc3d15501a84bf9636b3ec5619b90c8d7f62a9a /src/image/SkSurface.cpp | |
parent | 7f22511c1cb4e823e17446c54aa308a2f2203899 (diff) |
add null-surface
Bug:crbug.com/737726
Change-Id: Iec9094d8d7232943e90fe2d9745fc83bcdf90954
Reviewed-on: https://skia-review.googlesource.com/21190
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/image/SkSurface.cpp')
-rw-r--r-- | src/image/SkSurface.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp index 57d419c408..dcf56493b5 100644 --- a/src/image/SkSurface.cpp +++ b/src/image/SkSurface.cpp @@ -200,6 +200,32 @@ bool SkSurface::wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores } ////////////////////////////////////////////////////////////////////////////////////// +#include "SkNoDrawCanvas.h" + +class SkNullSurface : public SkSurface_Base { +public: + SkNullSurface(int width, int height) : SkSurface_Base(width, height, nullptr) {} + +protected: + SkCanvas* onNewCanvas() override { + return new SkNoDrawCanvas(this->width(), this->height()); + } + sk_sp<SkSurface> onNewSurface(const SkImageInfo& info) override { + return MakeNull(info.width(), info.height()); + } + sk_sp<SkImage> onNewImageSnapshot() override { return nullptr; } + void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) override {} + void onCopyOnWrite(ContentChangeMode) override {} +}; + +sk_sp<SkSurface> SkSurface::MakeNull(int width, int height) { + if (width < 1 || height < 1) { + return nullptr; + } + return sk_sp<SkSurface>(new SkNullSurface(width, height)); +} + +////////////////////////////////////////////////////////////////////////////////////// #if !SK_SUPPORT_GPU |