Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: cc/layers/effect_tree_layer_list_iterator.h

Issue 2751783002: cc: Replace LayerIterator with iterator that walks layer list and effect tree (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/BUILD.gn ('k') | cc/layers/effect_tree_layer_list_iterator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_LAYERS_EFFECT_TREE_LAYER_LIST_ITERATOR_H_
6 #define CC_LAYERS_EFFECT_TREE_LAYER_LIST_ITERATOR_H_
7
8 #include "cc/cc_export.h"
9 #include "cc/trees/effect_node.h"
10 #include "cc/trees/layer_tree_impl.h"
11 #include "cc/trees/property_tree.h"
12
13 namespace cc {
14
15 class LayerImpl;
16 class LayerTreeImpl;
17
18 // This iterates over layers and render surfaces in front-to-back order (that
19 // is, in reverse-draw-order). Only layers that draw content to some render
20 // surface are visited. A render surface is visited immediately after all
21 // layers and surfaces that contribute content to that surface are visited.
22 // Surfaces are first visited in state TARGET_SURFACE. Immediately after that,
23 // every surface other than the root surface is visited in state
24 // CONTRIBUTING_SURFACE, as it contributes to the next target surface.
25 //
26 // The iterator takes on the following states:
27 // 1. LAYER: The iterator is visiting layer |current_layer()| that contributes
28 // to surface |target_render_surface()|.
29 // 2. TARGET_SURFACE: The iterator is visiting render surface
30 // |target_render_surface()|.
31 // 3. CONTRIBUTING_SURFACE: The iterator is visiting render surface
32 // |current_render_surface()| that contributes to surface
33 // |target_render_surface()|.
34 // 4. END: All layers and render surfaces have already been visited.
35 class CC_EXPORT EffectTreeLayerListIterator {
36 public:
37 enum class State { LAYER, TARGET_SURFACE, CONTRIBUTING_SURFACE, END };
38
39 explicit EffectTreeLayerListIterator(LayerTreeImpl* layer_tree_impl);
40 EffectTreeLayerListIterator(const EffectTreeLayerListIterator& iterator);
41 ~EffectTreeLayerListIterator();
42
43 void operator++();
44
45 State state() { return state_; }
46
47 LayerImpl* current_layer() const {
48 DCHECK(state_ == State::LAYER);
49 return *layer_list_iterator_;
50 }
51
52 RenderSurfaceImpl* current_render_surface() const {
53 DCHECK(state_ == State::CONTRIBUTING_SURFACE);
54 return effect_tree_->GetRenderSurface(current_effect_tree_index_);
55 }
56
57 RenderSurfaceImpl* target_render_surface() const {
58 switch (state_) {
59 case State::LAYER:
60 case State::TARGET_SURFACE:
61 return effect_tree_->GetRenderSurface(current_effect_tree_index_);
62 case State::CONTRIBUTING_SURFACE: {
63 int target_node_id =
64 effect_tree_->Node(current_effect_tree_index_)->target_id;
65 return effect_tree_->GetRenderSurface(target_node_id);
66 }
67 case State::END:
68 NOTREACHED();
69 }
70 NOTREACHED();
71 return nullptr;
72 }
73
74 struct Position {
75 State state = State::END;
76 LayerImpl* current_layer = nullptr;
77 RenderSurfaceImpl* current_render_surface = nullptr;
78 RenderSurfaceImpl* target_render_surface = nullptr;
79 };
80
81 operator const Position() const {
82 Position position;
83 if (state_ == State::END)
84 return position;
85
86 position.state = state_;
87 position.target_render_surface = target_render_surface();
88 if (state_ == State::LAYER)
89 position.current_layer = current_layer();
90 else if (state_ == State::CONTRIBUTING_SURFACE)
91 position.current_render_surface = current_render_surface();
92
93 return position;
94 }
95
96 private:
97 State state_;
98
99 // When in state LAYER, this is the layer that's currently being visited.
100 // Otherwise, this is the layer that will be visited the next time we're in
101 // state LAYER.
102 LayerImplList::reverse_iterator layer_list_iterator_;
103
104 // When in state LAYER, this is the render target effect tree index for the
105 // currently visited layer. Otherwise, this is the the effect tree index of
106 // the currently visited render surface.
107 int current_effect_tree_index_;
108
109 // Render target effect tree index for the layer currently visited by
110 // layer_list_iterator_.
111 int next_effect_tree_index_;
112
113 // The index in the effect tree of the lowest common ancestor
114 // current_effect_tree_index_ and next_effect_tree_index_, that has a
115 // render surface.
116 int lowest_common_effect_tree_ancestor_index_;
117
118 LayerTreeImpl* layer_tree_impl_;
119 EffectTree* effect_tree_;
120 };
121
122 } // namespace cc
123
124 #endif // CC_LAYERS_EFFECT_TREE_LAYER_LIST_ITERATOR_H_
OLDNEW
« no previous file with comments | « cc/BUILD.gn ('k') | cc/layers/effect_tree_layer_list_iterator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698