Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Unified Diff: tools/viewer/Viewer.cpp

Issue 1978573003: Add OpenGL context to Viewer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase to ToT Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/viewer/Viewer.h ('k') | tools/viewer/sk_app/DisplayParams.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/viewer/Viewer.cpp
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index d492cdeefeb854246b90d5e721cfa43c28662cb9..7f18652c2c024ba98599f24969ba85e4f506a883 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -48,9 +48,15 @@ DEFINE_string2(match, m, nullptr,
"it is skipped unless some list entry starts with ~");
DEFINE_string(skps, "skps", "Directory to read skps from.");
+const char *kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = {
+ " [OpenGL]",
+ " [Vulkan]"
+};
+
Viewer::Viewer(int argc, char** argv, void* platformData)
: fCurrentMeasurement(0)
, fDisplayStats(false)
+ , fBackendType(sk_app::Window::kVulkan_BackendType)
, fZoomCenterX(0.0f)
, fZoomCenterY(0.0f)
, fZoomLevel(0.0f)
@@ -67,7 +73,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
SkCommandLineFlags::Parse(argc, argv);
fWindow = Window::CreateNativeWindow(platformData);
- fWindow->attach(Window::kVulkan_BackendType, DisplayParams());
+ fWindow->attach(fBackendType, DisplayParams());
// register callbacks
fCommands.attach(fWindow);
@@ -111,6 +117,22 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
this->changeZoomLevel(-1.f / 32.f);
fWindow->inval();
});
+#ifndef SK_BUILD_FOR_ANDROID
+ fCommands.addCommand('d', "Modes", "Change rendering backend", [this]() {
+ fWindow->detach();
+
+ if (sk_app::Window::kVulkan_BackendType == fBackendType) {
+ fBackendType = sk_app::Window::kNativeGL_BackendType;
+ }
+ // TODO: get Vulkan -> OpenGL working without swapchain creation failure
+ //else if (sk_app::Window::kNativeGL_BackendType == fBackendType) {
+ // fBackendType = sk_app::Window::kVulkan_BackendType;
+ //}
+
+ fWindow->attach(fBackendType, DisplayParams());
+ this->updateTitle();
+ });
+#endif
// set up slides
this->initSlides();
@@ -186,6 +208,7 @@ void Viewer::updateTitle() {
if (kSRGB_SkColorProfileType == fWindow->getDisplayParams().fProfileType) {
title.append(" sRGB");
}
+ title.append(kBackendTypeStrings[fBackendType]);
fWindow->setTitle(title.c_str());
}
@@ -237,7 +260,6 @@ SkMatrix Viewer::computeMatrix() {
}
void Viewer::onPaint(SkCanvas* canvas) {
-
int count = canvas->save();
if (fWindow->supportsContentRect()) {
« no previous file with comments | « tools/viewer/Viewer.h ('k') | tools/viewer/sk_app/DisplayParams.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698