OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "cc/base/region.h" | 8 #include "cc/base/region.h" |
9 #include "cc/playback/raster_source.h" | 9 #include "cc/playback/raster_source.h" |
10 #include "cc/proto/recording_source.pb.h" | 10 #include "cc/proto/recording_source.pb.h" |
11 #include "cc/test/fake_content_layer_client.h" | 11 #include "cc/test/fake_content_layer_client.h" |
12 #include "cc/test/fake_image_serialization_processor.h" | 12 #include "cc/test/fake_image_serialization_processor.h" |
| 13 #include "cc/test/fake_picture_cache.h" |
13 #include "cc/test/fake_recording_source.h" | 14 #include "cc/test/fake_recording_source.h" |
14 #include "cc/test/skia_common.h" | 15 #include "cc/test/skia_common.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "third_party/skia/include/core/SkRefCnt.h" | 17 #include "third_party/skia/include/core/SkRefCnt.h" |
17 | 18 |
18 namespace cc { | 19 namespace cc { |
19 namespace { | 20 namespace { |
20 | 21 |
21 std::unique_ptr<FakeRecordingSource> CreateRecordingSource( | 22 std::unique_ptr<FakeRecordingSource> CreateRecordingSource( |
22 const gfx::Rect& viewport) { | 23 const gfx::Rect& viewport) { |
23 gfx::Rect layer_rect(viewport.right(), viewport.bottom()); | 24 gfx::Rect layer_rect(viewport.right(), viewport.bottom()); |
24 std::unique_ptr<FakeRecordingSource> recording_source = | 25 std::unique_ptr<FakeRecordingSource> recording_source = |
25 FakeRecordingSource::CreateRecordingSource(viewport, layer_rect.size()); | 26 FakeRecordingSource::CreateRecordingSource(viewport, layer_rect.size()); |
26 return recording_source; | 27 return recording_source; |
27 } | 28 } |
28 | 29 |
29 scoped_refptr<RasterSource> CreateRasterSource( | 30 scoped_refptr<RasterSource> CreateRasterSource( |
30 FakeRecordingSource* recording_source) { | 31 FakeRecordingSource* recording_source) { |
31 bool can_use_lcd_text = true; | 32 bool can_use_lcd_text = true; |
32 return RasterSource::CreateFromRecordingSource(recording_source, | 33 return RasterSource::CreateFromRecordingSource(recording_source, |
33 can_use_lcd_text); | 34 can_use_lcd_text); |
34 } | 35 } |
35 | 36 |
36 void ValidateRecordingSourceSerialization(FakeRecordingSource* source) { | 37 void ValidateRecordingSourceSerialization(FakeRecordingSource* source) { |
37 std::unique_ptr<FakeImageSerializationProcessor> | 38 std::unique_ptr<FakeImageSerializationProcessor> |
38 fake_image_serialization_processor = | 39 fake_image_serialization_processor = |
39 base::WrapUnique(new FakeImageSerializationProcessor); | 40 base::WrapUnique(new FakeImageSerializationProcessor); |
| 41 std::unique_ptr<EnginePictureCache> fake_engine_picture_cache = |
| 42 fake_image_serialization_processor->CreateEnginePictureCache(); |
| 43 std::unique_ptr<ClientPictureCache> fake_client_picture_cache = |
| 44 fake_image_serialization_processor->CreateClientPictureCache(); |
| 45 proto::RecordingSource proto; |
| 46 source->ToProtobuf(&proto); |
40 | 47 |
41 proto::RecordingSource proto; | 48 source->set_engine_picture_cache(fake_engine_picture_cache.get()); |
42 source->ToProtobuf(&proto, fake_image_serialization_processor.get()); | 49 // Forcefully mark the full RecordingSource for registration to ensure that |
| 50 // all data is made available to the client. |
| 51 source->MarkForRegistration(); |
43 | 52 |
44 FakeRecordingSource new_source; | 53 FakeRecordingSource new_source; |
45 new_source.FromProtobuf(proto, fake_image_serialization_processor.get()); | 54 new_source.set_client_picture_cache(fake_client_picture_cache.get()); |
| 55 new_source.FromProtobuf(proto); |
46 | 56 |
47 EXPECT_TRUE(source->EqualsTo(new_source)); | 57 EXPECT_TRUE(source->EqualsTo(new_source)); |
48 } | 58 } |
49 | 59 |
50 TEST(RecordingSourceTest, TestNullDisplayListSerialization) { | 60 TEST(RecordingSourceTest, TestNullDisplayListSerialization) { |
51 gfx::Rect recorded_viewport(0, 0, 256, 256); | 61 gfx::Rect recorded_viewport(0, 0, 256, 256); |
52 | 62 |
53 std::unique_ptr<FakeRecordingSource> recording_source = | 63 std::unique_ptr<FakeRecordingSource> recording_source = |
54 CreateRecordingSource(recorded_viewport); | 64 CreateRecordingSource(recorded_viewport); |
55 recording_source->SetDisplayListUsesCachedPicture(false); | 65 recording_source->SetDisplayListUsesCachedPicture(false); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 &images); | 436 &images); |
427 EXPECT_EQ(3u, images.size()); | 437 EXPECT_EQ(3u, images.size()); |
428 EXPECT_TRUE(images[0].image() == discardable_image[0][0]); | 438 EXPECT_TRUE(images[0].image() == discardable_image[0][0]); |
429 EXPECT_TRUE(images[1].image() == discardable_image[0][1]); | 439 EXPECT_TRUE(images[1].image() == discardable_image[0][1]); |
430 EXPECT_TRUE(images[2].image() == discardable_image[1][1]); | 440 EXPECT_TRUE(images[2].image() == discardable_image[1][1]); |
431 } | 441 } |
432 } | 442 } |
433 | 443 |
434 } // namespace | 444 } // namespace |
435 } // namespace cc | 445 } // namespace cc |
OLD | NEW |