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_RESOURCES_DISPLAY_ITEM_LIST_H_
6 #define CC_RESOURCES_DISPLAY_ITEM_LIST_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/trace_event/trace_event.h"
11 #include "cc/base/cc_export.h"
12 #include "cc/base/scoped_ptr_vector.h"
13 #include "cc/resources/display_item.h"
14 #include "cc/resources/pixel_ref_map.h"
15 #include "skia/ext/refptr.h"
16 #include "third_party/skia/include/core/SkPicture.h"
17 #include "ui/gfx/geometry/rect.h"
20 class SkDrawPictureCallback
;
21 class SkPictureRecorder
;
25 class CC_EXPORT DisplayItemList
26 : public base::RefCountedThreadSafe
<DisplayItemList
> {
28 static scoped_refptr
<DisplayItemList
> Create(gfx::Rect layer_rect
,
29 bool use_cached_picture
);
31 void Raster(SkCanvas
* canvas
,
32 SkDrawPictureCallback
* callback
,
33 float contents_scale
) const;
35 void AppendItem(scoped_ptr
<DisplayItem
> item
);
37 void CreateAndCacheSkPicture();
39 bool IsSuitableForGpuRasterization() const;
40 int ApproximateOpCount() const;
41 size_t PictureMemoryUsage() const;
43 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> AsValue() const;
45 void EmitTraceSnapshot() const;
47 void GatherPixelRefs(const gfx::Size
& grid_cell_size
);
50 DisplayItemList(gfx::Rect layer_rect
, bool use_cached_picture
);
52 ScopedPtrVector
<DisplayItem
> items_
;
53 skia::RefPtr
<SkPicture
> picture_
;
55 scoped_ptr
<SkPictureRecorder
> recorder_
;
56 skia::RefPtr
<SkCanvas
> canvas_
;
57 bool use_cached_picture_
;
58 bool retain_individual_display_items_
;
60 gfx::Rect layer_rect_
;
61 bool is_suitable_for_gpu_rasterization_
;
62 int approximate_op_count_
;
64 scoped_ptr
<PixelRefMap
> pixel_refs_
;
66 friend class base::RefCountedThreadSafe
<DisplayItemList
>;
67 friend class PixelRefMap::Iterator
;
68 DISALLOW_COPY_AND_ASSIGN(DisplayItemList
);
73 #endif // CC_RESOURCES_DISPLAY_ITEM_LIST_H_