| 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/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 TestContentLayerImpl* CreateRoot(const gfx::Transform& transform, | 98 TestContentLayerImpl* CreateRoot(const gfx::Transform& transform, |
| 99 const gfx::PointF& position, | 99 const gfx::PointF& position, |
| 100 const gfx::Size& bounds) { | 100 const gfx::Size& bounds) { |
| 101 LayerTreeImpl* tree = host_->host_impl()->active_tree(); | 101 LayerTreeImpl* tree = host_->host_impl()->active_tree(); |
| 102 int id = next_layer_impl_id_++; | 102 int id = next_layer_impl_id_++; |
| 103 std::unique_ptr<TestContentLayerImpl> layer( | 103 std::unique_ptr<TestContentLayerImpl> layer( |
| 104 new TestContentLayerImpl(tree, id)); | 104 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 host_->host_impl()->active_tree()->SetRootLayer(std::move(layer)); | 108 host_->host_impl()->active_tree()->SetRootLayerForTesting(std::move(layer)); |
| 109 | 109 |
| 110 layer_ptr->test_properties()->force_render_surface = true; | 110 layer_ptr->test_properties()->force_render_surface = true; |
| 111 SetRootLayerOnMainThread(layer_ptr); | 111 SetRootLayerOnMainThread(layer_ptr); |
| 112 | 112 |
| 113 return layer_ptr; | 113 return layer_ptr; |
| 114 } | 114 } |
| 115 | 115 |
| 116 LayerImpl* CreateLayer(LayerImpl* parent, | 116 LayerImpl* CreateLayer(LayerImpl* parent, |
| 117 const gfx::Transform& transform, | 117 const gfx::Transform& transform, |
| 118 const gfx::PointF& position, | 118 const gfx::PointF& position, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 const gfx::PointF& position, | 191 const gfx::PointF& position, |
| 192 const gfx::Size& bounds, | 192 const gfx::Size& bounds, |
| 193 bool opaque) { | 193 bool opaque) { |
| 194 TestContentLayerImpl* layer = | 194 TestContentLayerImpl* layer = |
| 195 CreateDrawingLayer(parent, transform, position, bounds, opaque); | 195 CreateDrawingLayer(parent, transform, position, bounds, opaque); |
| 196 layer->test_properties()->force_render_surface = true; | 196 layer->test_properties()->force_render_surface = true; |
| 197 return layer; | 197 return layer; |
| 198 } | 198 } |
| 199 | 199 |
| 200 void DestroyLayers() { | 200 void DestroyLayers() { |
| 201 host_->host_impl()->active_tree()->SetRootLayer(nullptr); | 201 host_->host_impl()->active_tree()->SetRootLayerForTesting(nullptr); |
| 202 render_surface_layer_list_impl_.clear(); | 202 render_surface_layer_list_impl_.clear(); |
| 203 replica_layers_.clear(); | 203 replica_layers_.clear(); |
| 204 mask_layers_.clear(); | 204 mask_layers_.clear(); |
| 205 ResetLayerIterator(); | 205 ResetLayerIterator(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} | 208 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} |
| 209 | 209 |
| 210 void AddCopyRequest(Layer* layer) { | 210 void AddCopyRequest(Layer* layer) { |
| 211 layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( | 211 layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
| 212 base::Bind(&OcclusionTrackerTest::CopyOutputCallback, | 212 base::Bind(&OcclusionTrackerTest::CopyOutputCallback, |
| 213 base::Unretained(this)))); | 213 base::Unretained(this)))); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void AddCopyRequest(LayerImpl* layer) { | 216 void AddCopyRequest(LayerImpl* layer) { |
| 217 layer->test_properties()->copy_requests.push_back( | 217 layer->test_properties()->copy_requests.push_back( |
| 218 CopyOutputRequest::CreateBitmapRequest( | 218 CopyOutputRequest::CreateBitmapRequest( |
| 219 base::Bind(&OcclusionTrackerTest::CopyOutputCallback, | 219 base::Bind(&OcclusionTrackerTest::CopyOutputCallback, |
| 220 base::Unretained(this)))); | 220 base::Unretained(this)))); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void CalcDrawEtc(TestContentLayerImpl* root) { | 223 void CalcDrawEtc(TestContentLayerImpl* root) { |
| 224 DCHECK(root == root->layer_tree_impl()->root_layer()); | 224 root->layer_tree_impl()->BuildLayerListForTesting(); |
| 225 DCHECK(root == root->layer_tree_impl()->root_layer_for_testing()); |
| 225 | 226 |
| 226 // These occlusion tests attach and detach layers in multiple | 227 // These occlusion tests attach and detach layers in multiple |
| 227 // iterations, so rebuild property trees every time. | 228 // iterations, so rebuild property trees every time. |
| 228 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 229 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 229 | 230 |
| 230 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); | 231 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); |
| 231 | 232 |
| 232 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 233 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 233 root, root->bounds(), &render_surface_layer_list_impl_); | 234 root, root->bounds(), &render_surface_layer_list_impl_); |
| 234 inputs.can_adjust_raster_scales = true; | 235 inputs.can_adjust_raster_scales = true; |
| (...skipping 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2514 EXPECT_EQ(gfx::Rect(), | 2515 EXPECT_EQ(gfx::Rect(), |
| 2515 occlusion.UnoccludedSurfaceContentRect( | 2516 occlusion.UnoccludedSurfaceContentRect( |
| 2516 surface, gfx::Rect(80, 70, 50, 50))); | 2517 surface, gfx::Rect(80, 70, 50, 50))); |
| 2517 } | 2518 } |
| 2518 }; | 2519 }; |
| 2519 | 2520 |
| 2520 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) | 2521 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) |
| 2521 | 2522 |
| 2522 } // namespace | 2523 } // namespace |
| 2523 } // namespace cc | 2524 } // namespace cc |
| OLD | NEW |