| 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 18 matching lines...) Expand all Loading... |
| 29 return make_scoped_refptr(new PictureLayer(client)); | 29 return make_scoped_refptr(new PictureLayer(client)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 PictureLayer::PictureLayer(ContentLayerClient* client) | 32 PictureLayer::PictureLayer(ContentLayerClient* client) |
| 33 : instrumentation_object_tracker_(id()), | 33 : instrumentation_object_tracker_(id()), |
| 34 update_source_frame_number_(-1), | 34 update_source_frame_number_(-1), |
| 35 is_mask_(false) { | 35 is_mask_(false) { |
| 36 picture_layer_inputs_.client = client; | 36 picture_layer_inputs_.client = client; |
| 37 } | 37 } |
| 38 | 38 |
| 39 PictureLayer::PictureLayer(int engine_layer_id, ContentLayerClient* client) |
| 40 : Layer(engine_layer_id), |
| 41 instrumentation_object_tracker_(id()), |
| 42 update_source_frame_number_(-1), |
| 43 is_mask_(false) { |
| 44 picture_layer_inputs_.client = client; |
| 45 } |
| 46 |
| 39 PictureLayer::PictureLayer(ContentLayerClient* client, | 47 PictureLayer::PictureLayer(ContentLayerClient* client, |
| 40 std::unique_ptr<RecordingSource> source) | 48 std::unique_ptr<RecordingSource> source) |
| 41 : PictureLayer(client) { | 49 : PictureLayer(client) { |
| 42 recording_source_ = std::move(source); | 50 recording_source_ = std::move(source); |
| 43 } | 51 } |
| 44 | 52 |
| 45 PictureLayer::~PictureLayer() { | 53 PictureLayer::~PictureLayer() { |
| 46 } | 54 } |
| 47 | 55 |
| 48 std::unique_ptr<LayerImpl> PictureLayer::CreateLayerImpl( | 56 std::unique_ptr<LayerImpl> PictureLayer::CreateLayerImpl( |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 211 } |
| 204 | 212 |
| 205 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { | 213 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { |
| 206 proto->set_type(proto::LayerNode::PICTURE_LAYER); | 214 proto->set_type(proto::LayerNode::PICTURE_LAYER); |
| 207 } | 215 } |
| 208 | 216 |
| 209 void PictureLayer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto, | 217 void PictureLayer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto, |
| 210 bool inputs_only) { | 218 bool inputs_only) { |
| 211 Layer::LayerSpecificPropertiesToProto(proto, inputs_only); | 219 Layer::LayerSpecificPropertiesToProto(proto, inputs_only); |
| 212 DropRecordingSourceContentIfInvalid(); | 220 DropRecordingSourceContentIfInvalid(); |
| 221 proto::PictureLayerProperties* picture = proto->mutable_picture(); |
| 213 | 222 |
| 214 proto::PictureLayerProperties* picture = proto->mutable_picture(); | 223 picture->set_nearest_neighbor(picture_layer_inputs_.nearest_neighbor); |
| 215 recording_source_->ToProtobuf(picture->mutable_recording_source()); | |
| 216 | |
| 217 RectToProto(picture_layer_inputs_.recorded_viewport, | 224 RectToProto(picture_layer_inputs_.recorded_viewport, |
| 218 picture->mutable_recorded_viewport()); | 225 picture->mutable_recorded_viewport()); |
| 219 if (picture_layer_inputs_.display_list) { | 226 if (picture_layer_inputs_.display_list) { |
| 220 picture_layer_inputs_.display_list->ToProtobuf( | 227 picture_layer_inputs_.display_list->ToProtobuf( |
| 221 picture->mutable_display_list()); | 228 picture->mutable_display_list()); |
| 222 for (const auto& item : *picture_layer_inputs_.display_list) { | 229 for (const auto& item : *picture_layer_inputs_.display_list) { |
| 223 sk_sp<const SkPicture> picture = item.GetPicture(); | 230 sk_sp<const SkPicture> picture = item.GetPicture(); |
| 224 // Only DrawingDisplayItems have SkPictures. | 231 // Only DrawingDisplayItems have SkPictures. |
| 225 if (!picture) | 232 if (!picture) |
| 226 continue; | 233 continue; |
| 227 | 234 |
| 228 GetLayerTree()->engine_picture_cache()->MarkUsed(picture.get()); | 235 GetLayerTree()->engine_picture_cache()->MarkUsed(picture.get()); |
| 229 } | 236 } |
| 230 } | 237 } |
| 231 | 238 |
| 239 if (inputs_only) |
| 240 return; |
| 241 |
| 242 recording_source_->ToProtobuf(picture->mutable_recording_source()); |
| 232 RegionToProto(last_updated_invalidation_, picture->mutable_invalidation()); | 243 RegionToProto(last_updated_invalidation_, picture->mutable_invalidation()); |
| 233 picture->set_is_mask(is_mask_); | 244 picture->set_is_mask(is_mask_); |
| 234 picture->set_nearest_neighbor(picture_layer_inputs_.nearest_neighbor); | |
| 235 | |
| 236 picture->set_update_source_frame_number(update_source_frame_number_); | 245 picture->set_update_source_frame_number(update_source_frame_number_); |
| 237 | |
| 238 last_updated_invalidation_.Clear(); | 246 last_updated_invalidation_.Clear(); |
| 239 } | 247 } |
| 240 | 248 |
| 241 void PictureLayer::FromLayerSpecificPropertiesProto( | 249 void PictureLayer::FromLayerSpecificPropertiesProto( |
| 242 const proto::LayerProperties& proto) { | 250 const proto::LayerProperties& proto) { |
| 243 Layer::FromLayerSpecificPropertiesProto(proto); | 251 Layer::FromLayerSpecificPropertiesProto(proto); |
| 244 const proto::PictureLayerProperties& picture = proto.picture(); | 252 const proto::PictureLayerProperties& picture = proto.picture(); |
| 245 // If this is a new layer, ensure it has a recording source. During layer | 253 // If this is a new layer, ensure it has a recording source. During layer |
| 246 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but | 254 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but |
| 247 // instead the member is set directly, so it needs to be set here explicitly. | 255 // instead the member is set directly, so it needs to be set here explicitly. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 picture_layer_inputs_.display_list = nullptr; | 319 picture_layer_inputs_.display_list = nullptr; |
| 312 picture_layer_inputs_.painter_reported_memory_usage = 0; | 320 picture_layer_inputs_.painter_reported_memory_usage = 0; |
| 313 } | 321 } |
| 314 } | 322 } |
| 315 | 323 |
| 316 const DisplayItemList* PictureLayer::GetDisplayItemList() { | 324 const DisplayItemList* PictureLayer::GetDisplayItemList() { |
| 317 return picture_layer_inputs_.display_list.get(); | 325 return picture_layer_inputs_.display_list.get(); |
| 318 } | 326 } |
| 319 | 327 |
| 320 } // namespace cc | 328 } // namespace cc |
| OLD | NEW |