OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
| 9 #include <vector> |
9 | 10 |
10 #include "cc/animation/keyframed_animation_curve.h" | 11 #include "cc/animation/keyframed_animation_curve.h" |
11 #include "cc/animation/layer_animation_controller.h" | 12 #include "cc/animation/layer_animation_controller.h" |
12 #include "cc/animation/transform_operations.h" | 13 #include "cc/animation/transform_operations.h" |
13 #include "cc/base/math_util.h" | 14 #include "cc/base/math_util.h" |
14 #include "cc/layers/content_layer_client.h" | 15 #include "cc/layers/content_layer_client.h" |
15 #include "cc/layers/layer.h" | 16 #include "cc/layers/layer.h" |
16 #include "cc/layers/layer_client.h" | 17 #include "cc/layers/layer_client.h" |
17 #include "cc/layers/layer_impl.h" | 18 #include "cc/layers/layer_impl.h" |
18 #include "cc/layers/layer_iterator.h" | 19 #include "cc/layers/layer_iterator.h" |
(...skipping 3263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3282 root->AddChild(child.Pass()); | 3283 root->AddChild(child.Pass()); |
3283 root->AddChild(occluding_child.Pass()); | 3284 root->AddChild(occluding_child.Pass()); |
3284 host_impl.active_tree()->SetRootLayer(root.Pass()); | 3285 host_impl.active_tree()->SetRootLayer(root.Pass()); |
3285 host_impl.SetVisible(true); | 3286 host_impl.SetVisible(true); |
3286 host_impl.InitializeRenderer(output_surface.get()); | 3287 host_impl.InitializeRenderer(output_surface.get()); |
3287 host_impl.active_tree()->BuildPropertyTreesForTesting(); | 3288 host_impl.active_tree()->BuildPropertyTreesForTesting(); |
3288 bool update_lcd_text = false; | 3289 bool update_lcd_text = false; |
3289 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); | 3290 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); |
3290 | 3291 |
3291 LayerImpl* grand_child_ptr = | 3292 LayerImpl* grand_child_ptr = |
3292 host_impl.active_tree()->root_layer()->children()[0]->children()[0]; | 3293 host_impl.active_tree()->root_layer()->children()[0]->children()[0].get(); |
3293 | 3294 |
3294 // Though all layers have invertible transforms, matrix multiplication using | 3295 // Though all layers have invertible transforms, matrix multiplication using |
3295 // floating-point math makes the draw transform uninvertible. | 3296 // floating-point math makes the draw transform uninvertible. |
3296 EXPECT_FALSE(grand_child_ptr->draw_transform().IsInvertible()); | 3297 EXPECT_FALSE(grand_child_ptr->draw_transform().IsInvertible()); |
3297 | 3298 |
3298 // Since |grand_child| has an uninvertible draw transform, it is treated as | 3299 // Since |grand_child| has an uninvertible draw transform, it is treated as |
3299 // unoccluded (even though |occluding_child| comes later in draw order, and | 3300 // unoccluded (even though |occluding_child| comes later in draw order, and |
3300 // hence potentially occludes it). | 3301 // hence potentially occludes it). |
3301 gfx::Rect layer_bounds = gfx::Rect(grand_child_ptr->bounds()); | 3302 gfx::Rect layer_bounds = gfx::Rect(grand_child_ptr->bounds()); |
3302 EXPECT_EQ( | 3303 EXPECT_EQ( |
(...skipping 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5364 root->AddChild(copy_grand_parent_sibling_before.Pass()); | 5365 root->AddChild(copy_grand_parent_sibling_before.Pass()); |
5365 root->AddChild(copy_grand_parent.Pass()); | 5366 root->AddChild(copy_grand_parent.Pass()); |
5366 root->AddChild(copy_grand_parent_sibling_after.Pass()); | 5367 root->AddChild(copy_grand_parent_sibling_after.Pass()); |
5367 | 5368 |
5368 // Hide the copy_grand_parent and its subtree. But make a copy request in that | 5369 // Hide the copy_grand_parent and its subtree. But make a copy request in that |
5369 // hidden subtree on copy_layer. | 5370 // hidden subtree on copy_layer. |
5370 copy_grand_parent_layer->SetHideLayerAndSubtree(true); | 5371 copy_grand_parent_layer->SetHideLayerAndSubtree(true); |
5371 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); | 5372 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); |
5372 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); | 5373 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); |
5373 | 5374 |
5374 ScopedPtrVector<CopyOutputRequest> copy_requests; | 5375 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; |
5375 copy_requests.push_back( | 5376 copy_requests.push_back( |
5376 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 5377 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
5377 copy_layer->PassCopyRequests(©_requests); | 5378 copy_layer->PassCopyRequests(©_requests); |
5378 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5379 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
5379 | 5380 |
5380 LayerImplList render_surface_layer_list; | 5381 LayerImplList render_surface_layer_list; |
5381 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5382 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5382 root.get(), root->bounds(), &render_surface_layer_list); | 5383 root.get(), root->bounds(), &render_surface_layer_list); |
5383 inputs.can_adjust_raster_scales = true; | 5384 inputs.can_adjust_raster_scales = true; |
5384 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5385 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5456 true, false, true); | 5457 true, false, true); |
5457 copy_layer->SetDrawsContent(true); | 5458 copy_layer->SetDrawsContent(true); |
5458 | 5459 |
5459 scoped_ptr<LayerImpl> copy_child = | 5460 scoped_ptr<LayerImpl> copy_child = |
5460 LayerImpl::Create(host_impl.pending_tree(), 4); | 5461 LayerImpl::Create(host_impl.pending_tree(), 4); |
5461 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, | 5462 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, |
5462 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | 5463 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
5463 true, false, false); | 5464 true, false, false); |
5464 copy_child->SetDrawsContent(true); | 5465 copy_child->SetDrawsContent(true); |
5465 | 5466 |
5466 ScopedPtrVector<CopyOutputRequest> copy_requests; | 5467 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; |
5467 copy_requests.push_back( | 5468 copy_requests.push_back( |
5468 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 5469 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
5469 copy_layer->PassCopyRequests(©_requests); | 5470 copy_layer->PassCopyRequests(©_requests); |
5470 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5471 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
5471 | 5472 |
5472 copy_layer->AddChild(copy_child.Pass()); | 5473 copy_layer->AddChild(copy_child.Pass()); |
5473 copy_parent->AddChild(copy_layer.Pass()); | 5474 copy_parent->AddChild(copy_layer.Pass()); |
5474 root->AddChild(copy_parent.Pass()); | 5475 root->AddChild(copy_parent.Pass()); |
5475 | 5476 |
5476 LayerImplList render_surface_layer_list; | 5477 LayerImplList render_surface_layer_list; |
(...skipping 3039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8516 child_ptr->SetHideLayerAndSubtree(false); | 8517 child_ptr->SetHideLayerAndSubtree(false); |
8517 | 8518 |
8518 child_ptr->SetOpacity(0.f); | 8519 child_ptr->SetOpacity(0.f); |
8519 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8520 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8520 EXPECT_EQ(gfx::Rect(0, 0), | 8521 EXPECT_EQ(gfx::Rect(0, 0), |
8521 grandchild_ptr->visible_rect_from_property_trees()); | 8522 grandchild_ptr->visible_rect_from_property_trees()); |
8522 | 8523 |
8523 // Now, even though child has zero opacity, we will configure |grandchild| and | 8524 // Now, even though child has zero opacity, we will configure |grandchild| and |
8524 // |greatgrandchild| in several ways that should force the subtree to be | 8525 // |greatgrandchild| in several ways that should force the subtree to be |
8525 // processed anyhow. | 8526 // processed anyhow. |
8526 ScopedPtrVector<CopyOutputRequest> requests; | 8527 std::vector<scoped_ptr<CopyOutputRequest>> requests; |
8527 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 8528 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
8528 | 8529 |
8529 greatgrandchild_ptr->PassCopyRequests(&requests); | 8530 greatgrandchild_ptr->PassCopyRequests(&requests); |
8530 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8531 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8531 EXPECT_EQ(gfx::Rect(10, 10), | 8532 EXPECT_EQ(gfx::Rect(10, 10), |
8532 grandchild_ptr->visible_rect_from_property_trees()); | 8533 grandchild_ptr->visible_rect_from_property_trees()); |
8533 } | 8534 } |
8534 | 8535 |
8535 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 8536 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
8536 gfx::Transform identity; | 8537 gfx::Transform identity; |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9266 bool root_in_rsll = | 9267 bool root_in_rsll = |
9267 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); | 9268 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); |
9268 EXPECT_TRUE(root_in_rsll); | 9269 EXPECT_TRUE(root_in_rsll); |
9269 bool render_surface2_in_rsll = | 9270 bool render_surface2_in_rsll = |
9270 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end(); | 9271 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end(); |
9271 EXPECT_FALSE(render_surface2_in_rsll); | 9272 EXPECT_FALSE(render_surface2_in_rsll); |
9272 } | 9273 } |
9273 | 9274 |
9274 } // namespace | 9275 } // namespace |
9275 } // namespace cc | 9276 } // namespace cc |
OLD | NEW |