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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "cc/layers/append_quads_data.h" | 12 #include "cc/layers/append_quads_data.h" |
13 #include "cc/layers/picture_layer.h" | 13 #include "cc/layers/picture_layer.h" |
| 14 #include "cc/quads/draw_quad.h" |
14 #include "cc/test/fake_content_layer_client.h" | 15 #include "cc/test/fake_content_layer_client.h" |
15 #include "cc/test/fake_impl_proxy.h" | 16 #include "cc/test/fake_impl_proxy.h" |
16 #include "cc/test/fake_layer_tree_host_impl.h" | 17 #include "cc/test/fake_layer_tree_host_impl.h" |
17 #include "cc/test/fake_output_surface.h" | 18 #include "cc/test/fake_output_surface.h" |
18 #include "cc/test/fake_picture_layer_impl.h" | 19 #include "cc/test/fake_picture_layer_impl.h" |
19 #include "cc/test/fake_picture_pile_impl.h" | 20 #include "cc/test/fake_picture_pile_impl.h" |
20 #include "cc/test/geometry_test_utils.h" | 21 #include "cc/test/geometry_test_utils.h" |
21 #include "cc/test/impl_side_painting_settings.h" | 22 #include "cc/test/impl_side_painting_settings.h" |
22 #include "cc/test/layer_test_common.h" | 23 #include "cc/test/layer_test_common.h" |
23 #include "cc/test/mock_quad_culler.h" | |
24 #include "cc/test/test_shared_bitmap_manager.h" | 24 #include "cc/test/test_shared_bitmap_manager.h" |
25 #include "cc/test/test_web_graphics_context_3d.h" | 25 #include "cc/test/test_web_graphics_context_3d.h" |
26 #include "cc/trees/layer_tree_impl.h" | 26 #include "cc/trees/layer_tree_impl.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "ui/gfx/rect_conversions.h" | 28 #include "ui/gfx/rect_conversions.h" |
29 | 29 |
30 namespace cc { | 30 namespace cc { |
31 namespace { | 31 namespace { |
32 | 32 |
33 class MockCanvas : public SkCanvas { | 33 class MockCanvas : public SkCanvas { |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 | 1378 |
1379 // Verify the tiles are not larger than the context's max texture size. | 1379 // Verify the tiles are not larger than the context's max texture size. |
1380 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1380 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
1381 EXPECT_GE(140, tile->content_rect().width()); | 1381 EXPECT_GE(140, tile->content_rect().width()); |
1382 EXPECT_GE(140, tile->content_rect().height()); | 1382 EXPECT_GE(140, tile->content_rect().height()); |
1383 } | 1383 } |
1384 | 1384 |
1385 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { | 1385 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { |
1386 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 1386 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
1387 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1387 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
1388 MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); | |
1389 | 1388 |
1390 gfx::Size tile_size(400, 400); | 1389 gfx::Size tile_size(400, 400); |
1391 gfx::Size layer_bounds(1300, 1900); | 1390 gfx::Size layer_bounds(1300, 1900); |
1392 | 1391 |
1393 scoped_refptr<FakePicturePileImpl> pending_pile = | 1392 scoped_refptr<FakePicturePileImpl> pending_pile = |
1394 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1393 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1395 scoped_refptr<FakePicturePileImpl> active_pile = | 1394 scoped_refptr<FakePicturePileImpl> active_pile = |
1396 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1395 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1397 | 1396 |
1398 SetupTrees(pending_pile, active_pile); | 1397 SetupTrees(pending_pile, active_pile); |
1399 | 1398 |
1400 active_layer_->SetContentBounds(layer_bounds); | 1399 active_layer_->SetContentBounds(layer_bounds); |
1401 active_layer_->draw_properties().visible_content_rect = | 1400 active_layer_->draw_properties().visible_content_rect = |
1402 gfx::Rect(layer_bounds); | 1401 gfx::Rect(layer_bounds); |
1403 | 1402 |
1404 gfx::Rect layer_invalidation(150, 200, 30, 180); | 1403 gfx::Rect layer_invalidation(150, 200, 30, 180); |
1405 Region invalidation(layer_invalidation); | 1404 Region invalidation(layer_invalidation); |
1406 AddDefaultTilingsWithInvalidation(invalidation); | 1405 AddDefaultTilingsWithInvalidation(invalidation); |
1407 | 1406 |
1408 AppendQuadsData data; | 1407 AppendQuadsData data; |
1409 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); | 1408 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); |
1410 active_layer_->AppendQuads(&quad_culler, &data); | 1409 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
1411 active_layer_->DidDraw(NULL); | 1410 active_layer_->DidDraw(NULL); |
1412 | 1411 |
1413 ASSERT_EQ(1U, quad_culler.quad_list().size()); | 1412 ASSERT_EQ(1U, render_pass->quad_list.size()); |
1414 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, quad_culler.quad_list()[0]->material); | 1413 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, render_pass->quad_list[0]->material); |
1415 } | 1414 } |
1416 | 1415 |
1417 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) { | 1416 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) { |
1418 gfx::Size tile_size(100, 100); | 1417 gfx::Size tile_size(100, 100); |
1419 gfx::Size layer_bounds(1000, 1000); | 1418 gfx::Size layer_bounds(1000, 1000); |
1420 | 1419 |
1421 scoped_refptr<FakePicturePileImpl> pending_pile = | 1420 scoped_refptr<FakePicturePileImpl> pending_pile = |
1422 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 1421 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
1423 // Layers with entirely empty piles can't get tilings. | 1422 // Layers with entirely empty piles can't get tilings. |
1424 pending_pile->AddRecordingAt(0, 0); | 1423 pending_pile->AddRecordingAt(0, 0); |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2444 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2443 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2445 | 2444 |
2446 // Initialize remaining tiles. | 2445 // Initialize remaining tiles. |
2447 pending_layer_->SetAllTilesReady(); | 2446 pending_layer_->SetAllTilesReady(); |
2448 | 2447 |
2449 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2448 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2450 } | 2449 } |
2451 | 2450 |
2452 } // namespace | 2451 } // namespace |
2453 } // namespace cc | 2452 } // namespace cc |
OLD | NEW |