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

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: Comments are hard Created 5 years, 1 month 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
« no previous file with comments | « cc/playback/display_item.h ('k') | cc/playback/display_item_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // (crbug.com/548434).
45 static scoped_refptr<DisplayItemList> CreateFromProto(
46 const proto::DisplayItemList& proto);
47
48 // Creates a Protobuf representing the state of this DisplayItemList.
49 // TODO(dtrainor): Don't resend DisplayItems that were already serialized
50 // (crbug.com/548434).
51 void ToProtobuf(proto::DisplayItemList* proto);
52
39 void Raster(SkCanvas* canvas, 53 void Raster(SkCanvas* canvas,
40 SkPicture::AbortCallback* callback, 54 SkPicture::AbortCallback* callback,
41 const gfx::Rect& canvas_target_playback_rect, 55 const gfx::Rect& canvas_target_playback_rect,
42 float contents_scale) const; 56 float contents_scale) const;
43 57
44 // This is a fast path for use only if canvas_ is set and 58 // This is a fast path for use only if canvas_ is set and
45 // retain_individual_display_items_ is false. This method also updates 59 // retain_individual_display_items_ is false. This method also updates
46 // is_suitable_for_gpu_rasterization_ and approximate_op_count_. 60 // is_suitable_for_gpu_rasterization_ and approximate_op_count_.
47 void RasterIntoCanvas(const DisplayItem& display_item); 61 void RasterIntoCanvas(const DisplayItem& display_item);
48 62
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 bool needs_process_; 110 bool needs_process_;
97 #else 111 #else
98 bool ProcessAppendedItemsCalled() const { return true; } 112 bool ProcessAppendedItemsCalled() const { return true; }
99 #endif 113 #endif
100 114
101 ListContainer<DisplayItem> items_; 115 ListContainer<DisplayItem> items_;
102 skia::RefPtr<SkPicture> picture_; 116 skia::RefPtr<SkPicture> picture_;
103 117
104 scoped_ptr<SkPictureRecorder> recorder_; 118 scoped_ptr<SkPictureRecorder> recorder_;
105 skia::RefPtr<SkCanvas> canvas_; 119 skia::RefPtr<SkCanvas> canvas_;
106 const bool use_cached_picture_; 120 const DisplayItemListSettings settings_;
107 bool retain_individual_display_items_; 121 bool retain_individual_display_items_;
108 122
109 gfx::Rect layer_rect_; 123 gfx::Rect layer_rect_;
110 bool is_suitable_for_gpu_rasterization_; 124 bool is_suitable_for_gpu_rasterization_;
111 int approximate_op_count_; 125 int approximate_op_count_;
112 126
113 // Memory usage due to the cached SkPicture. 127 // Memory usage due to the cached SkPicture.
114 size_t picture_memory_usage_; 128 size_t picture_memory_usage_;
115 129
116 // Memory usage due to external data held by display items. 130 // Memory usage due to external data held by display items.
117 size_t external_memory_usage_; 131 size_t external_memory_usage_;
118 132
119 DiscardableImageMap image_map_; 133 DiscardableImageMap image_map_;
120 134
121 friend class base::RefCountedThreadSafe<DisplayItemList>; 135 friend class base::RefCountedThreadSafe<DisplayItemList>;
122 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); 136 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage);
123 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); 137 DISALLOW_COPY_AND_ASSIGN(DisplayItemList);
124 }; 138 };
125 139
126 } // namespace cc 140 } // namespace cc
127 141
128 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ 142 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_
OLDNEW
« 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