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

Unified Diff: cc/resources/display_item_list.h

Issue 1123983002: cc: Use a ListContainer for DisplayItemList to reduce allocations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/resources/display_item_list.h
diff --git a/cc/resources/display_item_list.h b/cc/resources/display_item_list.h
index a0db78ecbcfd4081cb4f774005e3b215a838fc26..bef5084c30b5af26bc6eab92d80a231620a0af8c 100644
--- a/cc/resources/display_item_list.h
+++ b/cc/resources/display_item_list.h
@@ -11,6 +11,8 @@
#include "base/trace_event/trace_event.h"
#include "cc/base/cc_export.h"
#include "cc/base/scoped_ptr_vector.h"
+// TODO(danakj): Move ListContainer out of cc/quads/
+#include "cc/quads/list_container.h"
#include "cc/resources/display_item.h"
#include "cc/resources/pixel_ref_map.h"
#include "skia/ext/refptr.h"
@@ -33,8 +35,15 @@ class CC_EXPORT DisplayItemList
SkDrawPictureCallback* callback,
float contents_scale) const;
- void AppendItem(scoped_ptr<DisplayItem> item);
+ template <typename DisplayItemType>
+ DisplayItemType* CreateAndAppendItem() {
+#if DCHECK_IS_ON()
+ needs_process_ = true;
+#endif
+ return items_.AllocateAndConstruct<DisplayItemType>();
+ }
+ void ProcessAppendedItems();
void CreateAndCacheSkPicture();
bool IsSuitableForGpuRasterization() const;
@@ -53,7 +62,15 @@ class CC_EXPORT DisplayItemList
bool retain_individual_display_items);
DisplayItemList(gfx::Rect layer_rect, bool use_cached_picture);
~DisplayItemList();
- ScopedPtrVector<DisplayItem> items_;
+
+#if DCHECK_IS_ON()
+ bool ProcessAppendedItemsCalled() const { return !needs_process_; }
+ bool needs_process_;
+#else
+ bool ProcessAppendedItemsCalled() const { return true; }
+#endif
+
+ ListContainer<DisplayItem> items_;
skia::RefPtr<SkPicture> picture_;
scoped_ptr<SkPictureRecorder> recorder_;

Powered by Google App Engine
This is Rietveld 408576698