| Index: cc/layers/picture_layer_unittest.cc
|
| diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc
|
| index c616f47763d4e3a68eb3071549abdee4a8f0bc73..10691e169890b1cfa70e81d93001634b8259f6ed 100644
|
| --- a/cc/layers/picture_layer_unittest.cc
|
| +++ b/cc/layers/picture_layer_unittest.cc
|
| @@ -60,23 +60,34 @@ class TestSerializationPictureLayer : public PictureLayer {
|
| nearest_neighbor_ = nearest_neighbor;
|
| }
|
|
|
| - void ValidateSerialization() {
|
| - proto::LayerProperties proto;
|
| - LayerSpecificPropertiesToProto(&proto);
|
| -
|
| + void ValidateSerialization(
|
| + ImageSerializationProcessor* image_serialization_processor) {
|
| FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D);
|
| TestTaskGraphRunner task_graph_runner;
|
| LayerTreeSettings settings;
|
| - std::unique_ptr<FakeImageSerializationProcessor>
|
| - fake_image_serialization_processor =
|
| - base::WrapUnique(new FakeImageSerializationProcessor);
|
| - std::unique_ptr<FakeLayerTreeHost> host =
|
| - FakeLayerTreeHost::Create(&host_client, &task_graph_runner, settings,
|
| - CompositorMode::SINGLE_THREADED,
|
| - fake_image_serialization_processor.get());
|
| + std::unique_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(
|
| + &host_client, &task_graph_runner, settings,
|
| + CompositorMode::SINGLE_THREADED, image_serialization_processor);
|
| + host->InitializePictureCacheForTesting();
|
| scoped_refptr<TestSerializationPictureLayer> layer =
|
| TestSerializationPictureLayer::Create(recording_source_viewport_);
|
| host->SetRootLayer(layer);
|
| +
|
| + recording_source()->set_engine_picture_cache(host->engine_picture_cache());
|
| + recording_source()->MarkForRegistration();
|
| +
|
| + proto::LayerProperties proto;
|
| + LayerSpecificPropertiesToProto(&proto);
|
| + // The EnginePictureCache will be invalid after this method ends, so ensure
|
| + // the recording source does not use it when the layer under test is
|
| + // destructed.
|
| + recording_source()->set_engine_picture_cache(nullptr);
|
| +
|
| + // The client must have the ClientPictureCache available during
|
| + // deserialization.
|
| + layer->recording_source()->set_client_picture_cache(
|
| + host->client_picture_cache());
|
| +
|
| layer->FromLayerSpecificPropertiesProto(proto);
|
|
|
| // Validate that the PictureLayer specific fields are properly set.
|
| @@ -112,6 +123,7 @@ TEST(PictureLayerTest, TestSetAllPropsSerializationDeserialization) {
|
| FakeLayerTreeHost::Create(&host_client, &task_graph_runner, settings,
|
| CompositorMode::SINGLE_THREADED,
|
| fake_image_serialization_processor.get());
|
| + host->InitializePictureCacheForTesting();
|
|
|
| gfx::Size recording_source_viewport(256, 256);
|
| scoped_refptr<TestSerializationPictureLayer> layer =
|
| @@ -130,7 +142,7 @@ TEST(PictureLayerTest, TestSetAllPropsSerializationDeserialization) {
|
| gfx::Rect(recording_source_viewport));
|
| layer->recording_source()->SetGenerateDiscardableImagesMetadata(true);
|
| layer->recording_source()->Rerecord();
|
| - layer->ValidateSerialization();
|
| + layer->ValidateSerialization(fake_image_serialization_processor.get());
|
| }
|
|
|
| TEST(PictureLayerTest, TestSerializationDeserialization) {
|
| @@ -143,6 +155,8 @@ TEST(PictureLayerTest, TestSerializationDeserialization) {
|
| &host_client, &task_graph_runner, LayerTreeSettings(),
|
| CompositorMode::SINGLE_THREADED,
|
| fake_image_serialization_processor.get());
|
| + host->InitializePictureCacheForTesting();
|
| +
|
| gfx::Size recording_source_viewport(256, 256);
|
| scoped_refptr<TestSerializationPictureLayer> layer =
|
| TestSerializationPictureLayer::Create(recording_source_viewport);
|
| @@ -155,20 +169,25 @@ TEST(PictureLayerTest, TestSerializationDeserialization) {
|
| gfx::Rect(recording_source_viewport));
|
| layer->recording_source()->SetGenerateDiscardableImagesMetadata(true);
|
| layer->recording_source()->Rerecord();
|
| - layer->ValidateSerialization();
|
| + layer->ValidateSerialization(fake_image_serialization_processor.get());
|
| }
|
|
|
| TEST(PictureLayerTest, TestEmptySerializationDeserialization) {
|
| + std::unique_ptr<FakeImageSerializationProcessor>
|
| + fake_image_serialization_processor =
|
| + base::WrapUnique(new FakeImageSerializationProcessor);
|
| FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D);
|
| TestTaskGraphRunner task_graph_runner;
|
| - std::unique_ptr<FakeLayerTreeHost> host =
|
| - FakeLayerTreeHost::Create(&host_client, &task_graph_runner);
|
| + std::unique_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(
|
| + &host_client, &task_graph_runner, LayerTreeSettings(),
|
| + CompositorMode::SINGLE_THREADED,
|
| + fake_image_serialization_processor.get());
|
|
|
| gfx::Size recording_source_viewport(256, 256);
|
| scoped_refptr<TestSerializationPictureLayer> layer =
|
| TestSerializationPictureLayer::Create(recording_source_viewport);
|
| host->SetRootLayer(layer);
|
| - layer->ValidateSerialization();
|
| + layer->ValidateSerialization(fake_image_serialization_processor.get());
|
| }
|
|
|
| TEST(PictureLayerTest, NoTilesIfEmptyBounds) {
|
|
|