| Index: cc/trees/layer_tree_host.cc
|
| diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
|
| index 9ab367896bb704950d2679505aefb47ad2abc2c8..7182c1838e433e8bb2c8ba533d2e64c9f760c190 100644
|
| --- a/cc/trees/layer_tree_host.cc
|
| +++ b/cc/trees/layer_tree_host.cc
|
| @@ -8,6 +8,7 @@
|
| #include <stdint.h>
|
|
|
| #include <algorithm>
|
| +#include <memory>
|
| #include <stack>
|
| #include <string>
|
| #include <unordered_map>
|
| @@ -40,7 +41,10 @@
|
| #include "cc/layers/layer_proto_converter.h"
|
| #include "cc/layers/painted_scrollbar_layer.h"
|
| #include "cc/proto/gfx_conversions.h"
|
| +#include "cc/proto/image_serialization_processor.h"
|
| #include "cc/proto/layer_tree_host.pb.h"
|
| +#include "cc/proto/picture_cache.h"
|
| +#include "cc/proto/picture_cache_conversions.h"
|
| #include "cc/resources/ui_resource_request.h"
|
| #include "cc/scheduler/begin_frame_source.h"
|
| #include "cc/trees/draw_property_utils.h"
|
| @@ -283,6 +287,11 @@ void LayerTreeHost::InitializeRemoteServer(
|
| scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) {
|
| task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr);
|
|
|
| + if (image_serialization_processor_) {
|
| + engine_picture_cache_ =
|
| + image_serialization_processor_->CreateEnginePictureCache();
|
| + }
|
| +
|
| // The LayerTreeHost on the server never requests the output surface since
|
| // it is only needed on the client. Since ProxyMain aborts commits if
|
| // output_surface_lost() is true, always assume we have the output surface
|
| @@ -301,6 +310,11 @@ void LayerTreeHost::InitializeRemoteClient(
|
| task_runner_provider_ =
|
| TaskRunnerProvider::Create(main_task_runner, impl_task_runner);
|
|
|
| + if (image_serialization_processor_) {
|
| + client_picture_cache_ =
|
| + image_serialization_processor_->CreateClientPictureCache();
|
| + }
|
| +
|
| // For the remote mode, the RemoteChannelImpl implements the Proxy, which is
|
| // owned by the LayerTreeHost. The RemoteChannelImpl pipes requests which need
|
| // to handled locally, for instance the Output Surface creation to the
|
| @@ -317,10 +331,25 @@ void LayerTreeHost::InitializeForTesting(
|
| std::unique_ptr<Proxy> proxy_for_testing,
|
| std::unique_ptr<BeginFrameSource> external_begin_frame_source) {
|
| task_runner_provider_ = std::move(task_runner_provider);
|
| +
|
| + InitializePictureCacheForTesting();
|
| +
|
| InitializeProxy(std::move(proxy_for_testing),
|
| std::move(external_begin_frame_source));
|
| }
|
|
|
| +void LayerTreeHost::InitializePictureCacheForTesting() {
|
| + if (!image_serialization_processor_)
|
| + return;
|
| +
|
| + // Initialize both engine and client cache to ensure serialization tests
|
| + // with a single LayerTreeHost can work correctly.
|
| + engine_picture_cache_ =
|
| + image_serialization_processor_->CreateEnginePictureCache();
|
| + client_picture_cache_ =
|
| + image_serialization_processor_->CreateClientPictureCache();
|
| +}
|
| +
|
| void LayerTreeHost::SetTaskRunnerProviderForTesting(
|
| std::unique_ptr<TaskRunnerProvider> task_runner_provider) {
|
| DCHECK(!task_runner_provider_);
|
| @@ -1489,6 +1518,7 @@ bool LayerTreeHost::IsRemoteClient() const {
|
| }
|
|
|
| void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) {
|
| + DCHECK(engine_picture_cache_);
|
| // Not all fields are serialized, as they are either not needed for a commit,
|
| // or implementation isn't ready yet.
|
| // Unsupported items:
|
| @@ -1525,6 +1555,11 @@ void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) {
|
| LayerProtoConverter::SerializeLayerProperties(this,
|
| proto->mutable_layer_updates());
|
|
|
| + PictureCacheUpdate pictures =
|
| + engine_picture_cache_->CalculateCacheUpdateAndFlush();
|
| + proto::PictureDataVectorToSkPicturesProto(pictures,
|
| + proto->mutable_pictures());
|
| +
|
| proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID);
|
| debug_state_.ToProtobuf(proto->mutable_debug_state());
|
| SizeToProto(device_viewport_size_, proto->mutable_device_viewport_size());
|
| @@ -1581,6 +1616,8 @@ void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) {
|
| }
|
|
|
| void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) {
|
| + DCHECK(client_picture_cache_);
|
| +
|
| needs_full_tree_sync_ = proto.needs_full_tree_sync();
|
| needs_meta_info_recomputation_ = proto.needs_meta_info_recomputation();
|
| source_frame_number_ = proto.source_frame_number();
|
| @@ -1596,9 +1633,19 @@ void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) {
|
| for (auto layer_id : proto.layers_that_should_push_properties())
|
| layers_that_should_push_properties_.insert(layer_id_map_[layer_id]);
|
|
|
| + // Ensure ClientPictureCache contains all the necessary SkPictures before
|
| + // deserializing the properties.
|
| + proto::SkPictures proto_pictures = proto.pictures();
|
| + PictureCacheUpdate pictures =
|
| + SkPicturesProtoToPictureDataVector(proto_pictures);
|
| + client_picture_cache_->ApplyCacheUpdate(pictures);
|
| +
|
| LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(),
|
| proto.layer_updates());
|
|
|
| + // The deserialization is finished, so now clear the cache.
|
| + client_picture_cache_->Flush();
|
| +
|
| debug_state_.FromProtobuf(proto.debug_state());
|
| device_viewport_size_ = ProtoToSize(proto.device_viewport_size());
|
| top_controls_shrink_blink_size_ = proto.top_controls_shrink_blink_size();
|
|
|