| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 | 31 |
| 32 scoped_refptr<RasterSource> CreateRasterSource( | 32 scoped_refptr<RasterSource> CreateRasterSource( |
| 33 FakeRecordingSource* recording_source) { | 33 FakeRecordingSource* recording_source) { |
| 34 bool can_use_lcd_text = true; | 34 bool can_use_lcd_text = true; |
| 35 return RasterSource::CreateFromRecordingSource(recording_source, | 35 return RasterSource::CreateFromRecordingSource(recording_source, |
| 36 can_use_lcd_text); | 36 can_use_lcd_text); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void ValidateRecordingSourceSerialization(FakeRecordingSource* source) { | 39 void ValidateRecordingSourceSerialization(FakeRecordingSource* source) { |
| 40 std::unique_ptr<FakeImageSerializationProcessor> | |
| 41 fake_image_serialization_processor = | |
| 42 base::WrapUnique(new FakeImageSerializationProcessor); | |
| 43 std::unique_ptr<EnginePictureCache> fake_engine_picture_cache = | |
| 44 fake_image_serialization_processor->CreateEnginePictureCache(); | |
| 45 FakeEnginePictureCache* fake_engine_picture_cache_ptr = | |
| 46 static_cast<FakeEnginePictureCache*>(fake_engine_picture_cache.get()); | |
| 47 std::unique_ptr<ClientPictureCache> fake_client_picture_cache = | |
| 48 fake_image_serialization_processor->CreateClientPictureCache(); | |
| 49 | |
| 50 fake_engine_picture_cache_ptr->MarkAllSkPicturesAsUsed( | |
| 51 source->GetDisplayItemList()); | |
| 52 | |
| 53 proto::RecordingSource proto; | 40 proto::RecordingSource proto; |
| 54 source->ToProtobuf(&proto); | 41 source->ToProtobuf(&proto); |
| 55 | 42 |
| 56 std::vector<uint32_t> actual_picture_ids; | |
| 57 FakeRecordingSource new_source; | 43 FakeRecordingSource new_source; |
| 58 new_source.FromProtobuf(proto, fake_client_picture_cache.get(), | 44 new_source.FromProtobuf(proto, nullptr); |
| 59 &actual_picture_ids); | |
| 60 | |
| 61 EXPECT_THAT(actual_picture_ids, | |
| 62 testing::UnorderedElementsAreArray( | |
| 63 fake_engine_picture_cache_ptr->GetAllUsedPictureIds())); | |
| 64 | 45 |
| 65 EXPECT_TRUE(source->EqualsTo(new_source)); | 46 EXPECT_TRUE(source->EqualsTo(new_source)); |
| 66 } | 47 } |
| 67 | 48 |
| 68 TEST(RecordingSourceTest, TestNullDisplayListSerialization) { | 49 TEST(RecordingSourceTest, TestNullDisplayListSerialization) { |
| 69 gfx::Rect recorded_viewport(0, 0, 256, 256); | 50 gfx::Rect recorded_viewport(0, 0, 256, 256); |
| 70 | 51 |
| 71 std::unique_ptr<FakeRecordingSource> recording_source = | 52 std::unique_ptr<FakeRecordingSource> recording_source = |
| 72 CreateRecordingSource(recorded_viewport); | 53 CreateRecordingSource(recorded_viewport); |
| 73 recording_source->SetDisplayListUsesCachedPicture(false); | 54 recording_source->SetDisplayListUsesCachedPicture(false); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 &images); | 425 &images); |
| 445 EXPECT_EQ(3u, images.size()); | 426 EXPECT_EQ(3u, images.size()); |
| 446 EXPECT_TRUE(images[0].image() == discardable_image[0][0]); | 427 EXPECT_TRUE(images[0].image() == discardable_image[0][0]); |
| 447 EXPECT_TRUE(images[1].image() == discardable_image[0][1]); | 428 EXPECT_TRUE(images[1].image() == discardable_image[0][1]); |
| 448 EXPECT_TRUE(images[2].image() == discardable_image[1][1]); | 429 EXPECT_TRUE(images[2].image() == discardable_image[1][1]); |
| 449 } | 430 } |
| 450 } | 431 } |
| 451 | 432 |
| 452 } // namespace | 433 } // namespace |
| 453 } // namespace cc | 434 } // namespace cc |
| OLD | NEW |