Index: cc/trees/layer_tree_host.cc |
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc |
index d2f2b54eea1fd6252cab9294aab1fd3f09e03fde..eac7de48eb20160091f43e240bcb483c0c2fb262 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" |
@@ -284,6 +288,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 |
@@ -302,6 +311,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 |
@@ -318,10 +332,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(); |
vmpstr
2016/06/16 22:09:59
I'm not sure the compiler will let you have this c
nyquist
2016/06/24 11:11:14
'git cl upload' asks me if I'm sure, but other tha
|
+ |
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_); |
@@ -1507,6 +1536,7 @@ bool LayerTreeHost::IsRemoteClient() const { |
void LayerTreeHost::ToProtobufForCommit( |
proto::LayerTreeHost* proto, |
std::vector<std::unique_ptr<SwapPromise>>* swap_promises) { |
+ 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: |
@@ -1546,6 +1576,11 @@ void LayerTreeHost::ToProtobufForCommit( |
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()); |
@@ -1602,6 +1637,8 @@ void LayerTreeHost::ToProtobufForCommit( |
} |
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(); |
@@ -1617,9 +1654,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(); |