OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/trees/quad_culler.h" | 5 #include "cc/trees/quad_culler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/debug/overdraw_metrics.h" | 10 #include "cc/debug/overdraw_metrics.h" |
11 #include "cc/layers/append_quads_data.h" | 11 #include "cc/layers/append_quads_data.h" |
| 12 #include "cc/layers/render_surface_impl.h" |
12 #include "cc/layers/tiled_layer_impl.h" | 13 #include "cc/layers/tiled_layer_impl.h" |
13 #include "cc/quads/tile_draw_quad.h" | 14 #include "cc/quads/tile_draw_quad.h" |
14 #include "cc/resources/layer_tiling_data.h" | 15 #include "cc/resources/layer_tiling_data.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/trees/occlusion_tracker.h" | 18 #include "cc/trees/occlusion_tracker.h" |
18 #include "cc/trees/single_thread_proxy.h" | 19 #include "cc/trees/single_thread_proxy.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
(...skipping 14 matching lines...) Expand all Loading... |
36 return scissor_rect_in_screen_; | 37 return scissor_rect_in_screen_; |
37 } | 38 } |
38 | 39 |
39 private: | 40 private: |
40 gfx::Rect scissor_rect_in_screen_; | 41 gfx::Rect scissor_rect_in_screen_; |
41 | 42 |
42 DISALLOW_COPY_AND_ASSIGN(TestOcclusionTrackerImpl); | 43 DISALLOW_COPY_AND_ASSIGN(TestOcclusionTrackerImpl); |
43 }; | 44 }; |
44 | 45 |
45 typedef LayerIterator<LayerImpl, | 46 typedef LayerIterator<LayerImpl, |
46 std::vector<LayerImpl*>, | 47 LayerImplList, |
47 RenderSurfaceImpl, | 48 RenderSurfaceImpl, |
48 LayerIteratorActions::FrontToBack> LayerIteratorType; | 49 LayerIteratorActions::FrontToBack> LayerIteratorType; |
49 | 50 |
50 class QuadCullerTest : public testing::Test { | 51 class QuadCullerTest : public testing::Test { |
51 public: | 52 public: |
52 QuadCullerTest() | 53 QuadCullerTest() |
53 : host_impl_(&proxy_), | 54 : host_impl_(&proxy_), |
54 layer_id_(1) {} | 55 layer_id_(1) {} |
55 | 56 |
56 scoped_ptr<TiledLayerImpl> MakeLayer( | 57 scoped_ptr<TiledLayerImpl> MakeLayer( |
57 TiledLayerImpl* parent, | 58 TiledLayerImpl* parent, |
58 const gfx::Transform& draw_transform, | 59 const gfx::Transform& draw_transform, |
59 gfx::Rect layer_rect, | 60 gfx::Rect layer_rect, |
60 float opacity, | 61 float opacity, |
61 bool opaque, | 62 bool opaque, |
62 gfx::Rect layer_opaque_rect, | 63 gfx::Rect layer_opaque_rect, |
63 std::vector<LayerImpl*>& surface_layer_list) { | 64 LayerImplList& surface_layer_list) { |
64 scoped_ptr<TiledLayerImpl> layer = | 65 scoped_ptr<TiledLayerImpl> layer = |
65 TiledLayerImpl::Create(host_impl_.active_tree(), layer_id_++); | 66 TiledLayerImpl::Create(host_impl_.active_tree(), layer_id_++); |
66 scoped_ptr<LayerTilingData> tiler = LayerTilingData::Create( | 67 scoped_ptr<LayerTilingData> tiler = LayerTilingData::Create( |
67 gfx::Size(100, 100), LayerTilingData::NO_BORDER_TEXELS); | 68 gfx::Size(100, 100), LayerTilingData::NO_BORDER_TEXELS); |
68 tiler->SetBounds(layer_rect.size()); | 69 tiler->SetBounds(layer_rect.size()); |
69 layer->SetTilingData(*tiler); | 70 layer->SetTilingData(*tiler); |
70 layer->set_skips_draw(false); | 71 layer->set_skips_draw(false); |
71 layer->draw_properties().target_space_transform = draw_transform; | 72 layer->draw_properties().target_space_transform = draw_transform; |
72 layer->draw_properties().screen_space_transform = draw_transform; | 73 layer->draw_properties().screen_space_transform = draw_transform; |
73 layer->draw_properties().visible_content_rect = layer_rect; | 74 layer->draw_properties().visible_content_rect = layer_rect; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 FakeImplProxy proxy_; | 125 FakeImplProxy proxy_; |
125 FakeLayerTreeHostImpl host_impl_; | 126 FakeLayerTreeHostImpl host_impl_; |
126 int layer_id_; | 127 int layer_id_; |
127 | 128 |
128 DISALLOW_COPY_AND_ASSIGN(QuadCullerTest); | 129 DISALLOW_COPY_AND_ASSIGN(QuadCullerTest); |
129 }; | 130 }; |
130 | 131 |
131 #define DECLARE_AND_INITIALIZE_TEST_QUADS() \ | 132 #define DECLARE_AND_INITIALIZE_TEST_QUADS() \ |
132 QuadList quad_list; \ | 133 QuadList quad_list; \ |
133 SharedQuadStateList shared_state_list; \ | 134 SharedQuadStateList shared_state_list; \ |
134 std::vector<LayerImpl*> render_surface_layer_list; \ | 135 LayerImplList render_surface_layer_list; \ |
135 gfx::Transform child_transform; \ | 136 gfx::Transform child_transform; \ |
136 gfx::Size root_size = gfx::Size(300, 300); \ | 137 gfx::Size root_size = gfx::Size(300, 300); \ |
137 gfx::Rect root_rect = gfx::Rect(root_size); \ | 138 gfx::Rect root_rect = gfx::Rect(root_size); \ |
138 gfx::Size child_size = gfx::Size(200, 200); \ | 139 gfx::Size child_size = gfx::Size(200, 200); \ |
139 gfx::Rect child_rect = gfx::Rect(child_size); | 140 gfx::Rect child_rect = gfx::Rect(child_size); |
140 | 141 |
141 TEST_F(QuadCullerTest, VerifyNoCulling) { | 142 TEST_F(QuadCullerTest, VerifyNoCulling) { |
142 DECLARE_AND_INITIALIZE_TEST_QUADS(); | 143 DECLARE_AND_INITIALIZE_TEST_QUADS(); |
143 | 144 |
144 scoped_ptr<TiledLayerImpl> root_layer = | 145 scoped_ptr<TiledLayerImpl> root_layer = |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 EXPECT_NEAR( | 927 EXPECT_NEAR( |
927 occlusion_tracker.overdraw_metrics()->pixels_drawn_opaque(), 0, 1); | 928 occlusion_tracker.overdraw_metrics()->pixels_drawn_opaque(), 0, 1); |
928 EXPECT_NEAR( | 929 EXPECT_NEAR( |
929 occlusion_tracker.overdraw_metrics()->pixels_drawn_translucent(), 0, 1); | 930 occlusion_tracker.overdraw_metrics()->pixels_drawn_translucent(), 0, 1); |
930 EXPECT_NEAR( | 931 EXPECT_NEAR( |
931 occlusion_tracker.overdraw_metrics()->pixels_culled_for_drawing(), 0, 1); | 932 occlusion_tracker.overdraw_metrics()->pixels_culled_for_drawing(), 0, 1); |
932 } | 933 } |
933 | 934 |
934 } // namespace | 935 } // namespace |
935 } // namespace cc | 936 } // namespace cc |
OLD | NEW |