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

Side by Side Diff: tools/VisualBench/VisualBench.cpp

Issue 1336043003: Add viewer mode to VisualBench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix init order Created 5 years, 3 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 | « tools/VisualBench/VisualBench.h ('k') | tools/VisualBench/VisualInteractiveModule.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 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 97 }
92 } 98 }
93 99
94 void VisualBench::draw(SkCanvas* canvas) { 100 void VisualBench::draw(SkCanvas* canvas) {
95 fModule->draw(canvas); 101 fModule->draw(canvas);
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
107 void VisualBench::clear(SkCanvas* canvas, SkColor color, int frames) {
108 canvas->clear(color);
109 for (int i = 0; i < frames - 1; ++i) {
110 canvas->flush();
111 this->present();
112 canvas->clear(color);
113 }
114 }
115
101 void VisualBench::onSizeChange() { 116 void VisualBench::onSizeChange() {
102 this->setupRenderTarget(); 117 this->setupRenderTarget();
103 } 118 }
104 119
105 bool VisualBench::onHandleChar(SkUnichar unichar) { 120 bool VisualBench::onHandleChar(SkUnichar unichar) {
106 return true; 121 static const auto kEscKey = 27;
122 if (kEscKey == unichar) {
123 this->closeWindow();
124 return true;
125 }
126
127 return fModule->onHandleChar(unichar);
107 } 128 }
108 129
109 // Externally declared entry points 130 // Externally declared entry points
110 void application_init() { 131 void application_init() {
111 SkGraphics::Init(); 132 SkGraphics::Init();
112 SkEvent::Init(); 133 SkEvent::Init();
113 } 134 }
114 135
115 void application_term() { 136 void application_term() {
116 SkEvent::Term(); 137 SkEvent::Term();
117 } 138 }
118 139
119 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { 140 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
120 return new VisualBench(hwnd, argc, argv); 141 return new VisualBench(hwnd, argc, argv);
121 } 142 }
122 143
OLDNEW
« no previous file with comments | « tools/VisualBench/VisualBench.h ('k') | tools/VisualBench/VisualInteractiveModule.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698