diff options
author | Mike Reed <reed@google.com> | 2018-01-02 15:40:29 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-02 21:06:41 +0000 |
commit | 46596ae50559e89a0a2462573ac9448cf309cf56 (patch) | |
tree | bc515e91123b6d0d14f7873c4ab7ce2d22b41bcc /gm/surface.cpp | |
parent | 99b504018b31d63566995b3fc114c940ed4749c4 (diff) |
use tool_utils to encapsulate checking for recording canvas and makeSurface
Bug: skia:
Change-Id: Ia93ee09dd213b8d6ad5c18e887add5ff3448c824
Reviewed-on: https://skia-review.googlesource.com/90243
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'gm/surface.cpp')
-rw-r--r-- | gm/surface.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/gm/surface.cpp b/gm/surface.cpp index 4b400caa44..30a7844742 100644 --- a/gm/surface.cpp +++ b/gm/surface.cpp @@ -124,10 +124,7 @@ protected: void onDraw(SkCanvas* canvas) override { SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); - auto surf(canvas->makeSurface(info, nullptr)); - if (!surf) { - surf = SkSurface::MakeRaster(info); - } + auto surf(sk_tool_utils::makeSurface(canvas, info, nullptr)); drawInto(surf->getCanvas()); sk_sp<SkImage> image(surf->makeImageSnapshot()); @@ -152,10 +149,7 @@ DEF_GM( return new NewSurfaceGM ) DEF_SIMPLE_GM(copy_on_write_retain, canvas, 256, 256) { const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256); - sk_sp<SkSurface> surf = canvas->makeSurface(info, nullptr); - if (!surf) { - surf = SkSurface::MakeRaster(info, nullptr); - } + sk_sp<SkSurface> surf = sk_tool_utils::makeSurface(canvas, info); surf->getCanvas()->clear(SK_ColorRED); // its important that image survives longer than the next draw, so the surface will see @@ -173,11 +167,7 @@ DEF_SIMPLE_GM(copy_on_write_retain, canvas, 256, 256) { DEF_SIMPLE_GM(copy_on_write_savelayer, canvas, 256, 256) { const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256); - sk_sp<SkSurface> surf = canvas->makeSurface(info, nullptr); - if (!surf) { - surf = SkSurface::MakeRaster(info, nullptr); - } - + sk_sp<SkSurface> surf = sk_tool_utils::makeSurface(canvas, info); surf->getCanvas()->clear(SK_ColorRED); // its important that image survives longer than the next draw, so the surface will see // an outstanding image, and have to decide if it should retain or discard those pixels |