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 5524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5535 SoftwareOutputDevice::EndPaint(frame_data); | 5535 SoftwareOutputDevice::EndPaint(frame_data); |
5536 } | 5536 } |
5537 | 5537 |
5538 int frames_began_, frames_ended_; | 5538 int frames_began_, frames_ended_; |
5539 }; | 5539 }; |
5540 | 5540 |
5541 TEST_F(LayerTreeHostImplTest, ForcedDrawToSoftwareDeviceBasicRender) { | 5541 TEST_F(LayerTreeHostImplTest, ForcedDrawToSoftwareDeviceBasicRender) { |
5542 // No main thread evictions in resourceless software mode. | 5542 // No main thread evictions in resourceless software mode. |
5543 set_reduce_memory_result(false); | 5543 set_reduce_memory_result(false); |
5544 CountingSoftwareDevice* software_device = new CountingSoftwareDevice(); | 5544 CountingSoftwareDevice* software_device = new CountingSoftwareDevice(); |
5545 FakeOutputSurface* output_surface = FakeOutputSurface::CreateDeferredGL( | 5545 bool delegated_rendering = false; |
5546 scoped_ptr<SoftwareOutputDevice>(software_device)).release(); | 5546 FakeOutputSurface* output_surface = |
| 5547 FakeOutputSurface::CreateDeferredGL( |
| 5548 scoped_ptr<SoftwareOutputDevice>(software_device), |
| 5549 delegated_rendering).release(); |
5547 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), | 5550 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), |
5548 scoped_ptr<OutputSurface>(output_surface))); | 5551 scoped_ptr<OutputSurface>(output_surface))); |
5549 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 5552 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
5550 | 5553 |
5551 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5554 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5552 | 5555 |
5553 output_surface->set_forced_draw_to_software_device(true); | 5556 output_surface->set_forced_draw_to_software_device(true); |
5554 EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice()); | 5557 EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice()); |
5555 | 5558 |
5556 EXPECT_EQ(0, software_device->frames_began_); | 5559 EXPECT_EQ(0, software_device->frames_began_); |
5557 EXPECT_EQ(0, software_device->frames_ended_); | 5560 EXPECT_EQ(0, software_device->frames_ended_); |
5558 | 5561 |
5559 DrawFrame(); | 5562 DrawFrame(); |
5560 | 5563 |
5561 EXPECT_EQ(1, software_device->frames_began_); | 5564 EXPECT_EQ(1, software_device->frames_began_); |
5562 EXPECT_EQ(1, software_device->frames_ended_); | 5565 EXPECT_EQ(1, software_device->frames_ended_); |
5563 | 5566 |
5564 // Call other API methods that are likely to hit NULL pointer in this mode. | 5567 // Call other API methods that are likely to hit NULL pointer in this mode. |
5565 EXPECT_TRUE(host_impl_->AsValue()); | 5568 EXPECT_TRUE(host_impl_->AsValue()); |
5566 EXPECT_TRUE(host_impl_->ActivationStateAsValue()); | 5569 EXPECT_TRUE(host_impl_->ActivationStateAsValue()); |
5567 } | 5570 } |
5568 | 5571 |
5569 TEST_F(LayerTreeHostImplTest, | 5572 TEST_F(LayerTreeHostImplTest, |
5570 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { | 5573 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { |
5571 set_reduce_memory_result(false); | 5574 set_reduce_memory_result(false); |
5572 FakeOutputSurface* output_surface = FakeOutputSurface::CreateDeferredGL( | 5575 bool delegated_rendering = false; |
5573 scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice())).release(); | 5576 FakeOutputSurface* output_surface = |
| 5577 FakeOutputSurface::CreateDeferredGL( |
| 5578 scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice()), |
| 5579 delegated_rendering).release(); |
5574 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), | 5580 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), |
5575 scoped_ptr<OutputSurface>(output_surface))); | 5581 scoped_ptr<OutputSurface>(output_surface))); |
5576 | 5582 |
5577 output_surface->set_forced_draw_to_software_device(true); | 5583 output_surface->set_forced_draw_to_software_device(true); |
5578 EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice()); | 5584 EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice()); |
5579 | 5585 |
5580 // SolidColorLayerImpl will be drawn. | 5586 // SolidColorLayerImpl will be drawn. |
5581 scoped_ptr<SolidColorLayerImpl> root_layer = | 5587 scoped_ptr<SolidColorLayerImpl> root_layer = |
5582 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 5588 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
5583 | 5589 |
(...skipping 16 matching lines...) Expand all Loading... |
5600 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); | 5606 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); |
5601 } | 5607 } |
5602 | 5608 |
5603 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { | 5609 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { |
5604 protected: | 5610 protected: |
5605 virtual void SetUp() OVERRIDE { | 5611 virtual void SetUp() OVERRIDE { |
5606 LayerTreeHostImplTest::SetUp(); | 5612 LayerTreeHostImplTest::SetUp(); |
5607 | 5613 |
5608 set_reduce_memory_result(false); | 5614 set_reduce_memory_result(false); |
5609 | 5615 |
| 5616 bool delegated_rendering = false; |
5610 scoped_ptr<FakeOutputSurface> output_surface( | 5617 scoped_ptr<FakeOutputSurface> output_surface( |
5611 FakeOutputSurface::CreateDeferredGL( | 5618 FakeOutputSurface::CreateDeferredGL( |
5612 scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice()))); | 5619 scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice()), |
| 5620 delegated_rendering)); |
5613 output_surface_ = output_surface.get(); | 5621 output_surface_ = output_surface.get(); |
5614 | 5622 |
5615 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), | 5623 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), |
5616 output_surface.PassAs<OutputSurface>())); | 5624 output_surface.PassAs<OutputSurface>())); |
5617 | 5625 |
5618 scoped_ptr<SolidColorLayerImpl> root_layer = | 5626 scoped_ptr<SolidColorLayerImpl> root_layer = |
5619 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 5627 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
5620 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); | 5628 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); |
5621 | 5629 |
5622 onscreen_context_provider_ = TestContextProvider::Create(); | 5630 onscreen_context_provider_ = TestContextProvider::Create(); |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6608 FakePictureLayerImpl* active_mask_content = | 6616 FakePictureLayerImpl* active_mask_content = |
6609 static_cast<FakePictureLayerImpl*>( | 6617 static_cast<FakePictureLayerImpl*>( |
6610 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); | 6618 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); |
6611 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); | 6619 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); |
6612 | 6620 |
6613 ASSERT_TRUE(!r2.IsEmpty()); | 6621 ASSERT_TRUE(!r2.IsEmpty()); |
6614 } | 6622 } |
6615 | 6623 |
6616 } // namespace | 6624 } // namespace |
6617 } // namespace cc | 6625 } // namespace cc |
OLD | NEW |