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

Side by Side Diff: gpu/tools/compositor_model_bench/compositor_model_bench.cc

Issue 8576003: base::Bind() conversion for compositor_model_bench. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This tool is used to benchmark the render model used by the compositor 5 // This tool is used to benchmark the render model used by the compositor
6 6
7 // Most of this file is derived from the source of the tile_render_bench tool, 7 // Most of this file is derived from the source of the tile_render_bench tool,
8 // and has been changed to support running a sequence of independent 8 // and has been changed to support running a sequence of independent
9 // simulations for our different render models and test cases. 9 // simulations for our different render models and test cases.
10 10
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <sys/dir.h> 12 #include <sys/dir.h>
13 #include <sys/file.h> 13 #include <sys/file.h>
14 #include <sys/stat.h> 14 #include <sys/stat.h>
15 #include <sys/types.h> 15 #include <sys/types.h>
16 #include <X11/keysym.h> 16 #include <X11/keysym.h>
17 #include <X11/Xlib.h> 17 #include <X11/Xlib.h>
18 #include <X11/Xutil.h> 18 #include <X11/Xutil.h>
19 19
20 #include <queue> 20 #include <queue>
21 #include <string> 21 #include <string>
22 #include <vector> 22 #include <vector>
23 23
24 #include "base/at_exit.h" 24 #include "base/at_exit.h"
25 #include "base/basictypes.h" 25 #include "base/basictypes.h"
26 #include "base/bind.h"
26 #include "base/command_line.h" 27 #include "base/command_line.h"
27 #include "base/file_path.h" 28 #include "base/file_path.h"
28 #include "base/file_util.h" 29 #include "base/file_util.h"
29 #include "base/memory/scoped_ptr.h" 30 #include "base/memory/scoped_ptr.h"
30 #include "base/message_loop.h" 31 #include "base/message_loop.h"
31 #include "base/task.h"
32 #include "base/time.h" 32 #include "base/time.h"
33 33
34 #include "gpu/tools/compositor_model_bench/render_model_utils.h" 34 #include "gpu/tools/compositor_model_bench/render_model_utils.h"
35 #include "gpu/tools/compositor_model_bench/render_models.h" 35 #include "gpu/tools/compositor_model_bench/render_models.h"
36 #include "gpu/tools/compositor_model_bench/render_tree.h" 36 #include "gpu/tools/compositor_model_bench/render_tree.h"
37 37
38 38
39 using base::TimeTicks; 39 using base::TimeTicks;
40 using file_util::CloseFile; 40 using file_util::CloseFile;
41 using file_util::DirectoryExists; 41 using file_util::DirectoryExists;
(...skipping 16 matching lines...) Expand all
58 void _process_events(Simulator* sim); 58 void _process_events(Simulator* sim);
59 void _update_loop(Simulator* sim); 59 void _update_loop(Simulator* sim);
60 60
61 class Simulator { 61 class Simulator {
62 public: 62 public:
63 Simulator(int seconds_per_test, const FilePath& output_path) 63 Simulator(int seconds_per_test, const FilePath& output_path)
64 : running_(false), 64 : running_(false),
65 current_sim_(NULL), 65 current_sim_(NULL),
66 output_path_(output_path), 66 output_path_(output_path),
67 seconds_per_test_(seconds_per_test), 67 seconds_per_test_(seconds_per_test),
68 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), 68 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
69 display_(NULL), 69 display_(NULL),
70 window_(0), 70 window_(0),
71 gl_context_(NULL), 71 gl_context_(NULL),
72 window_width_(WINDOW_WIDTH), 72 window_width_(WINDOW_WIDTH),
73 window_height_(WINDOW_HEIGHT) { 73 window_height_(WINDOW_HEIGHT) {
74 } 74 }
75 75
76 ~Simulator() { 76 ~Simulator() {
77 // Cleanup GL. 77 // Cleanup GL.
78 glXMakeCurrent(display_, 0, NULL); 78 glXMakeCurrent(display_, 0, NULL);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 MessageLoop loop; 117 MessageLoop loop;
118 if (!InitX11() || !InitGLContext()) { 118 if (!InitX11() || !InitGLContext()) {
119 LOG(FATAL) << "Failed to set up GUI."; 119 LOG(FATAL) << "Failed to set up GUI.";
120 } 120 }
121 121
122 InitBuffers(); 122 InitBuffers();
123 123
124 LOG(INFO) << "Running " << sims_remaining_.size() << " simulations."; 124 LOG(INFO) << "Running " << sims_remaining_.size() << " simulations.";
125 125
126 loop.PostTask(FROM_HERE, 126 loop.PostTask(FROM_HERE,
127 method_factory_.NewRunnableMethod(&Simulator::ProcessEvents)); 127 base::Bind(&Simulator::ProcessEvents,
128 weak_factory_.GetWeakPtr()));
128 loop.Run(); 129 loop.Run();
129 } 130 }
130 131
131 void ProcessEvents() { 132 void ProcessEvents() {
132 // Consume all the X events. 133 // Consume all the X events.
133 while (XPending(display_)) { 134 while (XPending(display_)) {
134 XEvent e; 135 XEvent e;
135 XNextEvent(display_, &e); 136 XNextEvent(display_, &e);
136 switch (e.type) { 137 switch (e.type) {
137 case Expose: 138 case Expose:
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 XExposeEvent ev = { Expose, 0, 1, display_, window_, 263 XExposeEvent ev = { Expose, 0, 1, display_, window_,
263 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 0 }; 264 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 0 };
264 XSendEvent(display_, 265 XSendEvent(display_,
265 window_, 266 window_,
266 False, 267 False,
267 ExposureMask, 268 ExposureMask,
268 reinterpret_cast<XEvent*>(&ev)); 269 reinterpret_cast<XEvent*>(&ev));
269 270
270 MessageLoop::current()->PostTask( 271 MessageLoop::current()->PostTask(
271 FROM_HERE, 272 FROM_HERE,
272 method_factory_.NewRunnableMethod(&Simulator::UpdateLoop)); 273 base::Bind(&Simulator::UpdateLoop, weak_factory_.GetWeakPtr()));
273 } 274 }
274 275
275 void DumpOutput() { 276 void DumpOutput() {
276 LOG(INFO) << "Successfully ran " << sims_completed_.size() << " tests"; 277 LOG(INFO) << "Successfully ran " << sims_completed_.size() << " tests";
277 278
278 FILE* f = OpenFile(output_path_, "w"); 279 FILE* f = OpenFile(output_path_, "w");
279 280
280 if (!f) { 281 if (!f) {
281 LOG(ERROR) << "Failed to open output file " << 282 LOG(ERROR) << "Failed to open output file " <<
282 output_path_.LossyDisplayName(); 283 output_path_.LossyDisplayName();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 342
342 // Simulation task list for this execution 343 // Simulation task list for this execution
343 bool running_; 344 bool running_;
344 RenderModelSimulator* current_sim_; 345 RenderModelSimulator* current_sim_;
345 queue<SimulationSpecification> sims_remaining_; 346 queue<SimulationSpecification> sims_remaining_;
346 queue<SimulationSpecification> sims_completed_; 347 queue<SimulationSpecification> sims_completed_;
347 FilePath output_path_; 348 FilePath output_path_;
348 // Amount of time to run each simulation 349 // Amount of time to run each simulation
349 int seconds_per_test_; 350 int seconds_per_test_;
350 // GUI data 351 // GUI data
351 ScopedRunnableMethodFactory<Simulator> method_factory_; 352 base::WeakPtrFactory<Simulator> weak_factory_;
352 Display* display_; 353 Display* display_;
353 Window window_; 354 Window window_;
354 GLXContext gl_context_; 355 GLXContext gl_context_;
355 int window_width_; 356 int window_width_;
356 int window_height_; 357 int window_height_;
357 }; 358 };
358 359
359 int main(int argc, char* argv[]) { 360 int main(int argc, char* argv[]) {
360 CommandLine::Init(argc, argv); 361 CommandLine::Init(argc, argv);
361 const CommandLine* cl = CommandLine::ForCurrentProcess(); 362 const CommandLine* cl = CommandLine::ForCurrentProcess();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 397 }
397 } else { 398 } else {
398 LOG(INFO) << "(input path is a file)"; 399 LOG(INFO) << "(input path is a file)";
399 sim.QueueTest(inPath); 400 sim.QueueTest(inPath);
400 } 401 }
401 402
402 sim.Run(); 403 sim.Run();
403 404
404 return 0; 405 return 0;
405 } 406 }
406
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698