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

Side by Side Diff: content/renderer/android/synchronous_compositor_proxy.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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/renderer/android/synchronous_compositor_proxy.h" 5 #include "content/renderer/android/synchronous_compositor_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "content/common/android/sync_compositor_messages.h" 10 #include "content/common/android/sync_compositor_messages.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 SetOutputSurface(nullptr); 59 SetOutputSurface(nullptr);
60 begin_frame_source_->SetClient(nullptr); 60 begin_frame_source_->SetClient(nullptr);
61 input_handler_proxy_->SetOnlySynchronouslyAnimateRootFlings(nullptr); 61 input_handler_proxy_->SetOnlySynchronouslyAnimateRootFlings(nullptr);
62 } 62 }
63 63
64 void SynchronousCompositorProxy::SetOutputSurface( 64 void SynchronousCompositorProxy::SetOutputSurface(
65 SynchronousCompositorOutputSurface* output_surface) { 65 SynchronousCompositorOutputSurface* output_surface) {
66 DCHECK_NE(output_surface_, output_surface); 66 DCHECK_NE(output_surface_, output_surface);
67 if (output_surface_) { 67 if (output_surface_) {
68 output_surface_->SetSyncClient(nullptr); 68 output_surface_->SetSyncClient(nullptr);
69 output_surface_->SetTreeActivationCallback(base::Closure());
70 } 69 }
71 output_surface_ = output_surface; 70 output_surface_ = output_surface;
72 if (output_surface_) { 71 if (output_surface_) {
73 output_surface_->SetSyncClient(this); 72 output_surface_->SetSyncClient(this);
74 output_surface_->SetTreeActivationCallback(
75 base::Bind(&SynchronousCompositorProxy::DidActivatePendingTree,
76 base::Unretained(this)));
77 } 73 }
78 } 74 }
79 75
80 void SynchronousCompositorProxy::SetNeedsSynchronousAnimateInput() { 76 void SynchronousCompositorProxy::SetNeedsSynchronousAnimateInput() {
81 need_animate_scroll_ = true; 77 need_animate_scroll_ = true;
82 Invalidate(); 78 Invalidate();
83 } 79 }
84 80
85 void SynchronousCompositorProxy::UpdateRootLayerState( 81 void SynchronousCompositorProxy::UpdateRootLayerState(
86 const gfx::ScrollOffset& total_scroll_offset, 82 const gfx::ScrollOffset& total_scroll_offset,
(...skipping 28 matching lines...) Expand all
115 } 111 }
116 112
117 void SynchronousCompositorProxy::Invalidate() { 113 void SynchronousCompositorProxy::Invalidate() {
118 ++need_invalidate_count_; 114 ++need_invalidate_count_;
119 SendAsyncRendererStateIfNeeded(); 115 SendAsyncRendererStateIfNeeded();
120 } 116 }
121 117
122 void SynchronousCompositorProxy::DidActivatePendingTree() { 118 void SynchronousCompositorProxy::DidActivatePendingTree() {
123 ++did_activate_pending_tree_count_; 119 ++did_activate_pending_tree_count_;
124 SendAsyncRendererStateIfNeeded(); 120 SendAsyncRendererStateIfNeeded();
125 DeliverMessages();
126 }
127
128 void SynchronousCompositorProxy::DeliverMessages() {
129 DCHECK(output_surface_);
130 std::vector<std::unique_ptr<IPC::Message>> messages;
131 output_surface_->GetMessagesToDeliver(&messages);
132 for (auto& msg : messages) {
133 Send(msg.release());
134 }
135 } 121 }
136 122
137 void SynchronousCompositorProxy::SendAsyncRendererStateIfNeeded() { 123 void SynchronousCompositorProxy::SendAsyncRendererStateIfNeeded() {
138 if (inside_receive_) 124 if (inside_receive_)
139 return; 125 return;
140 SyncCompositorCommonRendererParams params; 126 SyncCompositorCommonRendererParams params;
141 PopulateCommonParams(&params); 127 PopulateCommonParams(&params);
142 Send(new SyncCompositorHostMsg_UpdateState(routing_id_, params)); 128 Send(new SyncCompositorHostMsg_UpdateState(routing_id_, params));
143 } 129 }
144 130
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 params.viewport, params.clip, 214 params.viewport, params.clip,
229 params.viewport_rect_for_tile_priority, 215 params.viewport_rect_for_tile_priority,
230 params.transform_for_tile_priority); 216 params.transform_for_tile_priority);
231 } 217 }
232 218
233 if (inside_receive_) { 219 if (inside_receive_) {
234 // Did not swap. 220 // Did not swap.
235 cc::CompositorFrame empty_frame; 221 cc::CompositorFrame empty_frame;
236 SendDemandDrawHwReply(&empty_frame, 0u, reply_message); 222 SendDemandDrawHwReply(&empty_frame, 0u, reply_message);
237 inside_receive_ = false; 223 inside_receive_ = false;
238 } else {
239 DeliverMessages();
240 } 224 }
241 } 225 }
242 226
243 void SynchronousCompositorProxy::SwapBuffersHw(uint32_t output_surface_id, 227 void SynchronousCompositorProxy::SwapBuffersHw(uint32_t output_surface_id,
244 cc::CompositorFrame* frame) { 228 cc::CompositorFrame* frame) {
245 DCHECK(inside_receive_); 229 DCHECK(inside_receive_);
246 DCHECK(hardware_draw_reply_); 230 DCHECK(hardware_draw_reply_);
247 DCHECK(frame); 231 DCHECK(frame);
248 SendDemandDrawHwReply(frame, output_surface_id, hardware_draw_reply_); 232 SendDemandDrawHwReply(frame, output_surface_id, hardware_draw_reply_);
249 inside_receive_ = false; 233 inside_receive_ = false;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } else { 298 } else {
315 DCHECK(!sk_canvas_for_draw); 299 DCHECK(!sk_canvas_for_draw);
316 DoDemandDrawSw(params); 300 DoDemandDrawSw(params);
317 } 301 }
318 } 302 }
319 if (inside_receive_) { 303 if (inside_receive_) {
320 // Did not swap. 304 // Did not swap.
321 cc::CompositorFrame empty_frame; 305 cc::CompositorFrame empty_frame;
322 SendDemandDrawSwReply(false, &empty_frame, reply_message); 306 SendDemandDrawSwReply(false, &empty_frame, reply_message);
323 inside_receive_ = false; 307 inside_receive_ = false;
324 } else {
325 DeliverMessages();
326 } 308 }
327 } 309 }
328 310
329 void SynchronousCompositorProxy::DoDemandDrawSw( 311 void SynchronousCompositorProxy::DoDemandDrawSw(
330 const SyncCompositorDemandDrawSwParams& params) { 312 const SyncCompositorDemandDrawSwParams& params) {
331 DCHECK(output_surface_); 313 DCHECK(output_surface_);
332 DCHECK(software_draw_shm_->zeroed); 314 DCHECK(software_draw_shm_->zeroed);
333 software_draw_shm_->zeroed = false; 315 software_draw_shm_->zeroed = false;
334 316
335 SkImageInfo info = 317 SkImageInfo info =
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 did_overscroll_params)); 398 did_overscroll_params));
417 } 399 }
418 400
419 void SynchronousCompositorProxy::ProcessCommonParams( 401 void SynchronousCompositorProxy::ProcessCommonParams(
420 const SyncCompositorCommonBrowserParams& common_params) { 402 const SyncCompositorCommonBrowserParams& common_params) {
421 begin_frame_source_->SetBeginFrameSourcePaused( 403 begin_frame_source_->SetBeginFrameSourcePaused(
422 common_params.begin_frame_source_paused); 404 common_params.begin_frame_source_paused);
423 } 405 }
424 406
425 } // namespace content 407 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698