| 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" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "cc/base/region.h" | 12 #include "cc/base/simple_enclosed_region.h" |
| 13 #include "cc/layers/layer_iterator.h" | 13 #include "cc/layers/layer_iterator.h" |
| 14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 class LayerImpl; | 17 class LayerImpl; |
| 18 class Region; |
| 18 class RenderSurfaceImpl; | 19 class RenderSurfaceImpl; |
| 19 class Layer; | 20 class Layer; |
| 20 class RenderSurface; | 21 class RenderSurface; |
| 21 | 22 |
| 22 // This class is used to track occlusion of layers while traversing them in a | 23 // 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 | 24 // front-to-back order. As each layer is visited, one of the methods in this |
| 24 // 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, |
| 25 // 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 |
| 26 // methods such as Occluded() and UnoccludedContentRect(). If the current layer | 27 // methods such as Occluded() and UnoccludedContentRect(). If the current layer |
| 27 // owns a RenderSurfaceImpl, then occlusion on that RenderSurfaceImpl may also | 28 // owns a RenderSurfaceImpl, then occlusion on that RenderSurfaceImpl may also |
| (...skipping 29 matching lines...) Expand all Loading... |
| 57 const gfx::Transform& draw_transform) const; | 58 const gfx::Transform& draw_transform) const; |
| 58 | 59 |
| 59 // Gives an unoccluded sub-rect of |content_rect| in the content space of the | 60 // Gives an unoccluded sub-rect of |content_rect| in the content space of the |
| 60 // render_target owned by the layer. Used when considering occlusion for a | 61 // render_target owned by the layer. Used when considering occlusion for a |
| 61 // contributing surface that is rendering into another target. | 62 // contributing surface that is rendering into another target. |
| 62 gfx::Rect UnoccludedContributingSurfaceContentRect( | 63 gfx::Rect UnoccludedContributingSurfaceContentRect( |
| 63 const gfx::Rect& content_rect, | 64 const gfx::Rect& content_rect, |
| 64 const gfx::Transform& draw_transform) const; | 65 const gfx::Transform& draw_transform) const; |
| 65 | 66 |
| 66 // Gives the region of the screen that is not occluded by something opaque. | 67 // Gives the region of the screen that is not occluded by something opaque. |
| 67 Region ComputeVisibleRegionInScreen() const { | 68 Region ComputeVisibleRegionInScreen() const; |
| 68 DCHECK(!stack_.back().target->parent()); | |
| 69 return SubtractRegions(screen_space_clip_rect_, | |
| 70 stack_.back().occlusion_from_inside_target); | |
| 71 } | |
| 72 | 69 |
| 73 void set_minimum_tracking_size(const gfx::Size& size) { | 70 void set_minimum_tracking_size(const gfx::Size& size) { |
| 74 minimum_tracking_size_ = size; | 71 minimum_tracking_size_ = size; |
| 75 } | 72 } |
| 76 | 73 |
| 77 // The following is used for visualization purposes. | 74 // The following is used for visualization purposes. |
| 78 void set_occluding_screen_space_rects_container( | 75 void set_occluding_screen_space_rects_container( |
| 79 std::vector<gfx::Rect>* rects) { | 76 std::vector<gfx::Rect>* rects) { |
| 80 occluding_screen_space_rects_ = rects; | 77 occluding_screen_space_rects_ = rects; |
| 81 } | 78 } |
| 82 void set_non_occluding_screen_space_rects_container( | 79 void set_non_occluding_screen_space_rects_container( |
| 83 std::vector<gfx::Rect>* rects) { | 80 std::vector<gfx::Rect>* rects) { |
| 84 non_occluding_screen_space_rects_ = rects; | 81 non_occluding_screen_space_rects_ = rects; |
| 85 } | 82 } |
| 86 | 83 |
| 87 protected: | 84 protected: |
| 88 struct StackObject { | 85 struct StackObject { |
| 89 StackObject() : target(0) {} | 86 StackObject() : target(0) {} |
| 90 explicit StackObject(const LayerType* target) : target(target) {} | 87 explicit StackObject(const LayerType* target) : target(target) {} |
| 91 const LayerType* target; | 88 const LayerType* target; |
| 92 Region occlusion_from_outside_target; | 89 SimpleEnclosedRegion occlusion_from_outside_target; |
| 93 Region occlusion_from_inside_target; | 90 SimpleEnclosedRegion occlusion_from_inside_target; |
| 94 }; | 91 }; |
| 95 | 92 |
| 96 // The stack holds occluded regions for subtrees in the | 93 // The stack holds occluded regions for subtrees in the |
| 97 // RenderSurfaceImpl-Layer tree, so that when we leave a subtree we may apply | 94 // RenderSurfaceImpl-Layer tree, so that when we leave a subtree we may apply |
| 98 // a mask to it, but not to the parts outside the subtree. | 95 // a mask to it, but not to the parts outside the subtree. |
| 99 // - The first time we see a new subtree under a target, we add that target to | 96 // - The first time we see a new subtree under a target, we add that target to |
| 100 // the top of the stack. This can happen as a layer representing itself, or as | 97 // the top of the stack. This can happen as a layer representing itself, or as |
| 101 // a target surface. | 98 // a target surface. |
| 102 // - When we visit a target surface, we apply its mask to its subtree, which | 99 // - When we visit a target surface, we apply its mask to its subtree, which |
| 103 // is at the top of the stack. | 100 // is at the top of the stack. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 }; | 137 }; |
| 141 | 138 |
| 142 #if !defined(COMPILER_MSVC) | 139 #if !defined(COMPILER_MSVC) |
| 143 extern template class OcclusionTracker<Layer>; | 140 extern template class OcclusionTracker<Layer>; |
| 144 extern template class OcclusionTracker<LayerImpl>; | 141 extern template class OcclusionTracker<LayerImpl>; |
| 145 #endif | 142 #endif |
| 146 | 143 |
| 147 } // namespace cc | 144 } // namespace cc |
| 148 | 145 |
| 149 #endif // CC_TREES_OCCLUSION_TRACKER_H_ | 146 #endif // CC_TREES_OCCLUSION_TRACKER_H_ |
| OLD | NEW |