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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: cc/quads/draw_quad.h
diff --git a/cc/quads/draw_quad.h b/cc/quads/draw_quad.h
index 0e26b6329f080e76b05a50488cdc720a3df87b39..055f41f261127e50b795a8775b0ac44cf5859e9b 100644
--- a/cc/quads/draw_quad.h
+++ b/cc/quads/draw_quad.h
@@ -96,9 +96,6 @@ class CC_EXPORT DrawQuad {
return !opaque_rect.Contains(visible_rect);
}
- typedef base::Callback<ResourceId(ResourceId)> ResourceIteratorCallback;
- virtual void IterateResources(const ResourceIteratorCallback& callback) = 0;
-
// Is the left edge of this tile aligned with the originating layer's
// left edge?
bool IsLeftEdge() const { return !rect.x(); }
@@ -127,6 +124,53 @@ class CC_EXPORT DrawQuad {
void AsValueInto(base::trace_event::TracedValue* value) const;
+ class CC_EXPORT Resources {
+ public:
+ static const size_t kMaxResourceIdCount = 4;
+
+ class Iterator {
+ public:
+ Iterator(Resources* resources, size_t index)
+ : resources_(resources), index_(index) {}
+
+ bool operator==(const Iterator& other) const {
+ 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
+ }
+ bool operator!=(const Iterator& other) const { return !(*this == other); }
+
+ ResourceId& operator*() {
+ DCHECK_LT(index_, resources_->count);
+ return resources_->ids[index_];
+ }
+ const ResourceId& operator*() const {
+ DCHECK_LT(index_, resources_->count);
+ return resources_->ids[index_];
+ }
+
+ Iterator& operator++() {
+ DCHECK_LT(index_, resources_->count);
+ ++index_;
+ return *this;
+ }
+
+ private:
+ Resources* resources_;
+ size_t index_;
+ };
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.
+
+ Resources();
+
+ Iterator begin() { return Iterator(this, 0); }
+ Iterator end() { return Iterator(this, count); }
+
+ 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
+
+ size_t count;
+ ResourceId ids[kMaxResourceIdCount];
+ };
+
+ Resources resources;
+
protected:
DrawQuad();

Powered by Google App Engine
This is Rietveld 408576698