Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/browser/android/synchronous_compositor_host.h" | 5 #include "content/browser/android/synchronous_compositor_host.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 | 89 |
| 90 SynchronousCompositorHost::~SynchronousCompositorHost() { | 90 SynchronousCompositorHost::~SynchronousCompositorHost() { |
| 91 client_->DidDestroyCompositor(this); | 91 client_->DidDestroyCompositor(this); |
| 92 if (weak_ptr_factory_.HasWeakPtrs()) | 92 if (weak_ptr_factory_.HasWeakPtrs()) |
| 93 UpdateStateTask(); | 93 UpdateStateTask(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool SynchronousCompositorHost::OnMessageReceived(const IPC::Message& message) { | 96 bool SynchronousCompositorHost::OnMessageReceived(const IPC::Message& message) { |
| 97 bool handled = true; | 97 bool handled = true; |
| 98 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorHost, message) | 98 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorHost, message) |
| 99 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_OutputSurfaceCreated, | |
| 100 OutputSurfaceCreated) | |
| 99 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_UpdateState, ProcessCommonParams) | 101 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_UpdateState, ProcessCommonParams) |
| 100 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_OverScroll, OnOverScroll) | 102 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_OverScroll, OnOverScroll) |
| 101 IPC_MESSAGE_UNHANDLED(handled = false) | 103 IPC_MESSAGE_UNHANDLED(handled = false) |
| 102 IPC_END_MESSAGE_MAP() | 104 IPC_END_MESSAGE_MAP() |
| 103 return handled; | 105 return handled; |
| 104 } | 106 } |
| 105 | 107 |
| 106 void SynchronousCompositorHost::DidBecomeCurrent() { | 108 void SynchronousCompositorHost::DidBecomeCurrent() { |
| 107 client_->DidBecomeCurrent(this); | 109 client_->DidBecomeCurrent(this); |
| 108 } | 110 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 } | 308 } |
| 307 | 309 |
| 308 void SynchronousCompositorHost::ReturnResources( | 310 void SynchronousCompositorHost::ReturnResources( |
| 309 uint32_t output_surface_id, | 311 uint32_t output_surface_id, |
| 310 const cc::CompositorFrameAck& frame_ack) { | 312 const cc::CompositorFrameAck& frame_ack) { |
| 311 DCHECK(!frame_ack.resources.empty()); | 313 DCHECK(!frame_ack.resources.empty()); |
| 312 sender_->Send(new SyncCompositorMsg_ReclaimResources( | 314 sender_->Send(new SyncCompositorMsg_ReclaimResources( |
| 313 routing_id_, output_surface_id, frame_ack)); | 315 routing_id_, output_surface_id, frame_ack)); |
| 314 } | 316 } |
| 315 | 317 |
| 316 void SynchronousCompositorHost::SetMemoryPolicy(size_t bytes_limit) { | 318 void SynchronousCompositorHost::SetMemoryPolicy(size_t bytes_limit) { |
|
hush (inactive)
2016/05/12 19:23:03
again, for multiprocess cross-bit (32bit renderer
boliu
2016/05/12 20:16:45
As discussed over lunch. The wire format is uint32
| |
| 317 if (bytes_limit_ == bytes_limit) | 319 if (bytes_limit_ == bytes_limit) |
| 318 return; | 320 return; |
| 319 bytes_limit_ = bytes_limit; | 321 |
| 320 SendAsyncCompositorStateIfNeeded(); | 322 if (sender_->Send( |
| 323 new SyncCompositorMsg_SetMemoryPolicy(routing_id_, bytes_limit))) { | |
| 324 bytes_limit_ = bytes_limit; | |
| 325 } | |
| 321 } | 326 } |
| 322 | 327 |
| 323 void SynchronousCompositorHost::DidChangeRootLayerScrollOffset( | 328 void SynchronousCompositorHost::DidChangeRootLayerScrollOffset( |
| 324 const gfx::ScrollOffset& root_offset) { | 329 const gfx::ScrollOffset& root_offset) { |
| 325 if (root_scroll_offset_ == root_offset) | 330 if (root_scroll_offset_ == root_offset) |
| 326 return; | 331 return; |
| 327 root_scroll_offset_updated_by_browser_ = true; | 332 root_scroll_offset_updated_by_browser_ = true; |
| 328 root_scroll_offset_ = root_offset; | 333 root_scroll_offset_ = root_offset; |
| 329 SendAsyncCompositorStateIfNeeded(); | 334 SendAsyncCompositorStateIfNeeded(); |
| 330 } | 335 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 PopulateCommonParams(&common_browser_params); | 417 PopulateCommonParams(&common_browser_params); |
| 413 SyncCompositorCommonRendererParams common_renderer_params; | 418 SyncCompositorCommonRendererParams common_renderer_params; |
| 414 if (!sender_->Send( | 419 if (!sender_->Send( |
| 415 new SyncCompositorMsg_BeginFrame(routing_id_, common_browser_params, | 420 new SyncCompositorMsg_BeginFrame(routing_id_, common_browser_params, |
| 416 args, &common_renderer_params))) { | 421 args, &common_renderer_params))) { |
| 417 return; | 422 return; |
| 418 } | 423 } |
| 419 ProcessCommonParams(common_renderer_params); | 424 ProcessCommonParams(common_renderer_params); |
| 420 } | 425 } |
| 421 | 426 |
| 427 void SynchronousCompositorHost::OutputSurfaceCreated() { | |
| 428 // New output surface is not aware of state from Browser side. So need to | |
| 429 // re-send all browser side state here. | |
| 430 sender_->Send( | |
| 431 new SyncCompositorMsg_SetMemoryPolicy(routing_id_, bytes_limit_)); | |
|
hush (inactive)
2016/05/12 19:23:03
so... memory policy is *all* the browser side stat
boliu
2016/05/12 20:16:45
It's not everything. I'm moving things to async IP
boliu
2016/05/12 21:12:47
Actually... this *is* everything for OutputSurface
| |
| 432 } | |
| 433 | |
| 422 void SynchronousCompositorHost::OnOverScroll( | 434 void SynchronousCompositorHost::OnOverScroll( |
| 423 const SyncCompositorCommonRendererParams& params, | 435 const SyncCompositorCommonRendererParams& params, |
| 424 const DidOverscrollParams& over_scroll_params) { | 436 const DidOverscrollParams& over_scroll_params) { |
| 425 ProcessCommonParams(params); | 437 ProcessCommonParams(params); |
| 426 DidOverscroll(over_scroll_params); | 438 DidOverscroll(over_scroll_params); |
| 427 } | 439 } |
| 428 | 440 |
| 429 void SynchronousCompositorHost::PopulateCommonParams( | 441 void SynchronousCompositorHost::PopulateCommonParams( |
| 430 SyncCompositorCommonBrowserParams* params) { | 442 SyncCompositorCommonBrowserParams* params) { |
| 431 DCHECK(params); | 443 DCHECK(params); |
| 432 params->bytes_limit = bytes_limit_; | |
| 433 if (root_scroll_offset_updated_by_browser_) { | 444 if (root_scroll_offset_updated_by_browser_) { |
| 434 params->root_scroll_offset = root_scroll_offset_; | 445 params->root_scroll_offset = root_scroll_offset_; |
| 435 params->update_root_scroll_offset = root_scroll_offset_updated_by_browser_; | 446 params->update_root_scroll_offset = root_scroll_offset_updated_by_browser_; |
| 436 root_scroll_offset_updated_by_browser_ = false; | 447 root_scroll_offset_updated_by_browser_ = false; |
| 437 } | 448 } |
| 438 params->begin_frame_source_paused = !is_active_; | 449 params->begin_frame_source_paused = !is_active_; |
| 439 | 450 |
| 440 weak_ptr_factory_.InvalidateWeakPtrs(); | 451 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 441 } | 452 } |
| 442 | 453 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 params.scrollable_size, params.page_scale_factor, | 487 params.scrollable_size, params.page_scale_factor, |
| 477 params.min_page_scale_factor, params.max_page_scale_factor); | 488 params.min_page_scale_factor, params.max_page_scale_factor); |
| 478 } | 489 } |
| 479 } | 490 } |
| 480 | 491 |
| 481 void SynchronousCompositorHost::UpdateNeedsBeginFrames() { | 492 void SynchronousCompositorHost::UpdateNeedsBeginFrames() { |
| 482 rwhva_->OnSetNeedsBeginFrames(is_active_ && need_begin_frame_); | 493 rwhva_->OnSetNeedsBeginFrames(is_active_ && need_begin_frame_); |
| 483 } | 494 } |
| 484 | 495 |
| 485 } // namespace content | 496 } // namespace content |
| OLD | NEW |