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/test/layer_test_common.h" | 5 #include "cc/test/layer_test_common.h" |
6 | 6 |
7 #include "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
8 #include "cc/base/region.h" | 8 #include "cc/base/region.h" |
9 #include "cc/layers/append_quads_data.h" | 9 #include "cc/layers/append_quads_data.h" |
10 #include "cc/quads/draw_quad.h" | 10 #include "cc/quads/draw_quad.h" |
11 #include "cc/quads/render_pass.h" | 11 #include "cc/quads/render_pass.h" |
12 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
| 13 #include "cc/test/mock_occlusion_tracker.h" |
13 #include "cc/trees/layer_tree_host_common.h" | 14 #include "cc/trees/layer_tree_host_common.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "ui/gfx/point_conversions.h" | 16 #include "ui/gfx/point_conversions.h" |
16 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
17 #include "ui/gfx/rect_conversions.h" | 18 #include "ui/gfx/rect_conversions.h" |
18 #include "ui/gfx/size_conversions.h" | 19 #include "ui/gfx/size_conversions.h" |
19 | 20 |
20 namespace cc { | 21 namespace cc { |
21 | 22 |
22 // Align with expected and actual output. | 23 // Align with expected and actual output. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 EXPECT_NE(quad->rect.ToString(), quad->visible_rect.ToString()); | 96 EXPECT_NE(quad->rect.ToString(), quad->visible_rect.ToString()); |
96 EXPECT_TRUE(quad->rect.Contains(quad->visible_rect)); | 97 EXPECT_TRUE(quad->rect.Contains(quad->visible_rect)); |
97 ++(*partially_occluded_count); | 98 ++(*partially_occluded_count); |
98 } | 99 } |
99 } | 100 } |
100 } | 101 } |
101 | 102 |
102 LayerTestCommon::LayerImplTest::LayerImplTest() | 103 LayerTestCommon::LayerImplTest::LayerImplTest() |
103 : host_(FakeLayerTreeHost::Create()), | 104 : host_(FakeLayerTreeHost::Create()), |
104 root_layer_impl_(LayerImpl::Create(host_->host_impl()->active_tree(), 1)), | 105 root_layer_impl_(LayerImpl::Create(host_->host_impl()->active_tree(), 1)), |
105 render_pass_(RenderPass::Create()), | 106 render_pass_(RenderPass::Create()) { |
106 quad_culler_(make_scoped_ptr( | |
107 new MockQuadCuller(render_pass_.get(), &occlusion_tracker_))) { | |
108 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); | 107 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); |
109 host_->host_impl()->InitializeRenderer( | 108 host_->host_impl()->InitializeRenderer( |
110 output_surface.PassAs<OutputSurface>()); | 109 output_surface.PassAs<OutputSurface>()); |
111 } | 110 } |
112 | 111 |
113 LayerTestCommon::LayerImplTest::~LayerImplTest() {} | 112 LayerTestCommon::LayerImplTest::~LayerImplTest() {} |
114 | 113 |
115 void LayerTestCommon::LayerImplTest::CalcDrawProps( | 114 void LayerTestCommon::LayerImplTest::CalcDrawProps( |
116 const gfx::Size& viewport_size) { | 115 const gfx::Size& viewport_size) { |
117 LayerImplList layer_list; | 116 LayerImplList layer_list; |
118 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 117 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
119 root_layer_impl_.get(), viewport_size, &layer_list); | 118 root_layer_impl_.get(), viewport_size, &layer_list); |
120 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 119 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
121 } | 120 } |
122 | 121 |
123 void LayerTestCommon::LayerImplTest::AppendQuadsWithOcclusion( | 122 void LayerTestCommon::LayerImplTest::AppendQuadsWithOcclusion( |
124 LayerImpl* layer_impl, | 123 LayerImpl* layer_impl, |
125 const gfx::Rect& occluded) { | 124 const gfx::Rect& occluded) { |
126 AppendQuadsData data; | 125 AppendQuadsData data; |
127 | 126 |
128 quad_culler_->clear_lists(); | 127 render_pass_->quad_list.clear(); |
129 quad_culler_->set_occluded_target_rect(occluded); | 128 render_pass_->shared_quad_state_list.clear(); |
| 129 occlusion_tracker_.set_occluded_target_rect(occluded); |
130 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); | 130 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); |
131 layer_impl->AppendQuads(quad_culler_.get(), &data); | 131 layer_impl->AppendQuads(render_pass_.get(), occlusion_tracker_, &data); |
132 layer_impl->DidDraw(resource_provider()); | 132 layer_impl->DidDraw(resource_provider()); |
133 } | 133 } |
134 | 134 |
135 void LayerTestCommon::LayerImplTest::AppendQuadsForPassWithOcclusion( | 135 void LayerTestCommon::LayerImplTest::AppendQuadsForPassWithOcclusion( |
136 LayerImpl* layer_impl, | 136 LayerImpl* layer_impl, |
137 const RenderPass::Id& id, | 137 const RenderPass::Id& id, |
138 const gfx::Rect& occluded) { | 138 const gfx::Rect& occluded) { |
139 AppendQuadsData data(id); | 139 AppendQuadsData data(id); |
140 | 140 |
141 quad_culler_->clear_lists(); | 141 render_pass_->quad_list.clear(); |
142 quad_culler_->set_occluded_target_rect(occluded); | 142 render_pass_->shared_quad_state_list.clear(); |
| 143 occlusion_tracker_.set_occluded_target_rect(occluded); |
143 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); | 144 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); |
144 layer_impl->AppendQuads(quad_culler_.get(), &data); | 145 layer_impl->AppendQuads(render_pass_.get(), occlusion_tracker_, &data); |
145 layer_impl->DidDraw(resource_provider()); | 146 layer_impl->DidDraw(resource_provider()); |
146 } | 147 } |
147 | 148 |
148 void LayerTestCommon::LayerImplTest::AppendSurfaceQuadsWithOcclusion( | 149 void LayerTestCommon::LayerImplTest::AppendSurfaceQuadsWithOcclusion( |
149 RenderSurfaceImpl* surface_impl, | 150 RenderSurfaceImpl* surface_impl, |
150 const gfx::Rect& occluded) { | 151 const gfx::Rect& occluded) { |
151 AppendQuadsData data; | 152 AppendQuadsData data; |
152 | 153 |
153 quad_culler_->clear_lists(); | 154 render_pass_->quad_list.clear(); |
154 quad_culler_->set_occluded_target_rect_for_contributing_surface(occluded); | 155 render_pass_->shared_quad_state_list.clear(); |
| 156 occlusion_tracker_.set_occluded_target_rect_for_contributing_surface( |
| 157 occluded); |
155 bool for_replica = false; | 158 bool for_replica = false; |
156 RenderPass::Id id(1, 1); | 159 RenderPass::Id id(1, 1); |
157 surface_impl->AppendQuads(quad_culler_.get(), &data, for_replica, id); | 160 surface_impl->AppendQuads( |
| 161 render_pass_.get(), occlusion_tracker_, &data, for_replica, id); |
158 } | 162 } |
159 | 163 |
160 } // namespace cc | 164 } // namespace cc |
OLD | NEW |