Chromium Code Reviews| 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 #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 5 #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| 6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <bitset> | 10 #include <bitset> |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 // Called when output surface asks for a draw. | 125 // Called when output surface asks for a draw. |
| 126 virtual void OnDrawForCompositorFrameSink( | 126 virtual void OnDrawForCompositorFrameSink( |
| 127 bool resourceless_software_draw) = 0; | 127 bool resourceless_software_draw) = 0; |
| 128 | 128 |
| 129 virtual void NeedsImplSideInvalidation() = 0; | 129 virtual void NeedsImplSideInvalidation() = 0; |
| 130 | 130 |
| 131 protected: | 131 protected: |
| 132 virtual ~LayerTreeHostImplClient() {} | 132 virtual ~LayerTreeHostImplClient() {} |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 #if DCHECK_IS_ON() | |
| 136 // The following states are the main steps performed when syncing properties | |
| 137 // using either LayerTreeHost (|FinishCommitOnImplThread|) or LayerTreeHostImpl | |
| 138 // (|ActivateSyncTree|). These states follow the order of the enum values. See: | |
| 139 // |AdvanceSyncState(...)|. | |
| 140 enum SyncState { | |
| 141 NOT_SYNCING = 0, | |
|
enne (OOO)
2017/05/12 17:25:06
Don't need value initialization here. This is alr
| |
| 142 BEGINNING_SYNC = 1, | |
| 143 SYNCED_PROPERTY_TREES = 2, | |
| 144 SYNCED_LAYER_PROPERTIES = 3, | |
| 145 SYNCED_LAYER_TREE_HOST_PROPERTIES = 4, | |
| 146 LAST_SYNC_STATE = SYNCED_LAYER_TREE_HOST_PROPERTIES, | |
| 147 }; | |
| 148 #endif | |
| 149 | |
| 135 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering | 150 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering |
| 136 // state. | 151 // state. |
| 137 class CC_EXPORT LayerTreeHostImpl | 152 class CC_EXPORT LayerTreeHostImpl |
| 138 : public InputHandler, | 153 : public InputHandler, |
| 139 public TileManagerClient, | 154 public TileManagerClient, |
| 140 public CompositorFrameSinkClient, | 155 public CompositorFrameSinkClient, |
| 141 public BrowserControlsOffsetManagerClient, | 156 public BrowserControlsOffsetManagerClient, |
| 142 public ScrollbarAnimationControllerClient, | 157 public ScrollbarAnimationControllerClient, |
| 143 public VideoFrameControllerClient, | 158 public VideoFrameControllerClient, |
| 144 public LayerTreeMutatorClient, | 159 public LayerTreeMutatorClient, |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 LayerTreeMutator* mutator() { return mutator_.get(); } | 611 LayerTreeMutator* mutator() { return mutator_.get(); } |
| 597 | 612 |
| 598 LayerImpl* ViewportMainScrollLayer(); | 613 LayerImpl* ViewportMainScrollLayer(); |
| 599 | 614 |
| 600 void QueueImageDecode(sk_sp<const SkImage> image, | 615 void QueueImageDecode(sk_sp<const SkImage> image, |
| 601 const base::Callback<void(bool)>& embedder_callback); | 616 const base::Callback<void(bool)>& embedder_callback); |
| 602 std::vector<base::Closure> TakeCompletedImageDecodeCallbacks(); | 617 std::vector<base::Closure> TakeCompletedImageDecodeCallbacks(); |
| 603 | 618 |
| 604 void ClearImageCacheOnNavigation(); | 619 void ClearImageCacheOnNavigation(); |
| 605 | 620 |
| 621 #if DCHECK_IS_ON() | |
|
enne (OOO)
2017/05/12 17:25:06
There's an awful lot of #ifdefs here. I get that
pdr.
2017/05/15 18:30:24
I totes agree with this. Done.
(In blink we've be
| |
| 622 // When syncing from LayerTreeHost (|FinishCommitOnImplThread|) or | |
| 623 // LayerTreeHostImpl (|ActivateSyncTree|), the steps should should follow the | |
| 624 // order defined by |SyncState|. This updates the current state and returns | |
| 625 // true if the state transition is allowed, and returns false otherwise. | |
|
enne (OOO)
2017/05/12 17:25:06
I think this would be cleaner if the function didn
| |
| 626 bool AdvanceSyncState(SyncState state) { | |
| 627 bool resetting = state == NOT_SYNCING && sync_state_ == LAST_SYNC_STATE; | |
| 628 if (state > sync_state_ || resetting) { | |
|
chrishtr
2017/05/12 23:13:29
Is it ever ok to skip one of the states in between
| |
| 629 sync_state_ = state; | |
| 630 return true; | |
| 631 } | |
| 632 return false; | |
| 633 } | |
| 634 // Returns true if properties are not currently in the process of syncing, or | |
| 635 // if the current |SyncState| has advanced past the passed in value. | |
| 636 bool SyncStateComplete(SyncState state) { | |
|
chrishtr
2017/05/12 23:13:29
Also, it woudl be great if this could go in a Comp
pdr.
2017/05/15 18:30:24
I've rewritten this code as a LayerTreeLifecycle c
| |
| 637 return !sync_state_ || sync_state_ >= state; | |
| 638 } | |
| 639 #endif | |
| 640 | |
| 606 protected: | 641 protected: |
| 607 LayerTreeHostImpl( | 642 LayerTreeHostImpl( |
| 608 const LayerTreeSettings& settings, | 643 const LayerTreeSettings& settings, |
| 609 LayerTreeHostImplClient* client, | 644 LayerTreeHostImplClient* client, |
| 610 TaskRunnerProvider* task_runner_provider, | 645 TaskRunnerProvider* task_runner_provider, |
| 611 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 646 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 612 TaskGraphRunner* task_graph_runner, | 647 TaskGraphRunner* task_graph_runner, |
| 613 std::unique_ptr<MutatorHost> mutator_host, | 648 std::unique_ptr<MutatorHost> mutator_host, |
| 614 int id, | 649 int id, |
| 615 scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner); | 650 scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 864 // begin main frame. These callbacks must only be called on the main thread. | 899 // begin main frame. These callbacks must only be called on the main thread. |
| 865 std::vector<base::Closure> completed_image_decode_callbacks_; | 900 std::vector<base::Closure> completed_image_decode_callbacks_; |
| 866 | 901 |
| 867 // These are used to transfer usage of touch and wheel scrolls to the main | 902 // These are used to transfer usage of touch and wheel scrolls to the main |
| 868 // thread. | 903 // thread. |
| 869 bool has_scrolled_by_wheel_; | 904 bool has_scrolled_by_wheel_; |
| 870 bool has_scrolled_by_touch_; | 905 bool has_scrolled_by_touch_; |
| 871 | 906 |
| 872 bool touchpad_and_wheel_scroll_latching_enabled_; | 907 bool touchpad_and_wheel_scroll_latching_enabled_; |
| 873 | 908 |
| 909 #if DCHECK_IS_ON() | |
| 910 // Used to enforce dependencies while syncing properties. See: |SyncState| and | |
| 911 // |AdvanceSyncState(...)|. | |
| 912 SyncState sync_state_; | |
|
enne (OOO)
2017/05/12 17:25:06
Hmmmmmm. I'm super surprised to see this on Layer
chrishtr
2017/05/12 23:13:29
Perhaps there should be two of these, one for each
| |
| 913 #endif | |
| 914 | |
| 874 ImplThreadPhase impl_thread_phase_; | 915 ImplThreadPhase impl_thread_phase_; |
| 875 | 916 |
| 876 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 917 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
| 877 }; | 918 }; |
| 878 | 919 |
| 879 } // namespace cc | 920 } // namespace cc |
| 880 | 921 |
| 881 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 922 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| OLD | NEW |