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/occlusion_tracker.h" | 5 #include "cc/trees/occlusion_tracker.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "cc/animation/layer_animation_controller.h" | 9 #include "cc/animation/layer_animation_controller.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 TestContentLayerImpl* CreateRoot(const gfx::Transform& transform, | 99 TestContentLayerImpl* CreateRoot(const gfx::Transform& transform, |
100 const gfx::PointF& position, | 100 const gfx::PointF& position, |
101 const gfx::Size& bounds) { | 101 const gfx::Size& bounds) { |
102 LayerTreeImpl* tree = host_->host_impl()->active_tree(); | 102 LayerTreeImpl* tree = host_->host_impl()->active_tree(); |
103 int id = next_layer_impl_id_++; | 103 int id = next_layer_impl_id_++; |
104 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); | 104 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); |
105 TestContentLayerImpl* layer_ptr = layer.get(); | 105 TestContentLayerImpl* layer_ptr = layer.get(); |
106 SetProperties(layer_ptr, transform, position, bounds); | 106 SetProperties(layer_ptr, transform, position, bounds); |
107 | 107 |
108 DCHECK(!root_.get()); | 108 host_->host_impl()->active_tree()->SetRootLayer(std::move(layer)); |
109 root_ = std::move(layer); | |
110 | 109 |
111 layer_ptr->SetForceRenderSurface(true); | 110 layer_ptr->SetForceRenderSurface(true); |
112 SetRootLayerOnMainThread(layer_ptr); | 111 SetRootLayerOnMainThread(layer_ptr); |
113 | 112 |
114 return layer_ptr; | 113 return layer_ptr; |
115 } | 114 } |
116 | 115 |
117 LayerImpl* CreateLayer(LayerImpl* parent, | 116 LayerImpl* CreateLayer(LayerImpl* parent, |
118 const gfx::Transform& transform, | 117 const gfx::Transform& transform, |
119 const gfx::PointF& position, | 118 const gfx::PointF& position, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 const gfx::PointF& position, | 188 const gfx::PointF& position, |
190 const gfx::Size& bounds, | 189 const gfx::Size& bounds, |
191 bool opaque) { | 190 bool opaque) { |
192 TestContentLayerImpl* layer = | 191 TestContentLayerImpl* layer = |
193 CreateDrawingLayer(parent, transform, position, bounds, opaque); | 192 CreateDrawingLayer(parent, transform, position, bounds, opaque); |
194 layer->SetForceRenderSurface(true); | 193 layer->SetForceRenderSurface(true); |
195 return layer; | 194 return layer; |
196 } | 195 } |
197 | 196 |
198 void DestroyLayers() { | 197 void DestroyLayers() { |
199 root_ = nullptr; | 198 host_->host_impl()->active_tree()->SetRootLayer(nullptr); |
200 render_surface_layer_list_impl_.clear(); | 199 render_surface_layer_list_impl_.clear(); |
201 replica_layers_.clear(); | 200 replica_layers_.clear(); |
202 mask_layers_.clear(); | 201 mask_layers_.clear(); |
203 ResetLayerIterator(); | 202 ResetLayerIterator(); |
204 } | 203 } |
205 | 204 |
206 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} | 205 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} |
207 | 206 |
208 void AddCopyRequest(Layer* layer) { | 207 void AddCopyRequest(Layer* layer) { |
209 layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( | 208 layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
210 base::Bind(&OcclusionTrackerTest::CopyOutputCallback, | 209 base::Bind(&OcclusionTrackerTest::CopyOutputCallback, |
211 base::Unretained(this)))); | 210 base::Unretained(this)))); |
212 } | 211 } |
213 | 212 |
214 void AddCopyRequest(LayerImpl* layer) { | 213 void AddCopyRequest(LayerImpl* layer) { |
215 std::vector<scoped_ptr<CopyOutputRequest>> requests; | 214 std::vector<scoped_ptr<CopyOutputRequest>> requests; |
216 requests.push_back(CopyOutputRequest::CreateBitmapRequest(base::Bind( | 215 requests.push_back(CopyOutputRequest::CreateBitmapRequest(base::Bind( |
217 &OcclusionTrackerTest::CopyOutputCallback, base::Unretained(this)))); | 216 &OcclusionTrackerTest::CopyOutputCallback, base::Unretained(this)))); |
218 layer->PassCopyRequests(&requests); | 217 layer->PassCopyRequests(&requests); |
219 } | 218 } |
220 | 219 |
221 void CalcDrawEtc(TestContentLayerImpl* root) { | 220 void CalcDrawEtc(TestContentLayerImpl* root) { |
222 DCHECK(root == root_.get()); | 221 DCHECK(root == root->layer_tree_impl()->root_layer()); |
223 | 222 |
224 // These occlusion tests attach and detach layers in multiple | 223 // These occlusion tests attach and detach layers in multiple |
225 // iterations, so rebuild property trees every time. | 224 // iterations, so rebuild property trees every time. |
226 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 225 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
227 | 226 |
228 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); | 227 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); |
229 | 228 |
230 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 229 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
231 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 230 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
232 root, root->bounds(), &render_surface_layer_list_impl_, | 231 root, root->bounds(), &render_surface_layer_list_impl_, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 303 |
305 void SetMask(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) { | 304 void SetMask(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) { |
306 owning_layer->SetMaskLayer(std::move(layer)); | 305 owning_layer->SetMaskLayer(std::move(layer)); |
307 } | 306 } |
308 | 307 |
309 bool opaque_layers_; | 308 bool opaque_layers_; |
310 FakeLayerTreeHostClient client_; | 309 FakeLayerTreeHostClient client_; |
311 TestTaskGraphRunner task_graph_runner_; | 310 TestTaskGraphRunner task_graph_runner_; |
312 scoped_ptr<FakeLayerTreeHost> host_; | 311 scoped_ptr<FakeLayerTreeHost> host_; |
313 // These hold ownership of the layers for the duration of the test. | 312 // These hold ownership of the layers for the duration of the test. |
314 scoped_ptr<LayerImpl> root_; | |
315 LayerImplList render_surface_layer_list_impl_; | 313 LayerImplList render_surface_layer_list_impl_; |
316 LayerIterator layer_iterator_begin_; | 314 LayerIterator layer_iterator_begin_; |
317 LayerIterator layer_iterator_; | 315 LayerIterator layer_iterator_; |
318 LayerList replica_layers_; | 316 LayerList replica_layers_; |
319 LayerList mask_layers_; | 317 LayerList mask_layers_; |
320 int next_layer_impl_id_; | 318 int next_layer_impl_id_; |
321 }; | 319 }; |
322 | 320 |
323 #define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ | 321 #define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ |
324 class ClassName##ImplThreadOpaqueLayers : public ClassName { \ | 322 class ClassName##ImplThreadOpaqueLayers : public ClassName { \ |
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 EXPECT_EQ(gfx::Rect(), | 2511 EXPECT_EQ(gfx::Rect(), |
2514 occlusion.UnoccludedSurfaceContentRect( | 2512 occlusion.UnoccludedSurfaceContentRect( |
2515 surface, gfx::Rect(80, 70, 50, 50))); | 2513 surface, gfx::Rect(80, 70, 50, 50))); |
2516 } | 2514 } |
2517 }; | 2515 }; |
2518 | 2516 |
2519 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) | 2517 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) |
2520 | 2518 |
2521 } // namespace | 2519 } // namespace |
2522 } // namespace cc | 2520 } // namespace cc |
OLD | NEW |