OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 |
(...skipping 10 matching lines...) Expand all Loading... |
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/bind.h" |
27 #include "base/command_line.h" | 27 #include "base/command_line.h" |
28 #include "base/files/file_enumerator.h" | 28 #include "base/files/file_enumerator.h" |
29 #include "base/files/file_path.h" | 29 #include "base/files/file_path.h" |
30 #include "base/files/file_util.h" | 30 #include "base/files/file_util.h" |
| 31 #include "base/location.h" |
31 #include "base/memory/scoped_ptr.h" | 32 #include "base/memory/scoped_ptr.h" |
32 #include "base/message_loop/message_loop.h" | 33 #include "base/message_loop/message_loop.h" |
| 34 #include "base/single_thread_task_runner.h" |
| 35 #include "base/thread_task_runner_handle.h" |
33 #include "base/time/time.h" | 36 #include "base/time/time.h" |
34 #include "gpu/tools/compositor_model_bench/render_model_utils.h" | 37 #include "gpu/tools/compositor_model_bench/render_model_utils.h" |
35 #include "gpu/tools/compositor_model_bench/render_models.h" | 38 #include "gpu/tools/compositor_model_bench/render_models.h" |
36 #include "gpu/tools/compositor_model_bench/render_tree.h" | 39 #include "gpu/tools/compositor_model_bench/render_tree.h" |
37 #include "ui/gl/gl_surface.h" | 40 #include "ui/gl/gl_surface.h" |
38 | 41 |
39 using base::TimeTicks; | 42 using base::TimeTicks; |
40 using base::DirectoryExists; | 43 using base::DirectoryExists; |
41 using base::PathExists; | 44 using base::PathExists; |
42 using std::queue; | 45 using std::queue; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 base::AtExitManager at_exit; | 115 base::AtExitManager at_exit; |
113 base::MessageLoop loop; | 116 base::MessageLoop loop; |
114 if (!InitX11() || !InitGLContext()) { | 117 if (!InitX11() || !InitGLContext()) { |
115 LOG(FATAL) << "Failed to set up GUI."; | 118 LOG(FATAL) << "Failed to set up GUI."; |
116 } | 119 } |
117 | 120 |
118 InitBuffers(); | 121 InitBuffers(); |
119 | 122 |
120 LOG(INFO) << "Running " << sims_remaining_.size() << " simulations."; | 123 LOG(INFO) << "Running " << sims_remaining_.size() << " simulations."; |
121 | 124 |
122 loop.PostTask(FROM_HERE, | 125 loop.task_runner()->PostTask( |
123 base::Bind(&Simulator::ProcessEvents, | 126 FROM_HERE, |
124 weak_factory_.GetWeakPtr())); | 127 base::Bind(&Simulator::ProcessEvents, weak_factory_.GetWeakPtr())); |
125 loop.Run(); | 128 loop.Run(); |
126 } | 129 } |
127 | 130 |
128 void ProcessEvents() { | 131 void ProcessEvents() { |
129 // Consume all the X events. | 132 // Consume all the X events. |
130 while (XPending(display_)) { | 133 while (XPending(display_)) { |
131 XEvent e; | 134 XEvent e; |
132 XNextEvent(display_, &e); | 135 XNextEvent(display_, &e); |
133 switch (e.type) { | 136 switch (e.type) { |
134 case Expose: | 137 case Expose: |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 glXSwapBuffers(display_, window_); | 260 glXSwapBuffers(display_, window_); |
258 | 261 |
259 XExposeEvent ev = { Expose, 0, 1, display_, window_, | 262 XExposeEvent ev = { Expose, 0, 1, display_, window_, |
260 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 0 }; | 263 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 0 }; |
261 XSendEvent(display_, | 264 XSendEvent(display_, |
262 window_, | 265 window_, |
263 False, | 266 False, |
264 ExposureMask, | 267 ExposureMask, |
265 reinterpret_cast<XEvent*>(&ev)); | 268 reinterpret_cast<XEvent*>(&ev)); |
266 | 269 |
267 base::MessageLoop::current()->PostTask( | 270 base::ThreadTaskRunnerHandle::Get()->PostTask( |
268 FROM_HERE, | 271 FROM_HERE, |
269 base::Bind(&Simulator::UpdateLoop, weak_factory_.GetWeakPtr())); | 272 base::Bind(&Simulator::UpdateLoop, weak_factory_.GetWeakPtr())); |
270 } | 273 } |
271 | 274 |
272 void DumpOutput() { | 275 void DumpOutput() { |
273 LOG(INFO) << "Successfully ran " << sims_completed_.size() << " tests"; | 276 LOG(INFO) << "Successfully ran " << sims_completed_.size() << " tests"; |
274 | 277 |
275 FILE* f = base::OpenFile(output_path_, "w"); | 278 FILE* f = base::OpenFile(output_path_, "w"); |
276 | 279 |
277 if (!f) { | 280 if (!f) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 395 } |
393 } else { | 396 } else { |
394 LOG(INFO) << "(input path is a file)"; | 397 LOG(INFO) << "(input path is a file)"; |
395 sim.QueueTest(inPath); | 398 sim.QueueTest(inPath); |
396 } | 399 } |
397 | 400 |
398 sim.Run(); | 401 sim.Run(); |
399 | 402 |
400 return 0; | 403 return 0; |
401 } | 404 } |
OLD | NEW |