OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CC_TREES_PROPERTY_TREE_H_ | 5 #ifndef CC_TREES_PROPERTY_TREE_H_ |
6 #define CC_TREES_PROPERTY_TREE_H_ | 6 #define CC_TREES_PROPERTY_TREE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 class CC_EXPORT ScrollTree final : public PropertyTree<ScrollNode> { | 356 class CC_EXPORT ScrollTree final : public PropertyTree<ScrollNode> { |
357 public: | 357 public: |
358 ScrollTree(); | 358 ScrollTree(); |
359 ~ScrollTree(); | 359 ~ScrollTree(); |
360 | 360 |
361 ScrollTree& operator=(const ScrollTree& from); | 361 ScrollTree& operator=(const ScrollTree& from); |
362 bool operator==(const ScrollTree& other) const; | 362 bool operator==(const ScrollTree& other) const; |
363 | 363 |
364 void clear(); | 364 void clear(); |
365 | 365 |
366 typedef std::unordered_map<int, scoped_refptr<SyncedScrollOffset>> | |
367 ScrollOffsetMap; | |
368 typedef std::unordered_map<int, bool> ScrollbarsEnabledMap; | 366 typedef std::unordered_map<int, bool> ScrollbarsEnabledMap; |
369 | 367 |
370 gfx::ScrollOffset MaxScrollOffset(int scroll_node_id) const; | 368 gfx::ScrollOffset MaxScrollOffset(int scroll_node_id) const; |
371 void OnScrollOffsetAnimated(int layer_id, | 369 void OnScrollOffsetAnimated(int layer_id, |
372 int transform_tree_index, | 370 int transform_tree_index, |
373 int scroll_tree_index, | 371 int scroll_tree_index, |
374 const gfx::ScrollOffset& scroll_offset, | 372 const gfx::ScrollOffset& scroll_offset, |
375 LayerTreeImpl* layer_tree_impl); | 373 LayerTreeImpl* layer_tree_impl); |
376 gfx::Size scroll_clip_layer_bounds(int scroll_node_id) const; | 374 gfx::Size scroll_clip_layer_bounds(int scroll_node_id) const; |
377 ScrollNode* CurrentlyScrollingNode(); | 375 ScrollNode* CurrentlyScrollingNode(); |
378 const ScrollNode* CurrentlyScrollingNode() const; | 376 const ScrollNode* CurrentlyScrollingNode() const; |
379 #if DCHECK_IS_ON() | 377 #if DCHECK_IS_ON() |
380 int CurrentlyScrollingNodeId() const; | 378 int CurrentlyScrollingNodeId() const; |
381 #endif | 379 #endif |
382 void set_currently_scrolling_node(int scroll_node_id); | 380 void set_currently_scrolling_node(int scroll_node_id); |
383 gfx::Transform ScreenSpaceTransform(int scroll_node_id) const; | 381 gfx::Transform ScreenSpaceTransform(int scroll_node_id) const; |
384 | 382 |
383 // Returns the current scroll offset. On the main thread this would return the | |
384 // value from the LayerTree while on the impl thread this is the current value | |
ajuma
2017/01/11 22:35:51
nit: "for the LayerTree" might be clearer that we'
Khushal
2017/01/11 23:04:53
Makes sense. Done.
| |
385 // on the active tree. | |
385 const gfx::ScrollOffset current_scroll_offset(int layer_id) const; | 386 const gfx::ScrollOffset current_scroll_offset(int layer_id) const; |
387 | |
388 // Collects deltas for scroll changes on the impl thread that need to be | |
389 // reported to the main thread during the main frame. As such, should only be | |
390 // called on the impl thread side PropertyTrees. | |
386 void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, | 391 void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, |
387 int inner_viewport_layer_id); | 392 int inner_viewport_layer_id); |
388 void UpdateScrollOffsetMap(ScrollOffsetMap* new_scroll_offset_map, | 393 |
389 LayerTreeImpl* layer_tree_impl); | 394 // Applies deltas sent in the previous main frame onto the impl thread state. |
390 ScrollOffsetMap& scroll_offset_map(); | 395 // Should only be called on the impl thread side PropertyTrees. |
391 const ScrollOffsetMap& scroll_offset_map() const; | |
392 void ApplySentScrollDeltasFromAbortedCommit(); | 396 void ApplySentScrollDeltasFromAbortedCommit(); |
397 | |
398 // Pushes scroll updates from the ScrollTree on the main thread onto the | |
399 // impl thread associated state. | |
400 void PushScrollUpdatesFromMainThread(PropertyTrees* main_property_trees, | |
401 LayerTreeImpl* sync_tree); | |
402 | |
403 // Pushes scroll updates from the ScrollTree on the pending tree onto the | |
404 // active tree associated state. | |
405 void PushScrollUpdatesFromPendingTree(PropertyTrees* pending_property_trees, | |
406 LayerTreeImpl* active_tree); | |
407 | |
393 bool SetBaseScrollOffset(int layer_id, | 408 bool SetBaseScrollOffset(int layer_id, |
394 const gfx::ScrollOffset& scroll_offset); | 409 const gfx::ScrollOffset& scroll_offset); |
395 bool SetScrollOffset(int layer_id, const gfx::ScrollOffset& scroll_offset); | 410 bool SetScrollOffset(int layer_id, const gfx::ScrollOffset& scroll_offset); |
396 void SetScrollOffsetClobberActiveValue(int layer_id) { | 411 void SetScrollOffsetClobberActiveValue(int layer_id) { |
397 synced_scroll_offset(layer_id)->set_clobber_active_value(); | 412 GetOrCreateSyncedScrollOffset(layer_id)->set_clobber_active_value(); |
398 } | 413 } |
399 bool UpdateScrollOffsetBaseForTesting(int layer_id, | 414 bool UpdateScrollOffsetBaseForTesting(int layer_id, |
400 const gfx::ScrollOffset& offset); | 415 const gfx::ScrollOffset& offset); |
401 bool SetScrollOffsetDeltaForTesting(int layer_id, | 416 bool SetScrollOffsetDeltaForTesting(int layer_id, |
402 const gfx::Vector2dF& delta); | 417 const gfx::Vector2dF& delta); |
403 const gfx::ScrollOffset GetScrollOffsetBaseForTesting(int layer_id) const; | 418 const gfx::ScrollOffset GetScrollOffsetBaseForTesting(int layer_id) const; |
404 const gfx::ScrollOffset GetScrollOffsetDeltaForTesting(int layer_id) const; | 419 const gfx::ScrollOffset GetScrollOffsetDeltaForTesting(int layer_id) const; |
405 void CollectScrollDeltasForTesting(); | 420 void CollectScrollDeltasForTesting(); |
406 | 421 |
407 void DistributeScroll(ScrollNode* scroll_node, ScrollState* scroll_state); | 422 void DistributeScroll(ScrollNode* scroll_node, ScrollState* scroll_state); |
408 gfx::Vector2dF ScrollBy(ScrollNode* scroll_node, | 423 gfx::Vector2dF ScrollBy(ScrollNode* scroll_node, |
409 const gfx::Vector2dF& scroll, | 424 const gfx::Vector2dF& scroll, |
410 LayerTreeImpl* layer_tree_impl); | 425 LayerTreeImpl* layer_tree_impl); |
411 gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset, | 426 gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset, |
412 ScrollNode* scroll_node) const; | 427 ScrollNode* scroll_node) const; |
413 | 428 |
429 const SyncedScrollOffset* synced_scroll_offset(int layer_id) const; | |
ajuma
2017/01/11 22:35:51
I know you're just moving this code in this CL, bu
Khushal
2017/01/11 23:04:53
Good point. Done.
| |
430 | |
431 #if DCHECK_IS_ON() | |
432 void CopyCompleteTreeState(const ScrollTree& other); | |
433 #endif | |
434 | |
414 private: | 435 private: |
436 using ScrollOffsetMap = std::unordered_map<int, gfx::ScrollOffset>; | |
437 using SyncedScrollOffsetMap = | |
438 std::unordered_map<int, scoped_refptr<SyncedScrollOffset>>; | |
439 | |
415 int currently_scrolling_node_id_; | 440 int currently_scrolling_node_id_; |
416 ScrollOffsetMap layer_id_to_scroll_offset_map_; | |
417 ScrollbarsEnabledMap layer_id_to_scrollbars_enabled_map_; | 441 ScrollbarsEnabledMap layer_id_to_scrollbars_enabled_map_; |
418 | 442 |
419 SyncedScrollOffset* synced_scroll_offset(int layer_id); | 443 // On the main thread we store the scroll offsets directly since the main |
420 const SyncedScrollOffset* synced_scroll_offset(int layer_id) const; | 444 // thread only needs to keep track of the current main thread state. The impl |
445 // thread stores a map of SyncedProperty instances in order to track | |
446 // additional state necessary to synchronize scroll changes between the main | |
447 // and impl threads. | |
448 ScrollOffsetMap layer_id_to_scroll_offset_map_; | |
449 SyncedScrollOffsetMap layer_id_to_synced_scroll_offset_map_; | |
450 | |
451 SyncedScrollOffset* GetOrCreateSyncedScrollOffset(int layer_id); | |
421 gfx::ScrollOffset PullDeltaForMainThread(SyncedScrollOffset* scroll_offset); | 452 gfx::ScrollOffset PullDeltaForMainThread(SyncedScrollOffset* scroll_offset); |
422 void UpdateScrollOffsetMapEntry(int key, | |
423 ScrollOffsetMap* new_scroll_offset_map, | |
424 LayerTreeImpl* layer_tree_impl); | |
425 }; | 453 }; |
426 | 454 |
427 struct AnimationScaleData { | 455 struct AnimationScaleData { |
428 // Variable used to invalidate cached animation scale data when transform tree | 456 // Variable used to invalidate cached animation scale data when transform tree |
429 // updates. | 457 // updates. |
430 int update_number; | 458 int update_number; |
431 | 459 |
432 // Current animations, considering only scales at keyframes not including the | 460 // Current animations, considering only scales at keyframes not including the |
433 // starting keyframe of each animation. | 461 // starting keyframe of each animation. |
434 float local_maximum_animation_target_scale; | 462 float local_maximum_animation_target_scale; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 DrawTransforms& GetDrawTransforms(int transform_id, int effect_id) const; | 641 DrawTransforms& GetDrawTransforms(int transform_id, int effect_id) const; |
614 DrawTransformData& FetchDrawTransformsDataFromCache(int transform_id, | 642 DrawTransformData& FetchDrawTransformsDataFromCache(int transform_id, |
615 int effect_id) const; | 643 int effect_id) const; |
616 | 644 |
617 PropertyTreesCachedData cached_data_; | 645 PropertyTreesCachedData cached_data_; |
618 }; | 646 }; |
619 | 647 |
620 } // namespace cc | 648 } // namespace cc |
621 | 649 |
622 #endif // CC_TREES_PROPERTY_TREE_H_ | 650 #endif // CC_TREES_PROPERTY_TREE_H_ |
OLD | NEW |