| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 IPC_MESSAGE_UNHANDLED(handled = false) | 97 IPC_MESSAGE_UNHANDLED(handled = false) |
| 98 IPC_END_MESSAGE_MAP() | 98 IPC_END_MESSAGE_MAP() |
| 99 return handled; | 99 return handled; |
| 100 } | 100 } |
| 101 | 101 |
| 102 scoped_refptr<SynchronousCompositor::FrameFuture> | 102 scoped_refptr<SynchronousCompositor::FrameFuture> |
| 103 SynchronousCompositorHost::DemandDrawHwAsync( | 103 SynchronousCompositorHost::DemandDrawHwAsync( |
| 104 const gfx::Size& viewport_size, | 104 const gfx::Size& viewport_size, |
| 105 const gfx::Rect& viewport_rect_for_tile_priority, | 105 const gfx::Rect& viewport_rect_for_tile_priority, |
| 106 const gfx::Transform& transform_for_tile_priority) { | 106 const gfx::Transform& transform_for_tile_priority) { |
| 107 scoped_refptr<FrameFuture> frame_future = new FrameFuture(); |
| 108 if (compute_scroll_needs_synchronous_draw_) { |
| 109 compute_scroll_needs_synchronous_draw_ = false; |
| 110 auto frame_ptr = base::MakeUnique<Frame>(); |
| 111 *frame_ptr = DemandDrawHw(viewport_size, viewport_rect_for_tile_priority, |
| 112 transform_for_tile_priority); |
| 113 frame_future->SetFrame(std::move(frame_ptr)); |
| 114 return frame_future; |
| 115 } |
| 116 |
| 107 SyncCompositorDemandDrawHwParams params(viewport_size, | 117 SyncCompositorDemandDrawHwParams params(viewport_size, |
| 108 viewport_rect_for_tile_priority, | 118 viewport_rect_for_tile_priority, |
| 109 transform_for_tile_priority); | 119 transform_for_tile_priority); |
| 110 scoped_refptr<FrameFuture> frame_future = new FrameFuture(); | |
| 111 if (SynchronousCompositorBrowserFilter* filter = GetFilter()) { | 120 if (SynchronousCompositorBrowserFilter* filter = GetFilter()) { |
| 112 if (!registered_with_filter_) { | 121 if (!registered_with_filter_) { |
| 113 filter->RegisterHost(this); | 122 filter->RegisterHost(this); |
| 114 registered_with_filter_ = true; | 123 registered_with_filter_ = true; |
| 115 } | 124 } |
| 116 filter->SetFrameFuture(routing_id_, frame_future); | 125 filter->SetFrameFuture(routing_id_, frame_future); |
| 117 sender_->Send(new SyncCompositorMsg_DemandDrawHwAsync(routing_id_, params)); | 126 sender_->Send(new SyncCompositorMsg_DemandDrawHwAsync(routing_id_, params)); |
| 118 } else { | 127 } else { |
| 119 frame_future->SetFrame(nullptr); | 128 frame_future->SetFrame(nullptr); |
| 120 } | 129 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 365 |
| 357 void SynchronousCompositorHost::OnComputeScroll( | 366 void SynchronousCompositorHost::OnComputeScroll( |
| 358 base::TimeTicks animation_time) { | 367 base::TimeTicks animation_time) { |
| 359 if (!need_animate_scroll_) | 368 if (!need_animate_scroll_) |
| 360 return; | 369 return; |
| 361 need_animate_scroll_ = false; | 370 need_animate_scroll_ = false; |
| 362 | 371 |
| 363 SyncCompositorCommonRendererParams common_renderer_params; | 372 SyncCompositorCommonRendererParams common_renderer_params; |
| 364 sender_->Send( | 373 sender_->Send( |
| 365 new SyncCompositorMsg_ComputeScroll(routing_id_, animation_time)); | 374 new SyncCompositorMsg_ComputeScroll(routing_id_, animation_time)); |
| 375 compute_scroll_needs_synchronous_draw_ = true; |
| 366 } | 376 } |
| 367 | 377 |
| 368 void SynchronousCompositorHost::DidOverscroll( | 378 void SynchronousCompositorHost::DidOverscroll( |
| 369 const ui::DidOverscrollParams& over_scroll_params) { | 379 const ui::DidOverscrollParams& over_scroll_params) { |
| 370 client_->DidOverscroll(this, over_scroll_params.accumulated_overscroll, | 380 client_->DidOverscroll(this, over_scroll_params.accumulated_overscroll, |
| 371 over_scroll_params.latest_overscroll_delta, | 381 over_scroll_params.latest_overscroll_delta, |
| 372 over_scroll_params.current_fling_velocity); | 382 over_scroll_params.current_fling_velocity); |
| 373 } | 383 } |
| 374 | 384 |
| 375 void SynchronousCompositorHost::DidSendBeginFrame( | 385 void SynchronousCompositorHost::DidSendBeginFrame( |
| 376 ui::WindowAndroid* window_android) { | 386 ui::WindowAndroid* window_android) { |
| 387 compute_scroll_needs_synchronous_draw_ = false; |
| 377 if (SynchronousCompositorBrowserFilter* filter = GetFilter()) | 388 if (SynchronousCompositorBrowserFilter* filter = GetFilter()) |
| 378 filter->SyncStateAfterVSync(window_android, this); | 389 filter->SyncStateAfterVSync(window_android, this); |
| 379 } | 390 } |
| 380 | 391 |
| 381 void SynchronousCompositorHost::CompositorFrameSinkCreated() { | 392 void SynchronousCompositorHost::CompositorFrameSinkCreated() { |
| 382 // New CompositorFrameSink is not aware of state from Browser side. So need to | 393 // New CompositorFrameSink is not aware of state from Browser side. So need to |
| 383 // re-send all browser side state here. | 394 // re-send all browser side state here. |
| 384 sender_->Send( | 395 sender_->Send( |
| 385 new SyncCompositorMsg_SetMemoryPolicy(routing_id_, bytes_limit_)); | 396 new SyncCompositorMsg_SetMemoryPolicy(routing_id_, bytes_limit_)); |
| 386 } | 397 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 413 if (params.page_scale_factor) { | 424 if (params.page_scale_factor) { |
| 414 client_->UpdateRootLayerState( | 425 client_->UpdateRootLayerState( |
| 415 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), | 426 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), |
| 416 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), | 427 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), |
| 417 params.scrollable_size, params.page_scale_factor, | 428 params.scrollable_size, params.page_scale_factor, |
| 418 params.min_page_scale_factor, params.max_page_scale_factor); | 429 params.min_page_scale_factor, params.max_page_scale_factor); |
| 419 } | 430 } |
| 420 } | 431 } |
| 421 | 432 |
| 422 } // namespace content | 433 } // namespace content |
| OLD | NEW |