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

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

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

Powered by Google App Engine
This is Rietveld 408576698