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

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

Issue 1473253002: Add offscreen mode to visualbench (Closed) Base URL: https://skia.googlesource.com/skia.git@visualbench_blit2
Patch Set: rebase Created 5 years 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/VisualBench/VisualBenchmarkStream.cpp » ('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 "GrContext.h" 11 #include "GrContext.h"
12 #include "ProcStats.h" 12 #include "ProcStats.h"
13 #include "SkApplication.h" 13 #include "SkApplication.h"
14 #include "SkCanvas.h" 14 #include "SkCanvas.h"
15 #include "SkCommandLineFlags.h" 15 #include "SkCommandLineFlags.h"
16 #include "SkGraphics.h" 16 #include "SkGraphics.h"
17 #include "SkGr.h" 17 #include "SkGr.h"
18 #include "SkOSFile.h" 18 #include "SkOSFile.h"
19 #include "SkStream.h" 19 #include "SkStream.h"
20 #include "Stats.h" 20 #include "Stats.h"
21 #include "VisualLightweightBenchModule.h" 21 #include "VisualLightweightBenchModule.h"
22 #include "VisualInteractiveModule.h" 22 #include "VisualInteractiveModule.h"
23 #include "gl/GrGLInterface.h" 23 #include "gl/GrGLInterface.h"
24 24
25 #include <stdlib.h>
26
25 DEFINE_bool2(fullscreen, f, true, "Run fullscreen."); 27 DEFINE_bool2(fullscreen, f, true, "Run fullscreen.");
26 DEFINE_bool2(interactive, n, false, "Run in interactive mode."); 28 DEFINE_bool2(interactive, n, false, "Run in interactive mode.");
27 DEFINE_bool2(dif, d, false, "Use device-independent fonts."); 29 DEFINE_bool2(dif, d, false, "Use device-independent fonts.");
28 30
29 VisualBench::VisualBench(void* hwnd, int argc, char** argv) 31 VisualBench::VisualBench(void* hwnd, int argc, char** argv)
30 : INHERITED(hwnd) { 32 : INHERITED(hwnd) {
31 SkDebugf("Command line arguments:"); 33 SkDebugf("Command line arguments:");
32 for (int i = 0; i < argc; ++i) { 34 for (int i = 0; i < argc; ++i) {
33 SkDebugf("%s\n", argv[i]); 35 SkDebugf("%s\n", argv[i]);
34 } 36 }
35 37
36 SkCommandLineFlags::Parse(argc, argv); 38 SkCommandLineFlags::Parse(argc, argv);
37 39
40 if (FLAGS_nvpr && !FLAGS_msaa) {
41 SkDebugf("Got nvpr without msaa. Exiting.\n");
42 exit(-1);
43 }
44
38 // these have to happen after commandline parsing 45 // these have to happen after commandline parsing
39 if (FLAGS_dif) { 46 if (FLAGS_dif) {
40 const SkSurfaceProps& props(INHERITED::getSurfaceProps()); 47 const SkSurfaceProps& props(INHERITED::getSurfaceProps());
41 uint32_t flags = SkSurfaceProps::kUseDeviceIndependentFonts_Flag | props .flags(); 48 uint32_t flags = SkSurfaceProps::kUseDeviceIndependentFonts_Flag | props .flags();
42 INHERITED::setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())) ; 49 INHERITED::setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())) ;
43 } 50 }
44 fModule.reset(new VisualLightweightBenchModule(this)); 51 fModule.reset(new VisualLightweightBenchModule(this));
45 if (FLAGS_interactive) { 52 if (FLAGS_interactive) {
46 fModule.reset(new VisualInteractiveModule(this)); 53 fModule.reset(new VisualInteractiveModule(this));
47 } 54 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 this->resetContext(); 90 this->resetContext();
84 return true; 91 return true;
85 } 92 }
86 93
87 void VisualBench::resetContext() { 94 void VisualBench::resetContext() {
88 this->tearDownContext(); 95 this->tearDownContext();
89 this->setupContext(); 96 this->setupContext();
90 } 97 }
91 98
92 void VisualBench::setupContext() { 99 void VisualBench::setupContext() {
93 if (!this->attach(kNativeGL_BackEndType, FLAGS_msaa, &fAttachmentInfo)) { 100 int screenSamples = FLAGS_offscreen ? 0 : FLAGS_msaa;
101 if (!this->attach(kNativeGL_BackEndType, screenSamples, &fAttachmentInfo)) {
94 SkDebugf("Not possible to create backend.\n"); 102 SkDebugf("Not possible to create backend.\n");
95 INHERITED::detach(); 103 INHERITED::detach();
96 SkFAIL("Could not create backend\n"); 104 SkFAIL("Could not create backend\n");
97 } 105 }
98 106
99 this->setVsync(false); 107 this->setVsync(false);
100 108
101 fSurface.reset(nullptr); 109 fSurface.reset(nullptr);
102 110
103 fInterface.reset(GrGLCreateNativeInterface()); 111 fInterface.reset(GrGLCreateNativeInterface());
104 112
105 // TODO use the GLContext creation factories and also set this all up in con figs 113 // TODO use the GLContext creation factories and also set this all up in con figs
106 if (0 == FLAGS_nvpr) { 114 if (!FLAGS_nvpr) {
107 fInterface.reset(GrGLInterfaceRemoveNVPR(fInterface)); 115 fInterface.reset(GrGLInterfaceRemoveNVPR(fInterface));
108 } 116 }
109 SkASSERT(fInterface); 117 SkASSERT(fInterface);
110 118
111 // setup contexts 119 // setup contexts
112 fContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInter face.get())); 120 fContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInter face.get()));
113 SkASSERT(fContext); 121 SkASSERT(fContext);
114 122
115 // setup rendertargets 123 // setup rendertargets
116 this->setupRenderTarget(); 124 this->setupRenderTarget();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 178 }
171 179
172 void application_term() { 180 void application_term() {
173 SkEvent::Term(); 181 SkEvent::Term();
174 } 182 }
175 183
176 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { 184 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
177 return new VisualBench(hwnd, argc, argv); 185 return new VisualBench(hwnd, argc, argv);
178 } 186 }
179 187
OLDNEW
« no previous file with comments | « no previous file | tools/VisualBench/VisualBenchmarkStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698