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

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

Issue 2100353002: cc: DCHECK that the OutputSurface was released in ~LayerTreeHostImpl(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: released-outputsurface: rebase Created 4 years, 5 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
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_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 settings.renderer_settings.texture_id_allocation_chunk_size = 1; 112 settings.renderer_settings.texture_id_allocation_chunk_size = 1;
113 settings.gpu_rasterization_enabled = true; 113 settings.gpu_rasterization_enabled = true;
114 settings.verify_clip_tree_calculations = true; 114 settings.verify_clip_tree_calculations = true;
115 return settings; 115 return settings;
116 } 116 }
117 117
118 void SetUp() override { 118 void SetUp() override {
119 CreateHostImpl(DefaultSettings(), CreateOutputSurface()); 119 CreateHostImpl(DefaultSettings(), CreateOutputSurface());
120 } 120 }
121 121
122 void TearDown() override {} 122 void TearDown() override {
123 if (host_impl_)
124 host_impl_->ReleaseOutputSurface();
125 }
123 126
124 void UpdateRendererCapabilitiesOnImplThread() override {} 127 void UpdateRendererCapabilitiesOnImplThread() override {}
125 void DidLoseOutputSurfaceOnImplThread() override {} 128 void DidLoseOutputSurfaceOnImplThread() override {}
126 void CommitVSyncParameters(base::TimeTicks timebase, 129 void CommitVSyncParameters(base::TimeTicks timebase,
127 base::TimeDelta interval) override {} 130 base::TimeDelta interval) override {}
128 void SetBeginFrameSource(BeginFrameSource* source) override {} 131 void SetBeginFrameSource(BeginFrameSource* source) override {}
129 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {} 132 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {}
130 void DidSwapBuffersOnImplThread() override {} 133 void DidSwapBuffersOnImplThread() override {}
131 void DidSwapBuffersCompleteOnImplThread() override {} 134 void DidSwapBuffersCompleteOnImplThread() override {}
132 void OnCanDrawStateChanged(bool can_draw) override { 135 void OnCanDrawStateChanged(bool can_draw) override {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 virtual bool CreateHostImpl(const LayerTreeSettings& settings, 187 virtual bool CreateHostImpl(const LayerTreeSettings& settings,
185 std::unique_ptr<OutputSurface> output_surface) { 188 std::unique_ptr<OutputSurface> output_surface) {
186 return CreateHostImplWithTaskRunnerProvider( 189 return CreateHostImplWithTaskRunnerProvider(
187 settings, std::move(output_surface), &task_runner_provider_); 190 settings, std::move(output_surface), &task_runner_provider_);
188 } 191 }
189 192
190 virtual bool CreateHostImplWithTaskRunnerProvider( 193 virtual bool CreateHostImplWithTaskRunnerProvider(
191 const LayerTreeSettings& settings, 194 const LayerTreeSettings& settings,
192 std::unique_ptr<OutputSurface> output_surface, 195 std::unique_ptr<OutputSurface> output_surface,
193 TaskRunnerProvider* task_runner_provider) { 196 TaskRunnerProvider* task_runner_provider) {
197 if (host_impl_)
198 host_impl_->ReleaseOutputSurface();
194 host_impl_ = LayerTreeHostImpl::Create( 199 host_impl_ = LayerTreeHostImpl::Create(
195 settings, this, task_runner_provider, &stats_instrumentation_, 200 settings, this, task_runner_provider, &stats_instrumentation_,
196 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, 201 &shared_bitmap_manager_, &gpu_memory_buffer_manager_,
197 &task_graph_runner_, 202 &task_graph_runner_,
198 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 203 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
199 output_surface_ = std::move(output_surface); 204 output_surface_ = std::move(output_surface);
200 host_impl_->SetVisible(true); 205 host_impl_->SetVisible(true);
201 bool init = host_impl_->InitializeRenderer(output_surface_.get()); 206 bool init = host_impl_->InitializeRenderer(output_surface_.get());
202 host_impl_->SetViewportSize(gfx::Size(10, 10)); 207 host_impl_->SetViewportSize(gfx::Size(10, 10));
203 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 208 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); 341 inner_scroll->test_properties()->AddChild(std::move(outer_clip));
337 page_scale->test_properties()->AddChild(std::move(inner_scroll)); 342 page_scale->test_properties()->AddChild(std::move(inner_scroll));
338 inner_clip->test_properties()->AddChild(std::move(page_scale)); 343 inner_clip->test_properties()->AddChild(std::move(page_scale));
339 root->test_properties()->AddChild(std::move(inner_clip)); 344 root->test_properties()->AddChild(std::move(inner_clip));
340 345
341 layer_tree_impl->SetRootLayer(std::move(root)); 346 layer_tree_impl->SetRootLayer(std::move(root));
342 layer_tree_impl->SetViewportLayersFromIds( 347 layer_tree_impl->SetViewportLayersFromIds(
343 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, 348 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId,
344 kOuterViewportScrollLayerId); 349 kOuterViewportScrollLayerId);
345 350
351 layer_tree_impl->property_trees()->needs_rebuild = true;
352 layer_tree_impl->BuildLayerListAndPropertyTreesForTesting();
346 layer_tree_impl->DidBecomeActive(); 353 layer_tree_impl->DidBecomeActive();
347 return layer_tree_impl->InnerViewportScrollLayer(); 354 return layer_tree_impl->InnerViewportScrollLayer();
348 } 355 }
349 356
350 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { 357 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) {
351 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( 358 return CreateScrollAndContentsLayers(host_impl_->active_tree(),
352 host_impl_->active_tree(), content_size); 359 content_size);
353 SetNeedsRebuildPropertyTrees();
354 RebuildPropertyTrees();
355 host_impl_->active_tree()->DidBecomeActive();
356 return scroll_layer;
357 } 360 }
358 361
359 // Sets up a typical virtual viewport setup with one child content layer. 362 // Sets up a typical virtual viewport setup with one child content layer.
360 // Returns a pointer to the content layer. 363 // Returns a pointer to the content layer.
361 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, 364 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size,
362 const gfx::Size& content_size) { 365 const gfx::Size& content_size) {
363 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and 366 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and
364 // the inner a different size from the outer. We'll reuse its layer 367 // the inner a different size from the outer. We'll reuse its layer
365 // hierarchy but adjust the sizing to our needs. 368 // hierarchy but adjust the sizing to our needs.
366 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); 369 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size);
367 370
368 LayerImpl* content_layer = host_impl_->OuterViewportScrollLayer() 371 LayerImpl* content_layer = host_impl_->OuterViewportScrollLayer()
369 ->test_properties() 372 ->test_properties()
370 ->children.back(); 373 ->children.back();
371 content_layer->SetBounds(content_size); 374 content_layer->SetBounds(content_size);
372 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size); 375 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size);
373 376
374 LayerImpl* outer_clip = 377 LayerImpl* outer_clip =
375 host_impl_->OuterViewportScrollLayer()->test_properties()->parent; 378 host_impl_->OuterViewportScrollLayer()->test_properties()->parent;
376 outer_clip->SetBounds(viewport_size); 379 outer_clip->SetBounds(viewport_size);
377 380
378 LayerImpl* inner_clip_layer = host_impl_->InnerViewportScrollLayer() 381 LayerImpl* inner_clip_layer = host_impl_->InnerViewportScrollLayer()
379 ->test_properties() 382 ->test_properties()
380 ->parent->test_properties() 383 ->parent->test_properties()
381 ->parent; 384 ->parent;
382 inner_clip_layer->SetBounds(viewport_size); 385 inner_clip_layer->SetBounds(viewport_size);
383 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); 386 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size);
387 host_impl_->active_tree()->property_trees()->needs_rebuild = true;
384 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); 388 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
385 389
386 host_impl_->SetViewportSize(viewport_size); 390 host_impl_->SetViewportSize(viewport_size);
387 host_impl_->active_tree()->DidBecomeActive(); 391 host_impl_->active_tree()->DidBecomeActive();
388 392
389 return content_layer; 393 return content_layer;
390 } 394 }
391 395
392 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id, 396 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id,
393 const gfx::Size& size, 397 const gfx::Size& size,
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 root->test_properties()->children[1]->test_properties()->AddChild( 611 root->test_properties()->children[1]->test_properties()->AddChild(
608 LayerImpl::Create(host_impl_->active_tree(), 5)); 612 LayerImpl::Create(host_impl_->active_tree(), 5));
609 root->test_properties() 613 root->test_properties()
610 ->children[1] 614 ->children[1]
611 ->test_properties() 615 ->test_properties()
612 ->children[0] 616 ->children[0]
613 ->test_properties() 617 ->test_properties()
614 ->AddChild(LayerImpl::Create(host_impl_->active_tree(), 6)); 618 ->AddChild(LayerImpl::Create(host_impl_->active_tree(), 6));
615 host_impl_->active_tree()->SetRootLayer(std::move(root)); 619 host_impl_->active_tree()->SetRootLayer(std::move(root));
616 } 620 }
621 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
617 LayerImpl* root = host_impl_->active_tree()->root_layer(); 622 LayerImpl* root = host_impl_->active_tree()->root_layer();
618 623
619 ExpectClearedScrollDeltasRecursive(root); 624 ExpectClearedScrollDeltasRecursive(root);
620 625
621 std::unique_ptr<ScrollAndScaleSet> scroll_info; 626 std::unique_ptr<ScrollAndScaleSet> scroll_info;
622 627
623 scroll_info = host_impl_->ProcessScrollDeltas(); 628 scroll_info = host_impl_->ProcessScrollDeltas();
624 ASSERT_EQ(scroll_info->scrolls.size(), 0u); 629 ASSERT_EQ(scroll_info->scrolls.size(), 0u);
625 ExpectClearedScrollDeltasRecursive(root); 630 ExpectClearedScrollDeltasRecursive(root);
626 631
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 root->SetBounds(gfx::Size(50, 50)); 1357 root->SetBounds(gfx::Size(50, 50));
1353 root->test_properties()->force_render_surface = true; 1358 root->test_properties()->force_render_surface = true;
1354 1359
1355 root->test_properties()->AddChild( 1360 root->test_properties()->AddChild(
1356 LayerImpl::Create(host_impl_->active_tree(), 2)); 1361 LayerImpl::Create(host_impl_->active_tree(), 2));
1357 LayerImpl* child = root->test_properties()->children[0]; 1362 LayerImpl* child = root->test_properties()->children[0];
1358 child->SetBounds(gfx::Size(10, 10)); 1363 child->SetBounds(gfx::Size(10, 10));
1359 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1364 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1360 child->SetDrawsContent(true); 1365 child->SetDrawsContent(true);
1361 1366
1367 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
1368
1362 // Add a translate from 6,7 to 8,9. 1369 // Add a translate from 6,7 to 8,9.
1363 TransformOperations start; 1370 TransformOperations start;
1364 start.AppendTranslate(6.f, 7.f, 0.f); 1371 start.AppendTranslate(6.f, 7.f, 0.f);
1365 TransformOperations end; 1372 TransformOperations end;
1366 end.AppendTranslate(8.f, 9.f, 0.f); 1373 end.AppendTranslate(8.f, 9.f, 0.f);
1367 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, 1374 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start,
1368 end); 1375 end);
1369 1376
1370 base::TimeTicks now = base::TimeTicks::Now(); 1377 base::TimeTicks now = base::TimeTicks::Now();
1371 host_impl_->WillBeginImplFrame( 1378 host_impl_->WillBeginImplFrame(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 1445
1439 host_impl_->CommitComplete(); 1446 host_impl_->CommitComplete();
1440 1447
1441 // Animations on the active tree should be started and ticked, and a new frame 1448 // Animations on the active tree should be started and ticked, and a new frame
1442 // should be requested to continue ticking them. 1449 // should be requested to continue ticking them.
1443 EXPECT_TRUE(did_request_next_frame_); 1450 EXPECT_TRUE(did_request_next_frame_);
1444 EXPECT_TRUE(did_request_redraw_); 1451 EXPECT_TRUE(did_request_redraw_);
1445 EXPECT_FALSE(did_request_commit_); 1452 EXPECT_FALSE(did_request_commit_);
1446 1453
1447 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. 1454 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away.
1455 host_impl_->ReleaseOutputSurface();
1448 host_impl_ = nullptr; 1456 host_impl_ = nullptr;
1449 } 1457 }
1450 1458
1451 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { 1459 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) {
1452 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1460 host_impl_->SetViewportSize(gfx::Size(50, 50));
1453 1461
1454 host_impl_->active_tree()->SetRootLayer( 1462 host_impl_->active_tree()->SetRootLayer(
1455 LayerImpl::Create(host_impl_->active_tree(), 1)); 1463 LayerImpl::Create(host_impl_->active_tree(), 1));
1456 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1464 LayerImpl* root = host_impl_->active_tree()->root_layer();
1457 root->SetBounds(gfx::Size(50, 50)); 1465 root->SetBounds(gfx::Size(50, 50));
1458 1466
1459 root->test_properties()->AddChild( 1467 root->test_properties()->AddChild(
1460 LayerImpl::Create(host_impl_->active_tree(), 2)); 1468 LayerImpl::Create(host_impl_->active_tree(), 2));
1461 LayerImpl* child = root->test_properties()->children[0]; 1469 LayerImpl* child = root->test_properties()->children[0];
1462 child->SetBounds(gfx::Size(10, 10)); 1470 child->SetBounds(gfx::Size(10, 10));
1463 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1471 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1464 child->SetDrawsContent(true); 1472 child->SetDrawsContent(true);
1465 1473
1474 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
1475
1466 // Add a translate animation. 1476 // Add a translate animation.
1467 TransformOperations start; 1477 TransformOperations start;
1468 start.AppendTranslate(6.f, 7.f, 0.f); 1478 start.AppendTranslate(6.f, 7.f, 0.f);
1469 TransformOperations end; 1479 TransformOperations end;
1470 end.AppendTranslate(8.f, 9.f, 0.f); 1480 end.AppendTranslate(8.f, 9.f, 0.f);
1471 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, 1481 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start,
1472 end); 1482 end);
1473 1483
1474 base::TimeTicks now = base::TimeTicks::Now(); 1484 base::TimeTicks now = base::TimeTicks::Now();
1475 host_impl_->WillBeginImplFrame( 1485 host_impl_->WillBeginImplFrame(
(...skipping 12 matching lines...) Expand all
1488 // An animation exists on the active layer. Doing Animate() requests another 1498 // An animation exists on the active layer. Doing Animate() requests another
1489 // frame after the current one. 1499 // frame after the current one.
1490 EXPECT_TRUE(did_request_next_frame_); 1500 EXPECT_TRUE(did_request_next_frame_);
1491 did_request_next_frame_ = false; 1501 did_request_next_frame_ = false;
1492 1502
1493 // Destroy layer, unregister animation target (element). 1503 // Destroy layer, unregister animation target (element).
1494 child->test_properties()->parent = nullptr; 1504 child->test_properties()->parent = nullptr;
1495 root->test_properties()->RemoveChild(child); 1505 root->test_properties()->RemoveChild(child);
1496 child = nullptr; 1506 child = nullptr;
1497 1507
1508 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
1509
1498 // Doing Animate() doesn't request another frame after the current one. 1510 // Doing Animate() doesn't request another frame after the current one.
1499 host_impl_->Animate(); 1511 host_impl_->Animate();
1500 EXPECT_FALSE(did_request_next_frame_); 1512 EXPECT_FALSE(did_request_next_frame_);
1501 1513
1502 host_impl_->Animate(); 1514 host_impl_->Animate();
1503 EXPECT_FALSE(did_request_next_frame_); 1515 EXPECT_FALSE(did_request_next_frame_);
1504 } 1516 }
1505 1517
1506 class MissingTilesLayer : public LayerImpl { 1518 class MissingTilesLayer : public LayerImpl {
1507 public: 1519 public:
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
2479 ExpectNone(*scroll_info, scroll_layer->id()); 2491 ExpectNone(*scroll_info, scroll_layer->id());
2480 } 2492 }
2481 } 2493 }
2482 2494
2483 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { 2495 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) {
2484 host_impl_->CreatePendingTree(); 2496 host_impl_->CreatePendingTree();
2485 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 2497 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
2486 CreateScrollAndContentsLayers( 2498 CreateScrollAndContentsLayers(
2487 host_impl_->pending_tree(), 2499 host_impl_->pending_tree(),
2488 gfx::Size(100, 100)); 2500 gfx::Size(100, 100));
2489 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
2490 host_impl_->ActivateSyncTree(); 2501 host_impl_->ActivateSyncTree();
2491 DrawFrame(); 2502 DrawFrame();
2492 2503
2493 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 2504 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
2494 DCHECK(scroll_layer); 2505 DCHECK(scroll_layer);
2495 2506
2496 float min_page_scale = 0.5f; 2507 float min_page_scale = 0.5f;
2497 float max_page_scale = 4.f; 2508 float max_page_scale = 4.f;
2498 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2509 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2499 max_page_scale); 2510 max_page_scale);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 fake_current_physical_time_ = fake_now; 2714 fake_current_physical_time_ = fake_now;
2704 } 2715 }
2705 2716
2706 private: 2717 private:
2707 base::TimeTicks fake_current_physical_time_; 2718 base::TimeTicks fake_current_physical_time_;
2708 }; 2719 };
2709 2720
2710 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { 2721 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest {
2711 protected: 2722 protected:
2712 void SetupLayers(LayerTreeSettings settings) { 2723 void SetupLayers(LayerTreeSettings settings) {
2724 host_impl_->ReleaseOutputSurface();
2725 host_impl_ = nullptr;
2726
2713 gfx::Size content_size(100, 100); 2727 gfx::Size content_size(100, 100);
2714 2728
2715 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = 2729 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time =
2716 new LayerTreeHostImplOverridePhysicalTime( 2730 new LayerTreeHostImplOverridePhysicalTime(
2717 settings, this, &task_runner_provider_, &shared_bitmap_manager_, 2731 settings, this, &task_runner_provider_, &shared_bitmap_manager_,
2718 &task_graph_runner_, &stats_instrumentation_); 2732 &task_graph_runner_, &stats_instrumentation_);
2719 host_impl_ = base::WrapUnique(host_impl_override_time); 2733 host_impl_ = base::WrapUnique(host_impl_override_time);
2720 output_surface_ = CreateOutputSurface(); 2734 output_surface_ = CreateOutputSurface();
2721 host_impl_->SetVisible(true); 2735 host_impl_->SetVisible(true);
2722 host_impl_->InitializeRenderer(output_surface_.get()); 2736 host_impl_->InitializeRenderer(output_surface_.get());
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2914 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 2928 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
2915 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, 2929 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
2916 VERTICAL, 10, 0, false, true); 2930 VERTICAL, 10, 0, false, true);
2917 scrollbar->test_properties()->opacity = 0.f; 2931 scrollbar->test_properties()->opacity = 0.f;
2918 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); 2932 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer();
2919 LayerImpl* container = 2933 LayerImpl* container =
2920 host_impl_->pending_tree()->InnerViewportContainerLayer(); 2934 host_impl_->pending_tree()->InnerViewportContainerLayer();
2921 scrollbar->SetScrollLayerId(scroll->id()); 2935 scrollbar->SetScrollLayerId(scroll->id());
2922 container->test_properties()->AddChild(std::move(scrollbar)); 2936 container->test_properties()->AddChild(std::move(scrollbar));
2923 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 2937 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
2938 host_impl_->pending_tree()->property_trees()->needs_rebuild = true;
2924 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); 2939 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
2925 host_impl_->ActivateSyncTree(); 2940 host_impl_->ActivateSyncTree();
2926 2941
2927 LayerImpl* active_scrollbar_layer = 2942 LayerImpl* active_scrollbar_layer =
2928 host_impl_->active_tree()->LayerById(400); 2943 host_impl_->active_tree()->LayerById(400);
2929 2944
2930 EffectNode* active_tree_node = 2945 EffectNode* active_tree_node =
2931 host_impl_->active_tree()->property_trees()->effect_tree.Node( 2946 host_impl_->active_tree()->property_trees()->effect_tree.Node(
2932 active_scrollbar_layer->effect_tree_index()); 2947 active_scrollbar_layer->effect_tree_index());
2933 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), 2948 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(),
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
3157 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, 3172 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6,
3158 VERTICAL, 5, 5, true, true); 3173 VERTICAL, 5, 5, true, true);
3159 scrollbar->SetScrollLayerId(root_scroll->id()); 3174 scrollbar->SetScrollLayerId(root_scroll->id());
3160 scrollbar->SetDrawsContent(true); 3175 scrollbar->SetDrawsContent(true);
3161 scrollbar->SetBounds(scrollbar_size); 3176 scrollbar->SetBounds(scrollbar_size);
3162 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); 3177 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size));
3163 host_impl_->active_tree() 3178 host_impl_->active_tree()
3164 ->InnerViewportContainerLayer() 3179 ->InnerViewportContainerLayer()
3165 ->test_properties() 3180 ->test_properties()
3166 ->AddChild(std::move(scrollbar)); 3181 ->AddChild(std::move(scrollbar));
3182 host_impl_->active_tree()->property_trees()->needs_rebuild = true;
3183 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
3167 host_impl_->active_tree()->DidBecomeActive(); 3184 host_impl_->active_tree()->DidBecomeActive();
3168 3185
3169 DrawFrame(); 3186 DrawFrame();
3170 host_impl_->active_tree()->UpdateDrawProperties(false); 3187 host_impl_->active_tree()->UpdateDrawProperties(false);
3171 3188
3172 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = 3189 ScrollbarAnimationControllerThinning* scrollbar_animation_controller =
3173 static_cast<ScrollbarAnimationControllerThinning*>( 3190 static_cast<ScrollbarAnimationControllerThinning*>(
3174 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); 3191 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()));
3175 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); 3192 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f);
3176 3193
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
3872 status.main_thread_scrolling_reasons); 3889 status.main_thread_scrolling_reasons);
3873 EXPECT_FALSE(did_request_redraw_); 3890 EXPECT_FALSE(did_request_redraw_);
3874 EXPECT_FALSE(did_request_commit_); 3891 EXPECT_FALSE(did_request_commit_);
3875 } 3892 }
3876 3893
3877 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) { 3894 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) {
3878 host_impl_->CreatePendingTree(); 3895 host_impl_->CreatePendingTree();
3879 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 3896 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
3880 CreateScrollAndContentsLayers(host_impl_->pending_tree(), 3897 CreateScrollAndContentsLayers(host_impl_->pending_tree(),
3881 gfx::Size(100, 100)); 3898 gfx::Size(100, 100));
3882 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
3883 host_impl_->ActivateSyncTree(); 3899 host_impl_->ActivateSyncTree();
3884 3900
3885 host_impl_->CreatePendingTree(); 3901 host_impl_->CreatePendingTree();
3886 const gfx::ScrollOffset pending_scroll = gfx::ScrollOffset(-100, -100); 3902 const gfx::ScrollOffset pending_scroll = gfx::ScrollOffset(-100, -100);
3887 LayerImpl* active_outer_layer = 3903 LayerImpl* active_outer_layer =
3888 host_impl_->active_tree()->OuterViewportScrollLayer(); 3904 host_impl_->active_tree()->OuterViewportScrollLayer();
3889 LayerImpl* pending_outer_layer = 3905 LayerImpl* pending_outer_layer =
3890 host_impl_->pending_tree()->OuterViewportScrollLayer(); 3906 host_impl_->pending_tree()->OuterViewportScrollLayer();
3891 pending_outer_layer->layer_tree_impl() 3907 pending_outer_layer->layer_tree_impl()
3892 ->property_trees() 3908 ->property_trees()
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3972 3988
3973 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); 3989 outer_clip->test_properties()->AddChild(std::move(outer_scroll));
3974 root->test_properties()->AddChild(std::move(outer_clip)); 3990 root->test_properties()->AddChild(std::move(outer_clip));
3975 page_scale->test_properties()->AddChild(std::move(root)); 3991 page_scale->test_properties()->AddChild(std::move(root));
3976 root_clip->test_properties()->AddChild(std::move(page_scale)); 3992 root_clip->test_properties()->AddChild(std::move(page_scale));
3977 3993
3978 tree_impl->SetRootLayer(std::move(root_clip)); 3994 tree_impl->SetRootLayer(std::move(root_clip));
3979 tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id, 3995 tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id,
3980 inner_viewport_scroll_layer_id, 3996 inner_viewport_scroll_layer_id,
3981 outer_viewport_scroll_layer_id); 3997 outer_viewport_scroll_layer_id);
3998 tree_impl->property_trees()->needs_rebuild = true;
3982 tree_impl->BuildLayerListAndPropertyTreesForTesting(); 3999 tree_impl->BuildLayerListAndPropertyTreesForTesting();
3983 4000
3984 host_impl_->SetViewportSize(inner_viewport_size); 4001 host_impl_->SetViewportSize(inner_viewport_size);
3985 LayerImpl* root_clip_ptr = tree_impl->root_layer(); 4002 LayerImpl* root_clip_ptr = tree_impl->root_layer();
3986 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); 4003 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds());
3987 } 4004 }
3988 4005
3989 protected: 4006 protected:
3990 gfx::Size layer_size_; 4007 gfx::Size layer_size_;
3991 gfx::Size clip_size_; 4008 gfx::Size clip_size_;
(...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after
5853 scroll_watcher.last_set_scroll_offset()); 5870 scroll_watcher.last_set_scroll_offset());
5854 host_impl_->ScrollEnd(EndState().get()); 5871 host_impl_->ScrollEnd(EndState().get());
5855 host_impl_->SetSynchronousInputHandlerRootScrollOffset(gfx::ScrollOffset()); 5872 host_impl_->SetSynchronousInputHandlerRootScrollOffset(gfx::ScrollOffset());
5856 5873
5857 // Forces a full tree synchronization and ensures that the scroll delegate 5874 // Forces a full tree synchronization and ensures that the scroll delegate
5858 // sees the correct size of the new tree. 5875 // sees the correct size of the new tree.
5859 gfx::Size new_size(42, 24); 5876 gfx::Size new_size(42, 24);
5860 host_impl_->CreatePendingTree(); 5877 host_impl_->CreatePendingTree();
5861 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 5878 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
5862 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); 5879 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size);
5863 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
5864 host_impl_->ActivateSyncTree(); 5880 host_impl_->ActivateSyncTree();
5865 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size()); 5881 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size());
5866 5882
5867 // Tear down the LayerTreeHostImpl before the InputHandlerClient. 5883 // Tear down the LayerTreeHostImpl before the InputHandlerClient.
5868 host_impl_.reset(); 5884 host_impl_->ReleaseOutputSurface();
5885 host_impl_ = nullptr;
5869 } 5886 }
5870 5887
5871 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { 5888 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) {
5872 const gfx::Transform target_space_transform = 5889 const gfx::Transform target_space_transform =
5873 layer->draw_properties().target_space_transform; 5890 layer->draw_properties().target_space_transform;
5874 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); 5891 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation());
5875 gfx::Point translated_point; 5892 gfx::Point translated_point;
5876 target_space_transform.TransformPoint(&translated_point); 5893 target_space_transform.TransformPoint(&translated_point);
5877 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); 5894 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta);
5878 EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); 5895 EXPECT_EQ(expected_point.ToString(), translated_point.ToString());
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
7024 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( 7041 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor(
7025 SK_ColorBLACK); 7042 SK_ColorBLACK);
7026 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 7043 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
7027 layer_tree_host_impl->DrawLayers(&frame); 7044 layer_tree_host_impl->DrawLayers(&frame);
7028 host_impl_->DidDrawAllLayers(frame); 7045 host_impl_->DidDrawAllLayers(frame);
7029 layer_tree_host_impl->SwapBuffers(frame); 7046 layer_tree_host_impl->SwapBuffers(frame);
7030 7047
7031 expected_swap_rect = gfx::Rect(0, 0, 10, 10); 7048 expected_swap_rect = gfx::Rect(0, 0, 10, 10);
7032 EXPECT_EQ(expected_swap_rect.ToString(), 7049 EXPECT_EQ(expected_swap_rect.ToString(),
7033 fake_output_surface->last_swap_rect().ToString()); 7050 fake_output_surface->last_swap_rect().ToString());
7051
7052 layer_tree_host_impl->ReleaseOutputSurface();
7034 } 7053 }
7035 7054
7036 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { 7055 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {
7037 std::unique_ptr<LayerImpl> root = 7056 std::unique_ptr<LayerImpl> root =
7038 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 7057 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
7039 std::unique_ptr<LayerImpl> child = 7058 std::unique_ptr<LayerImpl> child =
7040 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); 7059 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
7041 child->SetBounds(gfx::Size(10, 10)); 7060 child->SetBounds(gfx::Size(10, 10));
7042 child->SetDrawsContent(true); 7061 child->SetDrawsContent(true);
7043 root->SetBounds(gfx::Size(10, 10)); 7062 root->SetBounds(gfx::Size(10, 10));
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
7342 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 7361 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
7343 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 7362 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
7344 EXPECT_EQ(DrawQuad::SOLID_COLOR, 7363 EXPECT_EQ(DrawQuad::SOLID_COLOR,
7345 frame.render_passes[0]->quad_list.front()->material); 7364 frame.render_passes[0]->quad_list.front()->material);
7346 EXPECT_EQ(DrawQuad::RENDER_PASS, 7365 EXPECT_EQ(DrawQuad::RENDER_PASS,
7347 frame.render_passes[1]->quad_list.front()->material); 7366 frame.render_passes[1]->quad_list.front()->material);
7348 7367
7349 my_host_impl->DrawLayers(&frame); 7368 my_host_impl->DrawLayers(&frame);
7350 my_host_impl->DidDrawAllLayers(frame); 7369 my_host_impl->DidDrawAllLayers(frame);
7351 } 7370 }
7371 my_host_impl->ReleaseOutputSurface();
7352 } 7372 }
7353 7373
7354 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 7374 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
7355 TestSharedBitmapManager shared_bitmap_manager; 7375 TestSharedBitmapManager shared_bitmap_manager;
7356 TestTaskGraphRunner task_graph_runner; 7376 TestTaskGraphRunner task_graph_runner;
7357 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 7377 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
7358 provider->BindToCurrentThread(); 7378 provider->BindToCurrentThread();
7359 provider->TestContext3d()->set_have_post_sub_buffer(true); 7379 provider->TestContext3d()->set_have_post_sub_buffer(true);
7360 std::unique_ptr<OutputSurface> output_surface( 7380 std::unique_ptr<OutputSurface> output_surface(
7361 FakeOutputSurface::Create3d(provider)); 7381 FakeOutputSurface::Create3d(provider));
(...skipping 10 matching lines...) Expand all
7372 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 7392 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
7373 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 7393 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
7374 EXPECT_EQ(DrawQuad::SOLID_COLOR, 7394 EXPECT_EQ(DrawQuad::SOLID_COLOR,
7375 frame.render_passes[0]->quad_list.front()->material); 7395 frame.render_passes[0]->quad_list.front()->material);
7376 EXPECT_EQ(DrawQuad::RENDER_PASS, 7396 EXPECT_EQ(DrawQuad::RENDER_PASS,
7377 frame.render_passes[1]->quad_list.front()->material); 7397 frame.render_passes[1]->quad_list.front()->material);
7378 7398
7379 my_host_impl->DrawLayers(&frame); 7399 my_host_impl->DrawLayers(&frame);
7380 my_host_impl->DidDrawAllLayers(frame); 7400 my_host_impl->DidDrawAllLayers(frame);
7381 } 7401 }
7402 my_host_impl->ReleaseOutputSurface();
7382 } 7403 }
7383 7404
7384 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { 7405 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) {
7385 std::unique_ptr<TestWebGraphicsContext3D> context = 7406 std::unique_ptr<TestWebGraphicsContext3D> context =
7386 TestWebGraphicsContext3D::Create(); 7407 TestWebGraphicsContext3D::Create();
7387 TestWebGraphicsContext3D* context3d = context.get(); 7408 TestWebGraphicsContext3D* context3d = context.get();
7388 std::unique_ptr<OutputSurface> output_surface( 7409 std::unique_ptr<OutputSurface> output_surface(
7389 FakeOutputSurface::Create3d(std::move(context))); 7410 FakeOutputSurface::Create3d(std::move(context)));
7390 CreateHostImpl(DefaultSettings(), std::move(output_surface)); 7411 CreateHostImpl(DefaultSettings(), std::move(output_surface));
7391 7412
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
7742 resourceless_software_draw); 7763 resourceless_software_draw);
7743 7764
7744 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); 7765 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size());
7745 EXPECT_EQ(host_impl_->active_tree()->root_layer(), 7766 EXPECT_EQ(host_impl_->active_tree()->root_layer(),
7746 last_on_draw_frame_->will_draw_layers[0]); 7767 last_on_draw_frame_->will_draw_layers[0]);
7747 } 7768 }
7748 7769
7749 // Checks that we have a non-0 default allocation if we pass a context that 7770 // Checks that we have a non-0 default allocation if we pass a context that
7750 // doesn't support memory management extensions. 7771 // doesn't support memory management extensions.
7751 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { 7772 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) {
7773 host_impl_->ReleaseOutputSurface();
7774 host_impl_ = nullptr;
7775
7752 LayerTreeSettings settings = DefaultSettings(); 7776 LayerTreeSettings settings = DefaultSettings();
7753 host_impl_ = LayerTreeHostImpl::Create( 7777 host_impl_ = LayerTreeHostImpl::Create(
7754 settings, this, &task_runner_provider_, &stats_instrumentation_, 7778 settings, this, &task_runner_provider_, &stats_instrumentation_,
7755 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, 7779 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_,
7756 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 7780 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
7757 7781
7758 output_surface_ = 7782 output_surface_ =
7759 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()); 7783 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create());
7760 host_impl_->SetVisible(true); 7784 host_impl_->SetVisible(true);
7761 host_impl_->InitializeRenderer(output_surface_.get()); 7785 host_impl_->InitializeRenderer(output_surface_.get());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
7924 LayerTreeHostImpl::FrameData frame; 7948 LayerTreeHostImpl::FrameData frame;
7925 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 7949 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
7926 host_impl_->DrawLayers(&frame); 7950 host_impl_->DrawLayers(&frame);
7927 host_impl_->DidDrawAllLayers(frame); 7951 host_impl_->DidDrawAllLayers(frame);
7928 7952
7929 // The CopyOutputResult's callback has a ref on the ContextProvider and a 7953 // The CopyOutputResult's callback has a ref on the ContextProvider and a
7930 // texture in a texture mailbox. 7954 // texture in a texture mailbox.
7931 EXPECT_FALSE(context_provider->HasOneRef()); 7955 EXPECT_FALSE(context_provider->HasOneRef());
7932 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 7956 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
7933 7957
7958 host_impl_->ReleaseOutputSurface();
7934 host_impl_ = nullptr; 7959 host_impl_ = nullptr;
7935 7960
7936 // The CopyOutputResult's callback was cancelled, the CopyOutputResult 7961 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
7937 // released, and the texture deleted. 7962 // released, and the texture deleted.
7938 EXPECT_TRUE(context_provider->HasOneRef()); 7963 EXPECT_TRUE(context_provider->HasOneRef());
7939 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); 7964 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
7940 } 7965 }
7941 7966
7942 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { 7967 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) {
7943 // When flinging via touch, only the child should scroll (we should not 7968 // When flinging via touch, only the child should scroll (we should not
(...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after
10270 layer->SetDrawsContent(true); 10295 layer->SetDrawsContent(true);
10271 layer->tilings()->AddTiling(1.0f, raster_source_with_tiles); 10296 layer->tilings()->AddTiling(1.0f, raster_source_with_tiles);
10272 layer->UpdateRasterSource(raster_source_with_tiles, &empty_invalidation, 10297 layer->UpdateRasterSource(raster_source_with_tiles, &empty_invalidation,
10273 nullptr); 10298 nullptr);
10274 layer->tilings()->tiling_at(0)->set_resolution( 10299 layer->tilings()->tiling_at(0)->set_resolution(
10275 TileResolution::HIGH_RESOLUTION); 10300 TileResolution::HIGH_RESOLUTION);
10276 layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 10301 layer->tilings()->tiling_at(0)->CreateAllTilesForTesting();
10277 layer->tilings()->UpdateTilePriorities(gfx::Rect(gfx::Size(10, 10)), 1.f, 1.0, 10302 layer->tilings()->UpdateTilePriorities(gfx::Rect(gfx::Size(10, 10)), 1.f, 1.0,
10278 Occlusion(), true); 10303 Occlusion(), true);
10279 host_impl_->pending_tree()->SetRootLayer(std::move(layer)); 10304 host_impl_->pending_tree()->SetRootLayer(std::move(layer));
10305 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
10280 10306
10281 FakePictureLayerImpl* root_layer = static_cast<FakePictureLayerImpl*>( 10307 FakePictureLayerImpl* root_layer = static_cast<FakePictureLayerImpl*>(
10282 host_impl_->pending_tree()->root_layer()); 10308 host_impl_->pending_tree()->root_layer());
10283 10309
10284 root_layer->set_has_valid_tile_priorities(true); 10310 root_layer->set_has_valid_tile_priorities(true);
10285 std::unique_ptr<RasterTilePriorityQueue> non_empty_raster_priority_queue_all = 10311 std::unique_ptr<RasterTilePriorityQueue> non_empty_raster_priority_queue_all =
10286 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, 10312 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES,
10287 RasterTilePriorityQueue::Type::ALL); 10313 RasterTilePriorityQueue::Type::ALL);
10288 EXPECT_FALSE(non_empty_raster_priority_queue_all->IsEmpty()); 10314 EXPECT_FALSE(non_empty_raster_priority_queue_all->IsEmpty());
10289 10315
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
10872 float expected_jitter = 10898 float expected_jitter =
10873 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10899 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10874 EXPECT_EQ(jitter, expected_jitter); 10900 EXPECT_EQ(jitter, expected_jitter);
10875 } 10901 }
10876 } 10902 }
10877 10903
10878 // Checks that if we lose a GPU raster enabled OutputSurface and replace it 10904 // Checks that if we lose a GPU raster enabled OutputSurface and replace it
10879 // with a software OutputSurface, LayerTreeHostImpl correctly re-computes GPU 10905 // with a software OutputSurface, LayerTreeHostImpl correctly re-computes GPU
10880 // rasterization status. 10906 // rasterization status.
10881 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnOutputSurfaceChange) { 10907 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnOutputSurfaceChange) {
10908 host_impl_->ReleaseOutputSurface();
10909 host_impl_ = nullptr;
10910
10882 LayerTreeSettings settings = DefaultSettings(); 10911 LayerTreeSettings settings = DefaultSettings();
10883 settings.gpu_rasterization_forced = true; 10912 settings.gpu_rasterization_forced = true;
10884 10913
10885 host_impl_ = LayerTreeHostImpl::Create( 10914 host_impl_ = LayerTreeHostImpl::Create(
10886 settings, this, &task_runner_provider_, &stats_instrumentation_, 10915 settings, this, &task_runner_provider_, &stats_instrumentation_,
10887 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, 10916 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_,
10888 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 10917 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
10889 host_impl_->SetVisible(true); 10918 host_impl_->SetVisible(true);
10890 10919
10891 // InitializeRenderer with a gpu-raster enabled output surface. 10920 // InitializeRenderer with a gpu-raster enabled output surface.
10892 auto gpu_raster_output_surface = 10921 auto gpu_raster_output_surface =
10893 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()); 10922 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create());
10894 host_impl_->InitializeRenderer(gpu_raster_output_surface.get()); 10923 host_impl_->InitializeRenderer(gpu_raster_output_surface.get());
10895 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 10924 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
10896 10925
10897 // Re-initialize with a software output surface. 10926 // Re-initialize with a software output surface.
10898 output_surface_ = FakeOutputSurface::CreateSoftware( 10927 output_surface_ = FakeOutputSurface::CreateSoftware(
10899 base::WrapUnique(new SoftwareOutputDevice)); 10928 base::WrapUnique(new SoftwareOutputDevice));
10900 host_impl_->InitializeRenderer(output_surface_.get()); 10929 host_impl_->InitializeRenderer(output_surface_.get());
10901 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10930 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10902 } 10931 }
10903 10932
10904 } // namespace 10933 } // namespace
10905 } // namespace cc 10934 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698