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

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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.cc » ('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/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->SetRootLayerForTesting(std::move(root)); 346 layer_tree_impl->SetRootLayerForTesting(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 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 root->SetBounds(gfx::Size(50, 50)); 1358 root->SetBounds(gfx::Size(50, 50));
1355 root->test_properties()->force_render_surface = true; 1359 root->test_properties()->force_render_surface = true;
1356 1360
1357 root->test_properties()->AddChild( 1361 root->test_properties()->AddChild(
1358 LayerImpl::Create(host_impl_->active_tree(), 2)); 1362 LayerImpl::Create(host_impl_->active_tree(), 2));
1359 LayerImpl* child = root->test_properties()->children[0]; 1363 LayerImpl* child = root->test_properties()->children[0];
1360 child->SetBounds(gfx::Size(10, 10)); 1364 child->SetBounds(gfx::Size(10, 10));
1361 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1365 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1362 child->SetDrawsContent(true); 1366 child->SetDrawsContent(true);
1363 1367
1368 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
1369
1364 // Add a translate from 6,7 to 8,9. 1370 // Add a translate from 6,7 to 8,9.
1365 TransformOperations start; 1371 TransformOperations start;
1366 start.AppendTranslate(6.f, 7.f, 0.f); 1372 start.AppendTranslate(6.f, 7.f, 0.f);
1367 TransformOperations end; 1373 TransformOperations end;
1368 end.AppendTranslate(8.f, 9.f, 0.f); 1374 end.AppendTranslate(8.f, 9.f, 0.f);
1369 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, 1375 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start,
1370 end); 1376 end);
1371 1377
1372 base::TimeTicks now = base::TimeTicks::Now(); 1378 base::TimeTicks now = base::TimeTicks::Now();
1373 host_impl_->WillBeginImplFrame( 1379 host_impl_->WillBeginImplFrame(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 1446
1441 host_impl_->CommitComplete(); 1447 host_impl_->CommitComplete();
1442 1448
1443 // Animations on the active tree should be started and ticked, and a new frame 1449 // Animations on the active tree should be started and ticked, and a new frame
1444 // should be requested to continue ticking them. 1450 // should be requested to continue ticking them.
1445 EXPECT_TRUE(did_request_next_frame_); 1451 EXPECT_TRUE(did_request_next_frame_);
1446 EXPECT_TRUE(did_request_redraw_); 1452 EXPECT_TRUE(did_request_redraw_);
1447 EXPECT_FALSE(did_request_commit_); 1453 EXPECT_FALSE(did_request_commit_);
1448 1454
1449 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. 1455 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away.
1456 host_impl_->ReleaseOutputSurface();
1450 host_impl_ = nullptr; 1457 host_impl_ = nullptr;
1451 } 1458 }
1452 1459
1453 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { 1460 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) {
1454 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1461 host_impl_->SetViewportSize(gfx::Size(50, 50));
1455 1462
1456 host_impl_->active_tree()->SetRootLayerForTesting( 1463 host_impl_->active_tree()->SetRootLayerForTesting(
1457 LayerImpl::Create(host_impl_->active_tree(), 1)); 1464 LayerImpl::Create(host_impl_->active_tree(), 1));
1458 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); 1465 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
1459 root->SetBounds(gfx::Size(50, 50)); 1466 root->SetBounds(gfx::Size(50, 50));
1460 1467
1461 root->test_properties()->AddChild( 1468 root->test_properties()->AddChild(
1462 LayerImpl::Create(host_impl_->active_tree(), 2)); 1469 LayerImpl::Create(host_impl_->active_tree(), 2));
1463 LayerImpl* child = root->test_properties()->children[0]; 1470 LayerImpl* child = root->test_properties()->children[0];
1464 child->SetBounds(gfx::Size(10, 10)); 1471 child->SetBounds(gfx::Size(10, 10));
1465 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1472 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1466 child->SetDrawsContent(true); 1473 child->SetDrawsContent(true);
1467 1474
1475 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
1476
1468 // Add a translate animation. 1477 // Add a translate animation.
1469 TransformOperations start; 1478 TransformOperations start;
1470 start.AppendTranslate(6.f, 7.f, 0.f); 1479 start.AppendTranslate(6.f, 7.f, 0.f);
1471 TransformOperations end; 1480 TransformOperations end;
1472 end.AppendTranslate(8.f, 9.f, 0.f); 1481 end.AppendTranslate(8.f, 9.f, 0.f);
1473 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, 1482 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start,
1474 end); 1483 end);
1475 1484
1476 base::TimeTicks now = base::TimeTicks::Now(); 1485 base::TimeTicks now = base::TimeTicks::Now();
1477 host_impl_->WillBeginImplFrame( 1486 host_impl_->WillBeginImplFrame(
(...skipping 12 matching lines...) Expand all
1490 // An animation exists on the active layer. Doing Animate() requests another 1499 // An animation exists on the active layer. Doing Animate() requests another
1491 // frame after the current one. 1500 // frame after the current one.
1492 EXPECT_TRUE(did_request_next_frame_); 1501 EXPECT_TRUE(did_request_next_frame_);
1493 did_request_next_frame_ = false; 1502 did_request_next_frame_ = false;
1494 1503
1495 // Destroy layer, unregister animation target (element). 1504 // Destroy layer, unregister animation target (element).
1496 child->test_properties()->parent = nullptr; 1505 child->test_properties()->parent = nullptr;
1497 root->test_properties()->RemoveChild(child); 1506 root->test_properties()->RemoveChild(child);
1498 child = nullptr; 1507 child = nullptr;
1499 1508
1509 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
1510
1500 // Doing Animate() doesn't request another frame after the current one. 1511 // Doing Animate() doesn't request another frame after the current one.
1501 host_impl_->Animate(); 1512 host_impl_->Animate();
1502 EXPECT_FALSE(did_request_next_frame_); 1513 EXPECT_FALSE(did_request_next_frame_);
1503 1514
1504 host_impl_->Animate(); 1515 host_impl_->Animate();
1505 EXPECT_FALSE(did_request_next_frame_); 1516 EXPECT_FALSE(did_request_next_frame_);
1506 } 1517 }
1507 1518
1508 class MissingTilesLayer : public LayerImpl { 1519 class MissingTilesLayer : public LayerImpl {
1509 public: 1520 public:
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
2481 ExpectNone(*scroll_info, scroll_layer->id()); 2492 ExpectNone(*scroll_info, scroll_layer->id());
2482 } 2493 }
2483 } 2494 }
2484 2495
2485 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { 2496 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) {
2486 host_impl_->CreatePendingTree(); 2497 host_impl_->CreatePendingTree();
2487 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 2498 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
2488 CreateScrollAndContentsLayers( 2499 CreateScrollAndContentsLayers(
2489 host_impl_->pending_tree(), 2500 host_impl_->pending_tree(),
2490 gfx::Size(100, 100)); 2501 gfx::Size(100, 100));
2491 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
2492 host_impl_->ActivateSyncTree(); 2502 host_impl_->ActivateSyncTree();
2493 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); 2503 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting();
2494 DrawFrame(); 2504 DrawFrame();
2495 2505
2496 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 2506 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
2497 DCHECK(scroll_layer); 2507 DCHECK(scroll_layer);
2498 2508
2499 float min_page_scale = 0.5f; 2509 float min_page_scale = 0.5f;
2500 float max_page_scale = 4.f; 2510 float max_page_scale = 4.f;
2501 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2511 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 fake_current_physical_time_ = fake_now; 2716 fake_current_physical_time_ = fake_now;
2707 } 2717 }
2708 2718
2709 private: 2719 private:
2710 base::TimeTicks fake_current_physical_time_; 2720 base::TimeTicks fake_current_physical_time_;
2711 }; 2721 };
2712 2722
2713 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { 2723 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest {
2714 protected: 2724 protected:
2715 void SetupLayers(LayerTreeSettings settings) { 2725 void SetupLayers(LayerTreeSettings settings) {
2726 host_impl_->ReleaseOutputSurface();
2727 host_impl_ = nullptr;
2728
2716 gfx::Size content_size(100, 100); 2729 gfx::Size content_size(100, 100);
2717 2730
2718 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = 2731 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time =
2719 new LayerTreeHostImplOverridePhysicalTime( 2732 new LayerTreeHostImplOverridePhysicalTime(
2720 settings, this, &task_runner_provider_, &shared_bitmap_manager_, 2733 settings, this, &task_runner_provider_, &shared_bitmap_manager_,
2721 &task_graph_runner_, &stats_instrumentation_); 2734 &task_graph_runner_, &stats_instrumentation_);
2722 host_impl_ = base::WrapUnique(host_impl_override_time); 2735 host_impl_ = base::WrapUnique(host_impl_override_time);
2723 output_surface_ = CreateOutputSurface(); 2736 output_surface_ = CreateOutputSurface();
2724 host_impl_->SetVisible(true); 2737 host_impl_->SetVisible(true);
2725 host_impl_->InitializeRenderer(output_surface_.get()); 2738 host_impl_->InitializeRenderer(output_surface_.get());
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 2930 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
2918 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, 2931 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
2919 VERTICAL, 10, 0, false, true); 2932 VERTICAL, 10, 0, false, true);
2920 scrollbar->test_properties()->opacity = 0.f; 2933 scrollbar->test_properties()->opacity = 0.f;
2921 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); 2934 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer();
2922 LayerImpl* container = 2935 LayerImpl* container =
2923 host_impl_->pending_tree()->InnerViewportContainerLayer(); 2936 host_impl_->pending_tree()->InnerViewportContainerLayer();
2924 scrollbar->SetScrollLayerId(scroll->id()); 2937 scrollbar->SetScrollLayerId(scroll->id());
2925 container->test_properties()->AddChild(std::move(scrollbar)); 2938 container->test_properties()->AddChild(std::move(scrollbar));
2926 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 2939 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
2940 host_impl_->pending_tree()->property_trees()->needs_rebuild = true;
2927 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); 2941 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
2928 host_impl_->ActivateSyncTree(); 2942 host_impl_->ActivateSyncTree();
2929 2943
2930 LayerImpl* active_scrollbar_layer = 2944 LayerImpl* active_scrollbar_layer =
2931 host_impl_->active_tree()->LayerById(400); 2945 host_impl_->active_tree()->LayerById(400);
2932 2946
2933 EffectNode* active_tree_node = 2947 EffectNode* active_tree_node =
2934 host_impl_->active_tree()->property_trees()->effect_tree.Node( 2948 host_impl_->active_tree()->property_trees()->effect_tree.Node(
2935 active_scrollbar_layer->effect_tree_index()); 2949 active_scrollbar_layer->effect_tree_index());
2936 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), 2950 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(),
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
3160 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, 3174 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6,
3161 VERTICAL, 5, 5, true, true); 3175 VERTICAL, 5, 5, true, true);
3162 scrollbar->SetScrollLayerId(root_scroll->id()); 3176 scrollbar->SetScrollLayerId(root_scroll->id());
3163 scrollbar->SetDrawsContent(true); 3177 scrollbar->SetDrawsContent(true);
3164 scrollbar->SetBounds(scrollbar_size); 3178 scrollbar->SetBounds(scrollbar_size);
3165 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); 3179 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size));
3166 host_impl_->active_tree() 3180 host_impl_->active_tree()
3167 ->InnerViewportContainerLayer() 3181 ->InnerViewportContainerLayer()
3168 ->test_properties() 3182 ->test_properties()
3169 ->AddChild(std::move(scrollbar)); 3183 ->AddChild(std::move(scrollbar));
3184 host_impl_->active_tree()->property_trees()->needs_rebuild = true;
3185 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
3170 host_impl_->active_tree()->DidBecomeActive(); 3186 host_impl_->active_tree()->DidBecomeActive();
3171 3187
3172 DrawFrame(); 3188 DrawFrame();
3173 host_impl_->active_tree()->UpdateDrawProperties(false); 3189 host_impl_->active_tree()->UpdateDrawProperties(false);
3174 3190
3175 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = 3191 ScrollbarAnimationControllerThinning* scrollbar_animation_controller =
3176 static_cast<ScrollbarAnimationControllerThinning*>( 3192 static_cast<ScrollbarAnimationControllerThinning*>(
3177 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); 3193 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()));
3178 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); 3194 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f);
3179 3195
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
3875 status.main_thread_scrolling_reasons); 3891 status.main_thread_scrolling_reasons);
3876 EXPECT_FALSE(did_request_redraw_); 3892 EXPECT_FALSE(did_request_redraw_);
3877 EXPECT_FALSE(did_request_commit_); 3893 EXPECT_FALSE(did_request_commit_);
3878 } 3894 }
3879 3895
3880 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) { 3896 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) {
3881 host_impl_->CreatePendingTree(); 3897 host_impl_->CreatePendingTree();
3882 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 3898 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
3883 CreateScrollAndContentsLayers(host_impl_->pending_tree(), 3899 CreateScrollAndContentsLayers(host_impl_->pending_tree(),
3884 gfx::Size(100, 100)); 3900 gfx::Size(100, 100));
3885 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
3886 host_impl_->ActivateSyncTree(); 3901 host_impl_->ActivateSyncTree();
3887 3902
3888 host_impl_->CreatePendingTree(); 3903 host_impl_->CreatePendingTree();
3889 const gfx::ScrollOffset pending_scroll = gfx::ScrollOffset(-100, -100); 3904 const gfx::ScrollOffset pending_scroll = gfx::ScrollOffset(-100, -100);
3890 LayerImpl* active_outer_layer = 3905 LayerImpl* active_outer_layer =
3891 host_impl_->active_tree()->OuterViewportScrollLayer(); 3906 host_impl_->active_tree()->OuterViewportScrollLayer();
3892 LayerImpl* pending_outer_layer = 3907 LayerImpl* pending_outer_layer =
3893 host_impl_->pending_tree()->OuterViewportScrollLayer(); 3908 host_impl_->pending_tree()->OuterViewportScrollLayer();
3894 pending_outer_layer->layer_tree_impl() 3909 pending_outer_layer->layer_tree_impl()
3895 ->property_trees() 3910 ->property_trees()
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3975 3990
3976 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); 3991 outer_clip->test_properties()->AddChild(std::move(outer_scroll));
3977 root->test_properties()->AddChild(std::move(outer_clip)); 3992 root->test_properties()->AddChild(std::move(outer_clip));
3978 page_scale->test_properties()->AddChild(std::move(root)); 3993 page_scale->test_properties()->AddChild(std::move(root));
3979 root_clip->test_properties()->AddChild(std::move(page_scale)); 3994 root_clip->test_properties()->AddChild(std::move(page_scale));
3980 3995
3981 tree_impl->SetRootLayerForTesting(std::move(root_clip)); 3996 tree_impl->SetRootLayerForTesting(std::move(root_clip));
3982 tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id, 3997 tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id,
3983 inner_viewport_scroll_layer_id, 3998 inner_viewport_scroll_layer_id,
3984 outer_viewport_scroll_layer_id); 3999 outer_viewport_scroll_layer_id);
4000 tree_impl->property_trees()->needs_rebuild = true;
3985 tree_impl->BuildLayerListAndPropertyTreesForTesting(); 4001 tree_impl->BuildLayerListAndPropertyTreesForTesting();
3986 4002
3987 host_impl_->SetViewportSize(inner_viewport_size); 4003 host_impl_->SetViewportSize(inner_viewport_size);
3988 LayerImpl* root_clip_ptr = tree_impl->root_layer_for_testing(); 4004 LayerImpl* root_clip_ptr = tree_impl->root_layer_for_testing();
3989 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); 4005 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds());
3990 } 4006 }
3991 4007
3992 protected: 4008 protected:
3993 gfx::Size layer_size_; 4009 gfx::Size layer_size_;
3994 gfx::Size clip_size_; 4010 gfx::Size clip_size_;
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after
5860 scroll_watcher.last_set_scroll_offset()); 5876 scroll_watcher.last_set_scroll_offset());
5861 host_impl_->ScrollEnd(EndState().get()); 5877 host_impl_->ScrollEnd(EndState().get());
5862 host_impl_->SetSynchronousInputHandlerRootScrollOffset(gfx::ScrollOffset()); 5878 host_impl_->SetSynchronousInputHandlerRootScrollOffset(gfx::ScrollOffset());
5863 5879
5864 // Forces a full tree synchronization and ensures that the scroll delegate 5880 // Forces a full tree synchronization and ensures that the scroll delegate
5865 // sees the correct size of the new tree. 5881 // sees the correct size of the new tree.
5866 gfx::Size new_size(42, 24); 5882 gfx::Size new_size(42, 24);
5867 host_impl_->CreatePendingTree(); 5883 host_impl_->CreatePendingTree();
5868 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 5884 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
5869 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); 5885 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size);
5870 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
5871 host_impl_->ActivateSyncTree(); 5886 host_impl_->ActivateSyncTree();
5872 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size()); 5887 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size());
5873 5888
5874 // Tear down the LayerTreeHostImpl before the InputHandlerClient. 5889 // Tear down the LayerTreeHostImpl before the InputHandlerClient.
5875 host_impl_.reset(); 5890 host_impl_->ReleaseOutputSurface();
5891 host_impl_ = nullptr;
5876 } 5892 }
5877 5893
5878 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { 5894 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) {
5879 const gfx::Transform target_space_transform = 5895 const gfx::Transform target_space_transform =
5880 layer->draw_properties().target_space_transform; 5896 layer->draw_properties().target_space_transform;
5881 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); 5897 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation());
5882 gfx::Point translated_point; 5898 gfx::Point translated_point;
5883 target_space_transform.TransformPoint(&translated_point); 5899 target_space_transform.TransformPoint(&translated_point);
5884 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); 5900 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta);
5885 EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); 5901 EXPECT_EQ(expected_point.ToString(), translated_point.ToString());
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
7034 ->root_layer_for_testing() 7050 ->root_layer_for_testing()
7035 ->SetBackgroundColor(SK_ColorBLACK); 7051 ->SetBackgroundColor(SK_ColorBLACK);
7036 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 7052 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
7037 layer_tree_host_impl->DrawLayers(&frame); 7053 layer_tree_host_impl->DrawLayers(&frame);
7038 host_impl_->DidDrawAllLayers(frame); 7054 host_impl_->DidDrawAllLayers(frame);
7039 layer_tree_host_impl->SwapBuffers(frame); 7055 layer_tree_host_impl->SwapBuffers(frame);
7040 7056
7041 expected_swap_rect = gfx::Rect(0, 0, 10, 10); 7057 expected_swap_rect = gfx::Rect(0, 0, 10, 10);
7042 EXPECT_EQ(expected_swap_rect.ToString(), 7058 EXPECT_EQ(expected_swap_rect.ToString(),
7043 fake_output_surface->last_swap_rect().ToString()); 7059 fake_output_surface->last_swap_rect().ToString());
7060
7061 layer_tree_host_impl->ReleaseOutputSurface();
7044 } 7062 }
7045 7063
7046 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { 7064 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {
7047 std::unique_ptr<LayerImpl> root = 7065 std::unique_ptr<LayerImpl> root =
7048 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 7066 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
7049 std::unique_ptr<LayerImpl> child = 7067 std::unique_ptr<LayerImpl> child =
7050 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); 7068 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
7051 child->SetBounds(gfx::Size(10, 10)); 7069 child->SetBounds(gfx::Size(10, 10));
7052 child->SetDrawsContent(true); 7070 child->SetDrawsContent(true);
7053 root->SetBounds(gfx::Size(10, 10)); 7071 root->SetBounds(gfx::Size(10, 10));
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
7354 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 7372 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
7355 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 7373 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
7356 EXPECT_EQ(DrawQuad::SOLID_COLOR, 7374 EXPECT_EQ(DrawQuad::SOLID_COLOR,
7357 frame.render_passes[0]->quad_list.front()->material); 7375 frame.render_passes[0]->quad_list.front()->material);
7358 EXPECT_EQ(DrawQuad::RENDER_PASS, 7376 EXPECT_EQ(DrawQuad::RENDER_PASS,
7359 frame.render_passes[1]->quad_list.front()->material); 7377 frame.render_passes[1]->quad_list.front()->material);
7360 7378
7361 my_host_impl->DrawLayers(&frame); 7379 my_host_impl->DrawLayers(&frame);
7362 my_host_impl->DidDrawAllLayers(frame); 7380 my_host_impl->DidDrawAllLayers(frame);
7363 } 7381 }
7382 my_host_impl->ReleaseOutputSurface();
7364 } 7383 }
7365 7384
7366 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 7385 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
7367 TestSharedBitmapManager shared_bitmap_manager; 7386 TestSharedBitmapManager shared_bitmap_manager;
7368 TestTaskGraphRunner task_graph_runner; 7387 TestTaskGraphRunner task_graph_runner;
7369 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 7388 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
7370 provider->BindToCurrentThread(); 7389 provider->BindToCurrentThread();
7371 provider->TestContext3d()->set_have_post_sub_buffer(true); 7390 provider->TestContext3d()->set_have_post_sub_buffer(true);
7372 std::unique_ptr<OutputSurface> output_surface( 7391 std::unique_ptr<OutputSurface> output_surface(
7373 FakeOutputSurface::Create3d(provider)); 7392 FakeOutputSurface::Create3d(provider));
(...skipping 10 matching lines...) Expand all
7384 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 7403 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
7385 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 7404 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
7386 EXPECT_EQ(DrawQuad::SOLID_COLOR, 7405 EXPECT_EQ(DrawQuad::SOLID_COLOR,
7387 frame.render_passes[0]->quad_list.front()->material); 7406 frame.render_passes[0]->quad_list.front()->material);
7388 EXPECT_EQ(DrawQuad::RENDER_PASS, 7407 EXPECT_EQ(DrawQuad::RENDER_PASS,
7389 frame.render_passes[1]->quad_list.front()->material); 7408 frame.render_passes[1]->quad_list.front()->material);
7390 7409
7391 my_host_impl->DrawLayers(&frame); 7410 my_host_impl->DrawLayers(&frame);
7392 my_host_impl->DidDrawAllLayers(frame); 7411 my_host_impl->DidDrawAllLayers(frame);
7393 } 7412 }
7413 my_host_impl->ReleaseOutputSurface();
7394 } 7414 }
7395 7415
7396 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { 7416 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) {
7397 std::unique_ptr<TestWebGraphicsContext3D> context = 7417 std::unique_ptr<TestWebGraphicsContext3D> context =
7398 TestWebGraphicsContext3D::Create(); 7418 TestWebGraphicsContext3D::Create();
7399 TestWebGraphicsContext3D* context3d = context.get(); 7419 TestWebGraphicsContext3D* context3d = context.get();
7400 std::unique_ptr<OutputSurface> output_surface( 7420 std::unique_ptr<OutputSurface> output_surface(
7401 FakeOutputSurface::Create3d(std::move(context))); 7421 FakeOutputSurface::Create3d(std::move(context)));
7402 CreateHostImpl(DefaultSettings(), std::move(output_surface)); 7422 CreateHostImpl(DefaultSettings(), std::move(output_surface));
7403 7423
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
7614 7634
7615 gfx::ScrollOffset scroll_offset(100000, 0); 7635 gfx::ScrollOffset scroll_offset(100000, 0);
7616 scrolling_layer->SetScrollClipLayer(root->id()); 7636 scrolling_layer->SetScrollClipLayer(root->id());
7617 scrolling_layer->layer_tree_impl() 7637 scrolling_layer->layer_tree_impl()
7618 ->property_trees() 7638 ->property_trees()
7619 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(), 7639 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(),
7620 scroll_offset); 7640 scroll_offset);
7621 7641
7622 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); 7642 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
7623 host_impl_->ActivateSyncTree(); 7643 host_impl_->ActivateSyncTree();
7624 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); 7644 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting();
danakj 2016/06/29 23:49:41 This is the magic change that fixes ASAN.
7625 7645
7626 bool update_lcd_text = false; 7646 bool update_lcd_text = false;
7627 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); 7647 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text);
7628 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); 7648 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size());
7629 7649
7630 LayerTreeHostImpl::FrameData frame; 7650 LayerTreeHostImpl::FrameData frame;
7631 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 7651 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
7632 7652
7633 ASSERT_EQ(1u, frame.render_passes.size()); 7653 ASSERT_EQ(1u, frame.render_passes.size());
7634 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); 7654 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
7756 resourceless_software_draw); 7776 resourceless_software_draw);
7757 7777
7758 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); 7778 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size());
7759 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(), 7779 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(),
7760 last_on_draw_frame_->will_draw_layers[0]); 7780 last_on_draw_frame_->will_draw_layers[0]);
7761 } 7781 }
7762 7782
7763 // Checks that we have a non-0 default allocation if we pass a context that 7783 // Checks that we have a non-0 default allocation if we pass a context that
7764 // doesn't support memory management extensions. 7784 // doesn't support memory management extensions.
7765 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { 7785 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) {
7786 host_impl_->ReleaseOutputSurface();
7787 host_impl_ = nullptr;
7788
7766 LayerTreeSettings settings = DefaultSettings(); 7789 LayerTreeSettings settings = DefaultSettings();
7767 host_impl_ = LayerTreeHostImpl::Create( 7790 host_impl_ = LayerTreeHostImpl::Create(
7768 settings, this, &task_runner_provider_, &stats_instrumentation_, 7791 settings, this, &task_runner_provider_, &stats_instrumentation_,
7769 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, 7792 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_,
7770 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 7793 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
7771 7794
7772 output_surface_ = 7795 output_surface_ =
7773 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()); 7796 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create());
7774 host_impl_->SetVisible(true); 7797 host_impl_->SetVisible(true);
7775 host_impl_->InitializeRenderer(output_surface_.get()); 7798 host_impl_->InitializeRenderer(output_surface_.get());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
7938 LayerTreeHostImpl::FrameData frame; 7961 LayerTreeHostImpl::FrameData frame;
7939 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 7962 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
7940 host_impl_->DrawLayers(&frame); 7963 host_impl_->DrawLayers(&frame);
7941 host_impl_->DidDrawAllLayers(frame); 7964 host_impl_->DidDrawAllLayers(frame);
7942 7965
7943 // The CopyOutputResult's callback has a ref on the ContextProvider and a 7966 // The CopyOutputResult's callback has a ref on the ContextProvider and a
7944 // texture in a texture mailbox. 7967 // texture in a texture mailbox.
7945 EXPECT_FALSE(context_provider->HasOneRef()); 7968 EXPECT_FALSE(context_provider->HasOneRef());
7946 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 7969 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
7947 7970
7971 host_impl_->ReleaseOutputSurface();
7948 host_impl_ = nullptr; 7972 host_impl_ = nullptr;
7949 7973
7950 // The CopyOutputResult's callback was cancelled, the CopyOutputResult 7974 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
7951 // released, and the texture deleted. 7975 // released, and the texture deleted.
7952 EXPECT_TRUE(context_provider->HasOneRef()); 7976 EXPECT_TRUE(context_provider->HasOneRef());
7953 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); 7977 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
7954 } 7978 }
7955 7979
7956 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { 7980 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) {
7957 // When flinging via touch, only the child should scroll (we should not 7981 // When flinging via touch, only the child should scroll (we should not
(...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after
10889 float expected_jitter = 10913 float expected_jitter =
10890 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10914 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10891 EXPECT_EQ(jitter, expected_jitter); 10915 EXPECT_EQ(jitter, expected_jitter);
10892 } 10916 }
10893 } 10917 }
10894 10918
10895 // Checks that if we lose a GPU raster enabled OutputSurface and replace it 10919 // Checks that if we lose a GPU raster enabled OutputSurface and replace it
10896 // with a software OutputSurface, LayerTreeHostImpl correctly re-computes GPU 10920 // with a software OutputSurface, LayerTreeHostImpl correctly re-computes GPU
10897 // rasterization status. 10921 // rasterization status.
10898 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnOutputSurfaceChange) { 10922 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnOutputSurfaceChange) {
10923 host_impl_->ReleaseOutputSurface();
10924 host_impl_ = nullptr;
10925
10899 LayerTreeSettings settings = DefaultSettings(); 10926 LayerTreeSettings settings = DefaultSettings();
10900 settings.gpu_rasterization_forced = true; 10927 settings.gpu_rasterization_forced = true;
10901 10928
10902 host_impl_ = LayerTreeHostImpl::Create( 10929 host_impl_ = LayerTreeHostImpl::Create(
10903 settings, this, &task_runner_provider_, &stats_instrumentation_, 10930 settings, this, &task_runner_provider_, &stats_instrumentation_,
10904 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, 10931 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_,
10905 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 10932 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
10906 host_impl_->SetVisible(true); 10933 host_impl_->SetVisible(true);
10907 10934
10908 // InitializeRenderer with a gpu-raster enabled output surface. 10935 // InitializeRenderer with a gpu-raster enabled output surface.
10909 auto gpu_raster_output_surface = 10936 auto gpu_raster_output_surface =
10910 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()); 10937 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create());
10911 host_impl_->InitializeRenderer(gpu_raster_output_surface.get()); 10938 host_impl_->InitializeRenderer(gpu_raster_output_surface.get());
10912 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 10939 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
10913 10940
10914 // Re-initialize with a software output surface. 10941 // Re-initialize with a software output surface.
10915 output_surface_ = FakeOutputSurface::CreateSoftware( 10942 output_surface_ = FakeOutputSurface::CreateSoftware(
10916 base::WrapUnique(new SoftwareOutputDevice)); 10943 base::WrapUnique(new SoftwareOutputDevice));
10917 host_impl_->InitializeRenderer(output_surface_.get()); 10944 host_impl_->InitializeRenderer(output_surface_.get());
10918 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10945 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10919 } 10946 }
10920 10947
10921 } // namespace 10948 } // namespace
10922 } // namespace cc 10949 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698