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_OCCLUSION_TRACKER_H_ | 5 #ifndef CC_OCCLUSION_TRACKER_H_ |
6 #define CC_OCCLUSION_TRACKER_H_ | 6 #define CC_OCCLUSION_TRACKER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "cc/cc_export.h" | 9 #include "cc/cc_export.h" |
10 #include "cc/layer_iterator.h" | 10 #include "cc/layer_iterator.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 public: | 28 public: |
29 OcclusionTrackerBase(gfx::Rect screenSpaceClipRect, bool recordMetricsForFra
me); | 29 OcclusionTrackerBase(gfx::Rect screenSpaceClipRect, bool recordMetricsForFra
me); |
30 ~OcclusionTrackerBase(); | 30 ~OcclusionTrackerBase(); |
31 | 31 |
32 // Called at the beginning of each step in the LayerIterator's front-to-back
traversal. | 32 // Called at the beginning of each step in the LayerIterator's front-to-back
traversal. |
33 void enterLayer(const LayerIteratorPosition<LayerType>&); | 33 void enterLayer(const LayerIteratorPosition<LayerType>&); |
34 // Called at the end of each step in the LayerIterator's front-to-back trave
rsal. | 34 // Called at the end of each step in the LayerIterator's front-to-back trave
rsal. |
35 void leaveLayer(const LayerIteratorPosition<LayerType>&); | 35 void leaveLayer(const LayerIteratorPosition<LayerType>&); |
36 | 36 |
37 // Returns true if the given rect in content space for a layer is fully occl
uded in either screen space or the layer's target surface. |renderTarget| is th
e contributing layer's render target, and |drawTransform|, |transformsToTargetKn
own| and |clippedRectInTarget| are relative to that. | 37 // Returns true if the given rect in content space for a layer is fully occl
uded in either screen space or the layer's target surface. |renderTarget| is th
e contributing layer's render target, and |drawTransform|, |transformsToTargetKn
own| and |clippedRectInTarget| are relative to that. |
38 bool occluded(const LayerType* renderTarget, const gfx::Rect& contentRect, c
onst gfx::Transform& drawTransform, bool implDrawTransformIsUnknown, const gfx::
Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) const
; | 38 bool occluded(const LayerType* renderTarget, gfx::Rect contentRect, const gf
x::Transform& drawTransform, bool implDrawTransformIsUnknown, bool isClipped, gf
x::Rect clipRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) const; |
39 // Gives an unoccluded sub-rect of |contentRect| in the content space of a l
ayer. Used when considering occlusion for a layer that paints/draws something. |
renderTarget| is the contributing layer's render target, and |drawTransform|, |t
ransformsToTargetKnown| and |clippedRectInTarget| are relative to that. | 39 // Gives an unoccluded sub-rect of |contentRect| in the content space of a l
ayer. Used when considering occlusion for a layer that paints/draws something. |
renderTarget| is the contributing layer's render target, and |drawTransform|, |t
ransformsToTargetKnown| and |clippedRectInTarget| are relative to that. |
40 gfx::Rect unoccludedContentRect(const LayerType* renderTarget, const gfx::Re
ct& contentRect, const gfx::Transform& drawTransform, bool implDrawTransformIsUn
known, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTarget
Surface = 0) const; | 40 gfx::Rect unoccludedContentRect(const LayerType* renderTarget, gfx::Rect con
tentRect, const gfx::Transform& drawTransform, bool implDrawTransformIsUnknown,
bool isClipped, gfx::Rect clipRectInTarget, bool* hasOcclusionFromOutsideTargetS
urface = 0) const; |
41 | 41 |
42 // Gives an unoccluded sub-rect of |contentRect| in the content space of the
renderTarget owned by the layer. | 42 // Gives an unoccluded sub-rect of |contentRect| in the content space of the
renderTarget owned by the layer. |
43 // Used when considering occlusion for a contributing surface that is render
ing into another target. | 43 // Used when considering occlusion for a contributing surface that is render
ing into another target. |
44 gfx::Rect unoccludedContributingSurfaceContentRect(const LayerType*, bool fo
rReplica, const gfx::Rect& contentRect, bool* hasOcclusionFromOutsideTargetSurfa
ce = 0) const; | 44 gfx::Rect unoccludedContributingSurfaceContentRect(const LayerType*, bool fo
rReplica, const gfx::Rect& contentRect, bool* hasOcclusionFromOutsideTargetSurfa
ce = 0) const; |
45 | 45 |
46 // Report operations for recording overdraw metrics. | 46 // Report operations for recording overdraw metrics. |
47 OverdrawMetrics& overdrawMetrics() const { return *m_overdrawMetrics.get();
} | 47 OverdrawMetrics& overdrawMetrics() const { return *m_overdrawMetrics.get();
} |
48 | 48 |
49 // Gives the region of the screen that is not occluded by something opaque. | 49 // Gives the region of the screen that is not occluded by something opaque. |
50 Region computeVisibleRegionInScreen() const { | 50 Region computeVisibleRegionInScreen() const { |
(...skipping 18 matching lines...) Expand all Loading... |
69 | 69 |
70 // The stack holds occluded regions for subtrees in the RenderSurfaceImpl-La
yer tree, so that when we leave a subtree we may | 70 // The stack holds occluded regions for subtrees in the RenderSurfaceImpl-La
yer tree, so that when we leave a subtree we may |
71 // apply a mask to it, but not to the parts outside the subtree. | 71 // apply a mask to it, but not to the parts outside the subtree. |
72 // - The first time we see a new subtree under a target, we add that target
to the top of the stack. This can happen as a layer representing itself, or as a
target surface. | 72 // - The first time we see a new subtree under a target, we add that target
to the top of the stack. This can happen as a layer representing itself, or as a
target surface. |
73 // - When we visit a target surface, we apply its mask to its subtree, which
is at the top of the stack. | 73 // - When we visit a target surface, we apply its mask to its subtree, which
is at the top of the stack. |
74 // - When we visit a layer representing itself, we add its occlusion to the
current subtree, which is at the top of the stack. | 74 // - When we visit a layer representing itself, we add its occlusion to the
current subtree, which is at the top of the stack. |
75 // - When we visit a layer representing a contributing surface, the current
target will never be the top of the stack since we just came from the contributi
ng surface. | 75 // - When we visit a layer representing a contributing surface, the current
target will never be the top of the stack since we just came from the contributi
ng surface. |
76 // We merge the occlusion at the top of the stack with the new current subtr
ee. This new target is pushed onto the stack if not already there. | 76 // We merge the occlusion at the top of the stack with the new current subtr
ee. This new target is pushed onto the stack if not already there. |
77 std::vector<StackObject> m_stack; | 77 std::vector<StackObject> m_stack; |
78 | 78 |
79 // Allow tests to override this. | |
80 virtual gfx::Rect layerClipRectInTarget(const LayerType*) const; | |
81 | |
82 private: | 79 private: |
83 // Called when visiting a layer representing itself. If the target was not a
lready current, then this indicates we have entered a new surface subtree. | 80 // Called when visiting a layer representing itself. If the target was not a
lready current, then this indicates we have entered a new surface subtree. |
84 void enterRenderTarget(const LayerType* newTarget); | 81 void enterRenderTarget(const LayerType* newTarget); |
85 | 82 |
86 // Called when visiting a layer representing a target surface. This indicate
s we have visited all the layers within the surface, and we may | 83 // Called when visiting a layer representing a target surface. This indicate
s we have visited all the layers within the surface, and we may |
87 // perform any surface-wide operations. | 84 // perform any surface-wide operations. |
88 void finishedRenderTarget(const LayerType* finishedTarget); | 85 void finishedRenderTarget(const LayerType* finishedTarget); |
89 | 86 |
90 // Called when visiting a layer representing a contributing surface. This in
dicates that we are leaving our current surface, and | 87 // Called when visiting a layer representing a contributing surface. This in
dicates that we are leaving our current surface, and |
91 // entering the new one. We then perform any operations required for merging
results from the child subtree into its parent. | 88 // entering the new one. We then perform any operations required for merging
results from the child subtree into its parent. |
(...skipping 16 matching lines...) Expand all Loading... |
108 typedef OcclusionTrackerBase<Layer, RenderSurface> OcclusionTracker; | 105 typedef OcclusionTrackerBase<Layer, RenderSurface> OcclusionTracker; |
109 typedef OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> OcclusionTrackerImpl; | 106 typedef OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> OcclusionTrackerImpl; |
110 #if !defined(COMPILER_MSVC) | 107 #if !defined(COMPILER_MSVC) |
111 extern template class OcclusionTrackerBase<Layer, RenderSurface>; | 108 extern template class OcclusionTrackerBase<Layer, RenderSurface>; |
112 extern template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; | 109 extern template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; |
113 #endif | 110 #endif |
114 | 111 |
115 } // namespace cc | 112 } // namespace cc |
116 | 113 |
117 #endif // CC_OCCLUSION_TRACKER_H_ | 114 #endif // CC_OCCLUSION_TRACKER_H_ |
OLD | NEW |