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>
diff --git a/gm/imagefilters.cpp b/gm/imagefilters.cpp
index 146388f..bc33a57 100644
--- a/gm/imagefilters.cpp
+++ b/gm/imagefilters.cpp
@@ -11,6 +11,7 @@
#include "SkImage.h"
#include "SkImageFilter.h"
#include "SkSurface.h"
+#include "sk_tool_utils.h"
/**
* Test drawing a primitive w/ an imagefilter (in this case, just matrix w/ identity) to see
@@ -69,10 +70,7 @@
static sk_sp<SkImage> make_image(SkCanvas* canvas) {
const SkImageInfo info = SkImageInfo::MakeS32(100, 100, kPremul_SkAlphaType);
- auto surface(canvas->makeSurface(info));
- if (!surface) {
- surface = SkSurface::MakeRaster(info);
- }
+ auto surface(sk_tool_utils::makeSurface(canvas, info));
surface->getCanvas()->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), SkPaint());
return surface->makeImageSnapshot();
}