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" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 picture->mutable_recorded_viewport()); | 218 picture->mutable_recorded_viewport()); |
219 if (picture_layer_inputs_.display_list) { | 219 if (picture_layer_inputs_.display_list) { |
220 picture_layer_inputs_.display_list->ToProtobuf( | 220 picture_layer_inputs_.display_list->ToProtobuf( |
221 picture->mutable_display_list()); | 221 picture->mutable_display_list()); |
222 for (const auto& item : *picture_layer_inputs_.display_list) { | 222 for (const auto& item : *picture_layer_inputs_.display_list) { |
223 sk_sp<const SkPicture> picture = item.GetPicture(); | 223 sk_sp<const SkPicture> picture = item.GetPicture(); |
224 // Only DrawingDisplayItems have SkPictures. | 224 // Only DrawingDisplayItems have SkPictures. |
225 if (!picture) | 225 if (!picture) |
226 continue; | 226 continue; |
227 | 227 |
228 layer_tree_host()->engine_picture_cache()->MarkUsed(picture.get()); | 228 GetLayerTree()->engine_picture_cache()->MarkUsed(picture.get()); |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 RegionToProto(last_updated_invalidation_, picture->mutable_invalidation()); | 232 RegionToProto(last_updated_invalidation_, picture->mutable_invalidation()); |
233 picture->set_is_mask(is_mask_); | 233 picture->set_is_mask(is_mask_); |
234 picture->set_nearest_neighbor(picture_layer_inputs_.nearest_neighbor); | 234 picture->set_nearest_neighbor(picture_layer_inputs_.nearest_neighbor); |
235 | 235 |
236 picture->set_update_source_frame_number(update_source_frame_number_); | 236 picture->set_update_source_frame_number(update_source_frame_number_); |
237 | 237 |
238 last_updated_invalidation_.Clear(); | 238 last_updated_invalidation_.Clear(); |
239 } | 239 } |
240 | 240 |
241 void PictureLayer::FromLayerSpecificPropertiesProto( | 241 void PictureLayer::FromLayerSpecificPropertiesProto( |
242 const proto::LayerProperties& proto) { | 242 const proto::LayerProperties& proto) { |
243 Layer::FromLayerSpecificPropertiesProto(proto); | 243 Layer::FromLayerSpecificPropertiesProto(proto); |
244 const proto::PictureLayerProperties& picture = proto.picture(); | 244 const proto::PictureLayerProperties& picture = proto.picture(); |
245 // If this is a new layer, ensure it has a recording source. During layer | 245 // If this is a new layer, ensure it has a recording source. During layer |
246 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but | 246 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but |
247 // instead the member is set directly, so it needs to be set here explicitly. | 247 // instead the member is set directly, so it needs to be set here explicitly. |
248 if (!recording_source_) | 248 if (!recording_source_) |
249 recording_source_.reset(new RecordingSource); | 249 recording_source_.reset(new RecordingSource); |
250 | 250 |
251 std::vector<uint32_t> used_engine_picture_ids; | 251 std::vector<uint32_t> used_engine_picture_ids; |
252 | 252 |
253 picture_layer_inputs_.recorded_viewport = | 253 picture_layer_inputs_.recorded_viewport = |
254 ProtoToRect(picture.recorded_viewport()); | 254 ProtoToRect(picture.recorded_viewport()); |
255 | 255 |
256 ClientPictureCache* client_picture_cache = | 256 ClientPictureCache* client_picture_cache = |
257 layer_tree_host()->client_picture_cache(); | 257 GetLayerTree()->client_picture_cache(); |
258 DCHECK(client_picture_cache); | 258 DCHECK(client_picture_cache); |
259 // This might not exist if the |input_.display_list| of the serialized | 259 // This might not exist if the |input_.display_list| of the serialized |
260 // RecordingSource was null, which can happen if |Clear()| is | 260 // RecordingSource was null, which can happen if |Clear()| is |
261 // called. | 261 // called. |
262 if (picture.has_display_list()) { | 262 if (picture.has_display_list()) { |
263 picture_layer_inputs_.display_list = DisplayItemList::CreateFromProto( | 263 picture_layer_inputs_.display_list = DisplayItemList::CreateFromProto( |
264 picture.display_list(), client_picture_cache, &used_engine_picture_ids); | 264 picture.display_list(), client_picture_cache, &used_engine_picture_ids); |
265 } else { | 265 } else { |
266 picture_layer_inputs_.display_list = nullptr; | 266 picture_layer_inputs_.display_list = nullptr; |
267 } | 267 } |
268 | 268 |
269 recording_source_->FromProtobuf(picture.recording_source(), | 269 recording_source_->FromProtobuf(picture.recording_source(), |
270 picture_layer_inputs_.display_list, | 270 picture_layer_inputs_.display_list, |
271 picture_layer_inputs_.recorded_viewport); | 271 picture_layer_inputs_.recorded_viewport); |
272 | 272 |
273 // Inform picture cache about which SkPictures are now in use. | 273 // Inform picture cache about which SkPictures are now in use. |
274 for (uint32_t engine_picture_id : used_engine_picture_ids) | 274 for (uint32_t engine_picture_id : used_engine_picture_ids) |
275 layer_tree_host()->client_picture_cache()->MarkUsed(engine_picture_id); | 275 GetLayerTree()->client_picture_cache()->MarkUsed(engine_picture_id); |
276 | 276 |
277 Region new_invalidation = RegionFromProto(picture.invalidation()); | 277 Region new_invalidation = RegionFromProto(picture.invalidation()); |
278 last_updated_invalidation_.Swap(&new_invalidation); | 278 last_updated_invalidation_.Swap(&new_invalidation); |
279 is_mask_ = picture.is_mask(); | 279 is_mask_ = picture.is_mask(); |
280 picture_layer_inputs_.nearest_neighbor = picture.nearest_neighbor(); | 280 picture_layer_inputs_.nearest_neighbor = picture.nearest_neighbor(); |
281 | 281 |
282 update_source_frame_number_ = picture.update_source_frame_number(); | 282 update_source_frame_number_ = picture.update_source_frame_number(); |
283 } | 283 } |
284 | 284 |
285 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 285 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
(...skipping 25 matching lines...) Expand all Loading... |
311 picture_layer_inputs_.display_list = nullptr; | 311 picture_layer_inputs_.display_list = nullptr; |
312 picture_layer_inputs_.painter_reported_memory_usage = 0; | 312 picture_layer_inputs_.painter_reported_memory_usage = 0; |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 const DisplayItemList* PictureLayer::GetDisplayItemList() { | 316 const DisplayItemList* PictureLayer::GetDisplayItemList() { |
317 return picture_layer_inputs_.display_list.get(); | 317 return picture_layer_inputs_.display_list.get(); |
318 } | 318 } |
319 | 319 |
320 } // namespace cc | 320 } // namespace cc |
OLD | NEW |