| 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 22 matching lines...) Expand all Loading... |
| 33 template <typename LayerType> | 33 template <typename LayerType> |
| 34 class CC_EXPORT OcclusionTracker { | 34 class CC_EXPORT OcclusionTracker { |
| 35 public: | 35 public: |
| 36 explicit OcclusionTracker(const gfx::Rect& screen_space_clip_rect); | 36 explicit OcclusionTracker(const gfx::Rect& screen_space_clip_rect); |
| 37 ~OcclusionTracker(); | 37 ~OcclusionTracker(); |
| 38 | 38 |
| 39 // Return an occlusion that retains the current state of the tracker | 39 // Return an occlusion that retains the current state of the tracker |
| 40 // and can be used outside of a layer walk to check occlusion. | 40 // and can be used outside of a layer walk to check occlusion. |
| 41 Occlusion GetCurrentOcclusionForLayer( | 41 Occlusion GetCurrentOcclusionForLayer( |
| 42 const gfx::Transform& draw_transform) const; | 42 const gfx::Transform& draw_transform) const; |
| 43 Occlusion GetCurrentOcclusionForContributingSurface( |
| 44 const gfx::Transform& draw_transform) const; |
| 43 | 45 |
| 44 // Called at the beginning of each step in the LayerIterator's front-to-back | 46 // Called at the beginning of each step in the LayerIterator's front-to-back |
| 45 // traversal. | 47 // traversal. |
| 46 void EnterLayer(const LayerIteratorPosition<LayerType>& layer_iterator); | 48 void EnterLayer(const LayerIteratorPosition<LayerType>& layer_iterator); |
| 47 // Called at the end of each step in the LayerIterator's front-to-back | 49 // Called at the end of each step in the LayerIterator's front-to-back |
| 48 // traversal. | 50 // traversal. |
| 49 void LeaveLayer(const LayerIteratorPosition<LayerType>& layer_iterator); | 51 void LeaveLayer(const LayerIteratorPosition<LayerType>& layer_iterator); |
| 50 | 52 |
| 51 // Gives an unoccluded sub-rect of |content_rect| in the content space of the | |
| 52 // render_target owned by the layer. Used when considering occlusion for a | |
| 53 // contributing surface that is rendering into another target. | |
| 54 gfx::Rect UnoccludedContributingSurfaceContentRect( | |
| 55 const gfx::Rect& content_rect, | |
| 56 const gfx::Transform& draw_transform) const; | |
| 57 | |
| 58 // Gives the region of the screen that is not occluded by something opaque. | 53 // Gives the region of the screen that is not occluded by something opaque. |
| 59 Region ComputeVisibleRegionInScreen() const; | 54 Region ComputeVisibleRegionInScreen() const; |
| 60 | 55 |
| 61 void set_minimum_tracking_size(const gfx::Size& size) { | 56 void set_minimum_tracking_size(const gfx::Size& size) { |
| 62 minimum_tracking_size_ = size; | 57 minimum_tracking_size_ = size; |
| 63 } | 58 } |
| 64 | 59 |
| 65 // The following is used for visualization purposes. | |
| 66 void set_occluding_screen_space_rects_container( | |
| 67 std::vector<gfx::Rect>* rects) { | |
| 68 occluding_screen_space_rects_ = rects; | |
| 69 } | |
| 70 void set_non_occluding_screen_space_rects_container( | |
| 71 std::vector<gfx::Rect>* rects) { | |
| 72 non_occluding_screen_space_rects_ = rects; | |
| 73 } | |
| 74 | |
| 75 protected: | 60 protected: |
| 76 struct StackObject { | 61 struct StackObject { |
| 77 StackObject() : target(0) {} | 62 StackObject() : target(0) {} |
| 78 explicit StackObject(const LayerType* target) : target(target) {} | 63 explicit StackObject(const LayerType* target) : target(target) {} |
| 79 const LayerType* target; | 64 const LayerType* target; |
| 80 SimpleEnclosedRegion occlusion_from_outside_target; | 65 SimpleEnclosedRegion occlusion_from_outside_target; |
| 81 SimpleEnclosedRegion occlusion_from_inside_target; | 66 SimpleEnclosedRegion occlusion_from_inside_target; |
| 82 }; | 67 }; |
| 83 | 68 |
| 84 // The stack holds occluded regions for subtrees in the | 69 // The stack holds occluded regions for subtrees in the |
| (...skipping 28 matching lines...) Expand all Loading... |
| 113 // one. We then perform any operations required for merging results from the | 98 // one. We then perform any operations required for merging results from the |
| 114 // child subtree into its parent. | 99 // child subtree into its parent. |
| 115 void LeaveToRenderTarget(const LayerType* new_target); | 100 void LeaveToRenderTarget(const LayerType* new_target); |
| 116 | 101 |
| 117 // Add the layer's occlusion to the tracked state. | 102 // Add the layer's occlusion to the tracked state. |
| 118 void MarkOccludedBehindLayer(const LayerType* layer); | 103 void MarkOccludedBehindLayer(const LayerType* layer); |
| 119 | 104 |
| 120 gfx::Rect screen_space_clip_rect_; | 105 gfx::Rect screen_space_clip_rect_; |
| 121 gfx::Size minimum_tracking_size_; | 106 gfx::Size minimum_tracking_size_; |
| 122 | 107 |
| 123 // This is used for visualizing the occlusion tracking process. | |
| 124 std::vector<gfx::Rect>* occluding_screen_space_rects_; | |
| 125 std::vector<gfx::Rect>* non_occluding_screen_space_rects_; | |
| 126 | |
| 127 DISALLOW_COPY_AND_ASSIGN(OcclusionTracker); | 108 DISALLOW_COPY_AND_ASSIGN(OcclusionTracker); |
| 128 }; | 109 }; |
| 129 | 110 |
| 130 #if !defined(COMPILER_MSVC) | 111 #if !defined(COMPILER_MSVC) |
| 131 extern template class OcclusionTracker<Layer>; | 112 extern template class OcclusionTracker<Layer>; |
| 132 extern template class OcclusionTracker<LayerImpl>; | 113 extern template class OcclusionTracker<LayerImpl>; |
| 133 #endif | 114 #endif |
| 134 | 115 |
| 135 } // namespace cc | 116 } // namespace cc |
| 136 | 117 |
| 137 #endif // CC_TREES_OCCLUSION_TRACKER_H_ | 118 #endif // CC_TREES_OCCLUSION_TRACKER_H_ |
| OLD | NEW |