OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 | 8 |
9 #include "VisualBench.h" | 9 #include "VisualBench.h" |
10 | 10 |
11 #include "ProcStats.h" | 11 #include "ProcStats.h" |
12 #include "SkApplication.h" | 12 #include "SkApplication.h" |
13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
14 #include "SkCommandLineFlags.h" | 14 #include "SkCommandLineFlags.h" |
15 #include "SkGraphics.h" | 15 #include "SkGraphics.h" |
16 #include "SkGr.h" | 16 #include "SkGr.h" |
17 #include "SkOSFile.h" | 17 #include "SkOSFile.h" |
18 #include "SkStream.h" | 18 #include "SkStream.h" |
19 #include "Stats.h" | 19 #include "Stats.h" |
20 #include "VisualLightweightBenchModule.h" | 20 #include "VisualLightweightBenchModule.h" |
21 #include "VisualInteractiveModule.h" | |
21 #include "gl/GrGLInterface.h" | 22 #include "gl/GrGLInterface.h" |
22 | 23 |
23 DEFINE_bool2(fullscreen, f, true, "Run fullscreen."); | 24 DEFINE_bool2(fullscreen, f, true, "Run fullscreen."); |
25 DEFINE_bool2(interactive, n, false, "Run in interactive mode."); | |
24 | 26 |
25 VisualBench::VisualBench(void* hwnd, int argc, char** argv) | 27 VisualBench::VisualBench(void* hwnd, int argc, char** argv) |
26 : INHERITED(hwnd) | 28 : INHERITED(hwnd) |
27 , fModule(new VisualLightweightBenchModule(this)) { | 29 , fModule(new VisualLightweightBenchModule(this)) { |
28 SkCommandLineFlags::Parse(argc, argv); | 30 SkCommandLineFlags::Parse(argc, argv); |
29 | 31 |
32 if (FLAGS_interactive) { | |
33 fModule.reset(new VisualInteractiveModule(this)); | |
34 } | |
35 | |
30 this->setTitle(); | 36 this->setTitle(); |
31 this->setupBackend(); | 37 this->setupBackend(); |
32 } | 38 } |
33 | 39 |
34 VisualBench::~VisualBench() { | 40 VisualBench::~VisualBench() { |
35 INHERITED::detach(); | 41 INHERITED::detach(); |
36 } | 42 } |
37 | 43 |
38 void VisualBench::setTitle() { | 44 void VisualBench::setTitle() { |
39 SkString title("VisualBench"); | 45 SkString title("VisualBench"); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 | 102 |
97 // Invalidate the window to force a redraw. Poor man's animation mechanism. | 103 // Invalidate the window to force a redraw. Poor man's animation mechanism. |
98 this->inval(nullptr); | 104 this->inval(nullptr); |
99 } | 105 } |
100 | 106 |
101 void VisualBench::onSizeChange() { | 107 void VisualBench::onSizeChange() { |
102 this->setupRenderTarget(); | 108 this->setupRenderTarget(); |
103 } | 109 } |
104 | 110 |
105 bool VisualBench::onHandleChar(SkUnichar unichar) { | 111 bool VisualBench::onHandleChar(SkUnichar unichar) { |
106 return true; | 112 // ESC |
113 if (27 == unichar) { | |
joshualitt
2015/09/14 14:07:45
static const kEscKey or something similar?
jvanverth1
2015/09/14 16:21:38
Done.
| |
114 this->closeWindow(); | |
115 return true; | |
116 } | |
117 | |
118 return fModule->onHandleChar(unichar); | |
107 } | 119 } |
108 | 120 |
109 // Externally declared entry points | 121 // Externally declared entry points |
110 void application_init() { | 122 void application_init() { |
111 SkGraphics::Init(); | 123 SkGraphics::Init(); |
112 SkEvent::Init(); | 124 SkEvent::Init(); |
113 } | 125 } |
114 | 126 |
115 void application_term() { | 127 void application_term() { |
116 SkEvent::Term(); | 128 SkEvent::Term(); |
117 } | 129 } |
118 | 130 |
119 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { | 131 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { |
120 return new VisualBench(hwnd, argc, argv); | 132 return new VisualBench(hwnd, argc, argv); |
121 } | 133 } |
122 | 134 |
OLD | NEW |