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

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

Issue 2690753002: cc: Move render surface ownership from layers to the effect tree (Closed)
Patch Set: Only update surfaces when can_render_to_separate_surface changes Created 3 years, 10 months 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
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/layers/layer_iterator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/layers/solid_color_scrollbar_layer_impl.h" 8 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
9 #include "cc/output/filter_operation.h" 9 #include "cc/output/filter_operation.h"
10 #include "cc/output/filter_operations.h" 10 #include "cc/output/filter_operations.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 FakeImplTaskRunnerProvider task_runner_provider; 242 FakeImplTaskRunnerProvider task_runner_provider;
243 TestTaskGraphRunner task_graph_runner; 243 TestTaskGraphRunner task_graph_runner;
244 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = 244 std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
245 FakeCompositorFrameSink::Create3d(); 245 FakeCompositorFrameSink::Create3d();
246 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 246 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
247 host_impl.SetVisible(true); 247 host_impl.SetVisible(true);
248 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); 248 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
249 host_impl.active_tree()->SetRootLayerForTesting( 249 host_impl.active_tree()->SetRootLayerForTesting(
250 LayerImpl::Create(host_impl.active_tree(), 1)); 250 LayerImpl::Create(host_impl.active_tree(), 1));
251 LayerImpl* root = host_impl.active_tree()->root_layer_for_testing(); 251 LayerImpl* root = host_impl.active_tree()->root_layer_for_testing();
252 root->SetHasRenderSurface(true);
253 std::unique_ptr<LayerImpl> layer_ptr = 252 std::unique_ptr<LayerImpl> layer_ptr =
254 LayerImpl::Create(host_impl.active_tree(), 2); 253 LayerImpl::Create(host_impl.active_tree(), 2);
255 LayerImpl* layer = layer_ptr.get(); 254 LayerImpl* layer = layer_ptr.get();
256 root->test_properties()->AddChild(std::move(layer_ptr)); 255 root->test_properties()->AddChild(std::move(layer_ptr));
257 layer->SetScrollClipLayer(root->id()); 256 layer->SetScrollClipLayer(root->id());
258 std::unique_ptr<LayerImpl> layer2_ptr = 257 std::unique_ptr<LayerImpl> layer2_ptr =
259 LayerImpl::Create(host_impl.active_tree(), 3); 258 LayerImpl::Create(host_impl.active_tree(), 3);
260 LayerImpl* layer2 = layer2_ptr.get(); 259 LayerImpl* layer2 = layer2_ptr.get();
261 root->test_properties()->AddChild(std::move(layer2_ptr)); 260 root->test_properties()->AddChild(std::move(layer2_ptr));
262 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 261 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
263 DCHECK(host_impl.CanDraw()); 262 DCHECK(host_impl.CanDraw());
264 263
265 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); 264 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f);
266 float arbitrary_number = 0.352f; 265 float arbitrary_number = 0.352f;
267 gfx::Size arbitrary_size = gfx::Size(111, 222); 266 gfx::Size arbitrary_size = gfx::Size(111, 222);
268 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); 267 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222);
269 gfx::Size large_size = gfx::Size(1000, 1000); 268 gfx::Size large_size = gfx::Size(1000, 1000);
270 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); 269 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30);
271 gfx::Transform arbitrary_transform; 270 gfx::Transform arbitrary_transform;
272 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); 271 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f);
273 FilterOperations arbitrary_filters; 272 FilterOperations arbitrary_filters;
274 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); 273 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f));
275 274
276 // Set layer to draw content so that their draw property by property trees is 275 // Set layer to draw content so that their draw property by property trees is
277 // verified. 276 // verified.
278 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true)); 277 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true));
279 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetDrawsContent(true)); 278 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetDrawsContent(true));
280 // Render surface functions should not trigger update draw properties, because 279
281 // creating render surface is part of update draw properties.
282 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true));
283 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(false));
284 // Create a render surface, because we must have a render surface if we have 280 // Create a render surface, because we must have a render surface if we have
285 // filters. 281 // filters.
286 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true)); 282 layer->test_properties()->force_render_surface = true;
283 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
287 284
288 // Related filter functions. 285 // Related filter functions.
289 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 286 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
290 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated( 287 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated(
291 arbitrary_filters, root->effect_tree_index(), 288 arbitrary_filters, root->effect_tree_index(),
292 host_impl.active_tree())); 289 host_impl.active_tree()));
293 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 290 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
294 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated( 291 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated(
295 arbitrary_filters, root->effect_tree_index(), 292 arbitrary_filters, root->effect_tree_index(),
296 host_impl.active_tree())); 293 host_impl.active_tree()));
297 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 294 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
298 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated( 295 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated(
299 FilterOperations(), root->effect_tree_index(), 296 FilterOperations(), root->effect_tree_index(),
300 host_impl.active_tree())); 297 host_impl.active_tree()));
301 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 298 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
302 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated( 299 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated(
303 arbitrary_filters, root->effect_tree_index(), 300 arbitrary_filters, root->effect_tree_index(),
304 host_impl.active_tree())); 301 host_impl.active_tree()));
305 302
306 // Related scrolling functions. 303 // Related scrolling functions.
307 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); 304 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size));
308 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); 305 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size));
309 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 306 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
307 host_impl.active_tree()->set_needs_update_draw_properties();
308 host_impl.active_tree()->UpdateDrawProperties(false /* update_lcd_text */);
310 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d)); 309 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d));
311 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(gfx::Vector2d())); 310 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(gfx::Vector2d()));
312 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 311 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
313 layer->layer_tree_impl()->DidUpdateScrollOffset(layer->id())); 312 layer->layer_tree_impl()->DidUpdateScrollOffset(layer->id()));
314 layer->layer_tree_impl() 313 layer->layer_tree_impl()
315 ->property_trees() 314 ->property_trees()
316 ->scroll_tree.SetScrollOffsetDeltaForTesting(layer->id(), 315 ->scroll_tree.SetScrollOffsetDeltaForTesting(layer->id(),
317 gfx::Vector2dF()); 316 gfx::Vector2dF());
318 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetCurrentScrollOffset( 317 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetCurrentScrollOffset(
319 gfx::ScrollOffset(arbitrary_vector2d.x(), arbitrary_vector2d.y()))); 318 gfx::ScrollOffset(arbitrary_vector2d.x(), arbitrary_vector2d.y())));
320 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetCurrentScrollOffset( 319 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetCurrentScrollOffset(
321 gfx::ScrollOffset(arbitrary_vector2d.x(), arbitrary_vector2d.y()))); 320 gfx::ScrollOffset(arbitrary_vector2d.x(), arbitrary_vector2d.y())));
322 321
323 // Unrelated functions, always set to new values, always set needs update. 322 // Unrelated functions, always set to new values, always set needs update.
324 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 323 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
324 host_impl.active_tree()->set_needs_update_draw_properties();
325 host_impl.active_tree()->UpdateDrawProperties(false /* update_lcd_text */);
325 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true); 326 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true);
326 layer->NoteLayerPropertyChanged()); 327 layer->NoteLayerPropertyChanged());
327 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true); 328 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true);
328 layer->NoteLayerPropertyChanged()); 329 layer->NoteLayerPropertyChanged());
329 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetPosition(arbitrary_point_f); 330 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetPosition(arbitrary_point_f);
330 layer->NoteLayerPropertyChanged()); 331 layer->NoteLayerPropertyChanged());
331 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 332 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
332 layer->SetBackgroundColor(arbitrary_color)); 333 layer->SetBackgroundColor(arbitrary_color));
333 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 334 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
334 host_impl.active_tree()->property_trees()->effect_tree.OnOpacityAnimated( 335 host_impl.active_tree()->property_trees()->effect_tree.OnOpacityAnimated(
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 580
580 pending_layer->PushPropertiesTo(layer()); 581 pending_layer->PushPropertiesTo(layer());
581 582
582 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); 583 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset());
583 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), 584 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(),
584 pending_layer->CurrentScrollOffset()); 585 pending_layer->CurrentScrollOffset());
585 } 586 }
586 587
587 } // namespace 588 } // namespace
588 } // namespace cc 589 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/layers/layer_iterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698