Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1182)

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 308193003: Removed QuadSink and MockQuadCuller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@plumLayerImpl
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/layers/quad_sink.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/gfx/size_conversions.h" 29 #include "ui/gfx/size_conversions.h"
30 30
31 namespace cc { 31 namespace cc {
32 namespace { 32 namespace {
33 33
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 1205
1206 // Verify the tiles are not larger than the context's max texture size. 1206 // Verify the tiles are not larger than the context's max texture size.
1207 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; 1207 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0];
1208 EXPECT_GE(140, tile->content_rect().width()); 1208 EXPECT_GE(140, tile->content_rect().width());
1209 EXPECT_GE(140, tile->content_rect().height()); 1209 EXPECT_GE(140, tile->content_rect().height());
1210 } 1210 }
1211 1211
1212 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { 1212 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) {
1213 MockOcclusionTracker<LayerImpl> occlusion_tracker; 1213 MockOcclusionTracker<LayerImpl> occlusion_tracker;
1214 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1214 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1215 MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker);
1216 1215
1217 gfx::Size tile_size(400, 400); 1216 gfx::Size tile_size(400, 400);
1218 gfx::Size layer_bounds(1300, 1900); 1217 gfx::Size layer_bounds(1300, 1900);
1219 1218
1220 scoped_refptr<FakePicturePileImpl> pending_pile = 1219 scoped_refptr<FakePicturePileImpl> pending_pile =
1221 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1220 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1222 scoped_refptr<FakePicturePileImpl> active_pile = 1221 scoped_refptr<FakePicturePileImpl> active_pile =
1223 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1222 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1224 1223
1225 SetupTrees(pending_pile, active_pile); 1224 SetupTrees(pending_pile, active_pile);
1226 1225
1227 active_layer_->draw_properties().visible_content_rect = 1226 active_layer_->draw_properties().visible_content_rect =
1228 gfx::Rect(layer_bounds); 1227 gfx::Rect(layer_bounds);
1229 1228
1230 gfx::Rect layer_invalidation(150, 200, 30, 180); 1229 gfx::Rect layer_invalidation(150, 200, 30, 180);
1231 Region invalidation(layer_invalidation); 1230 Region invalidation(layer_invalidation);
1232 AddDefaultTilingsWithInvalidation(invalidation); 1231 AddDefaultTilingsWithInvalidation(invalidation);
1233 1232
1234 AppendQuadsData data; 1233 AppendQuadsData data;
1235 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); 1234 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL);
1236 active_layer_->AppendQuads(&quad_culler, &data); 1235 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data);
1237 active_layer_->DidDraw(NULL); 1236 active_layer_->DidDraw(NULL);
1238 1237
1239 ASSERT_EQ(1U, quad_culler.quad_list().size()); 1238 ASSERT_EQ(1U, render_pass->quad_list.size());
1240 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, quad_culler.quad_list()[0]->material); 1239 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, render_pass->quad_list[0]->material);
1241 } 1240 }
1242 1241
1243 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) { 1242 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) {
1244 gfx::Size tile_size(100, 100); 1243 gfx::Size tile_size(100, 100);
1245 gfx::Size layer_bounds(1000, 1000); 1244 gfx::Size layer_bounds(1000, 1000);
1246 1245
1247 scoped_refptr<FakePicturePileImpl> pending_pile = 1246 scoped_refptr<FakePicturePileImpl> pending_pile =
1248 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 1247 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
1249 // Layers with entirely empty piles can't get tilings. 1248 // Layers with entirely empty piles can't get tilings.
1250 pending_pile->AddRecordingAt(0, 0); 1249 pending_pile->AddRecordingAt(0, 0);
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 2.7f, // device scale 2711 2.7f, // device scale
2713 3.2f, // page scale 2712 3.2f, // page scale
2714 1.f, // maximum animation scale 2713 1.f, // maximum animation scale
2715 false); 2714 false);
2716 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 2715 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
2717 } 2716 }
2718 2717
2719 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { 2718 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) {
2720 MockOcclusionTracker<LayerImpl> occlusion_tracker; 2719 MockOcclusionTracker<LayerImpl> occlusion_tracker;
2721 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 2720 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
2722 MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker);
2723 2721
2724 gfx::Size tile_size(400, 400); 2722 gfx::Size tile_size(400, 400);
2725 gfx::Size layer_bounds(1000, 2000); 2723 gfx::Size layer_bounds(1000, 2000);
2726 2724
2727 scoped_refptr<FakePicturePileImpl> pending_pile = 2725 scoped_refptr<FakePicturePileImpl> pending_pile =
2728 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2726 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2729 scoped_refptr<FakePicturePileImpl> active_pile = 2727 scoped_refptr<FakePicturePileImpl> active_pile =
2730 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2728 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2731 2729
2732 SetupTrees(pending_pile, active_pile); 2730 SetupTrees(pending_pile, active_pile);
2733 2731
2734 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 2.5f, 1.f, 1.f, 1.f, false); 2732 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 2.5f, 1.f, 1.f, 1.f, false);
2735 host_impl_.pending_tree()->UpdateDrawProperties(); 2733 host_impl_.pending_tree()->UpdateDrawProperties();
2736 2734
2737 active_layer_->draw_properties().visible_content_rect = 2735 active_layer_->draw_properties().visible_content_rect =
2738 gfx::Rect(layer_bounds); 2736 gfx::Rect(layer_bounds);
2739 host_impl_.active_tree()->UpdateDrawProperties(); 2737 host_impl_.active_tree()->UpdateDrawProperties();
2740 2738
2741 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); 2739 float max_contents_scale = active_layer_->MaximumTilingContentsScale();
2742 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); 2740 gfx::Transform scaled_draw_transform = active_layer_->draw_transform();
2743 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, 2741 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale,
2744 SK_MScalar1 / max_contents_scale); 2742 SK_MScalar1 / max_contents_scale);
2745 2743
2746 AppendQuadsData data; 2744 AppendQuadsData data;
2747 active_layer_->AppendQuads(&quad_culler, &data); 2745 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data);
2748 2746
2749 // SharedQuadState should have be of size 1, as we are doing AppenQuad once. 2747 // SharedQuadState should have be of size 1, as we are doing AppenQuad once.
2750 EXPECT_EQ(1u, quad_culler.shared_quad_state_list().size()); 2748 EXPECT_EQ(1u, render_pass->shared_quad_state_list.size());
2751 // The content_to_target_transform should be scaled by the 2749 // The content_to_target_transform should be scaled by the
2752 // MaximumTilingContentsScale on the layer. 2750 // MaximumTilingContentsScale on the layer.
2753 EXPECT_EQ(scaled_draw_transform.ToString(), 2751 EXPECT_EQ(scaled_draw_transform.ToString(),
2754 quad_culler.shared_quad_state_list()[0] 2752 render_pass->shared_quad_state_list[0]
2755 ->content_to_target_transform.ToString()); 2753 ->content_to_target_transform.ToString());
2756 // The content_bounds should be scaled by the 2754 // The content_bounds should be scaled by the
2757 // MaximumTilingContentsScale on the layer. 2755 // MaximumTilingContentsScale on the layer.
2758 EXPECT_EQ(gfx::Size(2500u, 5000u).ToString(), 2756 EXPECT_EQ(gfx::Size(2500u, 5000u).ToString(),
2759 quad_culler.shared_quad_state_list()[0]->content_bounds.ToString()); 2757 render_pass->shared_quad_state_list[0]->content_bounds.ToString());
2760 // The visible_content_rect should be scaled by the 2758 // The visible_content_rect should be scaled by the
2761 // MaximumTilingContentsScale on the layer. 2759 // MaximumTilingContentsScale on the layer.
2762 EXPECT_EQ( 2760 EXPECT_EQ(
2763 gfx::Rect(0u, 0u, 2500u, 5000u).ToString(), 2761 gfx::Rect(0u, 0u, 2500u, 5000u).ToString(),
2764 quad_culler.shared_quad_state_list()[0]->visible_content_rect.ToString()); 2762 render_pass->shared_quad_state_list[0]->visible_content_rect.ToString());
2765 } 2763 }
2766 2764
2767 TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) { 2765 TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) {
2768 gfx::Size tile_size(400, 400); 2766 gfx::Size tile_size(400, 400);
2769 gfx::Size bounds(100000, 100); 2767 gfx::Size bounds(100000, 100);
2770 2768
2771 host_impl_.CreatePendingTree(); 2769 host_impl_.CreatePendingTree();
2772 2770
2773 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1); 2771 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1);
2774 2772
(...skipping 29 matching lines...) Expand all
2804 2802
2805 host_impl_.pending_tree()->SetRootLayer(root.Pass()); 2803 host_impl_.pending_tree()->SetRootLayer(root.Pass());
2806 2804
2807 EXPECT_FALSE(pending_mask_content->tilings()); 2805 EXPECT_FALSE(pending_mask_content->tilings());
2808 host_impl_.pending_tree()->UpdateDrawProperties(); 2806 host_impl_.pending_tree()->UpdateDrawProperties();
2809 EXPECT_NE(0u, pending_mask_content->num_tilings()); 2807 EXPECT_NE(0u, pending_mask_content->num_tilings());
2810 } 2808 }
2811 2809
2812 } // namespace 2810 } // namespace
2813 } // namespace cc 2811 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/layers/quad_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698