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_QUADS_DRAW_QUAD_H_ | 5 #ifndef CC_QUADS_DRAW_QUAD_H_ |
6 #define CC_QUADS_DRAW_QUAD_H_ | 6 #define CC_QUADS_DRAW_QUAD_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
10 #include "cc/quads/shared_quad_state.h" | 10 #include "cc/quads/shared_quad_state.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 bool IsDebugQuad() const { return material == DEBUG_BORDER; } | 89 bool IsDebugQuad() const { return material == DEBUG_BORDER; } |
90 | 90 |
91 bool ShouldDrawWithBlending() const { | 91 bool ShouldDrawWithBlending() const { |
92 if (needs_blending || shared_quad_state->opacity < 1.0f) | 92 if (needs_blending || shared_quad_state->opacity < 1.0f) |
93 return true; | 93 return true; |
94 if (visible_rect.IsEmpty()) | 94 if (visible_rect.IsEmpty()) |
95 return false; | 95 return false; |
96 return !opaque_rect.Contains(visible_rect); | 96 return !opaque_rect.Contains(visible_rect); |
97 } | 97 } |
98 | 98 |
99 typedef base::Callback<ResourceId(ResourceId)> ResourceIteratorCallback; | 99 template <typename Lambda> |
100 virtual void IterateResources(const ResourceIteratorCallback& callback) = 0; | 100 void IterateResources(const Lambda& lambda) { |
| 101 for (size_t i = 0; i < resources.count; ++i) |
| 102 resources.ids[i] = lambda(resources.ids[i]); |
| 103 } |
101 | 104 |
102 // Is the left edge of this tile aligned with the originating layer's | 105 // Is the left edge of this tile aligned with the originating layer's |
103 // left edge? | 106 // left edge? |
104 bool IsLeftEdge() const { return !rect.x(); } | 107 bool IsLeftEdge() const { return !rect.x(); } |
105 | 108 |
106 // Is the top edge of this tile aligned with the originating layer's | 109 // Is the top edge of this tile aligned with the originating layer's |
107 // top edge? | 110 // top edge? |
108 bool IsTopEdge() const { return !rect.y(); } | 111 bool IsTopEdge() const { return !rect.y(); } |
109 | 112 |
110 // Is the right edge of this tile aligned with the originating layer's | 113 // Is the right edge of this tile aligned with the originating layer's |
111 // right edge? | 114 // right edge? |
112 bool IsRightEdge() const { | 115 bool IsRightEdge() const { |
113 return rect.right() == shared_quad_state->content_bounds.width(); | 116 return rect.right() == shared_quad_state->content_bounds.width(); |
114 } | 117 } |
115 | 118 |
116 // Is the bottom edge of this tile aligned with the originating layer's | 119 // Is the bottom edge of this tile aligned with the originating layer's |
117 // bottom edge? | 120 // bottom edge? |
118 bool IsBottomEdge() const { | 121 bool IsBottomEdge() const { |
119 return rect.bottom() == shared_quad_state->content_bounds.height(); | 122 return rect.bottom() == shared_quad_state->content_bounds.height(); |
120 } | 123 } |
121 | 124 |
122 // Is any edge of this tile aligned with the originating layer's | 125 // Is any edge of this tile aligned with the originating layer's |
123 // corresponding edge? | 126 // corresponding edge? |
124 bool IsEdge() const { | 127 bool IsEdge() const { |
125 return IsLeftEdge() || IsTopEdge() || IsRightEdge() || IsBottomEdge(); | 128 return IsLeftEdge() || IsTopEdge() || IsRightEdge() || IsBottomEdge(); |
126 } | 129 } |
127 | 130 |
128 void AsValueInto(base::trace_event::TracedValue* value) const; | 131 void AsValueInto(base::trace_event::TracedValue* value) const; |
129 | 132 |
| 133 struct CC_EXPORT Resources { |
| 134 enum { kMaxResourceIdCount = 4 }; |
| 135 Resources(); |
| 136 |
| 137 size_t count; |
| 138 ResourceId ids[kMaxResourceIdCount]; |
| 139 }; |
| 140 |
| 141 Resources resources; |
| 142 |
130 protected: | 143 protected: |
131 DrawQuad(); | 144 DrawQuad(); |
132 | 145 |
133 void SetAll(const SharedQuadState* shared_quad_state, | 146 void SetAll(const SharedQuadState* shared_quad_state, |
134 Material material, | 147 Material material, |
135 const gfx::Rect& rect, | 148 const gfx::Rect& rect, |
136 const gfx::Rect& opaque_rect, | 149 const gfx::Rect& opaque_rect, |
137 const gfx::Rect& visible_rect, | 150 const gfx::Rect& visible_rect, |
138 bool needs_blending); | 151 bool needs_blending); |
139 virtual void ExtendValue(base::trace_event::TracedValue* value) const = 0; | 152 virtual void ExtendValue(base::trace_event::TracedValue* value) const = 0; |
140 }; | 153 }; |
141 | 154 |
142 } // namespace cc | 155 } // namespace cc |
143 | 156 |
144 #endif // CC_QUADS_DRAW_QUAD_H_ | 157 #endif // CC_QUADS_DRAW_QUAD_H_ |
OLD | NEW |