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