| 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.h" | 5 #include "cc/layers/picture_layer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 TestSharedBitmapManager shared_bitmap_manager; | 280 TestSharedBitmapManager shared_bitmap_manager; |
| 281 std::unique_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); | 281 std::unique_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); |
| 282 LayerTreeSettings layer_tree_settings = LayerTreeSettings(); | 282 LayerTreeSettings layer_tree_settings = LayerTreeSettings(); |
| 283 layer_tree_settings.image_decode_tasks_enabled = true; | 283 layer_tree_settings.image_decode_tasks_enabled = true; |
| 284 FakeLayerTreeHostImpl host_impl(layer_tree_settings, | 284 FakeLayerTreeHostImpl host_impl(layer_tree_settings, |
| 285 &impl_task_runner_provider, | 285 &impl_task_runner_provider, |
| 286 &shared_bitmap_manager, &task_graph_runner); | 286 &shared_bitmap_manager, &task_graph_runner); |
| 287 host_impl.SetVisible(true); | 287 host_impl.SetVisible(true); |
| 288 host_impl.InitializeRenderer(output_surface.get()); | 288 host_impl.InitializeRenderer(output_surface.get()); |
| 289 host_impl.CreatePendingTree(); | 289 host_impl.CreatePendingTree(); |
| 290 host_impl.pending_tree()->SetRootLayer( | 290 host_impl.pending_tree()->SetRootLayerForTesting( |
| 291 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); | 291 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); |
| 292 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( | 292 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( |
| 293 host_impl.pending_tree()->root_layer()); | 293 host_impl.pending_tree()->root_layer_for_testing()); |
| 294 layer->PushPropertiesTo(layer_impl); | 294 layer->PushPropertiesTo(layer_impl); |
| 295 | 295 |
| 296 EXPECT_EQ(invalidation_bounds, | 296 EXPECT_EQ(invalidation_bounds, |
| 297 layer_impl->GetPendingInvalidation()->bounds()); | 297 layer_impl->GetPendingInvalidation()->bounds()); |
| 298 } | 298 } |
| 299 | 299 |
| 300 TEST(PictureLayerTest, InvalidateRasterWithoutUpdate) { | 300 TEST(PictureLayerTest, InvalidateRasterWithoutUpdate) { |
| 301 gfx::Size layer_size(50, 50); | 301 gfx::Size layer_size(50, 50); |
| 302 FakeContentLayerClient client; | 302 FakeContentLayerClient client; |
| 303 client.set_bounds(layer_size); | 303 client.set_bounds(layer_size); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 322 TestSharedBitmapManager shared_bitmap_manager; | 322 TestSharedBitmapManager shared_bitmap_manager; |
| 323 std::unique_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); | 323 std::unique_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); |
| 324 LayerTreeSettings layer_tree_settings = LayerTreeSettings(); | 324 LayerTreeSettings layer_tree_settings = LayerTreeSettings(); |
| 325 layer_tree_settings.image_decode_tasks_enabled = true; | 325 layer_tree_settings.image_decode_tasks_enabled = true; |
| 326 FakeLayerTreeHostImpl host_impl(layer_tree_settings, | 326 FakeLayerTreeHostImpl host_impl(layer_tree_settings, |
| 327 &impl_task_runner_provider, | 327 &impl_task_runner_provider, |
| 328 &shared_bitmap_manager, &task_graph_runner); | 328 &shared_bitmap_manager, &task_graph_runner); |
| 329 host_impl.SetVisible(true); | 329 host_impl.SetVisible(true); |
| 330 host_impl.InitializeRenderer(output_surface.get()); | 330 host_impl.InitializeRenderer(output_surface.get()); |
| 331 host_impl.CreatePendingTree(); | 331 host_impl.CreatePendingTree(); |
| 332 host_impl.pending_tree()->SetRootLayer( | 332 host_impl.pending_tree()->SetRootLayerForTesting( |
| 333 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); | 333 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); |
| 334 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( | 334 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( |
| 335 host_impl.pending_tree()->root_layer()); | 335 host_impl.pending_tree()->root_layer_for_testing()); |
| 336 layer->PushPropertiesTo(layer_impl); | 336 layer->PushPropertiesTo(layer_impl); |
| 337 | 337 |
| 338 EXPECT_EQ(gfx::Rect(), layer_impl->GetPendingInvalidation()->bounds()); | 338 EXPECT_EQ(gfx::Rect(), layer_impl->GetPendingInvalidation()->bounds()); |
| 339 } | 339 } |
| 340 | 340 |
| 341 TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) { | 341 TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) { |
| 342 gfx::Size layer_size(50, 50); | 342 gfx::Size layer_size(50, 50); |
| 343 FakeContentLayerClient client; | 343 FakeContentLayerClient client; |
| 344 client.set_bounds(layer_size); | 344 client.set_bounds(layer_size); |
| 345 client.add_draw_image(CreateDiscardableImage(layer_size), gfx::Point(), | 345 client.add_draw_image(CreateDiscardableImage(layer_size), gfx::Point(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 369 std::unique_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); | 369 std::unique_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); |
| 370 LayerTreeSettings layer_tree_settings = LayerTreeSettingsForTesting(); | 370 LayerTreeSettings layer_tree_settings = LayerTreeSettingsForTesting(); |
| 371 layer_tree_settings.image_decode_tasks_enabled = true; | 371 layer_tree_settings.image_decode_tasks_enabled = true; |
| 372 FakeLayerTreeHostImpl host_impl(layer_tree_settings, | 372 FakeLayerTreeHostImpl host_impl(layer_tree_settings, |
| 373 &impl_task_runner_provider, | 373 &impl_task_runner_provider, |
| 374 &shared_bitmap_manager, &task_graph_runner); | 374 &shared_bitmap_manager, &task_graph_runner); |
| 375 host_impl.SetVisible(true); | 375 host_impl.SetVisible(true); |
| 376 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); | 376 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); |
| 377 | 377 |
| 378 host_impl.CreatePendingTree(); | 378 host_impl.CreatePendingTree(); |
| 379 host_impl.pending_tree()->SetRootLayer( | 379 host_impl.pending_tree()->SetRootLayerForTesting( |
| 380 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); | 380 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); |
| 381 host_impl.pending_tree()->BuildLayerListForTesting(); | 381 host_impl.pending_tree()->BuildLayerListForTesting(); |
| 382 | 382 |
| 383 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( | 383 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( |
| 384 host_impl.pending_tree()->root_layer()); | 384 host_impl.pending_tree()->root_layer_for_testing()); |
| 385 | 385 |
| 386 layer->PushPropertiesTo(layer_impl); | 386 layer->PushPropertiesTo(layer_impl); |
| 387 | 387 |
| 388 host->CommitComplete(); | 388 host->CommitComplete(); |
| 389 EXPECT_EQ(2, host->source_frame_number()); | 389 EXPECT_EQ(2, host->source_frame_number()); |
| 390 | 390 |
| 391 host_impl.ActivateSyncTree(); | 391 host_impl.ActivateSyncTree(); |
| 392 host_impl.active_tree()->SetRootLayerFromLayerListForTesting(); |
| 392 | 393 |
| 393 // By updating the draw proprties on the active tree, we will set the viewport | 394 // By updating the draw proprties on the active tree, we will set the viewport |
| 394 // rect for tile priorities to something non-empty. | 395 // rect for tile priorities to something non-empty. |
| 395 const bool can_use_lcd_text = false; | 396 const bool can_use_lcd_text = false; |
| 396 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 397 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 397 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 398 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 398 host_impl.active_tree()->UpdateDrawProperties(can_use_lcd_text); | 399 host_impl.active_tree()->UpdateDrawProperties(can_use_lcd_text); |
| 399 | 400 |
| 400 layer->SetBounds(gfx::Size(11, 11)); | 401 layer->SetBounds(gfx::Size(11, 11)); |
| 401 layer->SavePaintProperties(); | 402 layer->SavePaintProperties(); |
| 402 | 403 |
| 403 host_impl.CreatePendingTree(); | 404 host_impl.CreatePendingTree(); |
| 404 layer_impl = static_cast<FakePictureLayerImpl*>( | 405 layer_impl = static_cast<FakePictureLayerImpl*>( |
| 405 host_impl.pending_tree()->root_layer()); | 406 host_impl.pending_tree()->root_layer_for_testing()); |
| 406 | 407 |
| 407 // We should now have invalid contents and should therefore clear the | 408 // We should now have invalid contents and should therefore clear the |
| 408 // recording source. | 409 // recording source. |
| 409 layer->PushPropertiesTo(layer_impl); | 410 layer->PushPropertiesTo(layer_impl); |
| 410 | 411 |
| 411 host_impl.ActivateSyncTree(); | 412 host_impl.ActivateSyncTree(); |
| 412 | 413 |
| 413 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); | 414 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 414 AppendQuadsData data; | 415 AppendQuadsData data; |
| 415 host_impl.active_tree()->root_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 416 host_impl.active_tree()->root_layer_for_testing()->WillDraw( |
| 416 host_impl.active_tree()->root_layer()->AppendQuads(render_pass.get(), &data); | 417 DRAW_MODE_SOFTWARE, nullptr); |
| 417 host_impl.active_tree()->root_layer()->DidDraw(nullptr); | 418 host_impl.active_tree()->root_layer_for_testing()->AppendQuads( |
| 419 render_pass.get(), &data); |
| 420 host_impl.active_tree()->root_layer_for_testing()->DidDraw(nullptr); |
| 418 } | 421 } |
| 419 | 422 |
| 420 TEST(PictureLayerTest, SuitableForGpuRasterization) { | 423 TEST(PictureLayerTest, SuitableForGpuRasterization) { |
| 421 std::unique_ptr<FakeRecordingSource> recording_source_owned( | 424 std::unique_ptr<FakeRecordingSource> recording_source_owned( |
| 422 new FakeRecordingSource); | 425 new FakeRecordingSource); |
| 423 FakeRecordingSource* recording_source = recording_source_owned.get(); | 426 FakeRecordingSource* recording_source = recording_source_owned.get(); |
| 424 | 427 |
| 425 ContentLayerClient* client = EmptyContentLayerClient::GetInstance(); | 428 ContentLayerClient* client = EmptyContentLayerClient::GetInstance(); |
| 426 scoped_refptr<FakePictureLayer> layer = | 429 scoped_refptr<FakePictureLayer> layer = |
| 427 FakePictureLayer::CreateWithRecordingSource( | 430 FakePictureLayer::CreateWithRecordingSource( |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 // Do a main frame, record the picture layers. The frame number has changed | 520 // Do a main frame, record the picture layers. The frame number has changed |
| 518 // non-monotonically. | 521 // non-monotonically. |
| 519 layer->SetNeedsDisplay(); | 522 layer->SetNeedsDisplay(); |
| 520 host2->Composite(base::TimeTicks::Now()); | 523 host2->Composite(base::TimeTicks::Now()); |
| 521 EXPECT_EQ(3, layer->update_count()); | 524 EXPECT_EQ(3, layer->update_count()); |
| 522 EXPECT_EQ(1, host2->source_frame_number()); | 525 EXPECT_EQ(1, host2->source_frame_number()); |
| 523 } | 526 } |
| 524 | 527 |
| 525 } // namespace | 528 } // namespace |
| 526 } // namespace cc | 529 } // namespace cc |
| OLD | NEW |