| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 return viewer->onTouch(owner, state, x, y); | 35 return viewer->onTouch(owner, state, x, y); |
| 36 } | 36 } |
| 37 | 37 |
| 38 static void on_ui_state_changed_handler(const SkString& stateName, const SkStrin
g& stateValue, void* userData) { | 38 static void on_ui_state_changed_handler(const SkString& stateName, const SkStrin
g& stateValue, void* userData) { |
| 39 Viewer* viewer = reinterpret_cast<Viewer*>(userData); | 39 Viewer* viewer = reinterpret_cast<Viewer*>(userData); |
| 40 | 40 |
| 41 return viewer->onUIStateChanged(stateName, stateValue); | 41 return viewer->onUIStateChanged(stateName, stateValue); |
| 42 } | 42 } |
| 43 | 43 |
| 44 DEFINE_bool2(fullscreen, f, false, "Run fullscreen."); | 44 DEFINE_bool2(fullscreen, f, true, "Run fullscreen."); |
| 45 DEFINE_string(key, "", "Space-separated key/value pairs to add to JSON identifyi
ng this builder."); | 45 DEFINE_string(key, "", "Space-separated key/value pairs to add to JSON identifyi
ng this builder."); |
| 46 DEFINE_string2(match, m, nullptr, | 46 DEFINE_string2(match, m, nullptr, |
| 47 "[~][^]substring[$] [...] of bench name to run.\n" | 47 "[~][^]substring[$] [...] of bench name to run.\n" |
| 48 "Multiple matches may be separated by spaces.\n" | 48 "Multiple matches may be separated by spaces.\n" |
| 49 "~ causes a matching bench to always be skipped\n" | 49 "~ causes a matching bench to always be skipped\n" |
| 50 "^ requires the start of the bench to match\n" | 50 "^ requires the start of the bench to match\n" |
| 51 "$ requires the end of the bench to match\n" | 51 "$ requires the end of the bench to match\n" |
| 52 "^ and $ requires an exact match\n" | 52 "^ and $ requires an exact match\n" |
| 53 "If a bench does not match any list entry,\n" | 53 "If a bench does not match any list entry,\n" |
| 54 "it is skipped unless some list entry starts with ~"); | 54 "it is skipped unless some list entry starts with ~"); |
| 55 DEFINE_string(skps, "skps", "Directory to read skps from."); | 55 DEFINE_string(skps, "skps", "Directory to read skps from."); |
| 56 DEFINE_bool(vulkan, true, "Run with Vulkan."); | |
| 57 | 56 |
| 58 const char *kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = { | 57 const char *kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = { |
| 59 " [OpenGL]", | 58 " [OpenGL]", |
| 60 " [Vulkan]" | 59 " [Vulkan]" |
| 61 }; | 60 }; |
| 62 | 61 |
| 63 const char* kName = "name"; | 62 const char* kName = "name"; |
| 64 const char* kValue = "value"; | 63 const char* kValue = "value"; |
| 65 const char* kOptions = "options"; | 64 const char* kOptions = "options"; |
| 66 const char* kSlideStateName = "Slide"; | 65 const char* kSlideStateName = "Slide"; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 78 memset(fMeasurements, 0, sizeof(fMeasurements)); | 77 memset(fMeasurements, 0, sizeof(fMeasurements)); |
| 79 | 78 |
| 80 SkDebugf("Command line arguments: "); | 79 SkDebugf("Command line arguments: "); |
| 81 for (int i = 1; i < argc; ++i) { | 80 for (int i = 1; i < argc; ++i) { |
| 82 SkDebugf("%s ", argv[i]); | 81 SkDebugf("%s ", argv[i]); |
| 83 } | 82 } |
| 84 SkDebugf("\n"); | 83 SkDebugf("\n"); |
| 85 | 84 |
| 86 SkCommandLineFlags::Parse(argc, argv); | 85 SkCommandLineFlags::Parse(argc, argv); |
| 87 | 86 |
| 88 fBackendType = FLAGS_vulkan ? sk_app::Window::kVulkan_BackendType | |
| 89 : sk_app::Window::kNativeGL_BackendType; | |
| 90 | |
| 91 fWindow = Window::CreateNativeWindow(platformData); | 87 fWindow = Window::CreateNativeWindow(platformData); |
| 92 fWindow->attach(fBackendType, DisplayParams()); | 88 fWindow->attach(fBackendType, DisplayParams()); |
| 93 | 89 |
| 94 // register callbacks | 90 // register callbacks |
| 95 fCommands.attach(fWindow); | 91 fCommands.attach(fWindow); |
| 96 fWindow->registerPaintFunc(on_paint_handler, this); | 92 fWindow->registerPaintFunc(on_paint_handler, this); |
| 97 fWindow->registerTouchFunc(on_touch_handler, this); | 93 fWindow->registerTouchFunc(on_touch_handler, this); |
| 98 fWindow->registerUIStateChangedFunc(on_ui_state_changed_handler, this); | 94 fWindow->registerUIStateChangedFunc(on_ui_state_changed_handler, this); |
| 99 | 95 |
| 100 // add key-bindings | 96 // add key-bindings |
| (...skipping 26 matching lines...) Expand all Loading... |
| 127 this->setupCurrentSlide(previousSlide); | 123 this->setupCurrentSlide(previousSlide); |
| 128 }); | 124 }); |
| 129 fCommands.addCommand(Window::Key::kUp, "Up", "Transform", "Zoom in", [this](
) { | 125 fCommands.addCommand(Window::Key::kUp, "Up", "Transform", "Zoom in", [this](
) { |
| 130 this->changeZoomLevel(1.f / 32.f); | 126 this->changeZoomLevel(1.f / 32.f); |
| 131 fWindow->inval(); | 127 fWindow->inval(); |
| 132 }); | 128 }); |
| 133 fCommands.addCommand(Window::Key::kDown, "Down", "Transform", "Zoom out", [t
his]() { | 129 fCommands.addCommand(Window::Key::kDown, "Down", "Transform", "Zoom out", [t
his]() { |
| 134 this->changeZoomLevel(-1.f / 32.f); | 130 this->changeZoomLevel(-1.f / 32.f); |
| 135 fWindow->inval(); | 131 fWindow->inval(); |
| 136 }); | 132 }); |
| 137 #if 0 // this doesn't seem to work on any platform right now | |
| 138 #ifndef SK_BUILD_FOR_ANDROID | 133 #ifndef SK_BUILD_FOR_ANDROID |
| 139 fCommands.addCommand('d', "Modes", "Change rendering backend", [this]() { | 134 fCommands.addCommand('d', "Modes", "Change rendering backend", [this]() { |
| 140 fWindow->detach(); | 135 fWindow->detach(); |
| 141 | 136 |
| 142 if (sk_app::Window::kVulkan_BackendType == fBackendType) { | 137 if (sk_app::Window::kVulkan_BackendType == fBackendType) { |
| 143 fBackendType = sk_app::Window::kNativeGL_BackendType; | 138 fBackendType = sk_app::Window::kNativeGL_BackendType; |
| 144 } | 139 } |
| 145 // TODO: get Vulkan -> OpenGL working on Windows without swapchain creat
ion failure | 140 // TODO: get Vulkan -> OpenGL working without swapchain creation failure |
| 146 //else if (sk_app::Window::kNativeGL_BackendType == fBackendType) { | 141 //else if (sk_app::Window::kNativeGL_BackendType == fBackendType) { |
| 147 // fBackendType = sk_app::Window::kVulkan_BackendType; | 142 // fBackendType = sk_app::Window::kVulkan_BackendType; |
| 148 //} | 143 //} |
| 149 | 144 |
| 150 fWindow->attach(fBackendType, DisplayParams()); | 145 fWindow->attach(fBackendType, DisplayParams()); |
| 151 this->updateTitle(); | 146 this->updateTitle(); |
| 152 fWindow->inval(); | |
| 153 }); | 147 }); |
| 154 #endif | 148 #endif |
| 155 #endif | |
| 156 | 149 |
| 157 // set up slides | 150 // set up slides |
| 158 this->initSlides(); | 151 this->initSlides(); |
| 159 | 152 |
| 160 fAnimTimer.run(); | 153 fAnimTimer.run(); |
| 161 | 154 |
| 162 // set up first frame | 155 // set up first frame |
| 163 fCurrentSlide = 0; | 156 fCurrentSlide = 0; |
| 164 setupCurrentSlide(-1); | 157 setupCurrentSlide(-1); |
| 165 | 158 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 fCurrentSlide++; | 439 fCurrentSlide++; |
| 447 } | 440 } |
| 448 if (fCurrentSlide >= fSlides.count()) { | 441 if (fCurrentSlide >= fSlides.count()) { |
| 449 fCurrentSlide = previousSlide; | 442 fCurrentSlide = previousSlide; |
| 450 SkDebugf("Slide not found: %s", stateValue.c_str()); | 443 SkDebugf("Slide not found: %s", stateValue.c_str()); |
| 451 } | 444 } |
| 452 } else { | 445 } else { |
| 453 SkDebugf("Unknown stateName: %s", stateName.c_str()); | 446 SkDebugf("Unknown stateName: %s", stateName.c_str()); |
| 454 } | 447 } |
| 455 } | 448 } |
| OLD | NEW |