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/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 // class is called to notify it about the current target surface. Then, | 25 // class is called to notify it about the current target surface. Then, |
26 // occlusion in the content space of the current layer may be queried, via | 26 // occlusion in the content space of the current layer may be queried, via |
27 // methods such as Occluded() and UnoccludedContentRect(). If the current layer | 27 // methods such as Occluded() and UnoccludedContentRect(). If the current layer |
28 // owns a RenderSurfaceImpl, then occlusion on that RenderSurfaceImpl may also | 28 // owns a RenderSurfaceImpl, then occlusion on that RenderSurfaceImpl may also |
29 // be queried via surfaceOccluded() and surfaceUnoccludedContentRect(). Finally, | 29 // be queried via surfaceOccluded() and surfaceUnoccludedContentRect(). Finally, |
30 // once finished with the layer, occlusion behind the layer should be marked by | 30 // once finished with the layer, occlusion behind the layer should be marked by |
31 // calling MarkOccludedBehindLayer(). | 31 // calling MarkOccludedBehindLayer(). |
32 template <typename LayerType, typename RenderSurfaceType> | 32 template <typename LayerType, typename RenderSurfaceType> |
33 class CC_EXPORT OcclusionTrackerBase { | 33 class CC_EXPORT OcclusionTrackerBase { |
34 public: | 34 public: |
35 OcclusionTrackerBase(gfx::Rect screen_space_clip_rect, | 35 explicit OcclusionTrackerBase(bool record_metrics_for_frame); |
36 bool record_metrics_for_frame); | |
37 ~OcclusionTrackerBase(); | 36 ~OcclusionTrackerBase(); |
38 | 37 |
39 // Called at the beginning of each step in the LayerIterator's front-to-back | 38 // Called at the beginning of each step in the LayerIterator's front-to-back |
40 // traversal. If |prevent_occlusion| is true, the layer will be considered | 39 // traversal. If |prevent_occlusion| is true, the layer will be considered |
41 // unoccluded. | 40 // unoccluded. |
42 void EnterLayer(const LayerIteratorPosition<LayerType>& layer_iterator, | 41 void EnterLayer(const LayerIteratorPosition<LayerType>& layer_iterator, |
43 bool prevent_occlusion); | 42 bool prevent_occlusion); |
44 // Called at the end of each step in the LayerIterator's front-to-back | 43 // Called at the end of each step in the LayerIterator's front-to-back |
45 // traversal. | 44 // traversal. |
46 void LeaveLayer(const LayerIteratorPosition<LayerType>& layer_iterator); | 45 void LeaveLayer(const LayerIteratorPosition<LayerType>& layer_iterator); |
47 | 46 |
48 // Returns true if the given rect in content space for a layer is fully | 47 // Returns true if the given rect in content space for a layer is fully |
49 // occluded in either screen space or the layer's target surface. | 48 // occluded in either screen space or the layer's target surface. |
50 // |render_target| is the contributing layer's render target, and | 49 // |render_target| is the contributing layer's render target, and |
51 // |draw_transform|, |transformsToTargetKnown| and |clippedRectInTarget| are | 50 // |draw_transform| is relative to that. |
danakj
2013/09/16 17:29:08
draw_transform and impl_draw_transform_is_unknown
alokp
2013/09/17 00:31:41
Done.
| |
52 // relative to that. | |
53 bool Occluded(const LayerType* render_target, | 51 bool Occluded(const LayerType* render_target, |
54 gfx::Rect content_rect, | 52 gfx::Rect content_rect, |
55 const gfx::Transform& draw_transform, | 53 const gfx::Transform& draw_transform, |
56 bool impl_draw_transform_is_unknown, | 54 bool impl_draw_transform_is_unknown, |
57 bool is_clipped, | |
58 gfx::Rect clip_rect_in_target, | |
59 bool* has_occlusion_from_outside_target_surface) const; | 55 bool* has_occlusion_from_outside_target_surface) const; |
60 | 56 |
61 // Gives an unoccluded sub-rect of |content_rect| in the content space of a | 57 // Gives an unoccluded sub-rect of |content_rect| in the content space of a |
62 // layer. Used when considering occlusion for a layer that paints/draws | 58 // layer. Used when considering occlusion for a layer that paints/draws |
63 // something. |render_target| is the contributing layer's render target, and | 59 // something. |render_target| is the contributing layer's render target, and |
64 // |draw_transform|, |transformsToTargetKnown| and |clippedRectInTarget| are | 60 // |draw_transform| is relative to that. |
danakj
2013/09/16 17:29:08
draw_transform and impl_draw_transform_is_unknown
alokp
2013/09/17 00:31:41
Done.
| |
65 // relative to that. | |
66 gfx::Rect UnoccludedContentRect( | 61 gfx::Rect UnoccludedContentRect( |
67 const LayerType* render_target, | 62 const LayerType* render_target, |
68 gfx::Rect content_rect, | 63 gfx::Rect content_rect, |
69 const gfx::Transform& draw_transform, | 64 const gfx::Transform& draw_transform, |
70 bool impl_draw_transform_is_unknown, | 65 bool impl_draw_transform_is_unknown, |
71 bool is_clipped, | |
72 gfx::Rect clip_rect_in_target, | |
73 bool* has_occlusion_from_outside_target_surface) const; | 66 bool* has_occlusion_from_outside_target_surface) const; |
74 | 67 |
75 // Gives an unoccluded sub-rect of |content_rect| in the content space of the | 68 // Gives an unoccluded sub-rect of |content_rect| in the content space of the |
76 // render_target owned by the layer. Used when considering occlusion for a | 69 // render_target owned by the layer. Used when considering occlusion for a |
77 // contributing surface that is rendering into another target. | 70 // contributing surface that is rendering into another target. |
78 gfx::Rect UnoccludedContributingSurfaceContentRect( | 71 gfx::Rect UnoccludedContributingSurfaceContentRect( |
79 const LayerType* layer, | 72 const LayerType* layer, |
80 bool for_replica, | 73 bool for_replica, |
81 gfx::Rect content_rect, | 74 gfx::Rect content_rect, |
82 bool* has_occlusion_from_outside_target_surface) const; | 75 bool* has_occlusion_from_outside_target_surface) const; |
83 | 76 |
84 // Report operations for recording overdraw metrics. | 77 // Report operations for recording overdraw metrics. |
85 OverdrawMetrics* overdraw_metrics() const { | 78 OverdrawMetrics* overdraw_metrics() const { |
86 return overdraw_metrics_.get(); | 79 return overdraw_metrics_.get(); |
87 } | 80 } |
88 | 81 |
89 // Gives the region of the screen that is not occluded by something opaque. | 82 // Gives the region of the screen that is not occluded by something opaque. |
90 Region ComputeVisibleRegionInScreen() const { | 83 Region ComputeVisibleRegionInScreen(gfx::Rect screen_space_clip_rect) const { |
91 DCHECK(!stack_.back().target->parent()); | 84 DCHECK(!stack_.back().target->parent()); |
92 return SubtractRegions(screen_space_clip_rect_, | 85 return SubtractRegions(screen_space_clip_rect, |
93 stack_.back().occlusion_from_inside_target); | 86 stack_.back().occlusion_from_inside_target); |
94 } | 87 } |
95 | 88 |
96 void set_minimum_tracking_size(gfx::Size size) { | 89 void set_minimum_tracking_size(gfx::Size size) { |
97 minimum_tracking_size_ = size; | 90 minimum_tracking_size_ = size; |
98 } | 91 } |
99 | 92 |
100 // The following is used for visualization purposes. | 93 // The following is used for visualization purposes. |
101 void set_occluding_screen_space_rects_container( | 94 void set_occluding_screen_space_rects_container( |
102 std::vector<gfx::Rect>* rects) { | 95 std::vector<gfx::Rect>* rects) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 | 138 |
146 // Called when visiting a layer representing a contributing surface. This | 139 // Called when visiting a layer representing a contributing surface. This |
147 // indicates that we are leaving our current surface, and entering the new | 140 // indicates that we are leaving our current surface, and entering the new |
148 // one. We then perform any operations required for merging results from the | 141 // one. We then perform any operations required for merging results from the |
149 // child subtree into its parent. | 142 // child subtree into its parent. |
150 void LeaveToRenderTarget(const LayerType* new_target); | 143 void LeaveToRenderTarget(const LayerType* new_target); |
151 | 144 |
152 // Add the layer's occlusion to the tracked state. | 145 // Add the layer's occlusion to the tracked state. |
153 void MarkOccludedBehindLayer(const LayerType* layer); | 146 void MarkOccludedBehindLayer(const LayerType* layer); |
154 | 147 |
155 gfx::Rect screen_space_clip_rect_; | |
156 scoped_ptr<class OverdrawMetrics> overdraw_metrics_; | 148 scoped_ptr<class OverdrawMetrics> overdraw_metrics_; |
157 gfx::Size minimum_tracking_size_; | 149 gfx::Size minimum_tracking_size_; |
158 bool prevent_occlusion_; | 150 bool prevent_occlusion_; |
159 | 151 |
160 // This is used for visualizing the occlusion tracking process. | 152 // This is used for visualizing the occlusion tracking process. |
161 std::vector<gfx::Rect>* occluding_screen_space_rects_; | 153 std::vector<gfx::Rect>* occluding_screen_space_rects_; |
162 std::vector<gfx::Rect>* non_occluding_screen_space_rects_; | 154 std::vector<gfx::Rect>* non_occluding_screen_space_rects_; |
163 | 155 |
164 DISALLOW_COPY_AND_ASSIGN(OcclusionTrackerBase); | 156 DISALLOW_COPY_AND_ASSIGN(OcclusionTrackerBase); |
165 }; | 157 }; |
166 | 158 |
167 typedef OcclusionTrackerBase<Layer, RenderSurface> OcclusionTracker; | 159 typedef OcclusionTrackerBase<Layer, RenderSurface> OcclusionTracker; |
168 typedef OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> OcclusionTrackerImpl; | 160 typedef OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> OcclusionTrackerImpl; |
169 #if !defined(COMPILER_MSVC) | 161 #if !defined(COMPILER_MSVC) |
170 extern template class OcclusionTrackerBase<Layer, RenderSurface>; | 162 extern template class OcclusionTrackerBase<Layer, RenderSurface>; |
171 extern template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; | 163 extern template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; |
172 #endif | 164 #endif |
173 | 165 |
174 } // namespace cc | 166 } // namespace cc |
175 | 167 |
176 #endif // CC_TREES_OCCLUSION_TRACKER_H_ | 168 #endif // CC_TREES_OCCLUSION_TRACKER_H_ |
OLD | NEW |