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; | |
100 virtual void IterateResources(const ResourceIteratorCallback& callback) = 0; | |
101 | |
102 // Is the left edge of this tile aligned with the originating layer's | 99 // Is the left edge of this tile aligned with the originating layer's |
103 // left edge? | 100 // left edge? |
104 bool IsLeftEdge() const { return !rect.x(); } | 101 bool IsLeftEdge() const { return !rect.x(); } |
105 | 102 |
106 // Is the top edge of this tile aligned with the originating layer's | 103 // Is the top edge of this tile aligned with the originating layer's |
107 // top edge? | 104 // top edge? |
108 bool IsTopEdge() const { return !rect.y(); } | 105 bool IsTopEdge() const { return !rect.y(); } |
109 | 106 |
110 // Is the right edge of this tile aligned with the originating layer's | 107 // Is the right edge of this tile aligned with the originating layer's |
111 // right edge? | 108 // right edge? |
112 bool IsRightEdge() const { | 109 bool IsRightEdge() const { |
113 return rect.right() == shared_quad_state->content_bounds.width(); | 110 return rect.right() == shared_quad_state->content_bounds.width(); |
114 } | 111 } |
115 | 112 |
116 // Is the bottom edge of this tile aligned with the originating layer's | 113 // Is the bottom edge of this tile aligned with the originating layer's |
117 // bottom edge? | 114 // bottom edge? |
118 bool IsBottomEdge() const { | 115 bool IsBottomEdge() const { |
119 return rect.bottom() == shared_quad_state->content_bounds.height(); | 116 return rect.bottom() == shared_quad_state->content_bounds.height(); |
120 } | 117 } |
121 | 118 |
122 // Is any edge of this tile aligned with the originating layer's | 119 // Is any edge of this tile aligned with the originating layer's |
123 // corresponding edge? | 120 // corresponding edge? |
124 bool IsEdge() const { | 121 bool IsEdge() const { |
125 return IsLeftEdge() || IsTopEdge() || IsRightEdge() || IsBottomEdge(); | 122 return IsLeftEdge() || IsTopEdge() || IsRightEdge() || IsBottomEdge(); |
126 } | 123 } |
127 | 124 |
128 void AsValueInto(base::trace_event::TracedValue* value) const; | 125 void AsValueInto(base::trace_event::TracedValue* value) const; |
129 | 126 |
| 127 struct CC_EXPORT Resources { |
| 128 static const size_t kMaxResourceIdCount = 4; |
| 129 Resources(); |
| 130 |
| 131 ResourceId* begin() { return ids; } |
| 132 ResourceId* end() { |
| 133 DCHECK(IsCountValid()); |
| 134 return ids + count; |
| 135 } |
| 136 |
| 137 bool IsCountValid() const { return count <= kMaxResourceIdCount; } |
| 138 |
| 139 size_t count; |
| 140 ResourceId ids[kMaxResourceIdCount]; |
| 141 }; |
| 142 |
| 143 Resources resources; |
| 144 |
130 protected: | 145 protected: |
131 DrawQuad(); | 146 DrawQuad(); |
132 | 147 |
133 void SetAll(const SharedQuadState* shared_quad_state, | 148 void SetAll(const SharedQuadState* shared_quad_state, |
134 Material material, | 149 Material material, |
135 const gfx::Rect& rect, | 150 const gfx::Rect& rect, |
136 const gfx::Rect& opaque_rect, | 151 const gfx::Rect& opaque_rect, |
137 const gfx::Rect& visible_rect, | 152 const gfx::Rect& visible_rect, |
138 bool needs_blending); | 153 bool needs_blending); |
139 virtual void ExtendValue(base::trace_event::TracedValue* value) const = 0; | 154 virtual void ExtendValue(base::trace_event::TracedValue* value) const = 0; |
140 }; | 155 }; |
141 | 156 |
142 } // namespace cc | 157 } // namespace cc |
143 | 158 |
144 #endif // CC_QUADS_DRAW_QUAD_H_ | 159 #endif // CC_QUADS_DRAW_QUAD_H_ |
OLD | NEW |