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

Unified Diff: content/renderer/android/synchronous_compositor_output_surface.cc

Issue 1976803003: sync compositor: Move DeliverMessages to OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unregister activation callback Created 4 years, 7 months 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: content/renderer/android/synchronous_compositor_output_surface.cc
diff --git a/content/renderer/android/synchronous_compositor_output_surface.cc b/content/renderer/android/synchronous_compositor_output_surface.cc
index 5ba04af1a4efe1da15846cebb8df14b2658f9912..119dac5988348126038552b914c9a671aa5bd70a 100644
--- a/content/renderer/android/synchronous_compositor_output_surface.cc
+++ b/content/renderer/android/synchronous_compositor_output_surface.cc
@@ -4,6 +4,8 @@
#include "content/renderer/android/synchronous_compositor_output_surface.h"
+#include <vector>
+
#include "base/auto_reset.h"
#include "base/logging.h"
#include "base/macros.h"
@@ -125,6 +127,9 @@ bool SynchronousCompositorOutputSurface::BindToClient(
return false;
client_->SetMemoryPolicy(memory_policy_);
+ client_->SetTreeActivationCallback(
+ base::Bind(&SynchronousCompositorOutputSurface::DidActivatePendingTree,
+ base::Unretained(this)));
registry_->RegisterOutputSurface(routing_id_, this);
registered_ = true;
Send(new SyncCompositorHostMsg_OutputSurfaceCreated(routing_id_));
@@ -136,6 +141,7 @@ void SynchronousCompositorOutputSurface::DetachFromClient() {
if (registered_) {
registry_->UnregisterOutputSurface(routing_id_, this);
}
+ client_->SetTreeActivationCallback(base::Closure());
boliu 2016/05/13 22:40:20 added this line
cc::OutputSurface::DetachFromClient();
CancelFallbackTick();
}
@@ -150,8 +156,10 @@ void SynchronousCompositorOutputSurface::SwapBuffers(
cc::CompositorFrame* frame) {
DCHECK(CalledOnValidThread());
DCHECK(sync_client_);
- if (!fallback_tick_running_)
+ if (!fallback_tick_running_) {
sync_client_->SwapBuffers(output_surface_id_, frame);
+ DeliverMessages();
+ }
client_->DidSwapBuffers();
did_swap_ = true;
}
@@ -276,18 +284,21 @@ void SynchronousCompositorOutputSurface::SetMemoryPolicy(size_t bytes_limit) {
}
}
-void SynchronousCompositorOutputSurface::SetTreeActivationCallback(
- const base::Closure& callback) {
- DCHECK(client_);
- client_->SetTreeActivationCallback(callback);
+void SynchronousCompositorOutputSurface::DidActivatePendingTree() {
+ DCHECK(CalledOnValidThread());
+ if (sync_client_)
+ sync_client_->DidActivatePendingTree();
+ DeliverMessages();
}
-void SynchronousCompositorOutputSurface::GetMessagesToDeliver(
- std::vector<std::unique_ptr<IPC::Message>>* messages) {
- DCHECK(CalledOnValidThread());
+void SynchronousCompositorOutputSurface::DeliverMessages() {
+ std::vector<std::unique_ptr<IPC::Message>> messages;
std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope =
frame_swap_message_queue_->AcquireSendMessageScope();
- frame_swap_message_queue_->DrainMessages(messages);
+ frame_swap_message_queue_->DrainMessages(&messages);
+ for (auto& msg : messages) {
+ Send(msg.release());
+ }
}
bool SynchronousCompositorOutputSurface::Send(IPC::Message* message) {

Powered by Google App Engine
This is Rietveld 408576698