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

Side by Side Diff: cc/occlusion_tracker.h

Issue 11122003: [cc] Rename all cc/ filenames to Chromium style (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
« no previous file with comments | « cc/math_util.cc ('k') | cc/occlusion_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
5 #ifndef CCOcclusionTracker_h
6 #define CCOcclusionTracker_h
7
8 #include "base/basictypes.h"
9 #include "CCLayerIterator.h"
10 #include "FloatQuad.h"
11 #include "Region.h"
12
13 namespace cc {
14 class CCOverdrawMetrics;
15 class CCLayerImpl;
16 class CCRenderSurface;
17 class LayerChromium;
18 class RenderSurfaceChromium;
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
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().
23 // If the current layer owns a RenderSurface, then occlusion on that RenderSurfa ce may also be queried via surfaceOccluded() and surfaceUnoccludedContentRect().
24 // Finally, once finished with the layer, occlusion behind the layer should be m arked by calling markOccludedBehindLayer().
25 template<typename LayerType, typename RenderSurfaceType>
26 class CCOcclusionTrackerBase {
27 public:
28 CCOcclusionTrackerBase(IntRect rootTargetRect, bool recordMetricsForFrame);
29
30 // Called at the beginning of each step in the CCLayerIterator's front-to-ba ck traversal.
31 void enterLayer(const CCLayerIteratorPosition<LayerType>&);
32 // Called at the end of each step in the CCLayerIterator's front-to-back tra versal.
33 void leaveLayer(const CCLayerIteratorPosition<LayerType>&);
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.
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.
38 IntRect unoccludedContentRect(const LayerType*, const IntRect& contentRect, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
39
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.
42 IntRect unoccludedContributingSurfaceContentRect(const LayerType*, bool forR eplica, const IntRect& contentRect, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
43
44 // Report operations for recording overdraw metrics.
45 CCOverdrawMetrics& overdrawMetrics() const { return *m_overdrawMetrics.get() ; }
46
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); }
49
50 void setMinimumTrackingSize(const IntSize& size) { m_minimumTrackingSize = s ize; }
51
52 // The following is used for visualization purposes.
53 void setOccludingScreenSpaceRectsContainer(Vector<IntRect>* rects) { m_occlu dingScreenSpaceRects = rects; }
54
55 protected:
56 struct StackObject {
57 StackObject() : target(0) { }
58 StackObject(const LayerType* target) : target(target) { }
59 const LayerType* target;
60 Region occlusionInScreen;
61 Region occlusionInTarget;
62 };
63
64 // The stack holds occluded regions for subtrees in the RenderSurface-Layer tree, so that when we leave a subtree we may
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.
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.
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.
71 Vector<StackObject, 1> m_stack;
72
73 // Allow tests to override this.
74 virtual IntRect layerClipRectInTarget(const LayerType*) const;
75
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.
78 void enterRenderTarget(const LayerType* newTarget);
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
81 // perform any surface-wide operations.
82 void finishedRenderTarget(const LayerType* finishedTarget);
83
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.
86 void leaveToRenderTarget(const LayerType* newTarget);
87
88 // Add the layer's occlusion to the tracked state.
89 void markOccludedBehindLayer(const LayerType*);
90
91 IntRect m_rootTargetRect;
92 OwnPtr<CCOverdrawMetrics> m_overdrawMetrics;
93 IntSize m_minimumTrackingSize;
94
95 // This is used for visualizing the occlusion tracking process.
96 Vector<IntRect>* m_occludingScreenSpaceRects;
97
98 DISALLOW_COPY_AND_ASSIGN(CCOcclusionTrackerBase);
99 };
100
101 typedef CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium> CCOcclusion Tracker;
102 typedef CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface> CCOcclusionTrackerI mpl;
103
104 }
105 #endif // CCOcclusionTracker_h
OLDNEW
« no previous file with comments | « cc/math_util.cc ('k') | cc/occlusion_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698