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

Side by Side Diff: tools/viewer/Viewer.cpp

Issue 2184163003: Enable backend switching for Windows Viewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Delete extra glMakeCurrent Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/viewer/sk_app/Window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Viewer.h" 8 #include "Viewer.h"
9 9
10 #include "GMSlide.h" 10 #include "GMSlide.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 "[~][^]substring[$] [...] of bench name to run.\n" 53 "[~][^]substring[$] [...] of bench name to run.\n"
54 "Multiple matches may be separated by spaces.\n" 54 "Multiple matches may be separated by spaces.\n"
55 "~ causes a matching bench to always be skipped\n" 55 "~ causes a matching bench to always be skipped\n"
56 "^ requires the start of the bench to match\n" 56 "^ requires the start of the bench to match\n"
57 "$ requires the end of the bench to match\n" 57 "$ requires the end of the bench to match\n"
58 "^ and $ requires an exact match\n" 58 "^ and $ requires an exact match\n"
59 "If a bench does not match any list entry,\n" 59 "If a bench does not match any list entry,\n"
60 "it is skipped unless some list entry starts with ~"); 60 "it is skipped unless some list entry starts with ~");
61 61
62 #ifdef SK_VULKAN 62 #ifdef SK_VULKAN
63 # define BACKENDS_STR "\"sw\", \"gl\", and \"vulkan\"" 63 # define BACKENDS_STR "\"sw\", \"gl\", and \"vk\""
64 #else 64 #else
65 # define BACKENDS_STR "\"sw\" and \"gl\"" 65 # define BACKENDS_STR "\"sw\" and \"gl\""
66 #endif 66 #endif
67 67
68 #ifdef SK_BUILD_FOR_ANDROID 68 #ifdef SK_BUILD_FOR_ANDROID
69 DEFINE_string(skps, "/data/local/tmp/skia", "Directory to read skps from."); 69 DEFINE_string(skps, "/data/local/tmp/skia", "Directory to read skps from.");
70 DEFINE_string(jpgs, "/data/local/tmp/skia", "Directory to read jpgs from."); 70 DEFINE_string(jpgs, "/data/local/tmp/skia", "Directory to read jpgs from.");
71 #else 71 #else
72 DEFINE_string(skps, "skps", "Directory to read skps from."); 72 DEFINE_string(skps, "skps", "Directory to read skps from.");
73 DEFINE_string(jpgs, "jpgs", "Directory to read jpgs from."); 73 DEFINE_string(jpgs, "jpgs", "Directory to read jpgs from.");
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 this->setupCurrentSlide(previousSlide); 173 this->setupCurrentSlide(previousSlide);
174 }); 174 });
175 fCommands.addCommand(Window::Key::kUp, "Up", "Transform", "Zoom in", [this]( ) { 175 fCommands.addCommand(Window::Key::kUp, "Up", "Transform", "Zoom in", [this]( ) {
176 this->changeZoomLevel(1.f / 32.f); 176 this->changeZoomLevel(1.f / 32.f);
177 fWindow->inval(); 177 fWindow->inval();
178 }); 178 });
179 fCommands.addCommand(Window::Key::kDown, "Down", "Transform", "Zoom out", [t his]() { 179 fCommands.addCommand(Window::Key::kDown, "Down", "Transform", "Zoom out", [t his]() {
180 this->changeZoomLevel(-1.f / 32.f); 180 this->changeZoomLevel(-1.f / 32.f);
181 fWindow->inval(); 181 fWindow->inval();
182 }); 182 });
183 #if 0 // this doesn't seem to work on any platform right now 183 #ifdef SK_BUILD_FOR_WIN
184 #ifndef SK_BUILD_FOR_ANDROID
185 fCommands.addCommand('d', "Modes", "Change rendering backend", [this]() { 184 fCommands.addCommand('d', "Modes", "Change rendering backend", [this]() {
185 if (sk_app::Window::kRaster_BackendType == fBackendType) {
186 fBackendType = sk_app::Window::kNativeGL_BackendType;
187 #ifdef SK_VULKAN
188 } else if (sk_app::Window::kNativeGL_BackendType == fBackendType) {
189 fBackendType = sk_app::Window::kVulkan_BackendType;
190 #endif
191 } else {
192 fBackendType = sk_app::Window::kRaster_BackendType;
193 }
194
186 fWindow->detach(); 195 fWindow->detach();
187 196
197 #ifdef SK_VULKAN
198 // Switching from OpenGL to Vulkan in the same window is problematic at this point,
199 // so we just delete the window and recreate it.
200 // On Windows, only tearing down the window when going from OpenGL to Vu lkan works fine.
201 // On Linux, we may need to tear down the window for the Vulkan to OpenG L case as well.
188 if (sk_app::Window::kVulkan_BackendType == fBackendType) { 202 if (sk_app::Window::kVulkan_BackendType == fBackendType) {
189 fBackendType = sk_app::Window::kNativeGL_BackendType; 203 delete fWindow;
190 } 204 fWindow = Window::CreateNativeWindow(nullptr);
191 // TODO: get Vulkan -> OpenGL working on Windows without swapchain creat ion failure
192 //else if (sk_app::Window::kNativeGL_BackendType == fBackendType) {
193 // fBackendType = sk_app::Window::kVulkan_BackendType;
194 //}
195 205
206 // re-register callbacks
207 fCommands.attach(fWindow);
208 fWindow->registerPaintFunc(on_paint_handler, this);
209 fWindow->registerTouchFunc(on_touch_handler, this);
210 fWindow->registerUIStateChangedFunc(on_ui_state_changed_handler, thi s);
211 }
212 #endif
196 fWindow->attach(fBackendType, DisplayParams()); 213 fWindow->attach(fBackendType, DisplayParams());
214
197 this->updateTitle(); 215 this->updateTitle();
198 fWindow->inval(); 216 fWindow->inval();
217 fWindow->show();
199 }); 218 });
200 #endif 219 #endif
201 #endif
202 220
203 // set up slides 221 // set up slides
204 this->initSlides(); 222 this->initSlides();
205 223
206 fAnimTimer.run(); 224 fAnimTimer.run();
207 225
208 // set up first frame 226 // set up first frame
209 fCurrentSlide = 0; 227 fCurrentSlide = 0;
210 setupCurrentSlide(-1); 228 setupCurrentSlide(-1);
211 229
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 updateUIState(); 646 updateUIState();
629 } 647 }
630 } else if (stateName.equals(kRefreshStateName)) { 648 } else if (stateName.equals(kRefreshStateName)) {
631 // This state is actually NOT in the UI state. 649 // This state is actually NOT in the UI state.
632 // We use this to allow Android to quickly set bool fRefresh. 650 // We use this to allow Android to quickly set bool fRefresh.
633 fRefresh = stateValue.equals(kON); 651 fRefresh = stateValue.equals(kON);
634 } else { 652 } else {
635 SkDebugf("Unknown stateName: %s", stateName.c_str()); 653 SkDebugf("Unknown stateName: %s", stateName.c_str());
636 } 654 }
637 } 655 }
OLDNEW
« no previous file with comments | « no previous file | tools/viewer/sk_app/Window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698