Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: cc/occlusion_tracker.h

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CCOcclusionTracker_h 5 #ifndef CCOcclusionTracker_h
6 #define CCOcclusionTracker_h 6 #define CCOcclusionTracker_h
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "CCLayerIterator.h" 9 #include "CCLayerIterator.h"
10 #include "FloatQuad.h" 10 #include "FloatQuad.h"
11 #include "Region.h" 11 #include "Region.h"
12 12
13 namespace cc { 13 namespace cc {
14 class CCOverdrawMetrics; 14 class OverdrawMetrics;
15 class CCLayerImpl; 15 class LayerImpl;
16 class CCRenderSurface; 16 class RenderSurfaceImpl;
17 class LayerChromium; 17 class Layer;
18 class RenderSurfaceChromium; 18 class RenderSurface;
19 19
20 // This class is used to track occlusion of layers while traversing them in a fr ont-to-back order. As each layer is visited, one of the 20 // This class is used to track occlusion of layers while traversing them in a fr ont-to-back order. As each layer is visited, one of the
21 // methods in this class is called to notify it about the current target surface . 21 // methods in this class is called to notify it about the current target surface .
22 // Then, occlusion in the content space of the current layer may be queried, via methods such as occluded() and unoccludedContentRect(). 22 // Then, occlusion in the content space of the current layer may be queried, via methods such as occluded() and unoccludedContentRect().
23 // If the current layer owns a RenderSurface, then occlusion on that RenderSurfa ce may also be queried via surfaceOccluded() and surfaceUnoccludedContentRect(). 23 // If the current layer owns a RenderSurfaceImpl, then occlusion on that RenderS urfaceImpl may also be queried via surfaceOccluded() and surfaceUnoccludedConten tRect().
24 // Finally, once finished with the layer, occlusion behind the layer should be m arked by calling markOccludedBehindLayer(). 24 // Finally, once finished with the layer, occlusion behind the layer should be m arked by calling markOccludedBehindLayer().
25 template<typename LayerType, typename RenderSurfaceType> 25 template<typename LayerType, typename RenderSurfaceType>
26 class CCOcclusionTrackerBase { 26 class OcclusionTrackerBase {
27 public: 27 public:
28 CCOcclusionTrackerBase(IntRect rootTargetRect, bool recordMetricsForFrame); 28 OcclusionTrackerBase(IntRect rootTargetRect, bool recordMetricsForFrame);
29 29
30 // Called at the beginning of each step in the CCLayerIterator's front-to-ba ck traversal. 30 // Called at the beginning of each step in the LayerIterator's front-to-back traversal.
31 void enterLayer(const CCLayerIteratorPosition<LayerType>&); 31 void enterLayer(const LayerIteratorPosition<LayerType>&);
32 // Called at the end of each step in the CCLayerIterator's front-to-back tra versal. 32 // Called at the end of each step in the LayerIterator's front-to-back trave rsal.
33 void leaveLayer(const CCLayerIteratorPosition<LayerType>&); 33 void leaveLayer(const LayerIteratorPosition<LayerType>&);
34 34
35 // Returns true if the given rect in content space for the layer is fully oc cluded in either screen space or the layer's target surface. 35 // Returns true if the given rect in content space for the layer is fully oc cluded in either screen space or the layer's target surface.
36 bool occluded(const LayerType*, const IntRect& contentRect, bool* hasOcclusi onFromOutsideTargetSurface = 0) const; 36 bool occluded(const LayerType*, const IntRect& contentRect, bool* hasOcclusi onFromOutsideTargetSurface = 0) const;
37 // Gives an unoccluded sub-rect of |contentRect| in the content space of the layer. Used when considering occlusion for a layer that paints/draws something. 37 // Gives an unoccluded sub-rect of |contentRect| in the content space of the layer. Used when considering occlusion for a layer that paints/draws something.
38 IntRect unoccludedContentRect(const LayerType*, const IntRect& contentRect, bool* hasOcclusionFromOutsideTargetSurface = 0) const; 38 IntRect unoccludedContentRect(const LayerType*, const IntRect& contentRect, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
39 39
40 // Gives an unoccluded sub-rect of |contentRect| in the content space of the renderTarget owned by the layer. 40 // Gives an unoccluded sub-rect of |contentRect| in the content space of the renderTarget owned by the layer.
41 // Used when considering occlusion for a contributing surface that is render ing into another target. 41 // Used when considering occlusion for a contributing surface that is render ing into another target.
42 IntRect unoccludedContributingSurfaceContentRect(const LayerType*, bool forR eplica, const IntRect& contentRect, bool* hasOcclusionFromOutsideTargetSurface = 0) const; 42 IntRect unoccludedContributingSurfaceContentRect(const LayerType*, bool forR eplica, const IntRect& contentRect, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
43 43
44 // Report operations for recording overdraw metrics. 44 // Report operations for recording overdraw metrics.
45 CCOverdrawMetrics& overdrawMetrics() const { return *m_overdrawMetrics.get() ; } 45 OverdrawMetrics& overdrawMetrics() const { return *m_overdrawMetrics.get(); }
46 46
47 // Gives the region of the screen that is not occluded by something opaque. 47 // Gives the region of the screen that is not occluded by something opaque.
48 Region computeVisibleRegionInScreen() const { return subtract(Region(m_rootT argetRect), m_stack.last().occlusionInScreen); } 48 Region computeVisibleRegionInScreen() const { return subtract(Region(m_rootT argetRect), m_stack.last().occlusionInScreen); }
49 49
50 void setMinimumTrackingSize(const IntSize& size) { m_minimumTrackingSize = s ize; } 50 void setMinimumTrackingSize(const IntSize& size) { m_minimumTrackingSize = s ize; }
51 51
52 // The following is used for visualization purposes. 52 // The following is used for visualization purposes.
53 void setOccludingScreenSpaceRectsContainer(Vector<IntRect>* rects) { m_occlu dingScreenSpaceRects = rects; } 53 void setOccludingScreenSpaceRectsContainer(Vector<IntRect>* rects) { m_occlu dingScreenSpaceRects = rects; }
54 54
55 protected: 55 protected:
56 struct StackObject { 56 struct StackObject {
57 StackObject() : target(0) { } 57 StackObject() : target(0) { }
58 StackObject(const LayerType* target) : target(target) { } 58 StackObject(const LayerType* target) : target(target) { }
59 const LayerType* target; 59 const LayerType* target;
60 Region occlusionInScreen; 60 Region occlusionInScreen;
61 Region occlusionInTarget; 61 Region occlusionInTarget;
62 }; 62 };
63 63
64 // The stack holds occluded regions for subtrees in the RenderSurface-Layer tree, so that when we leave a subtree we may 64 // The stack holds occluded regions for subtrees in the RenderSurfaceImpl-La yer tree, so that when we leave a subtree we may
65 // apply a mask to it, but not to the parts outside the subtree. 65 // apply a mask to it, but not to the parts outside the subtree.
66 // - 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. 66 // - 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.
67 // - When we visit a target surface, we apply its mask to its subtree, which is at the top of the stack. 67 // - When we visit a target surface, we apply its mask to its subtree, which is at the top of the stack.
68 // - When we visit a layer representing itself, we add its occlusion to the current subtree, which is at the top of the stack. 68 // - When we visit a layer representing itself, we add its occlusion to the current subtree, which is at the top of the stack.
69 // - 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. 69 // - 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.
70 // 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. 70 // 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.
71 Vector<StackObject, 1> m_stack; 71 Vector<StackObject, 1> m_stack;
72 72
73 // Allow tests to override this. 73 // Allow tests to override this.
74 virtual IntRect layerClipRectInTarget(const LayerType*) const; 74 virtual IntRect layerClipRectInTarget(const LayerType*) const;
75 75
76 private: 76 private:
77 // 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. 77 // 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.
78 void enterRenderTarget(const LayerType* newTarget); 78 void enterRenderTarget(const LayerType* newTarget);
79 79
80 // Called when visiting a layer representing a target surface. This indicate s we have visited all the layers within the surface, and we may 80 // Called when visiting a layer representing a target surface. This indicate s we have visited all the layers within the surface, and we may
81 // perform any surface-wide operations. 81 // perform any surface-wide operations.
82 void finishedRenderTarget(const LayerType* finishedTarget); 82 void finishedRenderTarget(const LayerType* finishedTarget);
83 83
84 // Called when visiting a layer representing a contributing surface. This in dicates that we are leaving our current surface, and 84 // Called when visiting a layer representing a contributing surface. This in dicates that we are leaving our current surface, and
85 // entering the new one. We then perform any operations required for merging results from the child subtree into its parent. 85 // entering the new one. We then perform any operations required for merging results from the child subtree into its parent.
86 void leaveToRenderTarget(const LayerType* newTarget); 86 void leaveToRenderTarget(const LayerType* newTarget);
87 87
88 // Add the layer's occlusion to the tracked state. 88 // Add the layer's occlusion to the tracked state.
89 void markOccludedBehindLayer(const LayerType*); 89 void markOccludedBehindLayer(const LayerType*);
90 90
91 IntRect m_rootTargetRect; 91 IntRect m_rootTargetRect;
92 scoped_ptr<CCOverdrawMetrics> m_overdrawMetrics; 92 scoped_ptr<OverdrawMetrics> m_overdrawMetrics;
93 IntSize m_minimumTrackingSize; 93 IntSize m_minimumTrackingSize;
94 94
95 // This is used for visualizing the occlusion tracking process. 95 // This is used for visualizing the occlusion tracking process.
96 Vector<IntRect>* m_occludingScreenSpaceRects; 96 Vector<IntRect>* m_occludingScreenSpaceRects;
97 97
98 DISALLOW_COPY_AND_ASSIGN(CCOcclusionTrackerBase); 98 DISALLOW_COPY_AND_ASSIGN(OcclusionTrackerBase);
99 }; 99 };
100 100
101 typedef CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium> CCOcclusion Tracker; 101 typedef OcclusionTrackerBase<Layer, RenderSurface> OcclusionTracker;
102 typedef CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface> CCOcclusionTrackerI mpl; 102 typedef OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> OcclusionTrackerImpl;
103 103
104 } 104 }
105 #endif // CCOcclusionTracker_h 105 #endif // CCOcclusionTracker_h
OLDNEW
« cc/active_animation.h ('K') | « cc/math_util_unittest.cc ('k') | cc/occlusion_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698