| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 : rwhva_(rwhva), | 70 : rwhva_(rwhva), |
| 71 client_(client), | 71 client_(client), |
| 72 ui_task_runner_( | 72 ui_task_runner_( |
| 73 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)), | 73 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)), |
| 74 routing_id_(rwhva_->GetRenderWidgetHost()->GetRoutingID()), | 74 routing_id_(rwhva_->GetRenderWidgetHost()->GetRoutingID()), |
| 75 sender_(rwhva_->GetRenderWidgetHost()), | 75 sender_(rwhva_->GetRenderWidgetHost()), |
| 76 async_input_(async_input), | 76 async_input_(async_input), |
| 77 use_in_process_zero_copy_software_draw_(use_in_proc_software_draw), | 77 use_in_process_zero_copy_software_draw_(use_in_proc_software_draw), |
| 78 is_active_(false), | 78 is_active_(false), |
| 79 bytes_limit_(0u), | 79 bytes_limit_(0u), |
| 80 root_scroll_offset_updated_by_browser_(false), | |
| 81 renderer_param_version_(0u), | 80 renderer_param_version_(0u), |
| 82 need_animate_scroll_(false), | 81 need_animate_scroll_(false), |
| 83 need_invalidate_count_(0u), | 82 need_invalidate_count_(0u), |
| 84 need_begin_frame_(false), | 83 need_begin_frame_(false), |
| 85 did_activate_pending_tree_count_(0u), | 84 did_activate_pending_tree_count_(0u), |
| 86 weak_ptr_factory_(this) { | 85 weak_ptr_factory_(this) { |
| 87 client_->DidInitializeCompositor(this); | 86 client_->DidInitializeCompositor(this); |
| 88 } | 87 } |
| 89 | 88 |
| 90 SynchronousCompositorHost::~SynchronousCompositorHost() { | 89 SynchronousCompositorHost::~SynchronousCompositorHost() { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 if (sender_->Send( | 321 if (sender_->Send( |
| 323 new SyncCompositorMsg_SetMemoryPolicy(routing_id_, bytes_limit))) { | 322 new SyncCompositorMsg_SetMemoryPolicy(routing_id_, bytes_limit))) { |
| 324 bytes_limit_ = bytes_limit; | 323 bytes_limit_ = bytes_limit; |
| 325 } | 324 } |
| 326 } | 325 } |
| 327 | 326 |
| 328 void SynchronousCompositorHost::DidChangeRootLayerScrollOffset( | 327 void SynchronousCompositorHost::DidChangeRootLayerScrollOffset( |
| 329 const gfx::ScrollOffset& root_offset) { | 328 const gfx::ScrollOffset& root_offset) { |
| 330 if (root_scroll_offset_ == root_offset) | 329 if (root_scroll_offset_ == root_offset) |
| 331 return; | 330 return; |
| 332 root_scroll_offset_updated_by_browser_ = true; | |
| 333 root_scroll_offset_ = root_offset; | 331 root_scroll_offset_ = root_offset; |
| 334 SendAsyncCompositorStateIfNeeded(); | 332 sender_->Send( |
| 333 new SyncCompositorMsg_SetScroll(routing_id_, root_scroll_offset_)); |
| 335 } | 334 } |
| 336 | 335 |
| 337 void SynchronousCompositorHost::SendAsyncCompositorStateIfNeeded() { | 336 void SynchronousCompositorHost::SendAsyncCompositorStateIfNeeded() { |
| 338 if (weak_ptr_factory_.HasWeakPtrs()) | 337 if (weak_ptr_factory_.HasWeakPtrs()) |
| 339 return; | 338 return; |
| 340 | 339 |
| 341 ui_task_runner_->PostTask( | 340 ui_task_runner_->PostTask( |
| 342 FROM_HERE, base::Bind(&SynchronousCompositorHost::UpdateStateTask, | 341 FROM_HERE, base::Bind(&SynchronousCompositorHost::UpdateStateTask, |
| 343 weak_ptr_factory_.GetWeakPtr())); | 342 weak_ptr_factory_.GetWeakPtr())); |
| 344 } | 343 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 void SynchronousCompositorHost::OnOverScroll( | 433 void SynchronousCompositorHost::OnOverScroll( |
| 435 const SyncCompositorCommonRendererParams& params, | 434 const SyncCompositorCommonRendererParams& params, |
| 436 const DidOverscrollParams& over_scroll_params) { | 435 const DidOverscrollParams& over_scroll_params) { |
| 437 ProcessCommonParams(params); | 436 ProcessCommonParams(params); |
| 438 DidOverscroll(over_scroll_params); | 437 DidOverscroll(over_scroll_params); |
| 439 } | 438 } |
| 440 | 439 |
| 441 void SynchronousCompositorHost::PopulateCommonParams( | 440 void SynchronousCompositorHost::PopulateCommonParams( |
| 442 SyncCompositorCommonBrowserParams* params) { | 441 SyncCompositorCommonBrowserParams* params) { |
| 443 DCHECK(params); | 442 DCHECK(params); |
| 444 if (root_scroll_offset_updated_by_browser_) { | |
| 445 params->root_scroll_offset = root_scroll_offset_; | |
| 446 params->update_root_scroll_offset = root_scroll_offset_updated_by_browser_; | |
| 447 root_scroll_offset_updated_by_browser_ = false; | |
| 448 } | |
| 449 params->begin_frame_source_paused = !is_active_; | 443 params->begin_frame_source_paused = !is_active_; |
| 450 | 444 |
| 451 weak_ptr_factory_.InvalidateWeakPtrs(); | 445 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 452 } | 446 } |
| 453 | 447 |
| 454 void SynchronousCompositorHost::ProcessCommonParams( | 448 void SynchronousCompositorHost::ProcessCommonParams( |
| 455 const SyncCompositorCommonRendererParams& params) { | 449 const SyncCompositorCommonRendererParams& params) { |
| 456 // Ignore if |renderer_param_version_| is newer than |params.version|. This | 450 // Ignore if |renderer_param_version_| is newer than |params.version|. This |
| 457 // comparison takes into account when the unsigned int wraps. | 451 // comparison takes into account when the unsigned int wraps. |
| 458 if ((renderer_param_version_ - params.version) < 0x80000000) { | 452 if ((renderer_param_version_ - params.version) < 0x80000000) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 487 params.scrollable_size, params.page_scale_factor, | 481 params.scrollable_size, params.page_scale_factor, |
| 488 params.min_page_scale_factor, params.max_page_scale_factor); | 482 params.min_page_scale_factor, params.max_page_scale_factor); |
| 489 } | 483 } |
| 490 } | 484 } |
| 491 | 485 |
| 492 void SynchronousCompositorHost::UpdateNeedsBeginFrames() { | 486 void SynchronousCompositorHost::UpdateNeedsBeginFrames() { |
| 493 rwhva_->OnSetNeedsBeginFrames(is_active_ && need_begin_frame_); | 487 rwhva_->OnSetNeedsBeginFrames(is_active_ && need_begin_frame_); |
| 494 } | 488 } |
| 495 | 489 |
| 496 } // namespace content | 490 } // namespace content |
| OLD | NEW |