GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / cc / resources / display_item_list.h
blobf49055209d79fa762392547cb6d1cd3c547b96b1
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"
19 class SkCanvas;
20 class SkDrawPictureCallback;
22 namespace cc {
24 class CC_EXPORT DisplayItemList
25 : public base::RefCountedThreadSafe<DisplayItemList> {
26 public:
27 static scoped_refptr<DisplayItemList> Create();
29 void Raster(SkCanvas* canvas,
30 SkDrawPictureCallback* callback,
31 float contents_scale) const;
33 void AppendItem(scoped_ptr<DisplayItem> item);
35 void set_layer_rect(gfx::Rect layer_rect) { layer_rect_ = layer_rect; }
36 gfx::Rect layer_rect() const { return layer_rect_; }
38 void CreateAndCacheSkPicture();
40 bool IsSuitableForGpuRasterization() const;
41 int ApproximateOpCount() const;
42 size_t PictureMemoryUsage() const;
44 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const;
46 void EmitTraceSnapshot() const;
48 void GatherPixelRefs(const gfx::Size& grid_cell_size);
50 private:
51 DisplayItemList();
52 ~DisplayItemList();
53 ScopedPtrVector<DisplayItem> items_;
54 skia::RefPtr<SkPicture> picture_;
56 gfx::Rect layer_rect_;
57 bool is_suitable_for_gpu_rasterization_;
58 int approximate_op_count_;
60 scoped_ptr<PixelRefMap> pixel_refs_;
62 friend class base::RefCountedThreadSafe<DisplayItemList>;
63 friend class PixelRefMap::Iterator;
64 DISALLOW_COPY_AND_ASSIGN(DisplayItemList);
67 } // namespace cc
69 #endif // CC_RESOURCES_DISPLAY_ITEM_LIST_H_