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

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

Issue 1413713006: Wire up configurations properly in VisualBench (Closed) Base URL: https://skia.googlesource.com/skia.git@detachattach
Patch Set: Created 5 years, 2 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/VisualBenchmarkStream.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
(...skipping 11 matching lines...) Expand all
22 #include "VisualInteractiveModule.h" 22 #include "VisualInteractiveModule.h"
23 #include "gl/GrGLInterface.h" 23 #include "gl/GrGLInterface.h"
24 24
25 DEFINE_bool2(fullscreen, f, true, "Run fullscreen."); 25 DEFINE_bool2(fullscreen, f, true, "Run fullscreen.");
26 DEFINE_bool2(interactive, n, false, "Run in interactive mode."); 26 DEFINE_bool2(interactive, n, false, "Run in interactive mode.");
27 27
28 VisualBench::VisualBench(void* hwnd, int argc, char** argv) 28 VisualBench::VisualBench(void* hwnd, int argc, char** argv)
29 : INHERITED(hwnd) { 29 : INHERITED(hwnd) {
30 SkCommandLineFlags::Parse(argc, argv); 30 SkCommandLineFlags::Parse(argc, argv);
31 31
32 for (int i = 0; i < FLAGS_config.count(); i++) {
33 SkString configStr(FLAGS_config[i]);
34
35 Configs::Config& config = fConfigs.push_back();
36
37 if (configStr.contains("gpu")) {
38 config.fType = Configs::Config::kGpu_Type;
39 config.fNumSamples = 0;
40 } else if (configStr.contains("msaa")) {
41 config.fType = Configs::Config::kMsaa_Type;
42 SkAssertResult(scanf("msaa%d", &config.fNumSamples));
43 } else if (configStr.contains("cpu")) {
44 config.fType = Configs::Config::kCpu_Type;
45 config.fNumSamples = 0;
46 } else if (configStr.contains("nvprmsaa")) {
47 config.fType = Configs::Config::kNvpr_Type;
48 SkAssertResult(scanf("nvprmsaa%d", &config.fNumSamples));
49 }
50 }
51
32 // this has to happen after commandline parsing 52 // this has to happen after commandline parsing
33 fModule.reset(new VisualLightweightBenchModule(this)); 53 fModule.reset(new VisualLightweightBenchModule(this));
34 if (FLAGS_interactive) { 54 if (FLAGS_interactive) {
35 fModule.reset(new VisualInteractiveModule(this)); 55 fModule.reset(new VisualInteractiveModule(this));
36 } 56 }
37 57
38 this->setTitle(); 58 this->setTitle();
39 this->setupBackend(); 59 this->setupBackend();
40 } 60 }
41 61
(...skipping 30 matching lines...) Expand all
72 this->resetContext(); 92 this->resetContext();
73 return true; 93 return true;
74 } 94 }
75 95
76 void VisualBench::resetContext() { 96 void VisualBench::resetContext() {
77 this->tearDownContext(); 97 this->tearDownContext();
78 this->setupContext(); 98 this->setupContext();
79 } 99 }
80 100
81 void VisualBench::setupContext() { 101 void VisualBench::setupContext() {
82 if (!this->attach(kNativeGL_BackEndType, FLAGS_msaa, &fAttachmentInfo)) { 102 // We only set the number of samples on the base render target for MSAA
103 int numSamples = fConfigs.current().fType == Configs::Config::kMsaa_Type ?
104 fConfigs.current().fNumSamples : 0;
105 if (!this->attach(kNativeGL_BackEndType, numSamples, &fAttachmentInfo)) {
83 SkDebugf("Not possible to create backend.\n"); 106 SkDebugf("Not possible to create backend.\n");
84 INHERITED::detach(); 107 INHERITED::detach();
85 SkFAIL("Could not create backend\n"); 108 SkFAIL("Could not create backend\n");
86 } 109 }
87 110
88 this->setVsync(false); 111 this->setVsync(false);
89 112
90 fSurface.reset(nullptr); 113 fSurface.reset(nullptr);
91 114
92 fInterface.reset(GrGLCreateNativeInterface()); 115 fInterface.reset(GrGLCreateNativeInterface());
93 116
94 // TODO use the GLContext creation factories and also set this all up in con figs 117 if (!fConfigs.current().fType == Configs::Config::kNvpr_Type) {
95 if (!FLAGS_nvpr) {
96 fInterface.reset(GrGLInterfaceRemoveNVPR(fInterface)); 118 fInterface.reset(GrGLInterfaceRemoveNVPR(fInterface));
97 } 119 }
98 SkASSERT(fInterface); 120 SkASSERT(fInterface);
99 121
100 // setup contexts 122 // setup contexts
101 fContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInter face.get())); 123 fContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInter face.get()));
102 SkASSERT(fContext); 124 SkASSERT(fContext);
103 125
104 // setup rendertargets 126 // setup rendertargets
105 this->setupRenderTarget(); 127 this->setupRenderTarget();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 181 }
160 182
161 void application_term() { 183 void application_term() {
162 SkEvent::Term(); 184 SkEvent::Term();
163 } 185 }
164 186
165 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { 187 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
166 return new VisualBench(hwnd, argc, argv); 188 return new VisualBench(hwnd, argc, argv);
167 } 189 }
168 190
OLDNEW
« no previous file with comments | « tools/VisualBench/VisualBench.h ('k') | tools/VisualBench/VisualBenchmarkStream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698