Add a commandline flag to force offscreen rendering in viewer
Change-Id: I0d6dd3625a8571c09af7557b1727812bba2a9ee4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262355
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index fcab247..05e9927 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -129,6 +129,7 @@
static DEFINE_bool(redraw, false, "Toggle continuous redraw.");
+static DEFINE_bool(offscreen, false, "Force rendering to an offscreen surface.");
const char* kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = {
"OpenGL",
@@ -1314,11 +1315,13 @@
// ... in fake perspective or zooming (so we have a snapped copy of the results)
// ... in any raster mode, because the window surface is actually GL
// ... in any color managed mode, because we always make the window surface with no color space
+ // ... or if the user explicitly requested offscreen rendering
sk_sp<SkSurface> offscreenSurface = nullptr;
if (kPerspective_Fake == fPerspectiveMode ||
fShowZoomWindow ||
Window::kRaster_BackendType == fBackendType ||
- colorSpace != nullptr) {
+ colorSpace != nullptr ||
+ FLAGS_offscreen) {
offscreenSurface = make_surface(fWindow->width(), fWindow->height());
slideSurface = offscreenSurface.get();