Chromium Code Reviews| 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/simple_enclosed_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 "cc/trees/occlusion_checker.h" | |
| 14 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 class LayerImpl; | 18 class LayerImpl; |
| 18 class Region; | 19 class Region; |
| 19 class RenderSurfaceImpl; | 20 class RenderSurfaceImpl; |
| 20 class Layer; | 21 class Layer; |
| 21 class RenderSurface; | 22 class RenderSurface; |
| 22 | 23 |
| 23 // This class is used to track occlusion of layers while traversing them in a | 24 // This class is used to track occlusion of layers while traversing them in a |
| 24 // front-to-back order. As each layer is visited, one of the methods in this | 25 // front-to-back order. As each layer is visited, one of the methods in this |
| 25 // class is called to notify it about the current target surface. Then, | 26 // 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 | 27 // occlusion in the content space of the current layer may be queried, via |
| 27 // methods such as Occluded() and UnoccludedContentRect(). If the current layer | 28 // methods such as Occluded() and UnoccludedContentRect(). If the current layer |
| 28 // owns a RenderSurfaceImpl, then occlusion on that RenderSurfaceImpl may also | 29 // owns a RenderSurfaceImpl, then occlusion on that RenderSurfaceImpl may also |
| 29 // be queried via surfaceOccluded() and surfaceUnoccludedContentRect(). Finally, | 30 // be queried via surfaceOccluded() and surfaceUnoccludedContentRect(). Finally, |
| 30 // once finished with the layer, occlusion behind the layer should be marked by | 31 // once finished with the layer, occlusion behind the layer should be marked by |
| 31 // calling MarkOccludedBehindLayer(). | 32 // calling MarkOccludedBehindLayer(). |
| 32 template <typename LayerType> | 33 template <typename LayerType> |
| 33 class CC_EXPORT OcclusionTracker { | 34 class CC_EXPORT OcclusionTracker { |
| 34 public: | 35 public: |
| 35 explicit OcclusionTracker(const gfx::Rect& screen_space_clip_rect); | 36 explicit OcclusionTracker(const gfx::Rect& screen_space_clip_rect); |
| 36 ~OcclusionTracker(); | 37 ~OcclusionTracker(); |
| 37 | 38 |
| 39 // Return an occlusion checker that retains the current state of the tracker | |
| 40 // and can be used outside of a layer walk to check occlusion. | |
| 41 OcclusionChecker<LayerType> GenerateOcclusionChecker( | |
|
danakj
2014/09/09 15:14:39
nit: GetCurrentOcclusionForLayer()? Or GetOcclusio
vmpstr
2014/09/09 21:56:57
Changed to GetCurrentOcclusionForLayer
| |
| 42 const gfx::Transform& draw_transform) const; | |
| 43 | |
| 38 // Called at the beginning of each step in the LayerIterator's front-to-back | 44 // Called at the beginning of each step in the LayerIterator's front-to-back |
| 39 // traversal. | 45 // traversal. |
| 40 void EnterLayer(const LayerIteratorPosition<LayerType>& layer_iterator); | 46 void EnterLayer(const LayerIteratorPosition<LayerType>& layer_iterator); |
| 41 // Called at the end of each step in the LayerIterator's front-to-back | 47 // Called at the end of each step in the LayerIterator's front-to-back |
| 42 // traversal. | 48 // traversal. |
| 43 void LeaveLayer(const LayerIteratorPosition<LayerType>& layer_iterator); | 49 void LeaveLayer(const LayerIteratorPosition<LayerType>& layer_iterator); |
| 44 | 50 |
| 45 // Returns true if the given rect in content space for a layer is fully | 51 // Returns true if the given rect in content space for a layer is fully |
| 46 // occluded in either screen space or the layer's target surface. | 52 // occluded in either screen space or the layer's target surface. |
| 47 // |render_target| is the contributing layer's render target, and | 53 // |render_target| is the contributing layer's render target, and |
| 48 // |draw_transform| and |impl_draw_transform_is_unknown| are relative to that. | 54 // |draw_transform| and |impl_draw_transform_is_unknown| are relative to that. |
| 49 bool Occluded(const LayerType* render_target, | 55 bool Occluded(const LayerType* render_target, |
|
danakj
2014/09/09 15:14:39
Will followups work on removing these query method
vmpstr
2014/09/09 21:56:56
Yes. I want to move to using Occlusion as early as
| |
| 50 const gfx::Rect& content_rect, | 56 const gfx::Rect& content_rect, |
| 51 const gfx::Transform& draw_transform) const; | 57 const gfx::Transform& draw_transform) const; |
| 52 | 58 |
| 53 // Gives an unoccluded sub-rect of |content_rect| in the content space of a | 59 // Gives an unoccluded sub-rect of |content_rect| in the content space of a |
| 54 // layer. Used when considering occlusion for a layer that paints/draws | 60 // layer. Used when considering occlusion for a layer that paints/draws |
| 55 // something. |render_target| is the contributing layer's render target, and | 61 // something. |render_target| is the contributing layer's render target, and |
| 56 // |draw_transform| and |impl_draw_transform_is_unknown| are relative to that. | 62 // |draw_transform| and |impl_draw_transform_is_unknown| are relative to that. |
| 57 gfx::Rect UnoccludedContentRect(const gfx::Rect& content_rect, | 63 gfx::Rect UnoccludedContentRect(const gfx::Rect& content_rect, |
| 58 const gfx::Transform& draw_transform) const; | 64 const gfx::Transform& draw_transform) const; |
| 59 | 65 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 }; | 143 }; |
| 138 | 144 |
| 139 #if !defined(COMPILER_MSVC) | 145 #if !defined(COMPILER_MSVC) |
| 140 extern template class OcclusionTracker<Layer>; | 146 extern template class OcclusionTracker<Layer>; |
| 141 extern template class OcclusionTracker<LayerImpl>; | 147 extern template class OcclusionTracker<LayerImpl>; |
| 142 #endif | 148 #endif |
| 143 | 149 |
| 144 } // namespace cc | 150 } // namespace cc |
| 145 | 151 |
| 146 #endif // CC_TREES_OCCLUSION_TRACKER_H_ | 152 #endif // CC_TREES_OCCLUSION_TRACKER_H_ |
| OLD | NEW |