Index: gpu/command_buffer/service/gpu_processor.cc |
=================================================================== |
--- gpu/command_buffer/service/gpu_processor.cc (revision 67289) |
+++ gpu/command_buffer/service/gpu_processor.cc (working copy) |
@@ -16,6 +16,10 @@ |
gles2::ContextGroup* group) |
: command_buffer_(command_buffer), |
commands_per_update_(100), |
+#if defined(OS_MACOSX) |
+ swap_buffers_count_(0), |
+ acknowledged_swap_buffers_count_(0), |
+#endif |
method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
DCHECK(command_buffer); |
decoder_.reset(gles2::GLES2Decoder::Create(group)); |
@@ -28,6 +32,10 @@ |
int commands_per_update) |
: command_buffer_(command_buffer), |
commands_per_update_(commands_per_update), |
+#if defined(OS_MACOSX) |
+ swap_buffers_count_(0), |
+ acknowledged_swap_buffers_count_(0), |
+#endif |
method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
DCHECK(command_buffer); |
decoder_.reset(decoder); |
@@ -87,6 +95,13 @@ |
parser_.reset(); |
} |
+#if defined(OS_MACOSX) |
+namespace { |
+const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1; |
+const int64 kWaitingTimeForSwapBuffers = 1; // ms |
+} |
+#endif |
+ |
void GPUProcessor::ProcessCommands() { |
CommandBuffer::State state = command_buffer_->GetState(); |
if (state.error != error::kNoError) |
@@ -102,6 +117,21 @@ |
parser_->set_put(state.put_offset); |
+#if defined(OS_MACOSX) |
+ bool do_rate_limiting = surface_.get() != NULL; |
+ // Don't swamp the browser process with SwapBuffers calls it can't handle. |
+ if (do_rate_limiting && |
+ swap_buffers_count_ - acknowledged_swap_buffers_count_ >= |
+ kMaxOutstandingSwapBuffersCallsPerOnscreenContext) { |
+ // Defer the processing of more commands. |
+ MessageLoop::current()->PostDelayedTask( |
apatrick_chromium
2010/11/24 23:56:09
Rather than repeatedly poll for progress every 1ms
Ken Russell (switch to Gerrit)
2010/11/25 01:02:08
Thanks, this is an excellent suggestion and cleans
|
+ FROM_HERE, |
+ method_factory_.NewRunnableMethod(&GPUProcessor::ProcessCommands), |
+ kWaitingTimeForSwapBuffers); |
+ return; |
+ } |
+#endif |
+ |
int commands_processed = 0; |
while (commands_processed < commands_per_update_ && !parser_->IsEmpty()) { |
error::Error error = parser_->ProcessCommand(); |