Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 1437413002: cc: Remove ScopedPtrVector and cc::remove_if. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3261 matching lines...) Expand 10 before | Expand all | Expand 10 after
3280 root->AddChild(child.Pass()); 3281 root->AddChild(child.Pass());
3281 root->AddChild(occluding_child.Pass()); 3282 root->AddChild(occluding_child.Pass());
3282 host_impl.active_tree()->SetRootLayer(root.Pass()); 3283 host_impl.active_tree()->SetRootLayer(root.Pass());
3283 host_impl.SetVisible(true); 3284 host_impl.SetVisible(true);
3284 host_impl.InitializeRenderer(output_surface.get()); 3285 host_impl.InitializeRenderer(output_surface.get());
3285 host_impl.active_tree()->BuildPropertyTreesForTesting(); 3286 host_impl.active_tree()->BuildPropertyTreesForTesting();
3286 bool update_lcd_text = false; 3287 bool update_lcd_text = false;
3287 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); 3288 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text);
3288 3289
3289 LayerImpl* grand_child_ptr = 3290 LayerImpl* grand_child_ptr =
3290 host_impl.active_tree()->root_layer()->children()[0]->children()[0]; 3291 host_impl.active_tree()->root_layer()->children()[0]->children()[0].get();
3291 3292
3292 // Though all layers have invertible transforms, matrix multiplication using 3293 // Though all layers have invertible transforms, matrix multiplication using
3293 // floating-point math makes the draw transform uninvertible. 3294 // floating-point math makes the draw transform uninvertible.
3294 EXPECT_FALSE(grand_child_ptr->draw_transform().IsInvertible()); 3295 EXPECT_FALSE(grand_child_ptr->draw_transform().IsInvertible());
3295 3296
3296 // Since |grand_child| has an uninvertible draw transform, it is treated as 3297 // Since |grand_child| has an uninvertible draw transform, it is treated as
3297 // unoccluded (even though |occluding_child| comes later in draw order, and 3298 // unoccluded (even though |occluding_child| comes later in draw order, and
3298 // hence potentially occludes it). 3299 // hence potentially occludes it).
3299 gfx::Rect layer_bounds = gfx::Rect(grand_child_ptr->bounds()); 3300 gfx::Rect layer_bounds = gfx::Rect(grand_child_ptr->bounds());
3300 EXPECT_EQ( 3301 EXPECT_EQ(
(...skipping 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after
5362 root->AddChild(copy_grand_parent_sibling_before.Pass()); 5363 root->AddChild(copy_grand_parent_sibling_before.Pass());
5363 root->AddChild(copy_grand_parent.Pass()); 5364 root->AddChild(copy_grand_parent.Pass());
5364 root->AddChild(copy_grand_parent_sibling_after.Pass()); 5365 root->AddChild(copy_grand_parent_sibling_after.Pass());
5365 5366
5366 // Hide the copy_grand_parent and its subtree. But make a copy request in that 5367 // Hide the copy_grand_parent and its subtree. But make a copy request in that
5367 // hidden subtree on copy_layer. 5368 // hidden subtree on copy_layer.
5368 copy_grand_parent_layer->SetHideLayerAndSubtree(true); 5369 copy_grand_parent_layer->SetHideLayerAndSubtree(true);
5369 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); 5370 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true);
5370 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); 5371 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true);
5371 5372
5372 ScopedPtrVector<CopyOutputRequest> copy_requests; 5373 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests;
5373 copy_requests.push_back( 5374 copy_requests.push_back(
5374 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 5375 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5375 copy_layer->PassCopyRequests(&copy_requests); 5376 copy_layer->PassCopyRequests(&copy_requests);
5376 EXPECT_TRUE(copy_layer->HasCopyRequest()); 5377 EXPECT_TRUE(copy_layer->HasCopyRequest());
5377 5378
5378 LayerImplList render_surface_layer_list; 5379 LayerImplList render_surface_layer_list;
5379 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5380 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5380 root.get(), root->bounds(), &render_surface_layer_list); 5381 root.get(), root->bounds(), &render_surface_layer_list);
5381 inputs.can_adjust_raster_scales = true; 5382 inputs.can_adjust_raster_scales = true;
5382 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5383 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
5454 true, false, true); 5455 true, false, true);
5455 copy_layer->SetDrawsContent(true); 5456 copy_layer->SetDrawsContent(true);
5456 5457
5457 scoped_ptr<LayerImpl> copy_child = 5458 scoped_ptr<LayerImpl> copy_child =
5458 LayerImpl::Create(host_impl.pending_tree(), 4); 5459 LayerImpl::Create(host_impl.pending_tree(), 4);
5459 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, 5460 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix,
5460 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), 5461 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20),
5461 true, false, false); 5462 true, false, false);
5462 copy_child->SetDrawsContent(true); 5463 copy_child->SetDrawsContent(true);
5463 5464
5464 ScopedPtrVector<CopyOutputRequest> copy_requests; 5465 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests;
5465 copy_requests.push_back( 5466 copy_requests.push_back(
5466 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 5467 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5467 copy_layer->PassCopyRequests(&copy_requests); 5468 copy_layer->PassCopyRequests(&copy_requests);
5468 EXPECT_TRUE(copy_layer->HasCopyRequest()); 5469 EXPECT_TRUE(copy_layer->HasCopyRequest());
5469 5470
5470 copy_layer->AddChild(copy_child.Pass()); 5471 copy_layer->AddChild(copy_child.Pass());
5471 copy_parent->AddChild(copy_layer.Pass()); 5472 copy_parent->AddChild(copy_layer.Pass());
5472 root->AddChild(copy_parent.Pass()); 5473 root->AddChild(copy_parent.Pass());
5473 5474
5474 LayerImplList render_surface_layer_list; 5475 LayerImplList render_surface_layer_list;
(...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after
8468 child_ptr->SetHideLayerAndSubtree(false); 8469 child_ptr->SetHideLayerAndSubtree(false);
8469 8470
8470 child_ptr->SetOpacity(0.f); 8471 child_ptr->SetOpacity(0.f);
8471 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8472 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8472 EXPECT_EQ(gfx::Rect(0, 0), 8473 EXPECT_EQ(gfx::Rect(0, 0),
8473 grandchild_ptr->visible_rect_from_property_trees()); 8474 grandchild_ptr->visible_rect_from_property_trees());
8474 8475
8475 // Now, even though child has zero opacity, we will configure |grandchild| and 8476 // Now, even though child has zero opacity, we will configure |grandchild| and
8476 // |greatgrandchild| in several ways that should force the subtree to be 8477 // |greatgrandchild| in several ways that should force the subtree to be
8477 // processed anyhow. 8478 // processed anyhow.
8478 ScopedPtrVector<CopyOutputRequest> requests; 8479 std::vector<scoped_ptr<CopyOutputRequest>> requests;
8479 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); 8480 requests.push_back(CopyOutputRequest::CreateEmptyRequest());
8480 8481
8481 greatgrandchild_ptr->PassCopyRequests(&requests); 8482 greatgrandchild_ptr->PassCopyRequests(&requests);
8482 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8483 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8483 EXPECT_EQ(gfx::Rect(10, 10), 8484 EXPECT_EQ(gfx::Rect(10, 10),
8484 grandchild_ptr->visible_rect_from_property_trees()); 8485 grandchild_ptr->visible_rect_from_property_trees());
8485 } 8486 }
8486 8487
8487 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { 8488 TEST_F(LayerTreeHostCommonTest, SkippingLayer) {
8488 gfx::Transform identity; 8489 gfx::Transform identity;
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
9218 bool root_in_rsll = 9219 bool root_in_rsll =
9219 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); 9220 std::find(rsll->begin(), rsll->end(), root) != rsll->end();
9220 EXPECT_TRUE(root_in_rsll); 9221 EXPECT_TRUE(root_in_rsll);
9221 bool render_surface2_in_rsll = 9222 bool render_surface2_in_rsll =
9222 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end(); 9223 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end();
9223 EXPECT_FALSE(render_surface2_in_rsll); 9224 EXPECT_FALSE(render_surface2_in_rsll);
9224 } 9225 }
9225 9226
9226 } // namespace 9227 } // namespace
9227 } // namespace cc 9228 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698