| Index: cc/layers/picture_layer.cc
|
| diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc
|
| index 1cccf689ada36921aeba67f1212b0bb575bf4493..a7939dedf848cc2fe4199f390fe41a623e762def 100644
|
| --- a/cc/layers/picture_layer.cc
|
| +++ b/cc/layers/picture_layer.cc
|
| @@ -19,6 +19,10 @@
|
|
|
| namespace cc {
|
|
|
| +PictureLayer::PictureLayerInputs::PictureLayerInputs() = default;
|
| +
|
| +PictureLayer::PictureLayerInputs::~PictureLayerInputs() = default;
|
| +
|
| scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) {
|
| return make_scoped_refptr(new PictureLayer(client));
|
| }
|
| @@ -110,11 +114,23 @@ bool PictureLayer::Update() {
|
| // to the impl side so that it drops tiles that may not have a recording
|
| // for them.
|
| DCHECK(picture_layer_inputs_.client);
|
| +
|
| + picture_layer_inputs_.recorded_viewport =
|
| + picture_layer_inputs_.client->PaintableRegion();
|
| +
|
| updated |= recording_source_->UpdateAndExpandInvalidation(
|
| - picture_layer_inputs_.client, &last_updated_invalidation_, layer_size,
|
| - update_source_frame_number_, RecordingSource::RECORD_NORMALLY);
|
| + &last_updated_invalidation_, layer_size,
|
| + picture_layer_inputs_.recorded_viewport);
|
|
|
| if (updated) {
|
| + picture_layer_inputs_.display_list =
|
| + picture_layer_inputs_.client->PaintContentsToDisplayList(
|
| + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
|
| + picture_layer_inputs_.painter_reported_memory_usage =
|
| + picture_layer_inputs_.client->GetApproximateUnsharedMemoryUsage();
|
| + recording_source_->UpdateDisplayItemList(
|
| + picture_layer_inputs_.display_list,
|
| + picture_layer_inputs_.painter_reported_memory_usage);
|
| SetNeedsPushProperties();
|
| } else {
|
| // If this invalidation did not affect the recording source, then it can be
|
| @@ -137,20 +153,35 @@ sk_sp<SkPicture> PictureLayer::GetPicture() const {
|
| return nullptr;
|
|
|
| gfx::Size layer_size = bounds();
|
| - std::unique_ptr<RecordingSource> recording_source(new RecordingSource);
|
| + RecordingSource recording_source;
|
| Region recording_invalidation;
|
| - recording_source->UpdateAndExpandInvalidation(
|
| - picture_layer_inputs_.client, &recording_invalidation, layer_size,
|
| - update_source_frame_number_, RecordingSource::RECORD_NORMALLY);
|
| +
|
| + gfx::Rect new_recorded_viewport =
|
| + picture_layer_inputs_.client->PaintableRegion();
|
| + scoped_refptr<DisplayItemList> display_list =
|
| + picture_layer_inputs_.client->PaintContentsToDisplayList(
|
| + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
|
| + size_t painter_reported_memory_usage =
|
| + picture_layer_inputs_.client->GetApproximateUnsharedMemoryUsage();
|
| +
|
| + recording_source.UpdateAndExpandInvalidation(
|
| + &recording_invalidation, layer_size, new_recorded_viewport);
|
| + recording_source.UpdateDisplayItemList(display_list,
|
| + painter_reported_memory_usage);
|
|
|
| scoped_refptr<RasterSource> raster_source =
|
| - recording_source->CreateRasterSource(false);
|
| + recording_source.CreateRasterSource(false);
|
|
|
| return raster_source->GetFlattenedPicture();
|
| }
|
|
|
| bool PictureLayer::IsSuitableForGpuRasterization() const {
|
| - return recording_source_->IsSuitableForGpuRasterization();
|
| + // The display list needs to be created (see: UpdateAndExpandInvalidation)
|
| + // before checking for suitability. There are cases where an update will not
|
| + // create a display list (e.g., if the size is empty). We return true in these
|
| + // cases because the gpu suitability bit sticks false.
|
| + return !picture_layer_inputs_.display_list ||
|
| + picture_layer_inputs_.display_list->IsSuitableForGpuRasterization();
|
| }
|
|
|
| void PictureLayer::ClearClient() {
|
| @@ -182,11 +213,13 @@ void PictureLayer::LayerSpecificPropertiesToProto(
|
| proto::PictureLayerProperties* picture = proto->mutable_picture();
|
| recording_source_->ToProtobuf(picture->mutable_recording_source());
|
|
|
| - // Add all SkPicture items to the picture cache.
|
| - const DisplayItemList* display_list = recording_source_->GetDisplayItemList();
|
| - if (display_list) {
|
| - for (auto it = display_list->begin(); it != display_list->end(); ++it) {
|
| - sk_sp<const SkPicture> picture = it->GetPicture();
|
| + RectToProto(picture_layer_inputs_.recorded_viewport,
|
| + picture->mutable_recorded_viewport());
|
| + if (picture_layer_inputs_.display_list) {
|
| + picture_layer_inputs_.display_list->ToProtobuf(
|
| + picture->mutable_display_list());
|
| + for (const auto& item : *picture_layer_inputs_.display_list) {
|
| + sk_sp<const SkPicture> picture = item.GetPicture();
|
| // Only DrawingDisplayItems have SkPictures.
|
| if (!picture)
|
| continue;
|
| @@ -215,9 +248,25 @@ void PictureLayer::FromLayerSpecificPropertiesProto(
|
| recording_source_.reset(new RecordingSource);
|
|
|
| std::vector<uint32_t> used_engine_picture_ids;
|
| +
|
| + picture_layer_inputs_.recorded_viewport =
|
| + ProtoToRect(picture.recorded_viewport());
|
| +
|
| + ClientPictureCache* client_picture_cache =
|
| + layer_tree_host()->client_picture_cache();
|
| + DCHECK(client_picture_cache);
|
| + // This might not exist if the |input_.display_list| of the serialized
|
| + // RecordingSource was null, which can happen if |Clear()| is
|
| + // called.
|
| + if (picture.has_display_list()) {
|
| + picture_layer_inputs_.display_list = DisplayItemList::CreateFromProto(
|
| + picture.display_list(), client_picture_cache, &used_engine_picture_ids);
|
| + } else {
|
| + picture_layer_inputs_.display_list = nullptr;
|
| + }
|
| +
|
| recording_source_->FromProtobuf(picture.recording_source(),
|
| - layer_tree_host()->client_picture_cache(),
|
| - &used_engine_picture_ids);
|
| + picture_layer_inputs_.display_list);
|
|
|
| // Inform picture cache about which SkPictures are now in use.
|
| for (uint32_t engine_picture_id : used_engine_picture_ids)
|
| @@ -256,7 +305,14 @@ void PictureLayer::DropRecordingSourceContentIfInvalid() {
|
| // for example), even though it has resized making the recording source no
|
| // longer valid. In this case just destroy the recording source.
|
| recording_source_->SetEmptyBounds();
|
| + picture_layer_inputs_.recorded_viewport = gfx::Rect();
|
| + picture_layer_inputs_.display_list = nullptr;
|
| + picture_layer_inputs_.painter_reported_memory_usage = 0;
|
| }
|
| }
|
|
|
| +const DisplayItemList* PictureLayer::GetDisplayItemList() {
|
| + return picture_layer_inputs_.display_list.get();
|
| +}
|
| +
|
| } // namespace cc
|
|
|