| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <stack> | 8 #include <stack> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 inside_begin_main_frame_(false), | 112 inside_begin_main_frame_(false), |
| 113 needs_full_tree_sync_(true), | 113 needs_full_tree_sync_(true), |
| 114 client_(client), | 114 client_(client), |
| 115 source_frame_number_(0), | 115 source_frame_number_(0), |
| 116 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), | 116 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), |
| 117 output_surface_lost_(true), | 117 output_surface_lost_(true), |
| 118 settings_(settings), | 118 settings_(settings), |
| 119 debug_state_(settings.initial_debug_state), | 119 debug_state_(settings.initial_debug_state), |
| 120 top_controls_shrink_blink_size_(false), | 120 top_controls_shrink_blink_size_(false), |
| 121 top_controls_height_(0.f), | 121 top_controls_height_(0.f), |
| 122 top_controls_content_offset_(0.f), | 122 top_controls_shown_ratio_(0.f), |
| 123 device_scale_factor_(1.f), | 123 device_scale_factor_(1.f), |
| 124 visible_(true), | 124 visible_(true), |
| 125 page_scale_factor_(1.f), | 125 page_scale_factor_(1.f), |
| 126 min_page_scale_factor_(1.f), | 126 min_page_scale_factor_(1.f), |
| 127 max_page_scale_factor_(1.f), | 127 max_page_scale_factor_(1.f), |
| 128 has_gpu_rasterization_trigger_(false), | 128 has_gpu_rasterization_trigger_(false), |
| 129 content_is_suitable_for_gpu_rasterization_(true), | 129 content_is_suitable_for_gpu_rasterization_(true), |
| 130 gpu_rasterization_histogram_recorded_(false), | 130 gpu_rasterization_histogram_recorded_(false), |
| 131 background_color_(SK_ColorWHITE), | 131 background_color_(SK_ColorWHITE), |
| 132 has_transparent_background_(false), | 132 has_transparent_background_(false), |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 sync_tree->RegisterSelection(selection_start_, selection_end_); | 328 sync_tree->RegisterSelection(selection_start_, selection_end_); |
| 329 | 329 |
| 330 sync_tree->PushPageScaleFromMainThread( | 330 sync_tree->PushPageScaleFromMainThread( |
| 331 page_scale_factor_, min_page_scale_factor_, max_page_scale_factor_); | 331 page_scale_factor_, min_page_scale_factor_, max_page_scale_factor_); |
| 332 sync_tree->elastic_overscroll()->PushFromMainThread(elastic_overscroll_); | 332 sync_tree->elastic_overscroll()->PushFromMainThread(elastic_overscroll_); |
| 333 if (sync_tree->IsActiveTree()) | 333 if (sync_tree->IsActiveTree()) |
| 334 sync_tree->elastic_overscroll()->PushPendingToActive(); | 334 sync_tree->elastic_overscroll()->PushPendingToActive(); |
| 335 | 335 |
| 336 sync_tree->PassSwapPromises(&swap_promise_list_); | 336 sync_tree->PassSwapPromises(&swap_promise_list_); |
| 337 | 337 |
| 338 // Track the change in top controls height to offset the top_controls_delta | |
| 339 // properly. This is so that the top controls offset will be maintained | |
| 340 // across height changes. | |
| 341 float top_controls_height_delta = | |
| 342 sync_tree->top_controls_height() - top_controls_height_; | |
| 343 | |
| 344 sync_tree->set_top_controls_shrink_blink_size( | 338 sync_tree->set_top_controls_shrink_blink_size( |
| 345 top_controls_shrink_blink_size_); | 339 top_controls_shrink_blink_size_); |
| 346 sync_tree->set_top_controls_height(top_controls_height_); | 340 sync_tree->set_top_controls_height(top_controls_height_); |
| 347 sync_tree->set_top_controls_content_offset(top_controls_content_offset_); | 341 sync_tree->PushTopControlsFromMainThread(top_controls_shown_ratio_); |
| 348 sync_tree->set_top_controls_delta(sync_tree->top_controls_delta() - | |
| 349 sync_tree->sent_top_controls_delta() - | |
| 350 top_controls_height_delta); | |
| 351 sync_tree->set_sent_top_controls_delta(0.f); | |
| 352 | 342 |
| 353 host_impl->SetUseGpuRasterization(UseGpuRasterization()); | 343 host_impl->SetUseGpuRasterization(UseGpuRasterization()); |
| 354 host_impl->set_gpu_rasterization_status(GetGpuRasterizationStatus()); | 344 host_impl->set_gpu_rasterization_status(GetGpuRasterizationStatus()); |
| 355 RecordGpuRasterizationHistogram(); | 345 RecordGpuRasterizationHistogram(); |
| 356 | 346 |
| 357 host_impl->SetViewportSize(device_viewport_size_); | 347 host_impl->SetViewportSize(device_viewport_size_); |
| 358 host_impl->SetDeviceScaleFactor(device_scale_factor_); | 348 host_impl->SetDeviceScaleFactor(device_scale_factor_); |
| 359 host_impl->SetDebugState(debug_state_); | 349 host_impl->SetDebugState(debug_state_); |
| 360 if (pending_page_scale_animation_) { | 350 if (pending_page_scale_animation_) { |
| 361 sync_tree->SetPendingPageScaleAnimation( | 351 sync_tree->SetPendingPageScaleAnimation( |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 } | 674 } |
| 685 | 675 |
| 686 void LayerTreeHost::SetTopControlsHeight(float height) { | 676 void LayerTreeHost::SetTopControlsHeight(float height) { |
| 687 if (top_controls_height_ == height) | 677 if (top_controls_height_ == height) |
| 688 return; | 678 return; |
| 689 | 679 |
| 690 top_controls_height_ = height; | 680 top_controls_height_ = height; |
| 691 SetNeedsCommit(); | 681 SetNeedsCommit(); |
| 692 } | 682 } |
| 693 | 683 |
| 694 void LayerTreeHost::SetTopControlsContentOffset(float offset) { | 684 void LayerTreeHost::SetTopControlsShownRatio(float ratio) { |
| 695 if (top_controls_content_offset_ == offset) | 685 if (top_controls_shown_ratio_ == ratio) |
| 696 return; | 686 return; |
| 697 | 687 |
| 698 top_controls_content_offset_ = offset; | 688 top_controls_shown_ratio_ = ratio; |
| 699 SetNeedsCommit(); | 689 SetNeedsCommit(); |
| 700 } | 690 } |
| 701 | 691 |
| 702 void LayerTreeHost::ApplyPageScaleDeltaFromImplSide(float page_scale_delta) { | 692 void LayerTreeHost::ApplyPageScaleDeltaFromImplSide(float page_scale_delta) { |
| 703 DCHECK(CommitRequested()); | 693 DCHECK(CommitRequested()); |
| 704 page_scale_factor_ *= page_scale_delta; | 694 page_scale_factor_ *= page_scale_delta; |
| 705 } | 695 } |
| 706 | 696 |
| 707 void LayerTreeHost::SetPageScaleFactorAndLimits(float page_scale_factor, | 697 void LayerTreeHost::SetPageScaleFactorAndLimits(float page_scale_factor, |
| 708 float min_page_scale_factor, | 698 float min_page_scale_factor, |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 // Top controls are only used in threaded mode. | 1212 // Top controls are only used in threaded mode. |
| 1223 proxy_->ImplThreadTaskRunner()->PostTask( | 1213 proxy_->ImplThreadTaskRunner()->PostTask( |
| 1224 FROM_HERE, | 1214 FROM_HERE, |
| 1225 base::Bind(&TopControlsManager::UpdateTopControlsState, | 1215 base::Bind(&TopControlsManager::UpdateTopControlsState, |
| 1226 top_controls_manager_weak_ptr_, | 1216 top_controls_manager_weak_ptr_, |
| 1227 constraints, | 1217 constraints, |
| 1228 current, | 1218 current, |
| 1229 animate)); | 1219 animate)); |
| 1230 } | 1220 } |
| 1231 | 1221 |
| 1232 void LayerTreeHost::AsValueInto(base::debug::TracedValue* state) const { | 1222 void LayerTreeHost::AsValueInto(base::trace_event::TracedValue* state) const { |
| 1233 state->BeginDictionary("proxy"); | 1223 state->BeginDictionary("proxy"); |
| 1234 proxy_->AsValueInto(state); | 1224 proxy_->AsValueInto(state); |
| 1235 state->EndDictionary(); | 1225 state->EndDictionary(); |
| 1236 } | 1226 } |
| 1237 | 1227 |
| 1238 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { | 1228 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { |
| 1239 if (!settings_.accelerated_animation_enabled || | 1229 if (!settings_.accelerated_animation_enabled || |
| 1240 animation_registrar_->active_animation_controllers().empty()) | 1230 animation_registrar_->active_animation_controllers().empty()) |
| 1241 return; | 1231 return; |
| 1242 | 1232 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 bool children_need_begin_frames) const { | 1370 bool children_need_begin_frames) const { |
| 1381 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); | 1371 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); |
| 1382 } | 1372 } |
| 1383 | 1373 |
| 1384 void LayerTreeHost::SendBeginFramesToChildren( | 1374 void LayerTreeHost::SendBeginFramesToChildren( |
| 1385 const BeginFrameArgs& args) const { | 1375 const BeginFrameArgs& args) const { |
| 1386 client_->SendBeginFramesToChildren(args); | 1376 client_->SendBeginFramesToChildren(args); |
| 1387 } | 1377 } |
| 1388 | 1378 |
| 1389 } // namespace cc | 1379 } // namespace cc |
| OLD | NEW |