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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 DCHECK(mutator_host_); | 258 DCHECK(mutator_host_); |
259 mutator_host_->SetMutatorHostClient(this); | 259 mutator_host_->SetMutatorHostClient(this); |
260 | 260 |
261 DCHECK(task_runner_provider_->IsImplThread()); | 261 DCHECK(task_runner_provider_->IsImplThread()); |
262 DidVisibilityChange(this, visible_); | 262 DidVisibilityChange(this, visible_); |
263 | 263 |
264 SetDebugState(settings.initial_debug_state); | 264 SetDebugState(settings.initial_debug_state); |
265 | 265 |
266 // LTHI always has an active tree. | 266 // LTHI always has an active tree. |
267 active_tree_ = base::MakeUnique<LayerTreeImpl>( | 267 active_tree_ = base::MakeUnique<LayerTreeImpl>( |
268 this, new SyncedProperty<ScaleGroup>, new SyncedBrowserControls, | 268 this, new SyncedProperty<ScaleGroup>, new SyncedProperty<ScaleGroup>, |
269 new SyncedElasticOverscroll); | 269 new SyncedBrowserControls, new SyncedElasticOverscroll); |
270 active_tree_->property_trees()->is_active = true; | 270 active_tree_->property_trees()->is_active = true; |
271 | 271 |
272 viewport_ = Viewport::Create(this); | 272 viewport_ = Viewport::Create(this); |
273 | 273 |
274 TRACE_EVENT_OBJECT_CREATED_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 274 TRACE_EVENT_OBJECT_CREATED_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
275 "cc::LayerTreeHostImpl", id_); | 275 "cc::LayerTreeHostImpl", id_); |
276 | 276 |
277 browser_controls_offset_manager_ = BrowserControlsOffsetManager::Create( | 277 browser_controls_offset_manager_ = BrowserControlsOffsetManager::Create( |
278 this, settings.top_controls_show_threshold, | 278 this, settings.top_controls_show_threshold, |
279 settings.top_controls_hide_threshold); | 279 settings.top_controls_hide_threshold); |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 UpdateTileManagerMemoryPolicy(ManagedMemoryPolicy(0)); | 1191 UpdateTileManagerMemoryPolicy(ManagedMemoryPolicy(0)); |
1192 } | 1192 } |
1193 | 1193 |
1194 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { | 1194 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { |
1195 NOTREACHED(); | 1195 NOTREACHED(); |
1196 } | 1196 } |
1197 | 1197 |
1198 void LayerTreeHostImpl::ResetTreesForTesting() { | 1198 void LayerTreeHostImpl::ResetTreesForTesting() { |
1199 if (active_tree_) | 1199 if (active_tree_) |
1200 active_tree_->DetachLayers(); | 1200 active_tree_->DetachLayers(); |
1201 active_tree_ = | 1201 active_tree_ = base::MakeUnique<LayerTreeImpl>( |
1202 base::MakeUnique<LayerTreeImpl>(this, active_tree()->page_scale_factor(), | 1202 this, active_tree()->page_scale_factor(), |
1203 active_tree()->top_controls_shown_ratio(), | 1203 active_tree()->subframe_page_scale_factor(), |
1204 active_tree()->elastic_overscroll()); | 1204 active_tree()->top_controls_shown_ratio(), |
| 1205 active_tree()->elastic_overscroll()); |
1205 active_tree_->property_trees()->is_active = true; | 1206 active_tree_->property_trees()->is_active = true; |
1206 if (pending_tree_) | 1207 if (pending_tree_) |
1207 pending_tree_->DetachLayers(); | 1208 pending_tree_->DetachLayers(); |
1208 pending_tree_ = nullptr; | 1209 pending_tree_ = nullptr; |
1209 pending_tree_duration_timer_ = nullptr; | 1210 pending_tree_duration_timer_ = nullptr; |
1210 if (recycle_tree_) | 1211 if (recycle_tree_) |
1211 recycle_tree_->DetachLayers(); | 1212 recycle_tree_->DetachLayers(); |
1212 recycle_tree_ = nullptr; | 1213 recycle_tree_ = nullptr; |
1213 } | 1214 } |
1214 | 1215 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 void LayerTreeHostImpl::OnCanDrawStateChangedForTree() { | 1535 void LayerTreeHostImpl::OnCanDrawStateChangedForTree() { |
1535 client_->OnCanDrawStateChanged(CanDraw()); | 1536 client_->OnCanDrawStateChanged(CanDraw()); |
1536 } | 1537 } |
1537 | 1538 |
1538 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { | 1539 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { |
1539 CompositorFrameMetadata metadata; | 1540 CompositorFrameMetadata metadata; |
1540 metadata.device_scale_factor = active_tree_->painted_device_scale_factor() * | 1541 metadata.device_scale_factor = active_tree_->painted_device_scale_factor() * |
1541 active_tree_->device_scale_factor(); | 1542 active_tree_->device_scale_factor(); |
1542 | 1543 |
1543 metadata.page_scale_factor = active_tree_->current_page_scale_factor(); | 1544 metadata.page_scale_factor = active_tree_->current_page_scale_factor(); |
| 1545 // TODO(wjmaclean): Should we sxpose subframe PSF here? |
1544 metadata.scrollable_viewport_size = active_tree_->ScrollableViewportSize(); | 1546 metadata.scrollable_viewport_size = active_tree_->ScrollableViewportSize(); |
1545 metadata.root_layer_size = active_tree_->ScrollableSize(); | 1547 metadata.root_layer_size = active_tree_->ScrollableSize(); |
1546 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor(); | 1548 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor(); |
1547 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor(); | 1549 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor(); |
1548 metadata.top_controls_height = | 1550 metadata.top_controls_height = |
1549 browser_controls_offset_manager_->TopControlsHeight(); | 1551 browser_controls_offset_manager_->TopControlsHeight(); |
1550 metadata.top_controls_shown_ratio = | 1552 metadata.top_controls_shown_ratio = |
1551 browser_controls_offset_manager_->TopControlsShownRatio(); | 1553 browser_controls_offset_manager_->TopControlsShownRatio(); |
1552 metadata.bottom_controls_height = | 1554 metadata.bottom_controls_height = |
1553 browser_controls_offset_manager_->BottomControlsHeight(); | 1555 browser_controls_offset_manager_->BottomControlsHeight(); |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 return did_lock_scrolling_layer_; | 1947 return did_lock_scrolling_layer_; |
1946 } | 1948 } |
1947 | 1949 |
1948 void LayerTreeHostImpl::CreatePendingTree() { | 1950 void LayerTreeHostImpl::CreatePendingTree() { |
1949 CHECK(!pending_tree_); | 1951 CHECK(!pending_tree_); |
1950 if (recycle_tree_) { | 1952 if (recycle_tree_) { |
1951 recycle_tree_.swap(pending_tree_); | 1953 recycle_tree_.swap(pending_tree_); |
1952 } else { | 1954 } else { |
1953 pending_tree_ = base::MakeUnique<LayerTreeImpl>( | 1955 pending_tree_ = base::MakeUnique<LayerTreeImpl>( |
1954 this, active_tree()->page_scale_factor(), | 1956 this, active_tree()->page_scale_factor(), |
| 1957 active_tree()->subframe_page_scale_factor(), |
1955 active_tree()->top_controls_shown_ratio(), | 1958 active_tree()->top_controls_shown_ratio(), |
1956 active_tree()->elastic_overscroll()); | 1959 active_tree()->elastic_overscroll()); |
1957 } | 1960 } |
1958 | 1961 |
1959 client_->OnCanDrawStateChanged(CanDraw()); | 1962 client_->OnCanDrawStateChanged(CanDraw()); |
1960 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); | 1963 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); |
1961 | 1964 |
1962 DCHECK(!pending_tree_duration_timer_); | 1965 DCHECK(!pending_tree_duration_timer_); |
1963 pending_tree_duration_timer_.reset(new PendingTreeDurationHistogramTimer()); | 1966 pending_tree_duration_timer_.reset(new PendingTreeDurationHistogramTimer()); |
1964 } | 1967 } |
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3311 pinch_gesture_active_ = true; | 3314 pinch_gesture_active_ = true; |
3312 client_->RenewTreePriority(); | 3315 client_->RenewTreePriority(); |
3313 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); | 3316 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); |
3314 active_tree_->SetCurrentlyScrollingLayer(viewport()->MainScrollLayer()); | 3317 active_tree_->SetCurrentlyScrollingLayer(viewport()->MainScrollLayer()); |
3315 browser_controls_offset_manager_->PinchBegin(); | 3318 browser_controls_offset_manager_->PinchBegin(); |
3316 } | 3319 } |
3317 | 3320 |
3318 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, | 3321 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, |
3319 const gfx::Point& anchor) { | 3322 const gfx::Point& anchor) { |
3320 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); | 3323 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); |
3321 if (!InnerViewportScrollLayer()) | 3324 if (InnerViewportScrollLayer()) { |
3322 return; | 3325 viewport()->PinchUpdate(magnify_delta, anchor); |
3323 viewport()->PinchUpdate(magnify_delta, anchor); | 3326 } else { |
| 3327 float subframe_page_scale_factor = |
| 3328 active_tree_->GetSubframePageScaleFactor(); |
| 3329 subframe_page_scale_factor *= magnify_delta; |
| 3330 active_tree_->SetSubframePageScaleOnActiveTree(subframe_page_scale_factor); |
| 3331 } |
3324 client_->SetNeedsCommitOnImplThread(); | 3332 client_->SetNeedsCommitOnImplThread(); |
3325 SetNeedsRedraw(); | 3333 SetNeedsRedraw(); |
3326 client_->RenewTreePriority(); | 3334 client_->RenewTreePriority(); |
3327 // Pinching can change the root scroll offset, so inform the synchronous input | 3335 // Pinching can change the root scroll offset, so inform the synchronous input |
3328 // handler. | 3336 // handler. |
3329 UpdateRootLayerStateForSynchronousInputHandler(); | 3337 UpdateRootLayerStateForSynchronousInputHandler(); |
3330 } | 3338 } |
3331 | 3339 |
3332 void LayerTreeHostImpl::PinchGestureEnd() { | 3340 void LayerTreeHostImpl::PinchGestureEnd() { |
3333 pinch_gesture_active_ = false; | 3341 pinch_gesture_active_ = false; |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4094 worker_context_visibility_ = | 4102 worker_context_visibility_ = |
4095 worker_context->CacheController()->ClientBecameVisible(); | 4103 worker_context->CacheController()->ClientBecameVisible(); |
4096 } else { | 4104 } else { |
4097 worker_context->CacheController()->ClientBecameNotVisible( | 4105 worker_context->CacheController()->ClientBecameNotVisible( |
4098 std::move(worker_context_visibility_)); | 4106 std::move(worker_context_visibility_)); |
4099 } | 4107 } |
4100 } | 4108 } |
4101 } | 4109 } |
4102 | 4110 |
4103 } // namespace cc | 4111 } // namespace cc |
OLD | NEW |