OLD | NEW |
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 <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 host_impl_->active_tree()->ResetContentsTexturesPurged(); | 372 host_impl_->active_tree()->ResetContentsTexturesPurged(); |
373 EXPECT_TRUE(host_impl_->CanDraw()); | 373 EXPECT_TRUE(host_impl_->CanDraw()); |
374 EXPECT_TRUE(on_can_draw_state_changed_called_); | 374 EXPECT_TRUE(on_can_draw_state_changed_called_); |
375 on_can_draw_state_changed_called_ = false; | 375 on_can_draw_state_changed_called_ = false; |
376 } | 376 } |
377 | 377 |
378 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); | 378 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); |
379 | 379 |
380 protected: | 380 protected: |
381 virtual scoped_ptr<OutputSurface> CreateOutputSurface() { | 381 virtual scoped_ptr<OutputSurface> CreateOutputSurface() { |
382 return FakeOutputSurface::Create3d(); | 382 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); |
383 } | 383 } |
384 | 384 |
385 void DrawOneFrame() { | 385 void DrawOneFrame() { |
386 LayerTreeHostImpl::FrameData frame_data; | 386 LayerTreeHostImpl::FrameData frame_data; |
387 host_impl_->PrepareToDraw(&frame_data); | 387 host_impl_->PrepareToDraw(&frame_data); |
388 host_impl_->DidDrawAllLayers(frame_data); | 388 host_impl_->DidDrawAllLayers(frame_data); |
389 } | 389 } |
390 | 390 |
391 FakeProxy proxy_; | 391 FakeProxy proxy_; |
392 DebugScopedSetImplThread always_impl_thread_; | 392 DebugScopedSetImplThread always_impl_thread_; |
(...skipping 15 matching lines...) Expand all Loading... |
408 size_t current_limit_bytes_; | 408 size_t current_limit_bytes_; |
409 int current_priority_cutoff_value_; | 409 int current_priority_cutoff_value_; |
410 }; | 410 }; |
411 | 411 |
412 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { | 412 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { |
413 bool always_draw = false; | 413 bool always_draw = false; |
414 CheckNotifyCalledIfCanDrawChanged(always_draw); | 414 CheckNotifyCalledIfCanDrawChanged(always_draw); |
415 } | 415 } |
416 | 416 |
417 TEST_F(LayerTreeHostImplTest, CanDrawIncompleteFrames) { | 417 TEST_F(LayerTreeHostImplTest, CanDrawIncompleteFrames) { |
418 CreateHostImpl(DefaultSettings(), | 418 scoped_ptr<FakeOutputSurface> output_surface( |
419 FakeOutputSurface::CreateAlwaysDrawAndSwap3d()); | 419 FakeOutputSurface::CreateAlwaysDrawAndSwap3d()); |
| 420 CreateHostImpl(DefaultSettings(), output_surface.PassAs<OutputSurface>()); |
420 | 421 |
421 bool always_draw = true; | 422 bool always_draw = true; |
422 CheckNotifyCalledIfCanDrawChanged(always_draw); | 423 CheckNotifyCalledIfCanDrawChanged(always_draw); |
423 } | 424 } |
424 | 425 |
425 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { | 426 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { |
426 ASSERT_FALSE(host_impl_->active_tree()->root_layer()); | 427 ASSERT_FALSE(host_impl_->active_tree()->root_layer()); |
427 | 428 |
428 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 429 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
429 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 430 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 // We should not crash when trying to scroll an empty layer tree. | 520 // We should not crash when trying to scroll an empty layer tree. |
520 EXPECT_EQ(InputHandler::ScrollIgnored, | 521 EXPECT_EQ(InputHandler::ScrollIgnored, |
521 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 522 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
522 } | 523 } |
523 | 524 |
524 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { | 525 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { |
525 scoped_ptr<TestWebGraphicsContext3D> context_owned = | 526 scoped_ptr<TestWebGraphicsContext3D> context_owned = |
526 TestWebGraphicsContext3D::Create(); | 527 TestWebGraphicsContext3D::Create(); |
527 context_owned->set_context_lost(true); | 528 context_owned->set_context_lost(true); |
528 | 529 |
| 530 scoped_ptr<FakeOutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 531 context_owned.Pass())); |
| 532 |
529 // Initialization will fail. | 533 // Initialization will fail. |
530 EXPECT_FALSE(CreateHostImpl( | 534 EXPECT_FALSE(CreateHostImpl(DefaultSettings(), |
531 DefaultSettings(), FakeOutputSurface::Create3d(context_owned.Pass()))); | 535 output_surface.PassAs<OutputSurface>())); |
532 | 536 |
533 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 537 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
534 | 538 |
535 // We should not crash when trying to scroll after the renderer initialization | 539 // We should not crash when trying to scroll after the renderer initialization |
536 // fails. | 540 // fails. |
537 EXPECT_EQ(InputHandler::ScrollStarted, | 541 EXPECT_EQ(InputHandler::ScrollStarted, |
538 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 542 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
539 } | 543 } |
540 | 544 |
541 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { | 545 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 contents->SetContentBounds(content_size); \ | 1322 contents->SetContentBounds(content_size); \ |
1319 \ | 1323 \ |
1320 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ | 1324 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ |
1321 SolidColorScrollbarLayerImpl::Create( \ | 1325 SolidColorScrollbarLayerImpl::Create( \ |
1322 host_impl_->active_tree(), 4, VERTICAL, 10, 0, false, true); \ | 1326 host_impl_->active_tree(), 4, VERTICAL, 10, 0, false, true); \ |
1323 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ | 1327 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ |
1324 \ | 1328 \ |
1325 scroll->AddChild(contents.Pass()); \ | 1329 scroll->AddChild(contents.Pass()); \ |
1326 root->AddChild(scroll.Pass()); \ | 1330 root->AddChild(scroll.Pass()); \ |
1327 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ | 1331 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ |
1328 root->AddChild(scrollbar.Pass()); \ | 1332 root->AddChild(scrollbar.PassAs<LayerImpl>()); \ |
1329 \ | 1333 \ |
1330 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ | 1334 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ |
1331 host_impl_->active_tree()->SetViewportLayersFromIds( \ | 1335 host_impl_->active_tree()->SetViewportLayersFromIds( \ |
1332 1, 2, Layer::INVALID_ID); \ | 1336 1, 2, Layer::INVALID_ID); \ |
1333 host_impl_->active_tree()->DidBecomeActive(); \ | 1337 host_impl_->active_tree()->DidBecomeActive(); \ |
1334 DrawFrame(); | 1338 DrawFrame(); |
1335 | 1339 |
1336 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { | 1340 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { |
1337 LayerTreeSettings settings; | 1341 LayerTreeSettings settings; |
1338 settings.scrollbar_animator = LayerTreeSettings::LinearFade; | 1342 settings.scrollbar_animator = LayerTreeSettings::LinearFade; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 scoped_ptr<PaintedScrollbarLayerImpl> scrollbar = | 1490 scoped_ptr<PaintedScrollbarLayerImpl> scrollbar = |
1487 PaintedScrollbarLayerImpl::Create(host_impl_->active_tree(), 5, VERTICAL); | 1491 PaintedScrollbarLayerImpl::Create(host_impl_->active_tree(), 5, VERTICAL); |
1488 scrollbar->SetDrawsContent(true); | 1492 scrollbar->SetDrawsContent(true); |
1489 scrollbar->SetBounds(gfx::Size(15, viewport_size.height())); | 1493 scrollbar->SetBounds(gfx::Size(15, viewport_size.height())); |
1490 scrollbar->SetContentBounds(gfx::Size(15, viewport_size.height())); | 1494 scrollbar->SetContentBounds(gfx::Size(15, viewport_size.height())); |
1491 scrollbar->SetPosition(gfx::Point(285, 0)); | 1495 scrollbar->SetPosition(gfx::Point(285, 0)); |
1492 | 1496 |
1493 scroll->AddChild(contents.Pass()); | 1497 scroll->AddChild(contents.Pass()); |
1494 root->AddChild(scroll.Pass()); | 1498 root->AddChild(scroll.Pass()); |
1495 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); | 1499 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); |
1496 root->AddChild(scrollbar.Pass()); | 1500 root->AddChild(scrollbar.PassAs<LayerImpl>()); |
1497 | 1501 |
1498 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 1502 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
1499 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); | 1503 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); |
1500 host_impl_->active_tree()->DidBecomeActive(); | 1504 host_impl_->active_tree()->DidBecomeActive(); |
1501 DrawFrame(); | 1505 DrawFrame(); |
1502 | 1506 |
1503 LayerImpl* root_scroll = | 1507 LayerImpl* root_scroll = |
1504 host_impl_->active_tree()->InnerViewportScrollLayer(); | 1508 host_impl_->active_tree()->InnerViewportScrollLayer(); |
1505 ASSERT_TRUE(root_scroll->scrollbar_animation_controller()); | 1509 ASSERT_TRUE(root_scroll->scrollbar_animation_controller()); |
1506 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = | 1510 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.scrollable_viewport_size); | 1604 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.scrollable_viewport_size); |
1601 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); | 1605 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); |
1602 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | 1606 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); |
1603 EXPECT_EQ(4.f, metadata.max_page_scale_factor); | 1607 EXPECT_EQ(4.f, metadata.max_page_scale_factor); |
1604 } | 1608 } |
1605 } | 1609 } |
1606 | 1610 |
1607 class DidDrawCheckLayer : public LayerImpl { | 1611 class DidDrawCheckLayer : public LayerImpl { |
1608 public: | 1612 public: |
1609 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 1613 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
1610 return make_scoped_ptr(new DidDrawCheckLayer(tree_impl, id)); | 1614 return scoped_ptr<LayerImpl>(new DidDrawCheckLayer(tree_impl, id)); |
1611 } | 1615 } |
1612 | 1616 |
1613 virtual bool WillDraw(DrawMode draw_mode, ResourceProvider* provider) | 1617 virtual bool WillDraw(DrawMode draw_mode, ResourceProvider* provider) |
1614 OVERRIDE { | 1618 OVERRIDE { |
1615 will_draw_called_ = true; | 1619 will_draw_called_ = true; |
1616 if (will_draw_returns_false_) | 1620 if (will_draw_returns_false_) |
1617 return false; | 1621 return false; |
1618 return LayerImpl::WillDraw(draw_mode, provider); | 1622 return LayerImpl::WillDraw(draw_mode, provider); |
1619 } | 1623 } |
1620 | 1624 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 } | 1830 } |
1827 | 1831 |
1828 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { | 1832 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { |
1829 public: | 1833 public: |
1830 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, | 1834 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, |
1831 int id, | 1835 int id, |
1832 bool tile_missing, | 1836 bool tile_missing, |
1833 bool had_incomplete_tile, | 1837 bool had_incomplete_tile, |
1834 bool animating, | 1838 bool animating, |
1835 ResourceProvider* resource_provider) { | 1839 ResourceProvider* resource_provider) { |
1836 return make_scoped_ptr(new MissingTextureAnimatingLayer(tree_impl, | 1840 return scoped_ptr<LayerImpl>( |
1837 id, | 1841 new MissingTextureAnimatingLayer(tree_impl, |
1838 tile_missing, | 1842 id, |
1839 had_incomplete_tile, | 1843 tile_missing, |
1840 animating, | 1844 had_incomplete_tile, |
1841 resource_provider)); | 1845 animating, |
| 1846 resource_provider)); |
1842 } | 1847 } |
1843 | 1848 |
1844 virtual void AppendQuads(RenderPass* render_pass, | 1849 virtual void AppendQuads(RenderPass* render_pass, |
1845 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 1850 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
1846 AppendQuadsData* append_quads_data) OVERRIDE { | 1851 AppendQuadsData* append_quads_data) OVERRIDE { |
1847 LayerImpl::AppendQuads(render_pass, occlusion_tracker, append_quads_data); | 1852 LayerImpl::AppendQuads(render_pass, occlusion_tracker, append_quads_data); |
1848 if (had_incomplete_tile_) | 1853 if (had_incomplete_tile_) |
1849 append_quads_data->num_incomplete_tiles++; | 1854 append_quads_data->num_incomplete_tiles++; |
1850 if (tile_missing_) | 1855 if (tile_missing_) |
1851 append_quads_data->num_missing_tiles++; | 1856 append_quads_data->num_missing_tiles++; |
(...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3628 host_impl_->accumulated_root_overscroll().ToString()); | 3633 host_impl_->accumulated_root_overscroll().ToString()); |
3629 host_impl_->ScrollEnd(); | 3634 host_impl_->ScrollEnd(); |
3630 } | 3635 } |
3631 } | 3636 } |
3632 | 3637 |
3633 class BlendStateCheckLayer : public LayerImpl { | 3638 class BlendStateCheckLayer : public LayerImpl { |
3634 public: | 3639 public: |
3635 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, | 3640 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, |
3636 int id, | 3641 int id, |
3637 ResourceProvider* resource_provider) { | 3642 ResourceProvider* resource_provider) { |
3638 return make_scoped_ptr( | 3643 return scoped_ptr<LayerImpl>(new BlendStateCheckLayer(tree_impl, |
3639 new BlendStateCheckLayer(tree_impl, id, resource_provider)); | 3644 id, |
| 3645 resource_provider)); |
3640 } | 3646 } |
3641 | 3647 |
3642 virtual void AppendQuads(RenderPass* render_pass, | 3648 virtual void AppendQuads(RenderPass* render_pass, |
3643 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 3649 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
3644 AppendQuadsData* append_quads_data) OVERRIDE { | 3650 AppendQuadsData* append_quads_data) OVERRIDE { |
3645 quads_appended_ = true; | 3651 quads_appended_ = true; |
3646 | 3652 |
3647 gfx::Rect opaque_rect; | 3653 gfx::Rect opaque_rect; |
3648 if (contents_opaque()) | 3654 if (contents_opaque()) |
3649 opaque_rect = quad_rect_; | 3655 opaque_rect = quad_rect_; |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3941 | 3947 |
3942 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 3948 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
3943 protected: | 3949 protected: |
3944 LayerTreeHostImplViewportCoveredTest() : | 3950 LayerTreeHostImplViewportCoveredTest() : |
3945 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 3951 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
3946 child_(NULL), | 3952 child_(NULL), |
3947 did_activate_pending_tree_(false) {} | 3953 did_activate_pending_tree_(false) {} |
3948 | 3954 |
3949 scoped_ptr<OutputSurface> CreateFakeOutputSurface(bool always_draw) { | 3955 scoped_ptr<OutputSurface> CreateFakeOutputSurface(bool always_draw) { |
3950 if (always_draw) { | 3956 if (always_draw) { |
3951 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d(); | 3957 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d() |
| 3958 .PassAs<OutputSurface>(); |
3952 } | 3959 } |
3953 return FakeOutputSurface::Create3d(); | 3960 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); |
3954 } | 3961 } |
3955 | 3962 |
3956 void SetupActiveTreeLayers() { | 3963 void SetupActiveTreeLayers() { |
3957 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 3964 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
3958 host_impl_->active_tree()->SetRootLayer( | 3965 host_impl_->active_tree()->SetRootLayer( |
3959 LayerImpl::Create(host_impl_->active_tree(), 1)); | 3966 LayerImpl::Create(host_impl_->active_tree(), 1)); |
3960 host_impl_->active_tree()->root_layer()->AddChild( | 3967 host_impl_->active_tree()->root_layer()->AddChild( |
3961 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 3968 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
3962 2, | 3969 2, |
3963 host_impl_->resource_provider())); | 3970 host_impl_->resource_provider())); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4223 | 4230 |
4224 SetupActiveTreeLayers(); | 4231 SetupActiveTreeLayers(); |
4225 TestEmptyLayer(); | 4232 TestEmptyLayer(); |
4226 TestLayerInMiddleOfViewport(); | 4233 TestLayerInMiddleOfViewport(); |
4227 TestLayerIsLargerThanViewport(); | 4234 TestLayerIsLargerThanViewport(); |
4228 } | 4235 } |
4229 | 4236 |
4230 class FakeDrawableLayerImpl: public LayerImpl { | 4237 class FakeDrawableLayerImpl: public LayerImpl { |
4231 public: | 4238 public: |
4232 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 4239 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
4233 return make_scoped_ptr(new FakeDrawableLayerImpl(tree_impl, id)); | 4240 return scoped_ptr<LayerImpl>(new FakeDrawableLayerImpl(tree_impl, id)); |
4234 } | 4241 } |
4235 protected: | 4242 protected: |
4236 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) | 4243 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) |
4237 : LayerImpl(tree_impl, id) {} | 4244 : LayerImpl(tree_impl, id) {} |
4238 }; | 4245 }; |
4239 | 4246 |
4240 // Only reshape when we know we are going to draw. Otherwise, the reshape | 4247 // Only reshape when we know we are going to draw. Otherwise, the reshape |
4241 // can leave the window at the wrong size if we never draw and the proper | 4248 // can leave the window at the wrong size if we never draw and the proper |
4242 // viewport size is never set. | 4249 // viewport size is never set. |
4243 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { | 4250 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4393 | 4400 |
4394 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4401 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4395 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 4402 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
4396 EXPECT_EQ(1u, frame.render_passes.size()); | 4403 EXPECT_EQ(1u, frame.render_passes.size()); |
4397 host_impl_->DidDrawAllLayers(frame); | 4404 host_impl_->DidDrawAllLayers(frame); |
4398 } | 4405 } |
4399 | 4406 |
4400 class FakeLayerWithQuads : public LayerImpl { | 4407 class FakeLayerWithQuads : public LayerImpl { |
4401 public: | 4408 public: |
4402 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 4409 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
4403 return make_scoped_ptr(new FakeLayerWithQuads(tree_impl, id)); | 4410 return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id)); |
4404 } | 4411 } |
4405 | 4412 |
4406 virtual void AppendQuads(RenderPass* render_pass, | 4413 virtual void AppendQuads(RenderPass* render_pass, |
4407 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 4414 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
4408 AppendQuadsData* append_quads_data) OVERRIDE { | 4415 AppendQuadsData* append_quads_data) OVERRIDE { |
4409 SharedQuadState* shared_quad_state = | 4416 SharedQuadState* shared_quad_state = |
4410 render_pass->CreateAndAppendSharedQuadState(); | 4417 render_pass->CreateAndAppendSharedQuadState(); |
4411 PopulateSharedQuadState(shared_quad_state); | 4418 PopulateSharedQuadState(shared_quad_state); |
4412 | 4419 |
4413 SkColor gray = SkColorSetRGB(100, 100, 100); | 4420 SkColor gray = SkColorSetRGB(100, 100, 100); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4507 .Times(0); | 4514 .Times(0); |
4508 | 4515 |
4509 EXPECT_CALL(*context_, scissor(_, _, _, _)) | 4516 EXPECT_CALL(*context_, scissor(_, _, _, _)) |
4510 .Times(0); | 4517 .Times(0); |
4511 } | 4518 } |
4512 }; | 4519 }; |
4513 | 4520 |
4514 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { | 4521 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { |
4515 scoped_ptr<MockContext> mock_context_owned(new MockContext); | 4522 scoped_ptr<MockContext> mock_context_owned(new MockContext); |
4516 MockContext* mock_context = mock_context_owned.get(); | 4523 MockContext* mock_context = mock_context_owned.get(); |
| 4524 |
| 4525 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 4526 mock_context_owned.PassAs<TestWebGraphicsContext3D>())); |
4517 MockContextHarness harness(mock_context); | 4527 MockContextHarness harness(mock_context); |
4518 | 4528 |
4519 // Run test case | 4529 // Run test case |
4520 LayerTreeSettings settings = DefaultSettings(); | 4530 LayerTreeSettings settings = DefaultSettings(); |
4521 settings.partial_swap_enabled = false; | 4531 settings.partial_swap_enabled = false; |
4522 CreateHostImpl(settings, | 4532 CreateHostImpl(settings, output_surface.Pass()); |
4523 FakeOutputSurface::Create3d(mock_context_owned.Pass())); | |
4524 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 4533 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
4525 | 4534 |
4526 // Without partial swap, and no clipping, no scissor is set. | 4535 // Without partial swap, and no clipping, no scissor is set. |
4527 harness.MustDrawSolidQuad(); | 4536 harness.MustDrawSolidQuad(); |
4528 harness.MustSetNoScissor(); | 4537 harness.MustSetNoScissor(); |
4529 { | 4538 { |
4530 LayerTreeHostImpl::FrameData frame; | 4539 LayerTreeHostImpl::FrameData frame; |
4531 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4540 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4532 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4541 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
4533 host_impl_->DidDrawAllLayers(frame); | 4542 host_impl_->DidDrawAllLayers(frame); |
(...skipping 10 matching lines...) Expand all Loading... |
4544 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4553 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4545 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4554 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
4546 host_impl_->DidDrawAllLayers(frame); | 4555 host_impl_->DidDrawAllLayers(frame); |
4547 } | 4556 } |
4548 Mock::VerifyAndClearExpectations(&mock_context); | 4557 Mock::VerifyAndClearExpectations(&mock_context); |
4549 } | 4558 } |
4550 | 4559 |
4551 TEST_F(LayerTreeHostImplTest, PartialSwap) { | 4560 TEST_F(LayerTreeHostImplTest, PartialSwap) { |
4552 scoped_ptr<MockContext> context_owned(new MockContext); | 4561 scoped_ptr<MockContext> context_owned(new MockContext); |
4553 MockContext* mock_context = context_owned.get(); | 4562 MockContext* mock_context = context_owned.get(); |
| 4563 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 4564 context_owned.PassAs<TestWebGraphicsContext3D>())); |
4554 MockContextHarness harness(mock_context); | 4565 MockContextHarness harness(mock_context); |
4555 | 4566 |
4556 LayerTreeSettings settings = DefaultSettings(); | 4567 LayerTreeSettings settings = DefaultSettings(); |
4557 settings.partial_swap_enabled = true; | 4568 settings.partial_swap_enabled = true; |
4558 CreateHostImpl(settings, FakeOutputSurface::Create3d(context_owned.Pass())); | 4569 CreateHostImpl(settings, output_surface.Pass()); |
4559 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 4570 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
4560 | 4571 |
4561 // The first frame is not a partially-swapped one. | 4572 // The first frame is not a partially-swapped one. |
4562 harness.MustSetScissor(0, 0, 10, 10); | 4573 harness.MustSetScissor(0, 0, 10, 10); |
4563 harness.MustDrawSolidQuad(); | 4574 harness.MustDrawSolidQuad(); |
4564 { | 4575 { |
4565 LayerTreeHostImpl::FrameData frame; | 4576 LayerTreeHostImpl::FrameData frame; |
4566 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4577 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4567 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4578 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
4568 host_impl_->DidDrawAllLayers(frame); | 4579 host_impl_->DidDrawAllLayers(frame); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4731 scoped_refptr<VideoFrame> softwareFrame = | 4742 scoped_refptr<VideoFrame> softwareFrame = |
4732 media::VideoFrame::CreateColorFrame( | 4743 media::VideoFrame::CreateColorFrame( |
4733 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 4744 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
4734 FakeVideoFrameProvider provider; | 4745 FakeVideoFrameProvider provider; |
4735 provider.set_frame(softwareFrame); | 4746 provider.set_frame(softwareFrame); |
4736 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 4747 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
4737 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 4748 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
4738 video_layer->SetBounds(gfx::Size(10, 10)); | 4749 video_layer->SetBounds(gfx::Size(10, 10)); |
4739 video_layer->SetContentBounds(gfx::Size(10, 10)); | 4750 video_layer->SetContentBounds(gfx::Size(10, 10)); |
4740 video_layer->SetDrawsContent(true); | 4751 video_layer->SetDrawsContent(true); |
4741 root_layer->AddChild(video_layer.Pass()); | 4752 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); |
4742 | 4753 |
4743 scoped_ptr<IOSurfaceLayerImpl> io_surface_layer = | 4754 scoped_ptr<IOSurfaceLayerImpl> io_surface_layer = |
4744 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5); | 4755 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5); |
4745 io_surface_layer->SetBounds(gfx::Size(10, 10)); | 4756 io_surface_layer->SetBounds(gfx::Size(10, 10)); |
4746 io_surface_layer->SetContentBounds(gfx::Size(10, 10)); | 4757 io_surface_layer->SetContentBounds(gfx::Size(10, 10)); |
4747 io_surface_layer->SetDrawsContent(true); | 4758 io_surface_layer->SetDrawsContent(true); |
4748 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); | 4759 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); |
4749 root_layer->AddChild(io_surface_layer.Pass()); | 4760 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); |
4750 | 4761 |
4751 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); | 4762 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); |
4752 | 4763 |
4753 EXPECT_EQ(0u, context3d->NumTextures()); | 4764 EXPECT_EQ(0u, context3d->NumTextures()); |
4754 | 4765 |
4755 LayerTreeHostImpl::FrameData frame; | 4766 LayerTreeHostImpl::FrameData frame; |
4756 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4767 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4757 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4768 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
4758 host_impl_->DidDrawAllLayers(frame); | 4769 host_impl_->DidDrawAllLayers(frame); |
4759 host_impl_->SwapBuffers(frame); | 4770 host_impl_->SwapBuffers(frame); |
(...skipping 14 matching lines...) Expand all Loading... |
4774 GLsizei count, | 4785 GLsizei count, |
4775 GLenum type, | 4786 GLenum type, |
4776 GLintptr offset)); | 4787 GLintptr offset)); |
4777 }; | 4788 }; |
4778 | 4789 |
4779 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { | 4790 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { |
4780 scoped_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( | 4791 scoped_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( |
4781 new MockDrawQuadsToFillScreenContext); | 4792 new MockDrawQuadsToFillScreenContext); |
4782 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); | 4793 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); |
4783 | 4794 |
| 4795 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 4796 mock_context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 4797 |
4784 // Run test case | 4798 // Run test case |
4785 LayerTreeSettings settings = DefaultSettings(); | 4799 LayerTreeSettings settings = DefaultSettings(); |
4786 settings.partial_swap_enabled = false; | 4800 settings.partial_swap_enabled = false; |
4787 CreateHostImpl(settings, | 4801 CreateHostImpl(settings, output_surface.Pass()); |
4788 FakeOutputSurface::Create3d(mock_context_owned.Pass())); | |
4789 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 4802 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
4790 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 4803 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
4791 | 4804 |
4792 // Verify one quad is drawn when transparent background set is not set. | 4805 // Verify one quad is drawn when transparent background set is not set. |
4793 host_impl_->active_tree()->set_has_transparent_background(false); | 4806 host_impl_->active_tree()->set_has_transparent_background(false); |
4794 EXPECT_CALL(*mock_context, useProgram(_)) | 4807 EXPECT_CALL(*mock_context, useProgram(_)) |
4795 .Times(1); | 4808 .Times(1); |
4796 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) | 4809 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) |
4797 .Times(1); | 4810 .Times(1); |
4798 LayerTreeHostImpl::FrameData frame; | 4811 LayerTreeHostImpl::FrameData frame; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4847 // re-commit. | 4860 // re-commit. |
4848 host_impl_->SetMemoryPolicy(ManagedMemoryPolicy( | 4861 host_impl_->SetMemoryPolicy(ManagedMemoryPolicy( |
4849 host_impl_->memory_allocation_limit_bytes())); | 4862 host_impl_->memory_allocation_limit_bytes())); |
4850 EXPECT_FALSE(did_request_commit_); | 4863 EXPECT_FALSE(did_request_commit_); |
4851 } | 4864 } |
4852 | 4865 |
4853 class LayerTreeHostImplTestWithDelegatingRenderer | 4866 class LayerTreeHostImplTestWithDelegatingRenderer |
4854 : public LayerTreeHostImplTest { | 4867 : public LayerTreeHostImplTest { |
4855 protected: | 4868 protected: |
4856 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { | 4869 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { |
4857 return FakeOutputSurface::CreateDelegating3d(); | 4870 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>(); |
4858 } | 4871 } |
4859 | 4872 |
4860 void DrawFrameAndTestDamage(const gfx::RectF& expected_damage) { | 4873 void DrawFrameAndTestDamage(const gfx::RectF& expected_damage) { |
4861 bool expect_to_draw = !expected_damage.IsEmpty(); | 4874 bool expect_to_draw = !expected_damage.IsEmpty(); |
4862 | 4875 |
4863 LayerTreeHostImpl::FrameData frame; | 4876 LayerTreeHostImpl::FrameData frame; |
4864 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4877 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4865 | 4878 |
4866 if (!expect_to_draw) { | 4879 if (!expect_to_draw) { |
4867 // With no damage, we don't draw, and no quads are created. | 4880 // With no damage, we don't draw, and no quads are created. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4902 root->SetContentBounds(gfx::Size(10, 10)); | 4915 root->SetContentBounds(gfx::Size(10, 10)); |
4903 root->SetDrawsContent(true); | 4916 root->SetDrawsContent(true); |
4904 | 4917 |
4905 // Child layer is in the bottom right corner. | 4918 // Child layer is in the bottom right corner. |
4906 scoped_ptr<SolidColorLayerImpl> child = | 4919 scoped_ptr<SolidColorLayerImpl> child = |
4907 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 4920 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
4908 child->SetPosition(gfx::PointF(9.f, 9.f)); | 4921 child->SetPosition(gfx::PointF(9.f, 9.f)); |
4909 child->SetBounds(gfx::Size(1, 1)); | 4922 child->SetBounds(gfx::Size(1, 1)); |
4910 child->SetContentBounds(gfx::Size(1, 1)); | 4923 child->SetContentBounds(gfx::Size(1, 1)); |
4911 child->SetDrawsContent(true); | 4924 child->SetDrawsContent(true); |
4912 root->AddChild(child.Pass()); | 4925 root->AddChild(child.PassAs<LayerImpl>()); |
4913 | 4926 |
4914 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4927 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); |
4915 | 4928 |
4916 // Draw a frame. In the first frame, the entire viewport should be damaged. | 4929 // Draw a frame. In the first frame, the entire viewport should be damaged. |
4917 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 4930 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
4918 DrawFrameAndTestDamage(full_frame_damage); | 4931 DrawFrameAndTestDamage(full_frame_damage); |
4919 | 4932 |
4920 // The second frame has damage that doesn't touch the child layer. Its quads | 4933 // The second frame has damage that doesn't touch the child layer. Its quads |
4921 // should still be generated. | 4934 // should still be generated. |
4922 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); | 4935 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); |
4923 host_impl_->active_tree()->root_layer()->SetUpdateRect(small_damage); | 4936 host_impl_->active_tree()->root_layer()->SetUpdateRect(small_damage); |
4924 DrawFrameAndTestDamage(small_damage); | 4937 DrawFrameAndTestDamage(small_damage); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4974 root->AddChild(scoped_scaling_layer.Pass()); | 4987 root->AddChild(scoped_scaling_layer.Pass()); |
4975 | 4988 |
4976 scoped_ptr<LayerImpl> scoped_content_layer = | 4989 scoped_ptr<LayerImpl> scoped_content_layer = |
4977 LayerImpl::Create(host_impl_->active_tree(), 3); | 4990 LayerImpl::Create(host_impl_->active_tree(), 3); |
4978 LayerImpl* content_layer = scoped_content_layer.get(); | 4991 LayerImpl* content_layer = scoped_content_layer.get(); |
4979 scaling_layer->AddChild(scoped_content_layer.Pass()); | 4992 scaling_layer->AddChild(scoped_content_layer.Pass()); |
4980 | 4993 |
4981 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 4994 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
4982 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 4995 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
4983 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 4996 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
4984 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 4997 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
4985 | 4998 |
4986 gfx::Size root_size(100, 100); | 4999 gfx::Size root_size(100, 100); |
4987 root->SetBounds(root_size); | 5000 root->SetBounds(root_size); |
4988 root->SetContentBounds(root_size); | 5001 root->SetContentBounds(root_size); |
4989 root->SetPosition(gfx::PointF()); | 5002 root->SetPosition(gfx::PointF()); |
4990 | 5003 |
4991 gfx::Size scaling_layer_size(50, 50); | 5004 gfx::Size scaling_layer_size(50, 50); |
4992 scaling_layer->SetBounds(scaling_layer_size); | 5005 scaling_layer->SetBounds(scaling_layer_size); |
4993 scaling_layer->SetContentBounds(scaling_layer_size); | 5006 scaling_layer->SetContentBounds(scaling_layer_size); |
4994 scaling_layer->SetPosition(gfx::PointF()); | 5007 scaling_layer->SetPosition(gfx::PointF()); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5103 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5116 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
5104 | 5117 |
5105 scoped_ptr<LayerImpl> scoped_content_layer = | 5118 scoped_ptr<LayerImpl> scoped_content_layer = |
5106 LayerImpl::Create(host_impl_->active_tree(), 3); | 5119 LayerImpl::Create(host_impl_->active_tree(), 3); |
5107 LayerImpl* content_layer = scoped_content_layer.get(); | 5120 LayerImpl* content_layer = scoped_content_layer.get(); |
5108 root->AddChild(scoped_content_layer.Pass()); | 5121 root->AddChild(scoped_content_layer.Pass()); |
5109 | 5122 |
5110 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5123 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
5111 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5124 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
5112 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5125 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
5113 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5126 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
5114 | 5127 |
5115 gfx::Size root_size(100, 100); | 5128 gfx::Size root_size(100, 100); |
5116 root->SetBounds(root_size); | 5129 root->SetBounds(root_size); |
5117 root->SetContentBounds(root_size); | 5130 root->SetContentBounds(root_size); |
5118 root->SetPosition(gfx::PointF()); | 5131 root->SetPosition(gfx::PointF()); |
5119 | 5132 |
5120 gfx::Size layer_size(50, 50); | 5133 gfx::Size layer_size(50, 50); |
5121 content_layer->SetBounds(layer_size); | 5134 content_layer->SetBounds(layer_size); |
5122 content_layer->SetContentBounds(layer_size); | 5135 content_layer->SetContentBounds(layer_size); |
5123 content_layer->SetPosition(gfx::PointF()); | 5136 content_layer->SetPosition(gfx::PointF()); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5254 root->AddChild(scoped_content_layer.Pass()); | 5267 root->AddChild(scoped_content_layer.Pass()); |
5255 | 5268 |
5256 scoped_ptr<LayerImpl> scoped_replica_layer = | 5269 scoped_ptr<LayerImpl> scoped_replica_layer = |
5257 LayerImpl::Create(host_impl_->active_tree(), 2); | 5270 LayerImpl::Create(host_impl_->active_tree(), 2); |
5258 LayerImpl* replica_layer = scoped_replica_layer.get(); | 5271 LayerImpl* replica_layer = scoped_replica_layer.get(); |
5259 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 5272 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
5260 | 5273 |
5261 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5274 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
5262 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5275 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
5263 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5276 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
5264 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5277 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
5265 | 5278 |
5266 gfx::Size root_size(100, 100); | 5279 gfx::Size root_size(100, 100); |
5267 root->SetBounds(root_size); | 5280 root->SetBounds(root_size); |
5268 root->SetContentBounds(root_size); | 5281 root->SetContentBounds(root_size); |
5269 root->SetPosition(gfx::PointF()); | 5282 root->SetPosition(gfx::PointF()); |
5270 | 5283 |
5271 gfx::Size layer_size(50, 50); | 5284 gfx::Size layer_size(50, 50); |
5272 content_layer->SetBounds(layer_size); | 5285 content_layer->SetBounds(layer_size); |
5273 content_layer->SetContentBounds(layer_size); | 5286 content_layer->SetContentBounds(layer_size); |
5274 content_layer->SetPosition(gfx::PointF()); | 5287 content_layer->SetPosition(gfx::PointF()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5406 content_layer->AddChild(scoped_content_child_layer.Pass()); | 5419 content_layer->AddChild(scoped_content_child_layer.Pass()); |
5407 | 5420 |
5408 scoped_ptr<LayerImpl> scoped_replica_layer = | 5421 scoped_ptr<LayerImpl> scoped_replica_layer = |
5409 LayerImpl::Create(host_impl_->active_tree(), 4); | 5422 LayerImpl::Create(host_impl_->active_tree(), 4); |
5410 LayerImpl* replica_layer = scoped_replica_layer.get(); | 5423 LayerImpl* replica_layer = scoped_replica_layer.get(); |
5411 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 5424 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
5412 | 5425 |
5413 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5426 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
5414 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); | 5427 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); |
5415 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5428 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
5416 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5429 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
5417 | 5430 |
5418 gfx::Size root_size(100, 100); | 5431 gfx::Size root_size(100, 100); |
5419 root->SetBounds(root_size); | 5432 root->SetBounds(root_size); |
5420 root->SetContentBounds(root_size); | 5433 root->SetContentBounds(root_size); |
5421 root->SetPosition(gfx::PointF()); | 5434 root->SetPosition(gfx::PointF()); |
5422 | 5435 |
5423 gfx::Size layer_size(50, 50); | 5436 gfx::Size layer_size(50, 50); |
5424 content_layer->SetBounds(layer_size); | 5437 content_layer->SetBounds(layer_size); |
5425 content_layer->SetContentBounds(layer_size); | 5438 content_layer->SetContentBounds(layer_size); |
5426 content_layer->SetPosition(gfx::PointF()); | 5439 content_layer->SetPosition(gfx::PointF()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5526 clipping_layer->AddChild(scoped_content_layer.Pass()); | 5539 clipping_layer->AddChild(scoped_content_layer.Pass()); |
5527 | 5540 |
5528 scoped_ptr<LayerImpl> scoped_content_child_layer = | 5541 scoped_ptr<LayerImpl> scoped_content_child_layer = |
5529 LayerImpl::Create(host_impl_->active_tree(), 4); | 5542 LayerImpl::Create(host_impl_->active_tree(), 4); |
5530 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | 5543 LayerImpl* content_child_layer = scoped_content_child_layer.get(); |
5531 content_layer->AddChild(scoped_content_child_layer.Pass()); | 5544 content_layer->AddChild(scoped_content_child_layer.Pass()); |
5532 | 5545 |
5533 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5546 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
5534 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); | 5547 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); |
5535 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5548 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
5536 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5549 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
5537 | 5550 |
5538 gfx::Size root_size(100, 100); | 5551 gfx::Size root_size(100, 100); |
5539 root->SetBounds(root_size); | 5552 root->SetBounds(root_size); |
5540 root->SetContentBounds(root_size); | 5553 root->SetContentBounds(root_size); |
5541 root->SetPosition(gfx::PointF()); | 5554 root->SetPosition(gfx::PointF()); |
5542 | 5555 |
5543 gfx::Rect clipping_rect(20, 10, 10, 20); | 5556 gfx::Rect clipping_rect(20, 10, 10, 20); |
5544 clipping_layer->SetBounds(clipping_rect.size()); | 5557 clipping_layer->SetBounds(clipping_rect.size()); |
5545 clipping_layer->SetContentBounds(clipping_rect.size()); | 5558 clipping_layer->SetContentBounds(clipping_rect.size()); |
5546 clipping_layer->SetPosition(clipping_rect.origin()); | 5559 clipping_layer->SetPosition(clipping_rect.origin()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5627 root->AddChild(scoped_scrolling_layer.Pass()); | 5640 root->AddChild(scoped_scrolling_layer.Pass()); |
5628 | 5641 |
5629 gfx::Size content_layer_bounds(100000, 100); | 5642 gfx::Size content_layer_bounds(100000, 100); |
5630 gfx::Size pile_tile_size(3000, 3000); | 5643 gfx::Size pile_tile_size(3000, 3000); |
5631 scoped_refptr<FakePicturePileImpl> pile(FakePicturePileImpl::CreateFilledPile( | 5644 scoped_refptr<FakePicturePileImpl> pile(FakePicturePileImpl::CreateFilledPile( |
5632 pile_tile_size, content_layer_bounds)); | 5645 pile_tile_size, content_layer_bounds)); |
5633 | 5646 |
5634 scoped_ptr<FakePictureLayerImpl> scoped_content_layer = | 5647 scoped_ptr<FakePictureLayerImpl> scoped_content_layer = |
5635 FakePictureLayerImpl::CreateWithPile(host_impl_->pending_tree(), 3, pile); | 5648 FakePictureLayerImpl::CreateWithPile(host_impl_->pending_tree(), 3, pile); |
5636 LayerImpl* content_layer = scoped_content_layer.get(); | 5649 LayerImpl* content_layer = scoped_content_layer.get(); |
5637 scrolling_layer->AddChild(scoped_content_layer.Pass()); | 5650 scrolling_layer->AddChild(scoped_content_layer.PassAs<LayerImpl>()); |
5638 content_layer->SetBounds(content_layer_bounds); | 5651 content_layer->SetBounds(content_layer_bounds); |
5639 content_layer->SetDrawsContent(true); | 5652 content_layer->SetDrawsContent(true); |
5640 | 5653 |
5641 root->SetBounds(root_size); | 5654 root->SetBounds(root_size); |
5642 | 5655 |
5643 gfx::Vector2d scroll_offset(100000, 0); | 5656 gfx::Vector2d scroll_offset(100000, 0); |
5644 scrolling_layer->SetScrollClipLayer(root->id()); | 5657 scrolling_layer->SetScrollClipLayer(root->id()); |
5645 scrolling_layer->SetScrollOffset(scroll_offset); | 5658 scrolling_layer->SetScrollOffset(scroll_offset); |
5646 | 5659 |
5647 host_impl_->ActivateSyncTree(); | 5660 host_impl_->ActivateSyncTree(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5775 scoped_ptr<SolidColorLayerImpl> root_layer = | 5788 scoped_ptr<SolidColorLayerImpl> root_layer = |
5776 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 5789 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
5777 | 5790 |
5778 // VideoLayerImpl will not be drawn. | 5791 // VideoLayerImpl will not be drawn. |
5779 FakeVideoFrameProvider provider; | 5792 FakeVideoFrameProvider provider; |
5780 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 5793 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
5781 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); | 5794 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); |
5782 video_layer->SetBounds(gfx::Size(10, 10)); | 5795 video_layer->SetBounds(gfx::Size(10, 10)); |
5783 video_layer->SetContentBounds(gfx::Size(10, 10)); | 5796 video_layer->SetContentBounds(gfx::Size(10, 10)); |
5784 video_layer->SetDrawsContent(true); | 5797 video_layer->SetDrawsContent(true); |
5785 root_layer->AddChild(video_layer.Pass()); | 5798 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); |
5786 SetupRootLayerImpl(root_layer.Pass()); | 5799 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); |
5787 | 5800 |
5788 LayerTreeHostImpl::FrameData frame; | 5801 LayerTreeHostImpl::FrameData frame; |
5789 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5802 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
5790 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5803 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
5791 host_impl_->DidDrawAllLayers(frame); | 5804 host_impl_->DidDrawAllLayers(frame); |
5792 | 5805 |
5793 EXPECT_EQ(1u, frame.will_draw_layers.size()); | 5806 EXPECT_EQ(1u, frame.will_draw_layers.size()); |
5794 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); | 5807 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); |
5795 } | 5808 } |
5796 | 5809 |
5797 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { | 5810 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { |
5798 protected: | 5811 protected: |
5799 virtual void SetUp() OVERRIDE { | 5812 virtual void SetUp() OVERRIDE { |
5800 LayerTreeHostImplTest::SetUp(); | 5813 LayerTreeHostImplTest::SetUp(); |
5801 | 5814 |
5802 set_reduce_memory_result(false); | 5815 set_reduce_memory_result(false); |
5803 | 5816 |
5804 bool delegated_rendering = false; | 5817 bool delegated_rendering = false; |
5805 scoped_ptr<FakeOutputSurface> output_surface( | 5818 scoped_ptr<FakeOutputSurface> output_surface( |
5806 FakeOutputSurface::CreateDeferredGL( | 5819 FakeOutputSurface::CreateDeferredGL( |
5807 scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice()), | 5820 scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice()), |
5808 delegated_rendering)); | 5821 delegated_rendering)); |
5809 output_surface_ = output_surface.get(); | 5822 output_surface_ = output_surface.get(); |
5810 | 5823 |
5811 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), output_surface.Pass())); | 5824 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), |
| 5825 output_surface.PassAs<OutputSurface>())); |
5812 | 5826 |
5813 scoped_ptr<SolidColorLayerImpl> root_layer = | 5827 scoped_ptr<SolidColorLayerImpl> root_layer = |
5814 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 5828 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
5815 SetupRootLayerImpl(root_layer.Pass()); | 5829 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); |
5816 | 5830 |
5817 onscreen_context_provider_ = TestContextProvider::Create(); | 5831 onscreen_context_provider_ = TestContextProvider::Create(); |
5818 } | 5832 } |
5819 | 5833 |
5820 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE { | 5834 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE { |
5821 did_update_renderer_capabilities_ = true; | 5835 did_update_renderer_capabilities_ = true; |
5822 } | 5836 } |
5823 | 5837 |
5824 FakeOutputSurface* output_surface_; | 5838 FakeOutputSurface* output_surface_; |
5825 scoped_refptr<TestContextProvider> onscreen_context_provider_; | 5839 scoped_refptr<TestContextProvider> onscreen_context_provider_; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6003 EXPECT_TRUE(fake_host_impl_->manage_tiles_needed()); | 6017 EXPECT_TRUE(fake_host_impl_->manage_tiles_needed()); |
6004 fake_host_impl_->SetVisible(false); | 6018 fake_host_impl_->SetVisible(false); |
6005 EXPECT_FALSE(fake_host_impl_->manage_tiles_needed()); | 6019 EXPECT_FALSE(fake_host_impl_->manage_tiles_needed()); |
6006 } | 6020 } |
6007 | 6021 |
6008 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { | 6022 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { |
6009 scoped_ptr<TestWebGraphicsContext3D> context = | 6023 scoped_ptr<TestWebGraphicsContext3D> context = |
6010 TestWebGraphicsContext3D::Create(); | 6024 TestWebGraphicsContext3D::Create(); |
6011 TestWebGraphicsContext3D* context3d = context.get(); | 6025 TestWebGraphicsContext3D* context3d = context.get(); |
6012 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); | 6026 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); |
6013 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 6027 CreateHostImpl(DefaultSettings(), output_surface.PassAs<OutputSurface>()); |
6014 | 6028 |
6015 EXPECT_EQ(0u, context3d->NumTextures()); | 6029 EXPECT_EQ(0u, context3d->NumTextures()); |
6016 | 6030 |
6017 UIResourceId ui_resource_id = 1; | 6031 UIResourceId ui_resource_id = 1; |
6018 bool is_opaque = false; | 6032 bool is_opaque = false; |
6019 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); | 6033 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); |
6020 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6034 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
6021 EXPECT_EQ(1u, context3d->NumTextures()); | 6035 EXPECT_EQ(1u, context3d->NumTextures()); |
6022 ResourceProvider::ResourceId id1 = | 6036 ResourceProvider::ResourceId id1 = |
6023 host_impl_->ResourceIdForUIResource(ui_resource_id); | 6037 host_impl_->ResourceIdForUIResource(ui_resource_id); |
(...skipping 23 matching lines...) Expand all Loading... |
6047 | 6061 |
6048 // Should not change state for multiple deletion on one UIResourceId | 6062 // Should not change state for multiple deletion on one UIResourceId |
6049 host_impl_->DeleteUIResource(ui_resource_id); | 6063 host_impl_->DeleteUIResource(ui_resource_id); |
6050 EXPECT_EQ(0u, context3d->NumTextures()); | 6064 EXPECT_EQ(0u, context3d->NumTextures()); |
6051 } | 6065 } |
6052 | 6066 |
6053 TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) { | 6067 TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) { |
6054 scoped_ptr<TestWebGraphicsContext3D> context = | 6068 scoped_ptr<TestWebGraphicsContext3D> context = |
6055 TestWebGraphicsContext3D::Create(); | 6069 TestWebGraphicsContext3D::Create(); |
6056 TestWebGraphicsContext3D* context3d = context.get(); | 6070 TestWebGraphicsContext3D* context3d = context.get(); |
6057 CreateHostImpl(DefaultSettings(), FakeOutputSurface::Create3d()); | 6071 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); |
| 6072 CreateHostImpl(DefaultSettings(), output_surface.PassAs<OutputSurface>()); |
6058 | 6073 |
6059 EXPECT_EQ(0u, context3d->NumTextures()); | 6074 EXPECT_EQ(0u, context3d->NumTextures()); |
6060 | 6075 |
6061 gfx::Size size(4, 4); | 6076 gfx::Size size(4, 4); |
6062 // SkImageInfo has no support for ETC1. The |info| below contains the right | 6077 // SkImageInfo has no support for ETC1. The |info| below contains the right |
6063 // total pixel size for the bitmap but not the right height and width. The | 6078 // total pixel size for the bitmap but not the right height and width. The |
6064 // correct width/height are passed directly to UIResourceBitmap. | 6079 // correct width/height are passed directly to UIResourceBitmap. |
6065 SkImageInfo info = | 6080 SkImageInfo info = |
6066 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType); | 6081 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType); |
6067 skia::RefPtr<SkPixelRef> pixel_ref = | 6082 skia::RefPtr<SkPixelRef> pixel_ref = |
6068 skia::AdoptRef(SkMallocPixelRef::NewAllocate(info, 0, 0)); | 6083 skia::AdoptRef(SkMallocPixelRef::NewAllocate(info, 0, 0)); |
6069 pixel_ref->setImmutable(); | 6084 pixel_ref->setImmutable(); |
6070 UIResourceBitmap bitmap(pixel_ref, size); | 6085 UIResourceBitmap bitmap(pixel_ref, size); |
6071 UIResourceId ui_resource_id = 1; | 6086 UIResourceId ui_resource_id = 1; |
6072 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6087 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
6073 EXPECT_EQ(1u, context3d->NumTextures()); | 6088 EXPECT_EQ(1u, context3d->NumTextures()); |
6074 ResourceProvider::ResourceId id1 = | 6089 ResourceProvider::ResourceId id1 = |
6075 host_impl_->ResourceIdForUIResource(ui_resource_id); | 6090 host_impl_->ResourceIdForUIResource(ui_resource_id); |
6076 EXPECT_NE(0u, id1); | 6091 EXPECT_NE(0u, id1); |
6077 } | 6092 } |
6078 | 6093 |
6079 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) { | 6094 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) { |
6080 } | 6095 } |
6081 | 6096 |
6082 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 6097 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
6083 scoped_refptr<TestContextProvider> context_provider = | 6098 scoped_refptr<TestContextProvider> context_provider = |
6084 TestContextProvider::Create(); | 6099 TestContextProvider::Create(); |
6085 | 6100 |
6086 CreateHostImpl(DefaultSettings(), | 6101 CreateHostImpl( |
6087 FakeOutputSurface::Create3d(context_provider)); | 6102 DefaultSettings(), |
| 6103 FakeOutputSurface::Create3d(context_provider).PassAs<OutputSurface>()); |
6088 | 6104 |
6089 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 6105 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
6090 | 6106 |
6091 ScopedPtrVector<CopyOutputRequest> requests; | 6107 ScopedPtrVector<CopyOutputRequest> requests; |
6092 requests.push_back(CopyOutputRequest::CreateRequest( | 6108 requests.push_back(CopyOutputRequest::CreateRequest( |
6093 base::Bind(&ShutdownReleasesContext_Callback))); | 6109 base::Bind(&ShutdownReleasesContext_Callback))); |
6094 | 6110 |
6095 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); | 6111 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); |
6096 | 6112 |
6097 LayerTreeHostImpl::FrameData frame; | 6113 LayerTreeHostImpl::FrameData frame; |
6098 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6114 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6099 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 6115 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
6100 host_impl_->DidDrawAllLayers(frame); | 6116 host_impl_->DidDrawAllLayers(frame); |
6101 | 6117 |
6102 // The CopyOutputResult's callback has a ref on the ContextProvider and a | 6118 // The CopyOutputResult's callback has a ref on the ContextProvider and a |
6103 // texture in a texture mailbox. | 6119 // texture in a texture mailbox. |
6104 EXPECT_FALSE(context_provider->HasOneRef()); | 6120 EXPECT_FALSE(context_provider->HasOneRef()); |
6105 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 6121 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
6106 | 6122 |
6107 host_impl_ = nullptr; | 6123 host_impl_.reset(); |
6108 | 6124 |
6109 // The CopyOutputResult's callback was cancelled, the CopyOutputResult | 6125 // The CopyOutputResult's callback was cancelled, the CopyOutputResult |
6110 // released, and the texture deleted. | 6126 // released, and the texture deleted. |
6111 EXPECT_TRUE(context_provider->HasOneRef()); | 6127 EXPECT_TRUE(context_provider->HasOneRef()); |
6112 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 6128 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
6113 } | 6129 } |
6114 | 6130 |
6115 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 6131 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
6116 // When flinging via touch, only the child should scroll (we should not | 6132 // When flinging via touch, only the child should scroll (we should not |
6117 // bubble). | 6133 // bubble). |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6429 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 6445 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
6430 // to CompositorFrameMetadata after SwapBuffers(); | 6446 // to CompositorFrameMetadata after SwapBuffers(); |
6431 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 6447 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
6432 scoped_ptr<SolidColorLayerImpl> root = | 6448 scoped_ptr<SolidColorLayerImpl> root = |
6433 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 6449 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
6434 root->SetPosition(gfx::PointF()); | 6450 root->SetPosition(gfx::PointF()); |
6435 root->SetBounds(gfx::Size(10, 10)); | 6451 root->SetBounds(gfx::Size(10, 10)); |
6436 root->SetContentBounds(gfx::Size(10, 10)); | 6452 root->SetContentBounds(gfx::Size(10, 10)); |
6437 root->SetDrawsContent(true); | 6453 root->SetDrawsContent(true); |
6438 | 6454 |
6439 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 6455 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); |
6440 | 6456 |
6441 FakeOutputSurface* fake_output_surface = | 6457 FakeOutputSurface* fake_output_surface = |
6442 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 6458 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
6443 | 6459 |
6444 const std::vector<ui::LatencyInfo>& metadata_latency_before = | 6460 const std::vector<ui::LatencyInfo>& metadata_latency_before = |
6445 fake_output_surface->last_sent_frame().metadata.latency_info; | 6461 fake_output_surface->last_sent_frame().metadata.latency_info; |
6446 EXPECT_TRUE(metadata_latency_before.empty()); | 6462 EXPECT_TRUE(metadata_latency_before.empty()); |
6447 | 6463 |
6448 ui::LatencyInfo latency_info; | 6464 ui::LatencyInfo latency_info; |
6449 latency_info.AddLatencyNumber( | 6465 latency_info.AddLatencyNumber( |
(...skipping 19 matching lines...) Expand all Loading... |
6469 | 6485 |
6470 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 6486 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
6471 int root_layer_id = 1; | 6487 int root_layer_id = 1; |
6472 scoped_ptr<SolidColorLayerImpl> root = | 6488 scoped_ptr<SolidColorLayerImpl> root = |
6473 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 6489 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
6474 root->SetPosition(gfx::PointF()); | 6490 root->SetPosition(gfx::PointF()); |
6475 root->SetBounds(gfx::Size(10, 10)); | 6491 root->SetBounds(gfx::Size(10, 10)); |
6476 root->SetContentBounds(gfx::Size(10, 10)); | 6492 root->SetContentBounds(gfx::Size(10, 10)); |
6477 root->SetDrawsContent(true); | 6493 root->SetDrawsContent(true); |
6478 | 6494 |
6479 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 6495 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); |
6480 | 6496 |
6481 // Ensure the default frame selection bounds are empty. | 6497 // Ensure the default frame selection bounds are empty. |
6482 FakeOutputSurface* fake_output_surface = | 6498 FakeOutputSurface* fake_output_surface = |
6483 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 6499 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
6484 const ViewportSelectionBound& selection_start_before = | 6500 const ViewportSelectionBound& selection_start_before = |
6485 fake_output_surface->last_sent_frame().metadata.selection_start; | 6501 fake_output_surface->last_sent_frame().metadata.selection_start; |
6486 const ViewportSelectionBound& selection_end_before = | 6502 const ViewportSelectionBound& selection_end_before = |
6487 fake_output_surface->last_sent_frame().metadata.selection_end; | 6503 fake_output_surface->last_sent_frame().metadata.selection_end; |
6488 EXPECT_EQ(ViewportSelectionBound(), selection_start_before); | 6504 EXPECT_EQ(ViewportSelectionBound(), selection_start_before); |
6489 EXPECT_EQ(ViewportSelectionBound(), selection_end_before); | 6505 EXPECT_EQ(ViewportSelectionBound(), selection_end_before); |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7103 host_impl_->CreatePendingTree(); | 7119 host_impl_->CreatePendingTree(); |
7104 host_impl_->ActivateSyncTree(); | 7120 host_impl_->ActivateSyncTree(); |
7105 host_impl_->CreatePendingTree(); | 7121 host_impl_->CreatePendingTree(); |
7106 | 7122 |
7107 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 7123 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
7108 | 7124 |
7109 scoped_ptr<FakePictureLayerImpl> pending_layer = | 7125 scoped_ptr<FakePictureLayerImpl> pending_layer = |
7110 FakePictureLayerImpl::Create(pending_tree, 10); | 7126 FakePictureLayerImpl::Create(pending_tree, 10); |
7111 pending_layer->DoPostCommitInitializationIfNeeded(); | 7127 pending_layer->DoPostCommitInitializationIfNeeded(); |
7112 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); | 7128 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); |
7113 pending_tree->SetRootLayer(pending_layer.Pass()); | 7129 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); |
7114 ASSERT_EQ(raw_pending_layer, pending_tree->root_layer()); | 7130 ASSERT_EQ(raw_pending_layer, pending_tree->root_layer()); |
7115 | 7131 |
7116 EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count()); | 7132 EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count()); |
7117 pending_tree->DidBecomeActive(); | 7133 pending_tree->DidBecomeActive(); |
7118 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); | 7134 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); |
7119 | 7135 |
7120 scoped_ptr<FakePictureLayerImpl> mask_layer = | 7136 scoped_ptr<FakePictureLayerImpl> mask_layer = |
7121 FakePictureLayerImpl::Create(pending_tree, 11); | 7137 FakePictureLayerImpl::Create(pending_tree, 11); |
7122 mask_layer->DoPostCommitInitializationIfNeeded(); | 7138 mask_layer->DoPostCommitInitializationIfNeeded(); |
7123 FakePictureLayerImpl* raw_mask_layer = mask_layer.get(); | 7139 FakePictureLayerImpl* raw_mask_layer = mask_layer.get(); |
7124 raw_pending_layer->SetMaskLayer(mask_layer.Pass()); | 7140 raw_pending_layer->SetMaskLayer(mask_layer.PassAs<LayerImpl>()); |
7125 ASSERT_EQ(raw_mask_layer, raw_pending_layer->mask_layer()); | 7141 ASSERT_EQ(raw_mask_layer, raw_pending_layer->mask_layer()); |
7126 | 7142 |
7127 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); | 7143 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); |
7128 EXPECT_EQ(0u, raw_mask_layer->did_become_active_call_count()); | 7144 EXPECT_EQ(0u, raw_mask_layer->did_become_active_call_count()); |
7129 pending_tree->DidBecomeActive(); | 7145 pending_tree->DidBecomeActive(); |
7130 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); | 7146 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); |
7131 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); | 7147 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); |
7132 | 7148 |
7133 scoped_ptr<FakePictureLayerImpl> replica_layer = | 7149 scoped_ptr<FakePictureLayerImpl> replica_layer = |
7134 FakePictureLayerImpl::Create(pending_tree, 12); | 7150 FakePictureLayerImpl::Create(pending_tree, 12); |
7135 scoped_ptr<FakePictureLayerImpl> replica_mask_layer = | 7151 scoped_ptr<FakePictureLayerImpl> replica_mask_layer = |
7136 FakePictureLayerImpl::Create(pending_tree, 13); | 7152 FakePictureLayerImpl::Create(pending_tree, 13); |
7137 replica_mask_layer->DoPostCommitInitializationIfNeeded(); | 7153 replica_mask_layer->DoPostCommitInitializationIfNeeded(); |
7138 FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get(); | 7154 FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get(); |
7139 replica_layer->SetMaskLayer(replica_mask_layer.Pass()); | 7155 replica_layer->SetMaskLayer(replica_mask_layer.PassAs<LayerImpl>()); |
7140 raw_pending_layer->SetReplicaLayer(replica_layer.Pass()); | 7156 raw_pending_layer->SetReplicaLayer(replica_layer.PassAs<LayerImpl>()); |
7141 ASSERT_EQ(raw_replica_mask_layer, | 7157 ASSERT_EQ(raw_replica_mask_layer, |
7142 raw_pending_layer->replica_layer()->mask_layer()); | 7158 raw_pending_layer->replica_layer()->mask_layer()); |
7143 | 7159 |
7144 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); | 7160 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); |
7145 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); | 7161 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); |
7146 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count()); | 7162 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count()); |
7147 pending_tree->DidBecomeActive(); | 7163 pending_tree->DidBecomeActive(); |
7148 EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count()); | 7164 EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count()); |
7149 EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count()); | 7165 EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count()); |
7150 EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count()); | 7166 EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count()); |
(...skipping 16 matching lines...) Expand all Loading... |
7167 // surface. | 7183 // surface. |
7168 EXPECT_EQ(0, num_lost_surfaces_); | 7184 EXPECT_EQ(0, num_lost_surfaces_); |
7169 host_impl_->DidLoseOutputSurface(); | 7185 host_impl_->DidLoseOutputSurface(); |
7170 EXPECT_EQ(1, num_lost_surfaces_); | 7186 EXPECT_EQ(1, num_lost_surfaces_); |
7171 host_impl_->DidLoseOutputSurface(); | 7187 host_impl_->DidLoseOutputSurface(); |
7172 EXPECT_LE(1, num_lost_surfaces_); | 7188 EXPECT_LE(1, num_lost_surfaces_); |
7173 } | 7189 } |
7174 | 7190 |
7175 } // namespace | 7191 } // namespace |
7176 } // namespace cc | 7192 } // namespace cc |
OLD | NEW |