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

Side by Side Diff: cc/quads/draw_quad.h

Issue 1152473006: cc: Remove DrawQuad::IterateResoruces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iterators! Created 5 years, 6 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
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_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
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 class CC_EXPORT Resources {
128 public:
129 static const size_t kMaxResourceIdCount = 4;
130
131 class Iterator {
132 public:
133 Iterator(Resources* resources, size_t index)
134 : resources_(resources), index_(index) {}
135
136 bool operator==(const Iterator& other) const {
137 return index_ == other.index_ && resources_ == other.resources_;
danakj 2015/05/28 20:57:37 I know it's safer but you could drop the resources
vmpstr 2015/05/28 22:36:59 Yeah I had that initially... Now I don't have the
138 }
139 bool operator!=(const Iterator& other) const { return !(*this == other); }
140
141 ResourceId& operator*() {
142 DCHECK_LT(index_, resources_->count);
143 return resources_->ids[index_];
144 }
145 const ResourceId& operator*() const {
146 DCHECK_LT(index_, resources_->count);
147 return resources_->ids[index_];
148 }
149
150 Iterator& operator++() {
151 DCHECK_LT(index_, resources_->count);
152 ++index_;
153 return *this;
154 }
155
156 private:
157 Resources* resources_;
158 size_t index_;
159 };
piman 2015/05/28 19:35:46 I don't think you need this - you should be able t
danakj 2015/05/28 20:57:37 yaa
vmpstr 2015/05/28 22:36:59 Done.
160
161 Resources();
162
163 Iterator begin() { return Iterator(this, 0); }
164 Iterator end() { return Iterator(this, count); }
165
166 bool IsCountValid() const { return count <= kMaxResourceIdCount; }
danakj 2015/05/28 20:57:37 not sure why this is here?
vmpstr 2015/05/28 22:36:59 This is used in cc_messages.cc. Initially I had DC
danakj 2015/05/28 23:00:15 FWIW I'm fine with an enum with a single value tha
167
168 size_t count;
169 ResourceId ids[kMaxResourceIdCount];
170 };
171
172 Resources resources;
173
130 protected: 174 protected:
131 DrawQuad(); 175 DrawQuad();
132 176
133 void SetAll(const SharedQuadState* shared_quad_state, 177 void SetAll(const SharedQuadState* shared_quad_state,
134 Material material, 178 Material material,
135 const gfx::Rect& rect, 179 const gfx::Rect& rect,
136 const gfx::Rect& opaque_rect, 180 const gfx::Rect& opaque_rect,
137 const gfx::Rect& visible_rect, 181 const gfx::Rect& visible_rect,
138 bool needs_blending); 182 bool needs_blending);
139 virtual void ExtendValue(base::trace_event::TracedValue* value) const = 0; 183 virtual void ExtendValue(base::trace_event::TracedValue* value) const = 0;
140 }; 184 };
141 185
142 } // namespace cc 186 } // namespace cc
143 187
144 #endif // CC_QUADS_DRAW_QUAD_H_ 188 #endif // CC_QUADS_DRAW_QUAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698