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 3408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3419 gfx::Size new_size(42, 24); | 3419 gfx::Size new_size(42, 24); |
3420 host_impl_->CreatePendingTree(); | 3420 host_impl_->CreatePendingTree(); |
3421 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); | 3421 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); |
3422 host_impl_->ActivateSyncTree(); | 3422 host_impl_->ActivateSyncTree(); |
3423 EXPECT_EQ(new_size, scroll_delegate.scrollable_size()); | 3423 EXPECT_EQ(new_size, scroll_delegate.scrollable_size()); |
3424 | 3424 |
3425 // Un-setting the delegate should propagate the delegate's current offset to | 3425 // Un-setting the delegate should propagate the delegate's current offset to |
3426 // the root scrollable layer. | 3426 // the root scrollable layer. |
3427 current_offset = gfx::ScrollOffset(13.f, 12.f); | 3427 current_offset = gfx::ScrollOffset(13.f, 12.f); |
3428 scroll_delegate.set_getter_return_value(current_offset); | 3428 scroll_delegate.set_getter_return_value(current_offset); |
3429 host_impl_->SetRootLayerScrollOffsetDelegate(NULL); | 3429 host_impl_->SetRootLayerScrollOffsetDelegate(nullptr); |
3430 | 3430 |
3431 EXPECT_EQ(current_offset.ToString(), | 3431 EXPECT_EQ(current_offset.ToString(), |
3432 scroll_layer->TotalScrollOffset().ToString()); | 3432 scroll_layer->TotalScrollOffset().ToString()); |
3433 } | 3433 } |
3434 | 3434 |
3435 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { | 3435 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { |
3436 const gfx::Transform target_space_transform = | 3436 const gfx::Transform target_space_transform = |
3437 layer->draw_properties().target_space_transform; | 3437 layer->draw_properties().target_space_transform; |
3438 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); | 3438 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); |
3439 gfx::Point translated_point; | 3439 gfx::Point translated_point; |
(...skipping 18 matching lines...) Expand all Loading... |
3458 | 3458 |
3459 // Set external scroll delta on delegate and notify LayerTreeHost. | 3459 // Set external scroll delta on delegate and notify LayerTreeHost. |
3460 gfx::ScrollOffset scroll_offset(10.f, 10.f); | 3460 gfx::ScrollOffset scroll_offset(10.f, 10.f); |
3461 scroll_delegate.set_getter_return_value(scroll_offset); | 3461 scroll_delegate.set_getter_return_value(scroll_offset); |
3462 host_impl_->OnRootLayerDelegatedScrollOffsetChanged(); | 3462 host_impl_->OnRootLayerDelegatedScrollOffsetChanged(); |
3463 | 3463 |
3464 // Check scroll delta reflected in layer. | 3464 // Check scroll delta reflected in layer. |
3465 DrawFrame(); | 3465 DrawFrame(); |
3466 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset)); | 3466 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset)); |
3467 | 3467 |
3468 host_impl_->SetRootLayerScrollOffsetDelegate(NULL); | 3468 host_impl_->SetRootLayerScrollOffsetDelegate(nullptr); |
3469 } | 3469 } |
3470 | 3470 |
3471 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { | 3471 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { |
3472 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 3472 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
3473 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 3473 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
3474 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); | 3474 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); |
3475 DrawFrame(); | 3475 DrawFrame(); |
3476 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 3476 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
3477 | 3477 |
3478 // In-bounds scrolling does not affect overscroll. | 3478 // In-bounds scrolling does not affect overscroll. |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4034 layer1->SetExpectation(false, false); | 4034 layer1->SetExpectation(false, false); |
4035 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 4035 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
4036 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4036 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4037 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4037 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
4038 EXPECT_TRUE(layer1->quads_appended()); | 4038 EXPECT_TRUE(layer1->quads_appended()); |
4039 host_impl_->DidDrawAllLayers(frame); | 4039 host_impl_->DidDrawAllLayers(frame); |
4040 } | 4040 } |
4041 | 4041 |
4042 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 4042 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
4043 protected: | 4043 protected: |
4044 LayerTreeHostImplViewportCoveredTest() : | 4044 LayerTreeHostImplViewportCoveredTest() |
4045 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 4045 : gutter_quad_material_(DrawQuad::SOLID_COLOR), |
4046 child_(NULL), | 4046 child_(nullptr), |
4047 did_activate_pending_tree_(false) {} | 4047 did_activate_pending_tree_(false) {} |
4048 | 4048 |
4049 scoped_ptr<OutputSurface> CreateFakeOutputSurface(bool always_draw) { | 4049 scoped_ptr<OutputSurface> CreateFakeOutputSurface(bool always_draw) { |
4050 if (always_draw) { | 4050 if (always_draw) { |
4051 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d(); | 4051 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d(); |
4052 } | 4052 } |
4053 return FakeOutputSurface::Create3d(); | 4053 return FakeOutputSurface::Create3d(); |
4054 } | 4054 } |
4055 | 4055 |
4056 void SetupActiveTreeLayers() { | 4056 void SetupActiveTreeLayers() { |
4057 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 4057 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5836 resourceless_software_draw); | 5836 resourceless_software_draw); |
5837 | 5837 |
5838 EXPECT_EQ(0, software_device->frames_began_); | 5838 EXPECT_EQ(0, software_device->frames_began_); |
5839 EXPECT_EQ(0, software_device->frames_ended_); | 5839 EXPECT_EQ(0, software_device->frames_ended_); |
5840 | 5840 |
5841 DrawFrame(); | 5841 DrawFrame(); |
5842 | 5842 |
5843 EXPECT_EQ(1, software_device->frames_began_); | 5843 EXPECT_EQ(1, software_device->frames_began_); |
5844 EXPECT_EQ(1, software_device->frames_ended_); | 5844 EXPECT_EQ(1, software_device->frames_ended_); |
5845 | 5845 |
5846 // Call other API methods that are likely to hit NULL pointer in this mode. | 5846 // Call other API methods that are likely to hit nullptr pointer in this mode. |
5847 EXPECT_TRUE(host_impl_->AsValue().get()); | 5847 EXPECT_TRUE(host_impl_->AsValue().get()); |
5848 EXPECT_TRUE(host_impl_->ActivationStateAsValue().get()); | 5848 EXPECT_TRUE(host_impl_->ActivationStateAsValue().get()); |
5849 } | 5849 } |
5850 | 5850 |
5851 TEST_F(LayerTreeHostImplTest, | 5851 TEST_F(LayerTreeHostImplTest, |
5852 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { | 5852 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { |
5853 set_reduce_memory_result(false); | 5853 set_reduce_memory_result(false); |
5854 bool delegated_rendering = false; | 5854 bool delegated_rendering = false; |
5855 FakeOutputSurface* output_surface = | 5855 FakeOutputSurface* output_surface = |
5856 FakeOutputSurface::CreateDeferredGL( | 5856 FakeOutputSurface::CreateDeferredGL( |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5997 int everything_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue( | 5997 int everything_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue( |
5998 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING); | 5998 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING); |
5999 int allow_nice_to_have_cutoff_value = | 5999 int allow_nice_to_have_cutoff_value = |
6000 ManagedMemoryPolicy::PriorityCutoffToValue( | 6000 ManagedMemoryPolicy::PriorityCutoffToValue( |
6001 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE); | 6001 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE); |
6002 int nothing_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue( | 6002 int nothing_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue( |
6003 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING); | 6003 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING); |
6004 | 6004 |
6005 // GPU rasterization should be disabled by default on the tree(s) | 6005 // GPU rasterization should be disabled by default on the tree(s) |
6006 EXPECT_FALSE(host_impl_->active_tree()->use_gpu_rasterization()); | 6006 EXPECT_FALSE(host_impl_->active_tree()->use_gpu_rasterization()); |
6007 EXPECT_TRUE(host_impl_->pending_tree() == NULL); | 6007 EXPECT_TRUE(host_impl_->pending_tree() == nullptr); |
6008 | 6008 |
6009 host_impl_->SetVisible(true); | 6009 host_impl_->SetVisible(true); |
6010 host_impl_->SetMemoryPolicy(policy1); | 6010 host_impl_->SetMemoryPolicy(policy1); |
6011 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); | 6011 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); |
6012 EXPECT_EQ(everything_cutoff_value, current_priority_cutoff_value_); | 6012 EXPECT_EQ(everything_cutoff_value, current_priority_cutoff_value_); |
6013 | 6013 |
6014 host_impl_->SetVisible(false); | 6014 host_impl_->SetVisible(false); |
6015 EXPECT_EQ(0u, current_limit_bytes_); | 6015 EXPECT_EQ(0u, current_limit_bytes_); |
6016 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); | 6016 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); |
6017 | 6017 |
6018 host_impl_->SetVisible(true); | 6018 host_impl_->SetVisible(true); |
6019 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); | 6019 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); |
6020 EXPECT_EQ(everything_cutoff_value, current_priority_cutoff_value_); | 6020 EXPECT_EQ(everything_cutoff_value, current_priority_cutoff_value_); |
6021 | 6021 |
6022 // Now enable GPU rasterization and test if we get nice to have cutoff, | 6022 // Now enable GPU rasterization and test if we get nice to have cutoff, |
6023 // when visible. | 6023 // when visible. |
6024 LayerTreeSettings settings; | 6024 LayerTreeSettings settings; |
6025 settings.gpu_rasterization_enabled = true; | 6025 settings.gpu_rasterization_enabled = true; |
6026 host_impl_ = LayerTreeHostImpl::Create( | 6026 host_impl_ = LayerTreeHostImpl::Create( |
6027 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); | 6027 settings, this, &proxy_, &stats_instrumentation_, nullptr, 0); |
6028 host_impl_->SetUseGpuRasterization(true); | 6028 host_impl_->SetUseGpuRasterization(true); |
6029 host_impl_->SetVisible(true); | 6029 host_impl_->SetVisible(true); |
6030 host_impl_->SetMemoryPolicy(policy1); | 6030 host_impl_->SetMemoryPolicy(policy1); |
6031 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); | 6031 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); |
6032 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_); | 6032 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_); |
6033 | 6033 |
6034 host_impl_->SetVisible(false); | 6034 host_impl_->SetVisible(false); |
6035 EXPECT_EQ(0u, current_limit_bytes_); | 6035 EXPECT_EQ(0u, current_limit_bytes_); |
6036 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); | 6036 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); |
6037 } | 6037 } |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6556 LayerTreeHostImpl::FrameData frame; | 6556 LayerTreeHostImpl::FrameData frame; |
6557 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6557 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6558 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 6558 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
6559 host_impl_->DidDrawAllLayers(frame); | 6559 host_impl_->DidDrawAllLayers(frame); |
6560 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 6560 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
6561 | 6561 |
6562 const std::vector<ui::LatencyInfo>& metadata_latency_after = | 6562 const std::vector<ui::LatencyInfo>& metadata_latency_after = |
6563 fake_output_surface->last_sent_frame().metadata.latency_info; | 6563 fake_output_surface->last_sent_frame().metadata.latency_info; |
6564 EXPECT_EQ(1u, metadata_latency_after.size()); | 6564 EXPECT_EQ(1u, metadata_latency_after.size()); |
6565 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 6565 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
6566 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 6566 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, nullptr)); |
6567 } | 6567 } |
6568 | 6568 |
6569 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 6569 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
6570 int root_layer_id = 1; | 6570 int root_layer_id = 1; |
6571 scoped_ptr<SolidColorLayerImpl> root = | 6571 scoped_ptr<SolidColorLayerImpl> root = |
6572 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 6572 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
6573 root->SetPosition(gfx::PointF()); | 6573 root->SetPosition(gfx::PointF()); |
6574 root->SetBounds(gfx::Size(10, 10)); | 6574 root->SetBounds(gfx::Size(10, 10)); |
6575 root->SetContentBounds(gfx::Size(10, 10)); | 6575 root->SetContentBounds(gfx::Size(10, 10)); |
6576 root->SetDrawsContent(true); | 6576 root->SetDrawsContent(true); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6653 int* forward_to_main_count_; | 6653 int* forward_to_main_count_; |
6654 }; | 6654 }; |
6655 | 6655 |
6656 TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) { | 6656 TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) { |
6657 int set_needs_commit_count = 0; | 6657 int set_needs_commit_count = 0; |
6658 int set_needs_redraw_count = 0; | 6658 int set_needs_redraw_count = 0; |
6659 int forward_to_main_count = 0; | 6659 int forward_to_main_count = 0; |
6660 | 6660 |
6661 { | 6661 { |
6662 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 6662 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
6663 new SimpleSwapPromiseMonitor(NULL, | 6663 new SimpleSwapPromiseMonitor(nullptr, |
6664 host_impl_.get(), | 6664 host_impl_.get(), |
6665 &set_needs_commit_count, | 6665 &set_needs_commit_count, |
6666 &set_needs_redraw_count, | 6666 &set_needs_redraw_count, |
6667 &forward_to_main_count)); | 6667 &forward_to_main_count)); |
6668 host_impl_->SetNeedsRedraw(); | 6668 host_impl_->SetNeedsRedraw(); |
6669 EXPECT_EQ(0, set_needs_commit_count); | 6669 EXPECT_EQ(0, set_needs_commit_count); |
6670 EXPECT_EQ(1, set_needs_redraw_count); | 6670 EXPECT_EQ(1, set_needs_redraw_count); |
6671 EXPECT_EQ(0, forward_to_main_count); | 6671 EXPECT_EQ(0, forward_to_main_count); |
6672 } | 6672 } |
6673 | 6673 |
6674 // Now the monitor is destroyed, SetNeedsRedraw() is no longer being | 6674 // Now the monitor is destroyed, SetNeedsRedraw() is no longer being |
6675 // monitored. | 6675 // monitored. |
6676 host_impl_->SetNeedsRedraw(); | 6676 host_impl_->SetNeedsRedraw(); |
6677 EXPECT_EQ(0, set_needs_commit_count); | 6677 EXPECT_EQ(0, set_needs_commit_count); |
6678 EXPECT_EQ(1, set_needs_redraw_count); | 6678 EXPECT_EQ(1, set_needs_redraw_count); |
6679 EXPECT_EQ(0, forward_to_main_count); | 6679 EXPECT_EQ(0, forward_to_main_count); |
6680 | 6680 |
6681 { | 6681 { |
6682 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 6682 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
6683 new SimpleSwapPromiseMonitor(NULL, | 6683 new SimpleSwapPromiseMonitor(nullptr, |
6684 host_impl_.get(), | 6684 host_impl_.get(), |
6685 &set_needs_commit_count, | 6685 &set_needs_commit_count, |
6686 &set_needs_redraw_count, | 6686 &set_needs_redraw_count, |
6687 &forward_to_main_count)); | 6687 &forward_to_main_count)); |
6688 host_impl_->SetNeedsRedrawRect(gfx::Rect(10, 10)); | 6688 host_impl_->SetNeedsRedrawRect(gfx::Rect(10, 10)); |
6689 EXPECT_EQ(0, set_needs_commit_count); | 6689 EXPECT_EQ(0, set_needs_commit_count); |
6690 EXPECT_EQ(2, set_needs_redraw_count); | 6690 EXPECT_EQ(2, set_needs_redraw_count); |
6691 EXPECT_EQ(0, forward_to_main_count); | 6691 EXPECT_EQ(0, forward_to_main_count); |
6692 } | 6692 } |
6693 | 6693 |
6694 { | 6694 { |
6695 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 6695 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
6696 new SimpleSwapPromiseMonitor(NULL, | 6696 new SimpleSwapPromiseMonitor(nullptr, |
6697 host_impl_.get(), | 6697 host_impl_.get(), |
6698 &set_needs_commit_count, | 6698 &set_needs_commit_count, |
6699 &set_needs_redraw_count, | 6699 &set_needs_redraw_count, |
6700 &forward_to_main_count)); | 6700 &forward_to_main_count)); |
6701 // Empty damage rect won't signal the monitor. | 6701 // Empty damage rect won't signal the monitor. |
6702 host_impl_->SetNeedsRedrawRect(gfx::Rect()); | 6702 host_impl_->SetNeedsRedrawRect(gfx::Rect()); |
6703 EXPECT_EQ(0, set_needs_commit_count); | 6703 EXPECT_EQ(0, set_needs_commit_count); |
6704 EXPECT_EQ(2, set_needs_redraw_count); | 6704 EXPECT_EQ(2, set_needs_redraw_count); |
6705 EXPECT_EQ(0, forward_to_main_count); | 6705 EXPECT_EQ(0, forward_to_main_count); |
6706 } | 6706 } |
6707 | 6707 |
6708 { | 6708 { |
6709 set_needs_commit_count = 0; | 6709 set_needs_commit_count = 0; |
6710 set_needs_redraw_count = 0; | 6710 set_needs_redraw_count = 0; |
6711 forward_to_main_count = 0; | 6711 forward_to_main_count = 0; |
6712 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 6712 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
6713 new SimpleSwapPromiseMonitor(NULL, | 6713 new SimpleSwapPromiseMonitor(nullptr, |
6714 host_impl_.get(), | 6714 host_impl_.get(), |
6715 &set_needs_commit_count, | 6715 &set_needs_commit_count, |
6716 &set_needs_redraw_count, | 6716 &set_needs_redraw_count, |
6717 &forward_to_main_count)); | 6717 &forward_to_main_count)); |
6718 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 6718 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
6719 | 6719 |
6720 // Scrolling normally should not trigger any forwarding. | 6720 // Scrolling normally should not trigger any forwarding. |
6721 EXPECT_EQ(InputHandler::ScrollStarted, | 6721 EXPECT_EQ(InputHandler::ScrollStarted, |
6722 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 6722 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
6723 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10))); | 6723 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10))); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7144 | 7144 |
7145 y = scrolling_layer->TotalScrollOffset().y(); | 7145 y = scrolling_layer->TotalScrollOffset().y(); |
7146 EXPECT_TRUE(y > 50 && y < 100); | 7146 EXPECT_TRUE(y > 50 && y < 100); |
7147 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 7147 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
7148 | 7148 |
7149 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); | 7149 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); |
7150 host_impl_->UpdateAnimationState(true); | 7150 host_impl_->UpdateAnimationState(true); |
7151 | 7151 |
7152 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 7152 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
7153 scrolling_layer->TotalScrollOffset()); | 7153 scrolling_layer->TotalScrollOffset()); |
7154 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 7154 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
7155 } | 7155 } |
7156 | 7156 |
7157 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { | 7157 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
7158 host_impl_->CreatePendingTree(); | 7158 host_impl_->CreatePendingTree(); |
7159 host_impl_->ActivateSyncTree(); | 7159 host_impl_->ActivateSyncTree(); |
7160 host_impl_->CreatePendingTree(); | 7160 host_impl_->CreatePendingTree(); |
7161 | 7161 |
7162 LayerTreeImpl* active_tree = host_impl_->active_tree(); | 7162 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
7163 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 7163 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
7164 EXPECT_NE(active_tree, pending_tree); | 7164 EXPECT_NE(active_tree, pending_tree); |
7165 | 7165 |
7166 scoped_ptr<FakePictureLayerImpl> active_layer = | 7166 scoped_ptr<FakePictureLayerImpl> active_layer = |
7167 FakePictureLayerImpl::Create(active_tree, 10); | 7167 FakePictureLayerImpl::Create(active_tree, 10); |
7168 scoped_ptr<FakePictureLayerImpl> pending_layer = | 7168 scoped_ptr<FakePictureLayerImpl> pending_layer = |
7169 FakePictureLayerImpl::Create(pending_tree, 10); | 7169 FakePictureLayerImpl::Create(pending_tree, 10); |
7170 | 7170 |
7171 std::vector<PictureLayerImpl::Pair> layer_pairs; | 7171 std::vector<PictureLayerImpl::Pair> layer_pairs; |
7172 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7172 host_impl_->GetPictureLayerImplPairs(&layer_pairs); |
7173 | 7173 |
7174 EXPECT_EQ(2u, layer_pairs.size()); | 7174 EXPECT_EQ(2u, layer_pairs.size()); |
7175 if (layer_pairs[0].active) { | 7175 if (layer_pairs[0].active) { |
7176 EXPECT_EQ(active_layer.get(), layer_pairs[0].active); | 7176 EXPECT_EQ(active_layer.get(), layer_pairs[0].active); |
7177 EXPECT_EQ(NULL, layer_pairs[0].pending); | 7177 EXPECT_EQ(nullptr, layer_pairs[0].pending); |
7178 } else { | 7178 } else { |
7179 EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending); | 7179 EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending); |
7180 EXPECT_EQ(NULL, layer_pairs[0].active); | 7180 EXPECT_EQ(nullptr, layer_pairs[0].active); |
7181 } | 7181 } |
7182 | 7182 |
7183 if (layer_pairs[1].active) { | 7183 if (layer_pairs[1].active) { |
7184 EXPECT_EQ(active_layer.get(), layer_pairs[1].active); | 7184 EXPECT_EQ(active_layer.get(), layer_pairs[1].active); |
7185 EXPECT_EQ(NULL, layer_pairs[1].pending); | 7185 EXPECT_EQ(nullptr, layer_pairs[1].pending); |
7186 } else { | 7186 } else { |
7187 EXPECT_EQ(pending_layer.get(), layer_pairs[1].pending); | 7187 EXPECT_EQ(pending_layer.get(), layer_pairs[1].pending); |
7188 EXPECT_EQ(NULL, layer_pairs[1].active); | 7188 EXPECT_EQ(nullptr, layer_pairs[1].active); |
7189 } | 7189 } |
7190 | 7190 |
7191 active_layer->set_twin_layer(pending_layer.get()); | 7191 active_layer->set_twin_layer(pending_layer.get()); |
7192 pending_layer->set_twin_layer(active_layer.get()); | 7192 pending_layer->set_twin_layer(active_layer.get()); |
7193 | 7193 |
7194 layer_pairs.clear(); | 7194 layer_pairs.clear(); |
7195 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7195 host_impl_->GetPictureLayerImplPairs(&layer_pairs); |
7196 EXPECT_EQ(1u, layer_pairs.size()); | 7196 EXPECT_EQ(1u, layer_pairs.size()); |
7197 | 7197 |
7198 EXPECT_EQ(active_layer.get(), layer_pairs[0].active); | 7198 EXPECT_EQ(active_layer.get(), layer_pairs[0].active); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7267 // surface. | 7267 // surface. |
7268 EXPECT_EQ(0, num_lost_surfaces_); | 7268 EXPECT_EQ(0, num_lost_surfaces_); |
7269 host_impl_->DidLoseOutputSurface(); | 7269 host_impl_->DidLoseOutputSurface(); |
7270 EXPECT_EQ(1, num_lost_surfaces_); | 7270 EXPECT_EQ(1, num_lost_surfaces_); |
7271 host_impl_->DidLoseOutputSurface(); | 7271 host_impl_->DidLoseOutputSurface(); |
7272 EXPECT_LE(1, num_lost_surfaces_); | 7272 EXPECT_LE(1, num_lost_surfaces_); |
7273 } | 7273 } |
7274 | 7274 |
7275 } // namespace | 7275 } // namespace |
7276 } // namespace cc | 7276 } // namespace cc |
OLD | NEW |