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

Side by Side Diff: cc/tiles/picture_layer_tiling_set_unittest.cc

Issue 1837263005: cc: Rename DisplayListRasterSource to just RasterSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/tiles/picture_layer_tiling_set.cc ('k') | cc/tiles/picture_layer_tiling_unittest.cc » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/tiles/picture_layer_tiling_set.h" 5 #include "cc/tiles/picture_layer_tiling_set.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "cc/resources/resource_provider.h" 10 #include "cc/resources/resource_provider.h"
11 #include "cc/test/fake_display_list_raster_source.h"
12 #include "cc/test/fake_output_surface.h" 11 #include "cc/test/fake_output_surface.h"
13 #include "cc/test/fake_output_surface_client.h" 12 #include "cc/test/fake_output_surface_client.h"
14 #include "cc/test/fake_picture_layer_tiling_client.h" 13 #include "cc/test/fake_picture_layer_tiling_client.h"
14 #include "cc/test/fake_raster_source.h"
15 #include "cc/test/fake_resource_provider.h" 15 #include "cc/test/fake_resource_provider.h"
16 #include "cc/test/test_shared_bitmap_manager.h" 16 #include "cc/test/test_shared_bitmap_manager.h"
17 #include "cc/trees/layer_tree_settings.h" 17 #include "cc/trees/layer_tree_settings.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/gfx/geometry/size_conversions.h" 19 #include "ui/gfx/geometry/size_conversions.h"
20 20
21 namespace cc { 21 namespace cc {
22 namespace { 22 namespace {
23 23
24 scoped_ptr<PictureLayerTilingSet> CreateTilingSet( 24 scoped_ptr<PictureLayerTilingSet> CreateTilingSet(
25 PictureLayerTilingClient* client) { 25 PictureLayerTilingClient* client) {
26 LayerTreeSettings defaults; 26 LayerTreeSettings defaults;
27 return PictureLayerTilingSet::Create( 27 return PictureLayerTilingSet::Create(
28 ACTIVE_TREE, client, defaults.tiling_interest_area_padding, 28 ACTIVE_TREE, client, defaults.tiling_interest_area_padding,
29 defaults.skewport_target_time_in_seconds, 29 defaults.skewport_target_time_in_seconds,
30 defaults.skewport_extrapolation_limit_in_content_pixels); 30 defaults.skewport_extrapolation_limit_in_content_pixels);
31 } 31 }
32 32
33 TEST(PictureLayerTilingSetTest, NoResources) { 33 TEST(PictureLayerTilingSetTest, NoResources) {
34 FakePictureLayerTilingClient client; 34 FakePictureLayerTilingClient client;
35 gfx::Size layer_bounds(1000, 800); 35 gfx::Size layer_bounds(1000, 800);
36 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); 36 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client);
37 client.SetTileSize(gfx::Size(256, 256)); 37 client.SetTileSize(gfx::Size(256, 256));
38 38
39 scoped_refptr<FakeDisplayListRasterSource> raster_source = 39 scoped_refptr<FakeRasterSource> raster_source =
40 FakeDisplayListRasterSource::CreateEmpty(layer_bounds); 40 FakeRasterSource::CreateEmpty(layer_bounds);
41 41
42 set->AddTiling(1.0, raster_source); 42 set->AddTiling(1.0, raster_source);
43 set->AddTiling(1.5, raster_source); 43 set->AddTiling(1.5, raster_source);
44 set->AddTiling(2.0, raster_source); 44 set->AddTiling(2.0, raster_source);
45 45
46 float contents_scale = 2.0; 46 float contents_scale = 2.0;
47 gfx::Size content_bounds( 47 gfx::Size content_bounds(
48 gfx::ScaleToCeiledSize(layer_bounds, contents_scale)); 48 gfx::ScaleToCeiledSize(layer_bounds, contents_scale));
49 gfx::Rect content_rect(content_bounds); 49 gfx::Rect content_rect(content_bounds);
50 50
(...skipping 16 matching lines...) Expand all
67 FakePictureLayerTilingClient client; 67 FakePictureLayerTilingClient client;
68 gfx::Size layer_bounds(10, 10); 68 gfx::Size layer_bounds(10, 10);
69 PictureLayerTilingSet::TilingRange higher_than_high_res_range(0, 0); 69 PictureLayerTilingSet::TilingRange higher_than_high_res_range(0, 0);
70 PictureLayerTilingSet::TilingRange high_res_range(0, 0); 70 PictureLayerTilingSet::TilingRange high_res_range(0, 0);
71 PictureLayerTilingSet::TilingRange between_high_and_low_res_range(0, 0); 71 PictureLayerTilingSet::TilingRange between_high_and_low_res_range(0, 0);
72 PictureLayerTilingSet::TilingRange low_res_range(0, 0); 72 PictureLayerTilingSet::TilingRange low_res_range(0, 0);
73 PictureLayerTilingSet::TilingRange lower_than_low_res_range(0, 0); 73 PictureLayerTilingSet::TilingRange lower_than_low_res_range(0, 0);
74 PictureLayerTiling* high_res_tiling; 74 PictureLayerTiling* high_res_tiling;
75 PictureLayerTiling* low_res_tiling; 75 PictureLayerTiling* low_res_tiling;
76 76
77 scoped_refptr<FakeDisplayListRasterSource> raster_source = 77 scoped_refptr<FakeRasterSource> raster_source =
78 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 78 FakeRasterSource::CreateFilled(layer_bounds);
79 79
80 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); 80 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client);
81 set->AddTiling(2.0, raster_source); 81 set->AddTiling(2.0, raster_source);
82 high_res_tiling = set->AddTiling(1.0, raster_source); 82 high_res_tiling = set->AddTiling(1.0, raster_source);
83 high_res_tiling->set_resolution(HIGH_RESOLUTION); 83 high_res_tiling->set_resolution(HIGH_RESOLUTION);
84 set->AddTiling(0.5, raster_source); 84 set->AddTiling(0.5, raster_source);
85 low_res_tiling = set->AddTiling(0.25, raster_source); 85 low_res_tiling = set->AddTiling(0.25, raster_source);
86 low_res_tiling->set_resolution(LOW_RESOLUTION); 86 low_res_tiling->set_resolution(LOW_RESOLUTION);
87 set->AddTiling(0.125, raster_source); 87 set->AddTiling(0.125, raster_source);
88 88
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 218 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
219 new TestSharedBitmapManager()); 219 new TestSharedBitmapManager());
220 scoped_ptr<ResourceProvider> resource_provider = 220 scoped_ptr<ResourceProvider> resource_provider =
221 FakeResourceProvider::Create(output_surface.get(), 221 FakeResourceProvider::Create(output_surface.get(),
222 shared_bitmap_manager.get()); 222 shared_bitmap_manager.get());
223 223
224 FakePictureLayerTilingClient client(resource_provider.get()); 224 FakePictureLayerTilingClient client(resource_provider.get());
225 client.SetTileSize(gfx::Size(256, 256)); 225 client.SetTileSize(gfx::Size(256, 256));
226 gfx::Size layer_bounds(1000, 800); 226 gfx::Size layer_bounds(1000, 800);
227 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); 227 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client);
228 scoped_refptr<FakeDisplayListRasterSource> raster_source = 228 scoped_refptr<FakeRasterSource> raster_source =
229 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 229 FakeRasterSource::CreateFilled(layer_bounds);
230 230
231 float scale = min_scale; 231 float scale = min_scale;
232 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { 232 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) {
233 PictureLayerTiling* tiling = set->AddTiling(scale, raster_source); 233 PictureLayerTiling* tiling = set->AddTiling(scale, raster_source);
234 tiling->set_resolution(HIGH_RESOLUTION); 234 tiling->set_resolution(HIGH_RESOLUTION);
235 tiling->CreateAllTilesForTesting(); 235 tiling->CreateAllTilesForTesting();
236 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); 236 std::vector<Tile*> tiles = tiling->AllTilesForTesting();
237 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 237 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
238 } 238 }
239 239
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 298
299 TEST(PictureLayerTilingSetTest, TileSizeChange) { 299 TEST(PictureLayerTilingSetTest, TileSizeChange) {
300 FakePictureLayerTilingClient pending_client; 300 FakePictureLayerTilingClient pending_client;
301 FakePictureLayerTilingClient active_client; 301 FakePictureLayerTilingClient active_client;
302 scoped_ptr<PictureLayerTilingSet> pending_set = PictureLayerTilingSet::Create( 302 scoped_ptr<PictureLayerTilingSet> pending_set = PictureLayerTilingSet::Create(
303 PENDING_TREE, &pending_client, 1000, 1.f, 1000); 303 PENDING_TREE, &pending_client, 1000, 1.f, 1000);
304 scoped_ptr<PictureLayerTilingSet> active_set = PictureLayerTilingSet::Create( 304 scoped_ptr<PictureLayerTilingSet> active_set = PictureLayerTilingSet::Create(
305 ACTIVE_TREE, &active_client, 1000, 1.f, 1000); 305 ACTIVE_TREE, &active_client, 1000, 1.f, 1000);
306 306
307 gfx::Size layer_bounds(100, 100); 307 gfx::Size layer_bounds(100, 100);
308 scoped_refptr<FakeDisplayListRasterSource> raster_source = 308 scoped_refptr<FakeRasterSource> raster_source =
309 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 309 FakeRasterSource::CreateFilled(layer_bounds);
310 310
311 gfx::Size tile_size1(10, 10); 311 gfx::Size tile_size1(10, 10);
312 gfx::Size tile_size2(30, 30); 312 gfx::Size tile_size2(30, 30);
313 gfx::Size tile_size3(20, 20); 313 gfx::Size tile_size3(20, 20);
314 314
315 pending_client.SetTileSize(tile_size1); 315 pending_client.SetTileSize(tile_size1);
316 pending_set->AddTiling(1.f, raster_source); 316 pending_set->AddTiling(1.f, raster_source);
317 // New tilings get the correct tile size. 317 // New tilings get the correct tile size.
318 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size()); 318 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size());
319 319
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 405
406 TEST(PictureLayerTilingSetTest, MaxContentScale) { 406 TEST(PictureLayerTilingSetTest, MaxContentScale) {
407 FakePictureLayerTilingClient pending_client; 407 FakePictureLayerTilingClient pending_client;
408 FakePictureLayerTilingClient active_client; 408 FakePictureLayerTilingClient active_client;
409 scoped_ptr<PictureLayerTilingSet> pending_set = PictureLayerTilingSet::Create( 409 scoped_ptr<PictureLayerTilingSet> pending_set = PictureLayerTilingSet::Create(
410 PENDING_TREE, &pending_client, 1000, 1.f, 1000); 410 PENDING_TREE, &pending_client, 1000, 1.f, 1000);
411 scoped_ptr<PictureLayerTilingSet> active_set = PictureLayerTilingSet::Create( 411 scoped_ptr<PictureLayerTilingSet> active_set = PictureLayerTilingSet::Create(
412 ACTIVE_TREE, &active_client, 1000, 1.f, 1000); 412 ACTIVE_TREE, &active_client, 1000, 1.f, 1000);
413 413
414 gfx::Size layer_bounds(100, 105); 414 gfx::Size layer_bounds(100, 105);
415 scoped_refptr<FakeDisplayListRasterSource> raster_source = 415 scoped_refptr<FakeRasterSource> raster_source =
416 FakeDisplayListRasterSource::CreateEmpty(layer_bounds); 416 FakeRasterSource::CreateEmpty(layer_bounds);
417 417
418 // Tilings can be added of any scale, the tiling client can controls this. 418 // Tilings can be added of any scale, the tiling client can controls this.
419 pending_set->AddTiling(1.f, raster_source); 419 pending_set->AddTiling(1.f, raster_source);
420 pending_set->AddTiling(2.f, raster_source); 420 pending_set->AddTiling(2.f, raster_source);
421 pending_set->AddTiling(3.f, raster_source); 421 pending_set->AddTiling(3.f, raster_source);
422 422
423 // Set some expected things for the tiling set to function. 423 // Set some expected things for the tiling set to function.
424 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); 424 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION);
425 active_client.set_twin_tiling_set(pending_set.get()); 425 active_client.set_twin_tiling_set(pending_set.get());
426 426
(...skipping 24 matching lines...) Expand all
451 451
452 // Clone from the pending to the active tree with the same max content size. 452 // Clone from the pending to the active tree with the same max content size.
453 active_set->UpdateTilingsToCurrentRasterSourceForActivation( 453 active_set->UpdateTilingsToCurrentRasterSourceForActivation(
454 raster_source.get(), pending_set.get(), Region(), 1.f, max_content_scale); 454 raster_source.get(), pending_set.get(), Region(), 1.f, max_content_scale);
455 // All the tilings are on the active tree. 455 // All the tilings are on the active tree.
456 EXPECT_EQ(2u, active_set->num_tilings()); 456 EXPECT_EQ(2u, active_set->num_tilings());
457 } 457 }
458 458
459 } // namespace 459 } // namespace
460 } // namespace cc 460 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/picture_layer_tiling_set.cc ('k') | cc/tiles/picture_layer_tiling_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698