Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: cc/playback/recording_source_unittest.cc

Issue 1982893002: [blimp] Add SkPicture caching support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from vmpstr, including adding //cc/blimp Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/playback/recording_source.cc ('k') | cc/playback/transform_display_item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_client_picture_cache.h"
11 #include "cc/test/fake_content_layer_client.h" 12 #include "cc/test/fake_content_layer_client.h"
13 #include "cc/test/fake_engine_picture_cache.h"
12 #include "cc/test/fake_image_serialization_processor.h" 14 #include "cc/test/fake_image_serialization_processor.h"
13 #include "cc/test/fake_recording_source.h" 15 #include "cc/test/fake_recording_source.h"
14 #include "cc/test/skia_common.h" 16 #include "cc/test/skia_common.h"
17 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/skia/include/core/SkRefCnt.h" 19 #include "third_party/skia/include/core/SkRefCnt.h"
17 20
18 namespace cc { 21 namespace cc {
19 namespace { 22 namespace {
20 23
21 std::unique_ptr<FakeRecordingSource> CreateRecordingSource( 24 std::unique_ptr<FakeRecordingSource> CreateRecordingSource(
22 const gfx::Rect& viewport) { 25 const gfx::Rect& viewport) {
23 gfx::Rect layer_rect(viewport.right(), viewport.bottom()); 26 gfx::Rect layer_rect(viewport.right(), viewport.bottom());
24 std::unique_ptr<FakeRecordingSource> recording_source = 27 std::unique_ptr<FakeRecordingSource> recording_source =
25 FakeRecordingSource::CreateRecordingSource(viewport, layer_rect.size()); 28 FakeRecordingSource::CreateRecordingSource(viewport, layer_rect.size());
26 return recording_source; 29 return recording_source;
27 } 30 }
28 31
29 scoped_refptr<RasterSource> CreateRasterSource( 32 scoped_refptr<RasterSource> CreateRasterSource(
30 FakeRecordingSource* recording_source) { 33 FakeRecordingSource* recording_source) {
31 bool can_use_lcd_text = true; 34 bool can_use_lcd_text = true;
32 return RasterSource::CreateFromRecordingSource(recording_source, 35 return RasterSource::CreateFromRecordingSource(recording_source,
33 can_use_lcd_text); 36 can_use_lcd_text);
34 } 37 }
35 38
36 void ValidateRecordingSourceSerialization(FakeRecordingSource* source) { 39 void ValidateRecordingSourceSerialization(FakeRecordingSource* source) {
37 std::unique_ptr<FakeImageSerializationProcessor> 40 std::unique_ptr<FakeImageSerializationProcessor>
38 fake_image_serialization_processor = 41 fake_image_serialization_processor =
39 base::WrapUnique(new FakeImageSerializationProcessor); 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());
40 52
41 proto::RecordingSource proto; 53 proto::RecordingSource proto;
42 source->ToProtobuf(&proto, fake_image_serialization_processor.get()); 54 source->ToProtobuf(&proto);
43 55
56 std::vector<uint32_t> actual_picture_ids;
44 FakeRecordingSource new_source; 57 FakeRecordingSource new_source;
45 new_source.FromProtobuf(proto, fake_image_serialization_processor.get()); 58 new_source.FromProtobuf(proto, fake_client_picture_cache.get(),
59 &actual_picture_ids);
60
61 EXPECT_THAT(actual_picture_ids,
62 testing::UnorderedElementsAreArray(
63 fake_engine_picture_cache_ptr->GetAllUsedPictureIds()));
46 64
47 EXPECT_TRUE(source->EqualsTo(new_source)); 65 EXPECT_TRUE(source->EqualsTo(new_source));
48 } 66 }
49 67
50 TEST(RecordingSourceTest, TestNullDisplayListSerialization) { 68 TEST(RecordingSourceTest, TestNullDisplayListSerialization) {
51 gfx::Rect recorded_viewport(0, 0, 256, 256); 69 gfx::Rect recorded_viewport(0, 0, 256, 256);
52 70
53 std::unique_ptr<FakeRecordingSource> recording_source = 71 std::unique_ptr<FakeRecordingSource> recording_source =
54 CreateRecordingSource(recorded_viewport); 72 CreateRecordingSource(recorded_viewport);
55 recording_source->SetDisplayListUsesCachedPicture(false); 73 recording_source->SetDisplayListUsesCachedPicture(false);
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 &images); 444 &images);
427 EXPECT_EQ(3u, images.size()); 445 EXPECT_EQ(3u, images.size());
428 EXPECT_TRUE(images[0].image() == discardable_image[0][0]); 446 EXPECT_TRUE(images[0].image() == discardable_image[0][0]);
429 EXPECT_TRUE(images[1].image() == discardable_image[0][1]); 447 EXPECT_TRUE(images[1].image() == discardable_image[0][1]);
430 EXPECT_TRUE(images[2].image() == discardable_image[1][1]); 448 EXPECT_TRUE(images[2].image() == discardable_image[1][1]);
431 } 449 }
432 } 450 }
433 451
434 } // namespace 452 } // namespace
435 } // namespace cc 453 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/recording_source.cc ('k') | cc/playback/transform_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698