Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / cc / playback / display_item_list.h
blob1c8d0885d14ceaf79431bfcf7d04d5029124f137
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_PLAYBACK_DISPLAY_ITEM_LIST_H_
6 #define CC_PLAYBACK_DISPLAY_ITEM_LIST_H_
8 #include "base/gtest_prod_util.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/trace_event/trace_event.h"
12 #include "cc/base/cc_export.h"
13 #include "cc/base/list_container.h"
14 #include "cc/base/scoped_ptr_vector.h"
15 #include "cc/playback/display_item.h"
16 #include "cc/playback/pixel_ref_map.h"
17 #include "skia/ext/refptr.h"
18 #include "third_party/skia/include/core/SkPicture.h"
19 #include "ui/gfx/geometry/rect.h"
21 class SkCanvas;
22 class SkPictureRecorder;
24 namespace cc {
26 class CC_EXPORT DisplayItemList
27 : public base::RefCountedThreadSafe<DisplayItemList> {
28 public:
29 static scoped_refptr<DisplayItemList> CreateWithoutCachedPicture();
31 static scoped_refptr<DisplayItemList> Create(gfx::Rect layer_rect,
32 bool use_cached_picture);
34 void Raster(SkCanvas* canvas,
35 SkPicture::AbortCallback* callback,
36 float contents_scale) const;
38 template <typename DisplayItemType>
39 DisplayItemType* CreateAndAppendItem() {
40 #if DCHECK_IS_ON()
41 needs_process_ = true;
42 #endif
43 ProcessAppendedItemsOnTheFly();
44 return items_.AllocateAndConstruct<DisplayItemType>();
47 void ProcessAppendedItems();
48 void CreateAndCacheSkPicture();
50 bool IsSuitableForGpuRasterization() const;
51 int ApproximateOpCount() const;
52 size_t PictureMemoryUsage() const;
54 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const;
56 void EmitTraceSnapshot() const;
58 void GatherPixelRefs(const gfx::Size& grid_cell_size);
60 private:
61 DisplayItemList(gfx::Rect layer_rect,
62 bool use_cached_picture,
63 bool retain_individual_display_items);
64 DisplayItemList(gfx::Rect layer_rect, bool use_cached_picture);
65 ~DisplayItemList();
67 // While appending new items, if they are not being retained, this can process
68 // periodically to avoid retaining all the items and processing at the end.
69 void ProcessAppendedItemsOnTheFly();
70 #if DCHECK_IS_ON()
71 bool ProcessAppendedItemsCalled() const { return !needs_process_; }
72 bool needs_process_;
73 #else
74 bool ProcessAppendedItemsCalled() const { return true; }
75 #endif
77 ListContainer<DisplayItem> items_;
78 skia::RefPtr<SkPicture> picture_;
80 scoped_ptr<SkPictureRecorder> recorder_;
81 skia::RefPtr<SkCanvas> canvas_;
82 bool use_cached_picture_;
83 bool retain_individual_display_items_;
85 gfx::Rect layer_rect_;
86 bool is_suitable_for_gpu_rasterization_;
87 int approximate_op_count_;
88 size_t picture_memory_usage_;
90 scoped_ptr<PixelRefMap> pixel_refs_;
92 friend class base::RefCountedThreadSafe<DisplayItemList>;
93 friend class PixelRefMap::Iterator;
94 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, PictureMemoryUsage);
95 DISALLOW_COPY_AND_ASSIGN(DisplayItemList);
98 } // namespace cc
100 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_