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

Side by Side Diff: cc/layers/layer_impl_unittest.cc

Issue 465853004: Moving RenderSurface creation outside of CalcDrawProps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "cc/layers/painted_scrollbar_layer_impl.h" 7 #include "cc/layers/painted_scrollbar_layer_impl.h"
8 #include "cc/output/filter_operation.h" 8 #include "cc/output/filter_operation.h"
9 #include "cc/output/filter_operations.h" 9 #include "cc/output/filter_operations.h"
10 #include "cc/test/fake_impl_proxy.h" 10 #include "cc/test/fake_impl_proxy.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 scoped_ptr<LayerImpl> root_ptr = 92 scoped_ptr<LayerImpl> root_ptr =
93 LayerImpl::Create(host_impl.active_tree(), 2); 93 LayerImpl::Create(host_impl.active_tree(), 2);
94 LayerImpl* root = root_ptr.get(); 94 LayerImpl* root = root_ptr.get();
95 root_clip->AddChild(root_ptr.Pass()); 95 root_clip->AddChild(root_ptr.Pass());
96 scoped_ptr<LayerImpl> scroll_parent = 96 scoped_ptr<LayerImpl> scroll_parent =
97 LayerImpl::Create(host_impl.active_tree(), 3); 97 LayerImpl::Create(host_impl.active_tree(), 3);
98 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); 98 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get();
99 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>(); 99 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>();
100 scroll_children->insert(scroll_child); 100 scroll_children->insert(scroll_child);
101 scroll_children->insert(root); 101 scroll_children->insert(root);
102 root->SetHasRenderSurface(true);
102 103
103 scoped_ptr<LayerImpl> clip_parent = 104 scoped_ptr<LayerImpl> clip_parent =
104 LayerImpl::Create(host_impl.active_tree(), 5); 105 LayerImpl::Create(host_impl.active_tree(), 5);
105 LayerImpl* clip_child = LayerImpl::Create(host_impl.active_tree(), 6).get(); 106 LayerImpl* clip_child = LayerImpl::Create(host_impl.active_tree(), 6).get();
106 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>(); 107 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>();
107 clip_children->insert(clip_child); 108 clip_children->insert(clip_child);
108 clip_children->insert(root); 109 clip_children->insert(root);
109 110
110 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); 111 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7));
111 LayerImpl* child = root->children()[0]; 112 LayerImpl* child = root->children()[0];
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 245 }
245 246
246 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { 247 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
247 FakeImplProxy proxy; 248 FakeImplProxy proxy;
248 TestSharedBitmapManager shared_bitmap_manager; 249 TestSharedBitmapManager shared_bitmap_manager;
249 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 250 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
250 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); 251 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d()));
251 host_impl.active_tree()->SetRootLayer( 252 host_impl.active_tree()->SetRootLayer(
252 LayerImpl::Create(host_impl.active_tree(), 1)); 253 LayerImpl::Create(host_impl.active_tree(), 1));
253 LayerImpl* root = host_impl.active_tree()->root_layer(); 254 LayerImpl* root = host_impl.active_tree()->root_layer();
255 root->SetHasRenderSurface(true);
254 scoped_ptr<LayerImpl> layer_ptr = 256 scoped_ptr<LayerImpl> layer_ptr =
255 LayerImpl::Create(host_impl.active_tree(), 2); 257 LayerImpl::Create(host_impl.active_tree(), 2);
256 LayerImpl* layer = layer_ptr.get(); 258 LayerImpl* layer = layer_ptr.get();
257 root->AddChild(layer_ptr.Pass()); 259 root->AddChild(layer_ptr.Pass());
258 layer->SetScrollClipLayer(root->id()); 260 layer->SetScrollClipLayer(root->id());
261 layer->SetHasRenderSurface(true);
259 DCHECK(host_impl.CanDraw()); 262 DCHECK(host_impl.CanDraw());
260 263
261 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); 264 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f);
262 float arbitrary_number = 0.352f; 265 float arbitrary_number = 0.352f;
263 gfx::Size arbitrary_size = gfx::Size(111, 222); 266 gfx::Size arbitrary_size = gfx::Size(111, 222);
264 gfx::Point arbitrary_point = gfx::Point(333, 444); 267 gfx::Point arbitrary_point = gfx::Point(333, 444);
265 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); 268 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222);
266 gfx::Size large_size = gfx::Size(1000, 1000); 269 gfx::Size large_size = gfx::Size(1000, 1000);
267 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size); 270 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size);
268 gfx::RectF arbitrary_rect_f = 271 gfx::RectF arbitrary_rect_f =
269 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f)); 272 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f));
270 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); 273 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30);
271 gfx::Transform arbitrary_transform; 274 gfx::Transform arbitrary_transform;
272 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); 275 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f);
273 FilterOperations arbitrary_filters; 276 FilterOperations arbitrary_filters;
274 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); 277 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f));
275 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; 278 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode;
276 279
280
277 // Related filter functions. 281 // Related filter functions.
278 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 282 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters));
279 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 283 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters));
280 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(FilterOperations())); 284 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(FilterOperations()));
281 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 285 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters));
282 286
283 // Related scrolling functions. 287 // Related scrolling functions.
284 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); 288 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size));
285 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); 289 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size));
286 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d)); 290 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d));
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 layer()->id(), tree()->root_layer()->id()); 735 layer()->id(), tree()->root_layer()->id());
732 736
733 int expected_horizontal_maximum = 737 int expected_horizontal_maximum =
734 layer()->bounds().width() - tree()->root_layer()->bounds().width(); 738 layer()->bounds().width() - tree()->root_layer()->bounds().width();
735 EXPECT_EQ(expected_horizontal_maximum, horizontal_scrollbar->maximum()); 739 EXPECT_EQ(expected_horizontal_maximum, horizontal_scrollbar->maximum());
736 EXPECT_EQ(scroll_offset.x(), horizontal_scrollbar->current_pos()); 740 EXPECT_EQ(scroll_offset.x(), horizontal_scrollbar->current_pos());
737 } 741 }
738 742
739 } // namespace 743 } // namespace
740 } // namespace cc 744 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698