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

Unified Diff: cc/playback/display_item_list.h

Issue 1494223003: cc: Shrink size of display item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix some compilation issues in ui oops Created 5 years 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/playback/display_item.h ('k') | cc/playback/display_item_list.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/playback/display_item_list.h
diff --git a/cc/playback/display_item_list.h b/cc/playback/display_item_list.h
index 4d245383f40944554310348344d11640c8853bc6..3ce166222de618831ec6f8597ef73a31b7235c30 100644
--- a/cc/playback/display_item_list.h
+++ b/cc/playback/display_item_list.h
@@ -22,6 +22,8 @@ class SkCanvas;
class SkPictureRecorder;
namespace cc {
+class DisplayItem;
+class DrawingDisplayItem;
namespace proto {
class DisplayItemList;
@@ -60,21 +62,24 @@ class CC_EXPORT DisplayItemList
// is_suitable_for_gpu_rasterization_ and approximate_op_count_.
void RasterIntoCanvas(const DisplayItem& display_item);
- template <typename DisplayItemType>
- DisplayItemType* CreateAndAppendItem(const gfx::Rect& visual_rect) {
-#if DCHECK_IS_ON()
- needs_process_ = true;
-#endif
+ // Because processing happens in this function, all the set up for
+ // this item should be done via the args, which is why the return
+ // type needs to be const, to prevent set-after-processing mistakes.
+ template <typename DisplayItemType, typename... Args>
+ const DisplayItemType& CreateAndAppendItem(const gfx::Rect& visual_rect,
+ const Args&... args) {
visual_rects_.push_back(visual_rect);
- ProcessAppendedItemsOnTheFly();
- return &items_.AllocateAndConstruct<DisplayItemType>();
+ // TODO(enne): This should forward the args.
+ auto* item = &items_.AllocateAndConstruct<DisplayItemType>(args...);
+ approximate_op_count_ += item->ApproximateOpCount();
+ // TODO(crbug.com/513016): None of the items might individually trigger a
+ // veto even though they collectively have enough "bad" operations that a
+ // corresponding flattened Picture would get vetoed.
+ is_suitable_for_gpu_rasterization_ &= item->IsSuitableForGpuRasterization();
+ ProcessAppendedItem(item);
+ return *item;
}
- // Removes the last item. This cannot be called on lists with cached pictures
- // (since the data may already have been incorporated into cached picture
- // sizes, etc).
- void RemoveLast();
-
// Called after all items are appended, to process the items and, if
// applicable, create an internally cached SkPicture.
void Finalize();
@@ -104,16 +109,7 @@ class CC_EXPORT DisplayItemList
bool retain_individual_display_items);
~DisplayItemList();
- // 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();
- void ProcessAppendedItems();
-#if DCHECK_IS_ON()
- bool ProcessAppendedItemsCalled() const { return !needs_process_; }
- bool needs_process_;
-#else
- bool ProcessAppendedItemsCalled() const { return true; }
-#endif
+ void ProcessAppendedItem(const DisplayItem* item);
ContiguousContainer<DisplayItem> items_;
// The visual rects associated with each of the display items in the
@@ -136,9 +132,6 @@ class CC_EXPORT DisplayItemList
// Memory usage due to the cached SkPicture.
size_t picture_memory_usage_;
- // Memory usage due to external data held by display items.
- size_t external_memory_usage_;
-
DiscardableImageMap image_map_;
friend class base::RefCountedThreadSafe<DisplayItemList>;
« no previous file with comments | « cc/playback/display_item.h ('k') | cc/playback/display_item_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698