Chromium Code Reviews| 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 4308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4319 FakeContentLayerClient client; | 4319 FakeContentLayerClient client; |
| 4320 client.set_bounds(layer_bounds); | 4320 client.set_bounds(layer_bounds); |
| 4321 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 4321 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 4322 FakeLayerTreeHostClient host_client; | 4322 FakeLayerTreeHostClient host_client; |
| 4323 TestTaskGraphRunner task_graph_runner; | 4323 TestTaskGraphRunner task_graph_runner; |
| 4324 std::unique_ptr<FakeLayerTreeHost> host = | 4324 std::unique_ptr<FakeLayerTreeHost> host = |
| 4325 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); | 4325 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); |
| 4326 host->SetRootLayer(layer); | 4326 host->SetRootLayer(layer); |
| 4327 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4327 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4328 | 4328 |
| 4329 int frame_number = 0; | |
| 4330 | |
| 4331 client.set_fill_with_nonsolid_color(!test_for_solid); | 4329 client.set_fill_with_nonsolid_color(!test_for_solid); |
| 4332 | 4330 |
| 4333 Region invalidation(layer_rect); | 4331 Region invalidation(layer_rect); |
| 4332 | |
| 4333 gfx::Rect new_recorded_viewport = client.PaintableRegion(); | |
| 4334 scoped_refptr<DisplayItemList> display_list = | |
| 4335 client.PaintContentsToDisplayList( | |
| 4336 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | |
| 4337 size_t painter_reported_memory_usage = | |
| 4338 client.GetApproximateUnsharedMemoryUsage(); | |
| 4339 | |
| 4334 recording_source->UpdateAndExpandInvalidation( | 4340 recording_source->UpdateAndExpandInvalidation( |
|
vmpstr
2016/07/27 18:18:37
I think it's worth to create a helper function her
Menglin
2016/07/27 19:17:48
yeah i agree
Menglin
2016/07/29 23:50:14
Done.
| |
| 4335 &client, &invalidation, layer_bounds, frame_number++, | 4341 &client, &invalidation, layer_bounds, new_recorded_viewport, display_list, |
| 4336 RecordingSource::RECORD_NORMALLY); | 4342 painter_reported_memory_usage); |
| 4337 | 4343 |
| 4338 scoped_refptr<RasterSource> pending_raster_source = | 4344 scoped_refptr<RasterSource> pending_raster_source = |
| 4339 recording_source->CreateRasterSource(true); | 4345 recording_source->CreateRasterSource(true); |
| 4340 | 4346 |
| 4341 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 4347 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
| 4342 ActivateTree(); | 4348 ActivateTree(); |
| 4343 | 4349 |
| 4344 if (test_for_solid) { | 4350 if (test_for_solid) { |
| 4345 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 4351 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 4346 } else { | 4352 } else { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4382 FakeContentLayerClient client; | 4388 FakeContentLayerClient client; |
| 4383 client.set_bounds(layer_bounds); | 4389 client.set_bounds(layer_bounds); |
| 4384 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 4390 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 4385 FakeLayerTreeHostClient host_client; | 4391 FakeLayerTreeHostClient host_client; |
| 4386 TestTaskGraphRunner task_graph_runner; | 4392 TestTaskGraphRunner task_graph_runner; |
| 4387 std::unique_ptr<FakeLayerTreeHost> host = | 4393 std::unique_ptr<FakeLayerTreeHost> host = |
| 4388 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); | 4394 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); |
| 4389 host->SetRootLayer(layer); | 4395 host->SetRootLayer(layer); |
| 4390 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4396 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4391 | 4397 |
| 4392 int frame_number = 0; | |
| 4393 | |
| 4394 client.set_fill_with_nonsolid_color(true); | 4398 client.set_fill_with_nonsolid_color(true); |
| 4395 | 4399 |
| 4396 recording_source->SetNeedsDisplayRect(layer_rect); | 4400 recording_source->SetNeedsDisplayRect(layer_rect); |
| 4397 Region invalidation1; | 4401 Region invalidation1; |
| 4402 | |
| 4403 gfx::Rect new_recorded_viewport = client.PaintableRegion(); | |
| 4404 scoped_refptr<DisplayItemList> display_list = | |
| 4405 client.PaintContentsToDisplayList( | |
| 4406 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | |
| 4407 size_t painter_reported_memory_usage = | |
| 4408 client.GetApproximateUnsharedMemoryUsage(); | |
| 4398 recording_source->UpdateAndExpandInvalidation( | 4409 recording_source->UpdateAndExpandInvalidation( |
| 4399 &client, &invalidation1, layer_bounds, frame_number++, | 4410 &client, &invalidation1, layer_bounds, new_recorded_viewport, |
| 4400 RecordingSource::RECORD_NORMALLY); | 4411 display_list, painter_reported_memory_usage); |
| 4401 | 4412 |
| 4402 scoped_refptr<RasterSource> raster_source1 = | 4413 scoped_refptr<RasterSource> raster_source1 = |
| 4403 recording_source->CreateRasterSource(true); | 4414 recording_source->CreateRasterSource(true); |
| 4404 | 4415 |
| 4405 SetupPendingTree(raster_source1); | 4416 SetupPendingTree(raster_source1); |
| 4406 ActivateTree(); | 4417 ActivateTree(); |
| 4407 bool update_lcd_text = false; | 4418 bool update_lcd_text = false; |
| 4408 host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); | 4419 host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 4409 | 4420 |
| 4410 // We've started with a solid layer that contains some tilings. | 4421 // We've started with a solid layer that contains some tilings. |
| 4411 ASSERT_TRUE(active_layer()->tilings()); | 4422 ASSERT_TRUE(active_layer()->tilings()); |
| 4412 EXPECT_NE(0u, active_layer()->tilings()->num_tilings()); | 4423 EXPECT_NE(0u, active_layer()->tilings()->num_tilings()); |
| 4413 | 4424 |
| 4414 client.set_fill_with_nonsolid_color(false); | 4425 client.set_fill_with_nonsolid_color(false); |
| 4415 | 4426 |
| 4416 recording_source->SetNeedsDisplayRect(layer_rect); | 4427 recording_source->SetNeedsDisplayRect(layer_rect); |
| 4417 Region invalidation2; | 4428 Region invalidation2; |
| 4429 | |
| 4430 new_recorded_viewport = client.PaintableRegion(); | |
| 4431 display_list = client.PaintContentsToDisplayList( | |
| 4432 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | |
| 4433 painter_reported_memory_usage = client.GetApproximateUnsharedMemoryUsage(); | |
| 4434 | |
| 4418 recording_source->UpdateAndExpandInvalidation( | 4435 recording_source->UpdateAndExpandInvalidation( |
| 4419 &client, &invalidation2, layer_bounds, frame_number++, | 4436 &client, &invalidation2, layer_bounds, new_recorded_viewport, |
| 4420 RecordingSource::RECORD_NORMALLY); | 4437 display_list, painter_reported_memory_usage); |
| 4421 | 4438 |
| 4422 scoped_refptr<RasterSource> raster_source2 = | 4439 scoped_refptr<RasterSource> raster_source2 = |
| 4423 recording_source->CreateRasterSource(true); | 4440 recording_source->CreateRasterSource(true); |
| 4424 | 4441 |
| 4425 SetupPendingTree(raster_source2); | 4442 SetupPendingTree(raster_source2); |
| 4426 ActivateTree(); | 4443 ActivateTree(); |
| 4427 | 4444 |
| 4428 // We've switched to a solid color, so we should end up with no tilings. | 4445 // We've switched to a solid color, so we should end up with no tilings. |
| 4429 ASSERT_TRUE(active_layer()->tilings()); | 4446 ASSERT_TRUE(active_layer()->tilings()); |
| 4430 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 4447 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, | 5020 EXPECT_FLOAT_EQ(expected_contents_scale, |
| 5004 pending_layer_ptr->picture_layer_tiling_set() | 5021 pending_layer_ptr->picture_layer_tiling_set() |
| 5005 ->FindTilingWithResolution(HIGH_RESOLUTION) | 5022 ->FindTilingWithResolution(HIGH_RESOLUTION) |
| 5006 ->contents_scale()) | 5023 ->contents_scale()) |
| 5007 << "ideal_contents_scale: " << ideal_contents_scale; | 5024 << "ideal_contents_scale: " << ideal_contents_scale; |
| 5008 } | 5025 } |
| 5009 } | 5026 } |
| 5010 | 5027 |
| 5011 } // namespace | 5028 } // namespace |
| 5012 } // namespace cc | 5029 } // namespace cc |
| OLD | NEW |