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" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } else { | 94 } else { |
95 EXPECT_NE(quad->rect.ToString(), quad->visible_rect.ToString()); | 95 EXPECT_NE(quad->rect.ToString(), quad->visible_rect.ToString()); |
96 EXPECT_TRUE(quad->rect.Contains(quad->visible_rect)); | 96 EXPECT_TRUE(quad->rect.Contains(quad->visible_rect)); |
97 ++(*partially_occluded_count); | 97 ++(*partially_occluded_count); |
98 } | 98 } |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 LayerTestCommon::LayerImplTest::LayerImplTest() | 102 LayerTestCommon::LayerImplTest::LayerImplTest() |
103 : host_(FakeLayerTreeHost::Create()), | 103 : host_(FakeLayerTreeHost::Create()), |
104 root_layer_impl_( | 104 root_layer_impl_(LayerImpl::Create(host_->host_impl()->active_tree(), 1)), |
105 LayerImpl::Create(host_->host_impl()->active_tree(), 1)) { | 105 render_pass_(RenderPass::Create()), |
| 106 quad_culler_(make_scoped_ptr( |
| 107 new MockQuadCuller(render_pass_.get(), &occlusion_tracker_))) { |
106 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); | 108 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); |
107 host_->host_impl()->InitializeRenderer( | 109 host_->host_impl()->InitializeRenderer( |
108 output_surface.PassAs<OutputSurface>()); | 110 output_surface.PassAs<OutputSurface>()); |
109 } | 111 } |
110 | 112 |
111 LayerTestCommon::LayerImplTest::~LayerImplTest() {} | 113 LayerTestCommon::LayerImplTest::~LayerImplTest() {} |
112 | 114 |
113 void LayerTestCommon::LayerImplTest::CalcDrawProps( | 115 void LayerTestCommon::LayerImplTest::CalcDrawProps( |
114 const gfx::Size& viewport_size) { | 116 const gfx::Size& viewport_size) { |
115 LayerImplList layer_list; | 117 LayerImplList layer_list; |
116 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 118 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
117 root_layer_impl_.get(), viewport_size, &layer_list); | 119 root_layer_impl_.get(), viewport_size, &layer_list); |
118 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 120 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
119 } | 121 } |
120 | 122 |
121 void LayerTestCommon::LayerImplTest::AppendQuadsWithOcclusion( | 123 void LayerTestCommon::LayerImplTest::AppendQuadsWithOcclusion( |
122 LayerImpl* layer_impl, | 124 LayerImpl* layer_impl, |
123 const gfx::Rect& occluded) { | 125 const gfx::Rect& occluded) { |
124 AppendQuadsData data; | 126 AppendQuadsData data; |
125 | 127 |
126 quad_culler_.clear_lists(); | 128 quad_culler_->clear_lists(); |
127 quad_culler_.set_occluded_target_rect(occluded); | 129 quad_culler_->set_occluded_target_rect(occluded); |
128 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); | 130 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); |
129 layer_impl->AppendQuads(&quad_culler_, &data); | 131 layer_impl->AppendQuads(quad_culler_.get(), &data); |
130 layer_impl->DidDraw(resource_provider()); | 132 layer_impl->DidDraw(resource_provider()); |
131 } | 133 } |
132 | 134 |
133 void LayerTestCommon::LayerImplTest::AppendQuadsForPassWithOcclusion( | 135 void LayerTestCommon::LayerImplTest::AppendQuadsForPassWithOcclusion( |
134 LayerImpl* layer_impl, | 136 LayerImpl* layer_impl, |
135 const RenderPass::Id& id, | 137 const RenderPass::Id& id, |
136 const gfx::Rect& occluded) { | 138 const gfx::Rect& occluded) { |
137 AppendQuadsData data(id); | 139 AppendQuadsData data(id); |
138 | 140 |
139 quad_culler_.clear_lists(); | 141 quad_culler_->clear_lists(); |
140 quad_culler_.set_occluded_target_rect(occluded); | 142 quad_culler_->set_occluded_target_rect(occluded); |
141 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); | 143 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); |
142 layer_impl->AppendQuads(&quad_culler_, &data); | 144 layer_impl->AppendQuads(quad_culler_.get(), &data); |
143 layer_impl->DidDraw(resource_provider()); | 145 layer_impl->DidDraw(resource_provider()); |
144 } | 146 } |
145 | 147 |
146 void LayerTestCommon::LayerImplTest::AppendSurfaceQuadsWithOcclusion( | 148 void LayerTestCommon::LayerImplTest::AppendSurfaceQuadsWithOcclusion( |
147 RenderSurfaceImpl* surface_impl, | 149 RenderSurfaceImpl* surface_impl, |
148 const gfx::Rect& occluded) { | 150 const gfx::Rect& occluded) { |
149 AppendQuadsData data; | 151 AppendQuadsData data; |
150 | 152 |
151 quad_culler_.clear_lists(); | 153 quad_culler_->clear_lists(); |
152 quad_culler_.set_occluded_target_rect_for_contributing_surface(occluded); | 154 quad_culler_->set_occluded_target_rect_for_contributing_surface(occluded); |
153 bool for_replica = false; | 155 bool for_replica = false; |
154 RenderPass::Id id(1, 1); | 156 RenderPass::Id id(1, 1); |
155 surface_impl->AppendQuads(&quad_culler_, &data, for_replica, id); | 157 surface_impl->AppendQuads(quad_culler_.get(), &data, for_replica, id); |
156 } | 158 } |
157 | 159 |
158 } // namespace cc | 160 } // namespace cc |
OLD | NEW |