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

Side by Side Diff: cc/playback/display_item_list.h

Issue 1407793002: Add protobuf serialization to DisplayItemList (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blimp_display2
Patch Set: Rebased Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ 5 #ifndef CC_PLAYBACK_DISPLAY_ITEM_LIST_H_
6 #define CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ 6 #define CC_PLAYBACK_DISPLAY_ITEM_LIST_H_
7 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "cc/base/cc_export.h" 12 #include "cc/base/cc_export.h"
13 #include "cc/base/list_container.h" 13 #include "cc/base/list_container.h"
14 #include "cc/playback/discardable_image_map.h" 14 #include "cc/playback/discardable_image_map.h"
15 #include "cc/playback/display_item.h" 15 #include "cc/playback/display_item.h"
16 #include "cc/playback/display_item_list_settings.h"
16 #include "skia/ext/refptr.h" 17 #include "skia/ext/refptr.h"
17 #include "third_party/skia/include/core/SkPicture.h" 18 #include "third_party/skia/include/core/SkPicture.h"
18 #include "ui/gfx/geometry/rect.h" 19 #include "ui/gfx/geometry/rect.h"
19 20
20 class SkCanvas; 21 class SkCanvas;
21 class SkPictureRecorder; 22 class SkPictureRecorder;
22 23
23 namespace cc { 24 namespace cc {
24 25
25 class DisplayItemListSettings; 26 namespace proto {
27 class DisplayItemList;
28 }
26 29
27 class CC_EXPORT DisplayItemList 30 class CC_EXPORT DisplayItemList
28 : public base::RefCountedThreadSafe<DisplayItemList> { 31 : public base::RefCountedThreadSafe<DisplayItemList> {
29 public: 32 public:
30 // Creates a display item list. If picture caching is used, then layer_rect 33 // Creates a display item list. If picture caching is used, then layer_rect
31 // specifies the cull rect of the display item list (the picture will not 34 // specifies the cull rect of the display item list (the picture will not
32 // exceed this rect). If picture caching is not used, then the given rect can 35 // exceed this rect). If picture caching is not used, then the given rect can
33 // be empty. 36 // be empty.
34 // TODO(vmpstr): Maybe this cull rect can be part of the settings instead. 37 // TODO(vmpstr): Maybe this cull rect can be part of the settings instead.
35 static scoped_refptr<DisplayItemList> Create( 38 static scoped_refptr<DisplayItemList> Create(
36 const gfx::Rect& layer_rect, 39 const gfx::Rect& layer_rect,
37 const DisplayItemListSettings& settings); 40 const DisplayItemListSettings& settings);
38 41
42 // Creates a DisplayItemList from a Protobuf.
43 // TODO(dtrainor): Pass in a list of possible DisplayItems to reuse.
44 static scoped_refptr<DisplayItemList> Create(
vmpstr 2015/10/26 17:46:17 CreateFromProto
David Trainor- moved to gerrit 2015/10/26 20:42:56 Done.
45 const proto::DisplayItemList& proto);
46
47 // Creates a Protobuf representing the state of this DisplayItemList.
48 // TODO(dtrainor): Don't resend DisplayItems that were already serialized.
49 void ToProtobuf(proto::DisplayItemList* proto);
50
39 void Raster(SkCanvas* canvas, 51 void Raster(SkCanvas* canvas,
40 SkPicture::AbortCallback* callback, 52 SkPicture::AbortCallback* callback,
41 const gfx::Rect& canvas_target_playback_rect, 53 const gfx::Rect& canvas_target_playback_rect,
42 float contents_scale) const; 54 float contents_scale) const;
43 55
44 // This is a fast path for use only if canvas_ is set and 56 // This is a fast path for use only if canvas_ is set and
45 // retain_individual_display_items_ is false. This method also updates 57 // retain_individual_display_items_ is false. This method also updates
46 // is_suitable_for_gpu_rasterization_ and approximate_op_count_. 58 // is_suitable_for_gpu_rasterization_ and approximate_op_count_.
47 void RasterIntoCanvas(const DisplayItem& display_item); 59 void RasterIntoCanvas(const DisplayItem& display_item);
48 60
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 bool needs_process_; 108 bool needs_process_;
97 #else 109 #else
98 bool ProcessAppendedItemsCalled() const { return true; } 110 bool ProcessAppendedItemsCalled() const { return true; }
99 #endif 111 #endif
100 112
101 ListContainer<DisplayItem> items_; 113 ListContainer<DisplayItem> items_;
102 skia::RefPtr<SkPicture> picture_; 114 skia::RefPtr<SkPicture> picture_;
103 115
104 scoped_ptr<SkPictureRecorder> recorder_; 116 scoped_ptr<SkPictureRecorder> recorder_;
105 skia::RefPtr<SkCanvas> canvas_; 117 skia::RefPtr<SkCanvas> canvas_;
106 const bool use_cached_picture_; 118 const DisplayItemListSettings settings_;
107 bool retain_individual_display_items_; 119 bool retain_individual_display_items_;
108 120
109 gfx::Rect layer_rect_; 121 gfx::Rect layer_rect_;
110 bool is_suitable_for_gpu_rasterization_; 122 bool is_suitable_for_gpu_rasterization_;
111 int approximate_op_count_; 123 int approximate_op_count_;
112 124
113 // Memory usage due to the cached SkPicture. 125 // Memory usage due to the cached SkPicture.
114 size_t picture_memory_usage_; 126 size_t picture_memory_usage_;
115 127
116 // Memory usage due to external data held by display items. 128 // Memory usage due to external data held by display items.
117 size_t external_memory_usage_; 129 size_t external_memory_usage_;
118 130
119 DiscardableImageMap image_map_; 131 DiscardableImageMap image_map_;
120 132
121 friend class base::RefCountedThreadSafe<DisplayItemList>; 133 friend class base::RefCountedThreadSafe<DisplayItemList>;
122 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); 134 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage);
123 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); 135 DISALLOW_COPY_AND_ASSIGN(DisplayItemList);
124 }; 136 };
125 137
126 } // namespace cc 138 } // namespace cc
127 139
128 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ 140 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698