| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 4291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4302 | 4302 |
| 4303 ActivateTree(); | 4303 ActivateTree(); |
| 4304 EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinLayer()); | 4304 EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinLayer()); |
| 4305 | 4305 |
| 4306 // Make an empty pending tree. | 4306 // Make an empty pending tree. |
| 4307 host_impl()->CreatePendingTree(); | 4307 host_impl()->CreatePendingTree(); |
| 4308 host_impl()->pending_tree()->DetachLayers(); | 4308 host_impl()->pending_tree()->DetachLayers(); |
| 4309 EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinLayer()); | 4309 EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinLayer()); |
| 4310 } | 4310 } |
| 4311 | 4311 |
| 4312 void GetClientDataAndUpdateInvalidation(RecordingSource* recording_source, |
| 4313 FakeContentLayerClient* client, |
| 4314 Region invalidation, |
| 4315 gfx::Size layer_bounds) { |
| 4316 gfx::Rect new_recorded_viewport = client->PaintableRegion(); |
| 4317 scoped_refptr<DisplayItemList> display_list = |
| 4318 client->PaintContentsToDisplayList( |
| 4319 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
| 4320 size_t painter_reported_memory_usage = |
| 4321 client->GetApproximateUnsharedMemoryUsage(); |
| 4322 |
| 4323 recording_source->UpdateAndExpandInvalidation(&invalidation, layer_bounds, |
| 4324 new_recorded_viewport); |
| 4325 recording_source->UpdateDisplayItemList(display_list, |
| 4326 painter_reported_memory_usage); |
| 4327 } |
| 4328 |
| 4312 void PictureLayerImplTest::TestQuadsForSolidColor(bool test_for_solid) { | 4329 void PictureLayerImplTest::TestQuadsForSolidColor(bool test_for_solid) { |
| 4313 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 4330 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 4314 | 4331 |
| 4315 gfx::Size tile_size(100, 100); | 4332 gfx::Size tile_size(100, 100); |
| 4316 gfx::Size layer_bounds(200, 200); | 4333 gfx::Size layer_bounds(200, 200); |
| 4317 gfx::Rect layer_rect(layer_bounds); | 4334 gfx::Rect layer_rect(layer_bounds); |
| 4318 | 4335 |
| 4319 FakeContentLayerClient client; | 4336 FakeContentLayerClient client; |
| 4320 client.set_bounds(layer_bounds); | 4337 client.set_bounds(layer_bounds); |
| 4321 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 4338 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 4322 FakeLayerTreeHostClient host_client; | 4339 FakeLayerTreeHostClient host_client; |
| 4323 TestTaskGraphRunner task_graph_runner; | 4340 TestTaskGraphRunner task_graph_runner; |
| 4324 std::unique_ptr<FakeLayerTreeHost> host = | 4341 std::unique_ptr<FakeLayerTreeHost> host = |
| 4325 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); | 4342 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); |
| 4326 host->SetRootLayer(layer); | 4343 host->SetRootLayer(layer); |
| 4327 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4344 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4328 | 4345 |
| 4329 int frame_number = 0; | |
| 4330 | |
| 4331 client.set_fill_with_nonsolid_color(!test_for_solid); | 4346 client.set_fill_with_nonsolid_color(!test_for_solid); |
| 4332 | 4347 |
| 4333 Region invalidation(layer_rect); | 4348 Region invalidation(layer_rect); |
| 4334 recording_source->UpdateAndExpandInvalidation( | 4349 |
| 4335 &client, &invalidation, layer_bounds, frame_number++, | 4350 GetClientDataAndUpdateInvalidation(recording_source, &client, invalidation, |
| 4336 RecordingSource::RECORD_NORMALLY); | 4351 layer_bounds); |
| 4337 | 4352 |
| 4338 scoped_refptr<RasterSource> pending_raster_source = | 4353 scoped_refptr<RasterSource> pending_raster_source = |
| 4339 recording_source->CreateRasterSource(true); | 4354 recording_source->CreateRasterSource(true); |
| 4340 | 4355 |
| 4341 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 4356 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
| 4342 ActivateTree(); | 4357 ActivateTree(); |
| 4343 | 4358 |
| 4344 if (test_for_solid) { | 4359 if (test_for_solid) { |
| 4345 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 4360 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 4346 } else { | 4361 } else { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4382 FakeContentLayerClient client; | 4397 FakeContentLayerClient client; |
| 4383 client.set_bounds(layer_bounds); | 4398 client.set_bounds(layer_bounds); |
| 4384 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 4399 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 4385 FakeLayerTreeHostClient host_client; | 4400 FakeLayerTreeHostClient host_client; |
| 4386 TestTaskGraphRunner task_graph_runner; | 4401 TestTaskGraphRunner task_graph_runner; |
| 4387 std::unique_ptr<FakeLayerTreeHost> host = | 4402 std::unique_ptr<FakeLayerTreeHost> host = |
| 4388 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); | 4403 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); |
| 4389 host->SetRootLayer(layer); | 4404 host->SetRootLayer(layer); |
| 4390 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4405 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4391 | 4406 |
| 4392 int frame_number = 0; | |
| 4393 | |
| 4394 client.set_fill_with_nonsolid_color(true); | 4407 client.set_fill_with_nonsolid_color(true); |
| 4395 | 4408 |
| 4396 recording_source->SetNeedsDisplayRect(layer_rect); | 4409 recording_source->SetNeedsDisplayRect(layer_rect); |
| 4397 Region invalidation1; | 4410 Region invalidation1; |
| 4398 recording_source->UpdateAndExpandInvalidation( | 4411 |
| 4399 &client, &invalidation1, layer_bounds, frame_number++, | 4412 GetClientDataAndUpdateInvalidation(recording_source, &client, invalidation1, |
| 4400 RecordingSource::RECORD_NORMALLY); | 4413 layer_bounds); |
| 4401 | 4414 |
| 4402 scoped_refptr<RasterSource> raster_source1 = | 4415 scoped_refptr<RasterSource> raster_source1 = |
| 4403 recording_source->CreateRasterSource(true); | 4416 recording_source->CreateRasterSource(true); |
| 4404 | 4417 |
| 4405 SetupPendingTree(raster_source1); | 4418 SetupPendingTree(raster_source1); |
| 4406 ActivateTree(); | 4419 ActivateTree(); |
| 4407 bool update_lcd_text = false; | 4420 bool update_lcd_text = false; |
| 4408 host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); | 4421 host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 4409 | 4422 |
| 4410 // We've started with a solid layer that contains some tilings. | 4423 // We've started with a solid layer that contains some tilings. |
| 4411 ASSERT_TRUE(active_layer()->tilings()); | 4424 ASSERT_TRUE(active_layer()->tilings()); |
| 4412 EXPECT_NE(0u, active_layer()->tilings()->num_tilings()); | 4425 EXPECT_NE(0u, active_layer()->tilings()->num_tilings()); |
| 4413 | 4426 |
| 4414 client.set_fill_with_nonsolid_color(false); | 4427 client.set_fill_with_nonsolid_color(false); |
| 4415 | 4428 |
| 4416 recording_source->SetNeedsDisplayRect(layer_rect); | 4429 recording_source->SetNeedsDisplayRect(layer_rect); |
| 4417 Region invalidation2; | 4430 Region invalidation2; |
| 4418 recording_source->UpdateAndExpandInvalidation( | 4431 |
| 4419 &client, &invalidation2, layer_bounds, frame_number++, | 4432 GetClientDataAndUpdateInvalidation(recording_source, &client, invalidation2, |
| 4420 RecordingSource::RECORD_NORMALLY); | 4433 layer_bounds); |
| 4421 | 4434 |
| 4422 scoped_refptr<RasterSource> raster_source2 = | 4435 scoped_refptr<RasterSource> raster_source2 = |
| 4423 recording_source->CreateRasterSource(true); | 4436 recording_source->CreateRasterSource(true); |
| 4424 | 4437 |
| 4425 SetupPendingTree(raster_source2); | 4438 SetupPendingTree(raster_source2); |
| 4426 ActivateTree(); | 4439 ActivateTree(); |
| 4427 | 4440 |
| 4428 // We've switched to a solid color, so we should end up with no tilings. | 4441 // We've switched to a solid color, so we should end up with no tilings. |
| 4429 ASSERT_TRUE(active_layer()->tilings()); | 4442 ASSERT_TRUE(active_layer()->tilings()); |
| 4430 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 4443 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5003 EXPECT_FLOAT_EQ(expected_contents_scale, | 5016 EXPECT_FLOAT_EQ(expected_contents_scale, |
| 5004 pending_layer_ptr->picture_layer_tiling_set() | 5017 pending_layer_ptr->picture_layer_tiling_set() |
| 5005 ->FindTilingWithResolution(HIGH_RESOLUTION) | 5018 ->FindTilingWithResolution(HIGH_RESOLUTION) |
| 5006 ->contents_scale()) | 5019 ->contents_scale()) |
| 5007 << "ideal_contents_scale: " << ideal_contents_scale; | 5020 << "ideal_contents_scale: " << ideal_contents_scale; |
| 5008 } | 5021 } |
| 5009 } | 5022 } |
| 5010 | 5023 |
| 5011 } // namespace | 5024 } // namespace |
| 5012 } // namespace cc | 5025 } // namespace cc |
| OLD | NEW |