OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #include "cc/layers/picture_layer.h" | 5 #include "cc/layers/picture_layer.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "cc/blimp/client_picture_cache.h" | 9 #include "cc/blimp/client_picture_cache.h" |
10 #include "cc/blimp/engine_picture_cache.h" | 10 #include "cc/blimp/engine_picture_cache.h" |
11 #include "cc/layers/content_layer_client.h" | 11 #include "cc/layers/content_layer_client.h" |
12 #include "cc/layers/picture_layer_impl.h" | 12 #include "cc/layers/picture_layer_impl.h" |
13 #include "cc/paint/paint_record.h" | |
13 #include "cc/playback/recording_source.h" | 14 #include "cc/playback/recording_source.h" |
14 #include "cc/proto/cc_conversions.h" | 15 #include "cc/proto/cc_conversions.h" |
15 #include "cc/proto/gfx_conversions.h" | 16 #include "cc/proto/gfx_conversions.h" |
16 #include "cc/proto/layer.pb.h" | 17 #include "cc/proto/layer.pb.h" |
17 #include "cc/trees/layer_tree_host.h" | 18 #include "cc/trees/layer_tree_host.h" |
18 #include "cc/trees/layer_tree_impl.h" | 19 #include "cc/trees/layer_tree_impl.h" |
19 #include "third_party/skia/include/core/SkPictureRecorder.h" | |
20 #include "ui/gfx/geometry/rect_conversions.h" | 20 #include "ui/gfx/geometry/rect_conversions.h" |
21 | 21 |
22 namespace cc { | 22 namespace cc { |
23 | 23 |
24 PictureLayer::PictureLayerInputs::PictureLayerInputs() = default; | 24 PictureLayer::PictureLayerInputs::PictureLayerInputs() = default; |
25 | 25 |
26 PictureLayer::PictureLayerInputs::~PictureLayerInputs() = default; | 26 PictureLayer::PictureLayerInputs::~PictureLayerInputs() = default; |
27 | 27 |
28 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { | 28 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { |
29 return make_scoped_refptr(new PictureLayer(client)); | 29 return make_scoped_refptr(new PictureLayer(client)); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 last_updated_invalidation_.Clear(); | 139 last_updated_invalidation_.Clear(); |
140 } | 140 } |
141 | 141 |
142 return updated; | 142 return updated; |
143 } | 143 } |
144 | 144 |
145 void PictureLayer::SetIsMask(bool is_mask) { | 145 void PictureLayer::SetIsMask(bool is_mask) { |
146 is_mask_ = is_mask; | 146 is_mask_ = is_mask; |
147 } | 147 } |
148 | 148 |
149 sk_sp<SkPicture> PictureLayer::GetPicture() const { | 149 sk_sp<PaintRecord> PictureLayer::GetPicture() const { |
150 // We could either flatten the RecordingSource into a single | 150 // We could either flatten the RecordingSource into a single |
151 // SkPicture, or paint a fresh one depending on what we intend to do with the | 151 // PaintRecord, or paint a fresh one depending on what we intend to do with |
152 // picture. For now we just paint a fresh one to get consistent results. | 152 // the picture. For now we just paint a fresh one to get consistent results. |
danakj
2017/01/20 23:34:13
"picture" no longer right
enne (OOO)
2017/01/24 01:51:27
Changed here. In general, I'll follow up with cha
| |
153 if (!DrawsContent()) | 153 if (!DrawsContent()) |
154 return nullptr; | 154 return nullptr; |
155 | 155 |
156 gfx::Size layer_size = bounds(); | 156 gfx::Size layer_size = bounds(); |
157 RecordingSource recording_source; | 157 RecordingSource recording_source; |
158 Region recording_invalidation; | 158 Region recording_invalidation; |
159 | 159 |
160 gfx::Rect new_recorded_viewport = | 160 gfx::Rect new_recorded_viewport = |
161 picture_layer_inputs_.client->PaintableRegion(); | 161 picture_layer_inputs_.client->PaintableRegion(); |
162 scoped_refptr<DisplayItemList> display_list = | 162 scoped_refptr<DisplayItemList> display_list = |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 } | 199 } |
200 | 200 |
201 bool PictureLayer::HasDrawableContent() const { | 201 bool PictureLayer::HasDrawableContent() const { |
202 return picture_layer_inputs_.client && Layer::HasDrawableContent(); | 202 return picture_layer_inputs_.client && Layer::HasDrawableContent(); |
203 } | 203 } |
204 | 204 |
205 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { | 205 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { |
206 proto->set_type(proto::LayerNode::PICTURE_LAYER); | 206 proto->set_type(proto::LayerNode::PICTURE_LAYER); |
207 } | 207 } |
208 | 208 |
209 void PictureLayer::ToLayerPropertiesProto(proto::LayerProperties* proto) { | 209 void PictureLayer::ToLayerPropertiesProto(proto::LayerProperties* proto) { |
vmpstr
2017/01/21 01:11:31
I think these proto functions are gone. Might be w
| |
210 DCHECK(GetLayerTree()); | 210 DCHECK(GetLayerTree()); |
211 DCHECK(GetLayerTree()->engine_picture_cache()); | 211 DCHECK(GetLayerTree()->engine_picture_cache()); |
212 | 212 |
213 Layer::ToLayerPropertiesProto(proto); | 213 Layer::ToLayerPropertiesProto(proto); |
214 DropRecordingSourceContentIfInvalid(); | 214 DropRecordingSourceContentIfInvalid(); |
215 proto::PictureLayerProperties* picture = proto->mutable_picture(); | 215 proto::PictureLayerProperties* picture = proto->mutable_picture(); |
216 | 216 |
217 picture->set_nearest_neighbor(picture_layer_inputs_.nearest_neighbor); | 217 picture->set_nearest_neighbor(picture_layer_inputs_.nearest_neighbor); |
218 RectToProto(picture_layer_inputs_.recorded_viewport, | 218 RectToProto(picture_layer_inputs_.recorded_viewport, |
219 picture->mutable_recorded_viewport()); | 219 picture->mutable_recorded_viewport()); |
220 if (picture_layer_inputs_.display_list) { | 220 if (picture_layer_inputs_.display_list) { |
221 picture_layer_inputs_.display_list->ToProtobuf( | 221 picture_layer_inputs_.display_list->ToProtobuf( |
222 picture->mutable_display_list()); | 222 picture->mutable_display_list()); |
223 for (const auto& item : *picture_layer_inputs_.display_list) { | 223 for (const auto& item : *picture_layer_inputs_.display_list) { |
224 sk_sp<const SkPicture> picture = item.GetPicture(); | 224 sk_sp<const SkPicture> picture = ToSkPicture(item.GetPicture()); |
225 // Only DrawingDisplayItems have SkPictures. | 225 // Only DrawingDisplayItems have SkPictures. |
226 if (!picture) | 226 if (!picture) |
227 continue; | 227 continue; |
228 | 228 |
229 GetLayerTree()->engine_picture_cache()->MarkUsed(picture.get()); | 229 GetLayerTree()->engine_picture_cache()->MarkUsed(picture.get()); |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 234 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
(...skipping 25 matching lines...) Expand all Loading... | |
260 picture_layer_inputs_.display_list = nullptr; | 260 picture_layer_inputs_.display_list = nullptr; |
261 picture_layer_inputs_.painter_reported_memory_usage = 0; | 261 picture_layer_inputs_.painter_reported_memory_usage = 0; |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 const DisplayItemList* PictureLayer::GetDisplayItemList() { | 265 const DisplayItemList* PictureLayer::GetDisplayItemList() { |
266 return picture_layer_inputs_.display_list.get(); | 266 return picture_layer_inputs_.display_list.get(); |
267 } | 267 } |
268 | 268 |
269 } // namespace cc | 269 } // namespace cc |
OLD | NEW |