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

Unified Diff: gpu/command_buffer/service/gpu_processor.cc

Issue 5317007: Add flow control between renderer and GPU processes, and, on Mac OS X,... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698