OLD | NEW |
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 #include "gpu/command_buffer/service/gpu_scheduler.h" | 5 #include "gpu/command_buffer/service/gpu_scheduler.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
9 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "ui/gfx/gl/gl_context.h" | 12 #include "ui/gfx/gl/gl_context.h" |
12 #include "ui/gfx/gl/gl_bindings.h" | 13 #include "ui/gfx/gl/gl_bindings.h" |
13 #include "ui/gfx/gl/gl_surface.h" | 14 #include "ui/gfx/gl/gl_surface.h" |
| 15 #include "ui/gfx/gl/gl_switches.h" |
14 | 16 |
15 using ::base::SharedMemory; | 17 using ::base::SharedMemory; |
16 | 18 |
17 namespace gpu { | 19 namespace gpu { |
18 | 20 |
19 GpuScheduler::GpuScheduler(CommandBuffer* command_buffer, | 21 GpuScheduler::GpuScheduler(CommandBuffer* command_buffer, |
20 gles2::ContextGroup* group) | 22 gles2::ContextGroup* group) |
21 : command_buffer_(command_buffer), | 23 : command_buffer_(command_buffer), |
22 commands_per_update_(100), | 24 commands_per_update_(100), |
23 unscheduled_count_(0), | 25 unscheduled_count_(0), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const gles2::DisallowedExtensions& disallowed_extensions, | 61 const gles2::DisallowedExtensions& disallowed_extensions, |
60 const char* allowed_extensions, | 62 const char* allowed_extensions, |
61 const std::vector<int32>& attribs, | 63 const std::vector<int32>& attribs, |
62 gles2::GLES2Decoder* parent_decoder, | 64 gles2::GLES2Decoder* parent_decoder, |
63 uint32 parent_texture_id) { | 65 uint32 parent_texture_id) { |
64 DCHECK(context); | 66 DCHECK(context); |
65 | 67 |
66 if (!context->MakeCurrent(surface)) | 68 if (!context->MakeCurrent(surface)) |
67 return false; | 69 return false; |
68 | 70 |
| 71 #if !defined(OS_MACOSX) |
| 72 // Set up swap interval for onscreen contexts. |
| 73 if (!surface->IsOffscreen()) { |
| 74 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) |
| 75 context->SetSwapInterval(0); |
| 76 else |
| 77 context->SetSwapInterval(1); |
| 78 } |
| 79 #endif |
| 80 |
69 // Do not limit to a certain number of commands before scheduling another | 81 // Do not limit to a certain number of commands before scheduling another |
70 // update when rendering onscreen. | 82 // update when rendering onscreen. |
71 if (!surface->IsOffscreen()) | 83 if (!surface->IsOffscreen()) |
72 commands_per_update_ = INT_MAX; | 84 commands_per_update_ = INT_MAX; |
73 | 85 |
74 // Map the ring buffer and create the parser. | 86 // Map the ring buffer and create the parser. |
75 Buffer ring_buffer = command_buffer_->GetRingBuffer(); | 87 Buffer ring_buffer = command_buffer_->GetRingBuffer(); |
76 if (ring_buffer.ptr) { | 88 if (ring_buffer.ptr) { |
77 parser_.reset(new CommandParser(ring_buffer.ptr, | 89 parser_.reset(new CommandParser(ring_buffer.ptr, |
78 ring_buffer.size, | 90 ring_buffer.size, |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 command_processed_callback_.reset(callback); | 273 command_processed_callback_.reset(callback); |
262 } | 274 } |
263 | 275 |
264 void GpuScheduler::ScheduleProcessCommands() { | 276 void GpuScheduler::ScheduleProcessCommands() { |
265 MessageLoop::current()->PostTask( | 277 MessageLoop::current()->PostTask( |
266 FROM_HERE, | 278 FROM_HERE, |
267 method_factory_.NewRunnableMethod(&GpuScheduler::ProcessCommands)); | 279 method_factory_.NewRunnableMethod(&GpuScheduler::ProcessCommands)); |
268 } | 280 } |
269 | 281 |
270 } // namespace gpu | 282 } // namespace gpu |
OLD | NEW |