OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_OCCLUSION_TRACKER_H_ | 5 #ifndef CC_TREES_OCCLUSION_TRACKER_H_ |
6 #define CC_TREES_OCCLUSION_TRACKER_H_ | 6 #define CC_TREES_OCCLUSION_TRACKER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "cc/base/simple_enclosed_region.h" | 11 #include "cc/base/simple_enclosed_region.h" |
12 #include "cc/cc_export.h" | 12 #include "cc/cc_export.h" |
13 #include "cc/layers/layer_iterator.h" | 13 #include "cc/layers/effect_tree_layer_list_iterator.h" |
14 #include "cc/trees/occlusion.h" | 14 #include "cc/trees/occlusion.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 class LayerImpl; | 18 class LayerImpl; |
19 class Region; | 19 class Region; |
20 class RenderSurfaceImpl; | 20 class RenderSurfaceImpl; |
21 | 21 |
22 // This class is used to track occlusion of layers while traversing them in a | 22 // This class is used to track occlusion of layers while traversing them in a |
23 // front-to-back order. As each layer is visited, one of the methods in this | 23 // front-to-back order. As each layer is visited, one of the methods in this |
(...skipping 10 matching lines...) Expand all Loading... |
34 ~OcclusionTracker(); | 34 ~OcclusionTracker(); |
35 | 35 |
36 // Return an occlusion that retains the current state of the tracker | 36 // Return an occlusion that retains the current state of the tracker |
37 // and can be used outside of a layer walk to check occlusion. | 37 // and can be used outside of a layer walk to check occlusion. |
38 Occlusion GetCurrentOcclusionForLayer( | 38 Occlusion GetCurrentOcclusionForLayer( |
39 const gfx::Transform& draw_transform) const; | 39 const gfx::Transform& draw_transform) const; |
40 Occlusion GetCurrentOcclusionForContributingSurface( | 40 Occlusion GetCurrentOcclusionForContributingSurface( |
41 const gfx::Transform& draw_transform) const; | 41 const gfx::Transform& draw_transform) const; |
42 | 42 |
43 const RenderSurfaceImpl* OcclusionSurfaceForContributingSurface() const; | 43 const RenderSurfaceImpl* OcclusionSurfaceForContributingSurface() const; |
44 // Called at the beginning of each step in the LayerIterator's front-to-back | 44 // Called at the beginning of each step in EffectTreeLayerListIterator's |
45 // traversal. | 45 // front-to-back traversal. |
46 void EnterLayer(const LayerIteratorPosition& layer_iterator); | 46 void EnterLayer(const EffectTreeLayerListIterator::Position& iterator); |
47 // Called at the end of each step in the LayerIterator's front-to-back | 47 // Called at the end of each step in EffectTreeLayerListIterator's |
48 // traversal. | 48 // front-to-back traversal. |
49 void LeaveLayer(const LayerIteratorPosition& layer_iterator); | 49 void LeaveLayer(const EffectTreeLayerListIterator::Position& iterator); |
50 | 50 |
51 // Gives the region of the screen that is not occluded by something opaque. | 51 // Gives the region of the screen that is not occluded by something opaque. |
52 Region ComputeVisibleRegionInScreen(const LayerTreeImpl* layer_tree) const; | 52 Region ComputeVisibleRegionInScreen(const LayerTreeImpl* layer_tree) const; |
53 | 53 |
54 void set_minimum_tracking_size(const gfx::Size& size) { | 54 void set_minimum_tracking_size(const gfx::Size& size) { |
55 minimum_tracking_size_ = size; | 55 minimum_tracking_size_ = size; |
56 } | 56 } |
57 | 57 |
58 protected: | 58 protected: |
59 struct StackObject { | 59 struct StackObject { |
(...skipping 15 matching lines...) Expand all Loading... |
75 // - When we visit a layer representing itself, we add its occlusion to the | 75 // - When we visit a layer representing itself, we add its occlusion to the |
76 // current subtree, which is at the top of the stack. | 76 // current subtree, which is at the top of the stack. |
77 // - When we visit a layer representing a contributing surface, the current | 77 // - When we visit a layer representing a contributing surface, the current |
78 // target will never be the top of the stack since we just came from the | 78 // target will never be the top of the stack since we just came from the |
79 // contributing surface. | 79 // contributing surface. |
80 // We merge the occlusion at the top of the stack with the new current | 80 // We merge the occlusion at the top of the stack with the new current |
81 // subtree. This new target is pushed onto the stack if not already there. | 81 // subtree. This new target is pushed onto the stack if not already there. |
82 std::vector<StackObject> stack_; | 82 std::vector<StackObject> stack_; |
83 | 83 |
84 private: | 84 private: |
85 // Called when visiting a layer representing itself. If the target was not | 85 // Called when visiting a layer. If the target was not already current, then |
86 // already current, then this indicates we have entered a new surface subtree. | 86 // this indicates we have entered a new surface subtree. |
87 void EnterRenderTarget(const LayerImpl* new_target); | 87 void EnterRenderTarget(const RenderSurfaceImpl* new_target_surface); |
88 | 88 |
89 // Called when visiting a layer representing a target surface. This indicates | 89 // Called when visiting a target surface. This indicates we have visited all |
90 // we have visited all the layers within the surface, and we may perform any | 90 // the layers within the surface, and we may perform any surface-wide |
91 // surface-wide operations. | 91 // operations. |
92 void FinishedRenderTarget(const LayerImpl* finished_target); | 92 void FinishedRenderTarget(const RenderSurfaceImpl* finished_target_surface); |
93 | 93 |
94 // Called when visiting a layer representing a contributing surface. This | 94 // Called when visiting a contributing surface. This indicates that we are |
95 // indicates that we are leaving our current surface, and entering the new | 95 // leaving our current surface, and entering the new one. We then perform any |
96 // one. We then perform any operations required for merging results from the | 96 // operations required for merging results from the child subtree into its |
97 // child subtree into its parent. | 97 // parent. |
98 void LeaveToRenderTarget(const LayerImpl* new_target); | 98 void LeaveToRenderTarget(const RenderSurfaceImpl* new_target_surface); |
99 | 99 |
100 // Add the layer's occlusion to the tracked state. | 100 // Add the layer's occlusion to the tracked state. |
101 void MarkOccludedBehindLayer(const LayerImpl* layer); | 101 void MarkOccludedBehindLayer(const LayerImpl* layer); |
102 | 102 |
103 gfx::Rect screen_space_clip_rect_; | 103 gfx::Rect screen_space_clip_rect_; |
104 gfx::Size minimum_tracking_size_; | 104 gfx::Size minimum_tracking_size_; |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(OcclusionTracker); | 106 DISALLOW_COPY_AND_ASSIGN(OcclusionTracker); |
107 }; | 107 }; |
108 | 108 |
109 } // namespace cc | 109 } // namespace cc |
110 | 110 |
111 #endif // CC_TREES_OCCLUSION_TRACKER_H_ | 111 #endif // CC_TREES_OCCLUSION_TRACKER_H_ |
OLD | NEW |