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

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: displaylistcontainer: fixdcheck 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
« no previous file with comments | « cc/resources/compositing_display_item.cc ('k') | cc/resources/display_item_list.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9bd157f33274e4f44c389f96f3dc9caca6a22ae7 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,16 @@ 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
+ ProcessAppendedItemsOnTheFly();
+ return items_.AllocateAndConstruct<DisplayItemType>();
+ }
+ void ProcessAppendedItems();
void CreateAndCacheSkPicture();
bool IsSuitableForGpuRasterization() const;
@@ -53,7 +63,18 @@ class CC_EXPORT DisplayItemList
bool retain_individual_display_items);
DisplayItemList(gfx::Rect layer_rect, bool use_cached_picture);
~DisplayItemList();
- ScopedPtrVector<DisplayItem> items_;
+
+ // While appending new items, if they are not being retained, this can process
+ // periodically to avoid retaining all the items and processing at the end.
+ void ProcessAppendedItemsOnTheFly();
+#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_;
« no previous file with comments | « cc/resources/compositing_display_item.cc ('k') | cc/resources/display_item_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698