| Index: cc/layers/picture_layer.cc
|
| diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc
|
| index 081e3158841943ab15a3d8bfaeff318afe457f5e..d52fd2715940362eb1cf99d64d9ce0520e17951f 100644
|
| --- a/cc/layers/picture_layer.cc
|
| +++ b/cc/layers/picture_layer.cc
|
| @@ -19,6 +19,10 @@
|
|
|
| namespace cc {
|
|
|
| +PictureLayer::Inputs::Inputs() = default;
|
| +
|
| +PictureLayer::Inputs::~Inputs() = default;
|
| +
|
| scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) {
|
| return make_scoped_refptr(new PictureLayer(client));
|
| }
|
| @@ -109,9 +113,17 @@ bool PictureLayer::Update() {
|
| // to the impl side so that it drops tiles that may not have a recording
|
| // for them.
|
| DCHECK(inputs_.client);
|
| +
|
| + inputs_.recorded_viewport = inputs_.client->PaintableRegion();
|
| + inputs_.display_list = inputs_.client->PaintContentsToDisplayList(
|
| + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
|
| + inputs_.painter_reported_memory_usage =
|
| + inputs_.client->GetApproximateUnsharedMemoryUsage();
|
| +
|
| updated |= recording_source_->UpdateAndExpandInvalidation(
|
| inputs_.client, &last_updated_invalidation_, layer_size,
|
| - update_source_frame_number_, RecordingSource::RECORD_NORMALLY);
|
| + inputs_.recorded_viewport, inputs_.display_list,
|
| + inputs_.painter_reported_memory_usage);
|
|
|
| if (updated) {
|
| SetNeedsPushProperties();
|
| @@ -136,20 +148,33 @@ 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(
|
| +
|
| + gfx::Rect new_recorded_viewport = inputs_.client->PaintableRegion();
|
| + scoped_refptr<DisplayItemList> display_list =
|
| + inputs_.client->PaintContentsToDisplayList(
|
| + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
|
| + size_t painter_reported_memory_usage =
|
| + inputs_.client->GetApproximateUnsharedMemoryUsage();
|
| +
|
| + recording_source.UpdateAndExpandInvalidation(
|
| inputs_.client, &recording_invalidation, layer_size,
|
| - update_source_frame_number_, RecordingSource::RECORD_NORMALLY);
|
| + new_recorded_viewport, 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 !inputs_.display_list ||
|
| + inputs_.display_list->IsSuitableForGpuRasterization();
|
| }
|
|
|
| void PictureLayer::ClearClient() {
|
| @@ -181,11 +206,11 @@ 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(inputs_.recorded_viewport, picture->mutable_recorded_viewport());
|
| + if (inputs_.display_list) {
|
| + inputs_.display_list->ToProtobuf(picture->mutable_display_list());
|
| + for (const auto& item : *inputs_.display_list) {
|
| + sk_sp<const SkPicture> picture = item.GetPicture();
|
| // Only DrawingDisplayItems have SkPictures.
|
| if (!picture)
|
| continue;
|
| @@ -214,9 +239,24 @@ void PictureLayer::FromLayerSpecificPropertiesProto(
|
| recording_source_.reset(new RecordingSource);
|
|
|
| std::vector<uint32_t> used_engine_picture_ids;
|
| +
|
| + 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()) {
|
| + inputs_.display_list = DisplayItemList::CreateFromProto(
|
| + picture.display_list(), client_picture_cache, &used_engine_picture_ids);
|
| + } else {
|
| + inputs_.display_list = nullptr;
|
| + }
|
| +
|
| recording_source_->FromProtobuf(picture.recording_source(),
|
| - layer_tree_host()->client_picture_cache(),
|
| - &used_engine_picture_ids);
|
| + inputs_.display_list);
|
|
|
| // Inform picture cache about which SkPictures are now in use.
|
| for (uint32_t engine_picture_id : used_engine_picture_ids)
|
| @@ -255,7 +295,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();
|
| + inputs_.recorded_viewport = gfx::Rect();
|
| + inputs_.display_list = nullptr;
|
| + inputs_.painter_reported_memory_usage = 0;
|
| }
|
| }
|
|
|
| +const DisplayItemList* PictureLayer::GetDisplayItemList() {
|
| + return inputs_.display_list.get();
|
| +}
|
| +
|
| } // namespace cc
|
|
|