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

Side by Side Diff: cc/occlusion_tracker.h

Issue 11366094: cc: Create a Region class that wraps SkRegion, to replace use of WebCore::Region. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move deg2rad etc to MathUtil Created 8 years, 1 month 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 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 "Region.h"
9 #include "base/basictypes.h" 8 #include "base/basictypes.h"
10 #include "cc/cc_export.h" 9 #include "cc/cc_export.h"
11 #include "cc/layer_iterator.h" 10 #include "cc/layer_iterator.h"
11 #include "cc/region.h"
12 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
13 13
14 namespace cc { 14 namespace cc {
15 class OverdrawMetrics; 15 class OverdrawMetrics;
16 class LayerImpl; 16 class LayerImpl;
17 class RenderSurfaceImpl; 17 class RenderSurfaceImpl;
18 class Layer; 18 class Layer;
19 class RenderSurface; 19 class RenderSurface;
20 20
21 // 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 // 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
(...skipping 18 matching lines...) Expand all
40 gfx::Rect unoccludedContentRect(const LayerType* renderTarget, const gfx::Re ct& contentRect, const WebKit::WebTransformationMatrix& drawTransform, bool impl DrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusion FromOutsideTargetSurface = 0) const; 40 gfx::Rect unoccludedContentRect(const LayerType* renderTarget, const gfx::Re ct& contentRect, const WebKit::WebTransformationMatrix& drawTransform, bool impl DrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusion FromOutsideTargetSurface = 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 { return subtract(Region(m_rootT argetRect), m_stack.last().occlusionInScreen); } 50 Region computeVisibleRegionInScreen() const { return SubtractRegions(m_rootT argetRect, m_stack.back().occlusionInScreen); }
51 51
52 void setMinimumTrackingSize(const gfx::Size& size) { m_minimumTrackingSize = size; } 52 void setMinimumTrackingSize(const gfx::Size& size) { m_minimumTrackingSize = size; }
53 53
54 // The following is used for visualization purposes. 54 // The following is used for visualization purposes.
55 void setOccludingScreenSpaceRectsContainer(std::vector<gfx::Rect>* rects) { m_occludingScreenSpaceRects = rects; } 55 void setOccludingScreenSpaceRectsContainer(std::vector<gfx::Rect>* rects) { m_occludingScreenSpaceRects = rects; }
56 56
57 protected: 57 protected:
58 struct StackObject { 58 struct StackObject {
59 StackObject() : target(0) { } 59 StackObject() : target(0) { }
60 StackObject(const LayerType* target) : target(target) { } 60 StackObject(const LayerType* target) : target(target) { }
61 const LayerType* target; 61 const LayerType* target;
62 Region occlusionInScreen; 62 Region occlusionInScreen;
63 Region occlusionInTarget; 63 Region occlusionInTarget;
64 }; 64 };
65 65
66 // The stack holds occluded regions for subtrees in the RenderSurfaceImpl-La yer tree, so that when we leave a subtree we may 66 // The stack holds occluded regions for subtrees in the RenderSurfaceImpl-La yer tree, so that when we leave a subtree we may
67 // apply a mask to it, but not to the parts outside the subtree. 67 // apply a mask to it, but not to the parts outside the subtree.
68 // - 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. 68 // - 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.
69 // - When we visit a target surface, we apply its mask to its subtree, which is at the top of the stack. 69 // - When we visit a target surface, we apply its mask to its subtree, which is at the top of the stack.
70 // - When we visit a layer representing itself, we add its occlusion to the current subtree, which is at the top of the stack. 70 // - When we visit a layer representing itself, we add its occlusion to the current subtree, which is at the top of the stack.
71 // - 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. 71 // - 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.
72 // 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. 72 // 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.
73 Vector<StackObject, 1> m_stack; 73 std::vector<StackObject> m_stack;
74 74
75 // Allow tests to override this. 75 // Allow tests to override this.
76 virtual gfx::Rect layerClipRectInTarget(const LayerType*) const; 76 virtual gfx::Rect layerClipRectInTarget(const LayerType*) const;
77 77
78 private: 78 private:
79 // 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. 79 // 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 void enterRenderTarget(const LayerType* newTarget); 80 void enterRenderTarget(const LayerType* newTarget);
81 81
82 // Called when visiting a layer representing a target surface. This indicate s we have visited all the layers within the surface, and we may 82 // 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 // perform any surface-wide operations. 83 // perform any surface-wide operations.
(...skipping 19 matching lines...) Expand all
103 typedef OcclusionTrackerBase<Layer, RenderSurface> OcclusionTracker; 103 typedef OcclusionTrackerBase<Layer, RenderSurface> OcclusionTracker;
104 typedef OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> OcclusionTrackerImpl; 104 typedef OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> OcclusionTrackerImpl;
105 #if !defined(COMPILER_MSVC) 105 #if !defined(COMPILER_MSVC)
106 extern template class OcclusionTrackerBase<Layer, RenderSurface>; 106 extern template class OcclusionTrackerBase<Layer, RenderSurface>;
107 extern template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; 107 extern template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>;
108 #endif 108 #endif
109 109
110 } // namespace cc 110 } // namespace cc
111 111
112 #endif // CC_OCCLUSION_TRACKER_H_ 112 #endif // CC_OCCLUSION_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698