| 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 5568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5579 FakeOutputSurface* output_surface = | 5579 FakeOutputSurface* output_surface = |
| 5580 FakeOutputSurface::CreateDeferredGL( | 5580 FakeOutputSurface::CreateDeferredGL( |
| 5581 scoped_ptr<SoftwareOutputDevice>(software_device), | 5581 scoped_ptr<SoftwareOutputDevice>(software_device), |
| 5582 delegated_rendering).release(); | 5582 delegated_rendering).release(); |
| 5583 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), | 5583 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), |
| 5584 scoped_ptr<OutputSurface>(output_surface))); | 5584 scoped_ptr<OutputSurface>(output_surface))); |
| 5585 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 5585 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 5586 | 5586 |
| 5587 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5587 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5588 | 5588 |
| 5589 output_surface->set_forced_draw_to_software_device(true); | 5589 const gfx::Transform external_transform; |
| 5590 EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice()); | 5590 const gfx::Rect external_viewport; |
| 5591 const gfx::Rect external_clip; |
| 5592 const bool resourceless_software_draw = true; |
| 5593 host_impl_->SetExternalDrawConstraints(external_transform, |
| 5594 external_viewport, |
| 5595 external_clip, |
| 5596 resourceless_software_draw); |
| 5591 | 5597 |
| 5592 EXPECT_EQ(0, software_device->frames_began_); | 5598 EXPECT_EQ(0, software_device->frames_began_); |
| 5593 EXPECT_EQ(0, software_device->frames_ended_); | 5599 EXPECT_EQ(0, software_device->frames_ended_); |
| 5594 | 5600 |
| 5595 DrawFrame(); | 5601 DrawFrame(); |
| 5596 | 5602 |
| 5597 EXPECT_EQ(1, software_device->frames_began_); | 5603 EXPECT_EQ(1, software_device->frames_began_); |
| 5598 EXPECT_EQ(1, software_device->frames_ended_); | 5604 EXPECT_EQ(1, software_device->frames_ended_); |
| 5599 | 5605 |
| 5600 // Call other API methods that are likely to hit NULL pointer in this mode. | 5606 // Call other API methods that are likely to hit NULL pointer in this mode. |
| 5601 EXPECT_TRUE(host_impl_->AsValue()); | 5607 EXPECT_TRUE(host_impl_->AsValue()); |
| 5602 EXPECT_TRUE(host_impl_->ActivationStateAsValue()); | 5608 EXPECT_TRUE(host_impl_->ActivationStateAsValue()); |
| 5603 } | 5609 } |
| 5604 | 5610 |
| 5605 TEST_F(LayerTreeHostImplTest, | 5611 TEST_F(LayerTreeHostImplTest, |
| 5606 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { | 5612 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { |
| 5607 set_reduce_memory_result(false); | 5613 set_reduce_memory_result(false); |
| 5608 bool delegated_rendering = false; | 5614 bool delegated_rendering = false; |
| 5609 FakeOutputSurface* output_surface = | 5615 FakeOutputSurface* output_surface = |
| 5610 FakeOutputSurface::CreateDeferredGL( | 5616 FakeOutputSurface::CreateDeferredGL( |
| 5611 scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice()), | 5617 scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice()), |
| 5612 delegated_rendering).release(); | 5618 delegated_rendering).release(); |
| 5613 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), | 5619 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), |
| 5614 scoped_ptr<OutputSurface>(output_surface))); | 5620 scoped_ptr<OutputSurface>(output_surface))); |
| 5615 | 5621 |
| 5616 output_surface->set_forced_draw_to_software_device(true); | 5622 const gfx::Transform external_transform; |
| 5617 EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice()); | 5623 const gfx::Rect external_viewport; |
| 5624 const gfx::Rect external_clip; |
| 5625 const bool resourceless_software_draw = true; |
| 5626 host_impl_->SetExternalDrawConstraints(external_transform, |
| 5627 external_viewport, |
| 5628 external_clip, |
| 5629 resourceless_software_draw); |
| 5618 | 5630 |
| 5619 // SolidColorLayerImpl will be drawn. | 5631 // SolidColorLayerImpl will be drawn. |
| 5620 scoped_ptr<SolidColorLayerImpl> root_layer = | 5632 scoped_ptr<SolidColorLayerImpl> root_layer = |
| 5621 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 5633 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 5622 | 5634 |
| 5623 // VideoLayerImpl will not be drawn. | 5635 // VideoLayerImpl will not be drawn. |
| 5624 FakeVideoFrameProvider provider; | 5636 FakeVideoFrameProvider provider; |
| 5625 scoped_ptr<VideoLayerImpl> video_layer = | 5637 scoped_ptr<VideoLayerImpl> video_layer = |
| 5626 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); | 5638 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); |
| 5627 video_layer->SetBounds(gfx::Size(10, 10)); | 5639 video_layer->SetBounds(gfx::Size(10, 10)); |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6695 300u * 1024u * 1024u); | 6707 300u * 1024u * 1024u); |
| 6696 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, | 6708 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, |
| 6697 150u * 1024u * 1024u); | 6709 150u * 1024u * 1024u); |
| 6698 } | 6710 } |
| 6699 | 6711 |
| 6700 TEST_F(LayerTreeHostImplTest, ExternalTransformReflectedInNextDraw) { | 6712 TEST_F(LayerTreeHostImplTest, ExternalTransformReflectedInNextDraw) { |
| 6701 const gfx::Size layer_size(100, 100); | 6713 const gfx::Size layer_size(100, 100); |
| 6702 gfx::Transform external_transform; | 6714 gfx::Transform external_transform; |
| 6703 const gfx::Rect external_viewport(layer_size); | 6715 const gfx::Rect external_viewport(layer_size); |
| 6704 const gfx::Rect external_clip(layer_size); | 6716 const gfx::Rect external_clip(layer_size); |
| 6705 const bool valid_for_tile_management = true; | 6717 const bool resourceless_software_draw = false; |
| 6706 LayerImpl* layer = SetupScrollAndContentsLayers(layer_size); | 6718 LayerImpl* layer = SetupScrollAndContentsLayers(layer_size); |
| 6707 | 6719 |
| 6708 host_impl_->SetExternalDrawConstraints(external_transform, | 6720 host_impl_->SetExternalDrawConstraints(external_transform, |
| 6709 external_viewport, | 6721 external_viewport, |
| 6710 external_clip, | 6722 external_clip, |
| 6711 valid_for_tile_management); | 6723 resourceless_software_draw); |
| 6712 DrawFrame(); | 6724 DrawFrame(); |
| 6713 EXPECT_TRANSFORMATION_MATRIX_EQ( | 6725 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 6714 external_transform, layer->draw_properties().target_space_transform); | 6726 external_transform, layer->draw_properties().target_space_transform); |
| 6715 | 6727 |
| 6716 external_transform.Translate(20, 20); | 6728 external_transform.Translate(20, 20); |
| 6717 host_impl_->SetExternalDrawConstraints(external_transform, | 6729 host_impl_->SetExternalDrawConstraints(external_transform, |
| 6718 external_viewport, | 6730 external_viewport, |
| 6719 external_clip, | 6731 external_clip, |
| 6720 valid_for_tile_management); | 6732 resourceless_software_draw); |
| 6721 DrawFrame(); | 6733 DrawFrame(); |
| 6722 EXPECT_TRANSFORMATION_MATRIX_EQ( | 6734 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 6723 external_transform, layer->draw_properties().target_space_transform); | 6735 external_transform, layer->draw_properties().target_space_transform); |
| 6724 } | 6736 } |
| 6725 | 6737 |
| 6726 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { | 6738 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { |
| 6727 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 6739 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 6728 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 6740 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 6729 DrawFrame(); | 6741 DrawFrame(); |
| 6730 | 6742 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6749 | 6761 |
| 6750 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); | 6762 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); |
| 6751 host_impl_->UpdateAnimationState(true); | 6763 host_impl_->UpdateAnimationState(true); |
| 6752 | 6764 |
| 6753 EXPECT_EQ(gfx::Vector2dF(0, 50), scrolling_layer->TotalScrollOffset()); | 6765 EXPECT_EQ(gfx::Vector2dF(0, 50), scrolling_layer->TotalScrollOffset()); |
| 6754 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 6766 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 6755 } | 6767 } |
| 6756 | 6768 |
| 6757 } // namespace | 6769 } // namespace |
| 6758 } // namespace cc | 6770 } // namespace cc |
| OLD | NEW |