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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 did_try_initialize_renderer_(false), | 67 did_try_initialize_renderer_(false), |
68 on_can_draw_state_changed_called_(false), | 68 on_can_draw_state_changed_called_(false), |
69 has_pending_tree_(false), | 69 has_pending_tree_(false), |
70 did_request_commit_(false), | 70 did_request_commit_(false), |
71 did_request_redraw_(false), | 71 did_request_redraw_(false), |
72 did_upload_visible_tile_(false), | 72 did_upload_visible_tile_(false), |
73 reduce_memory_result_(true) { | 73 reduce_memory_result_(true) { |
74 media::InitializeMediaLibraryForTesting(); | 74 media::InitializeMediaLibraryForTesting(); |
75 } | 75 } |
76 | 76 |
77 virtual void OverrideSettings(LayerTreeSettings* settings) {} | |
78 | |
79 virtual void SetUp() OVERRIDE { | 77 virtual void SetUp() OVERRIDE { |
80 LayerTreeSettings settings; | 78 LayerTreeSettings settings; |
81 settings.minimum_occlusion_tracking_size = gfx::Size(); | 79 settings.minimum_occlusion_tracking_size = gfx::Size(); |
82 OverrideSettings(&settings); | |
83 | 80 |
84 host_impl_ = LayerTreeHostImpl::Create(settings, | 81 host_impl_ = LayerTreeHostImpl::Create(settings, |
85 this, | 82 this, |
86 &proxy_, | 83 &proxy_, |
87 &stats_instrumentation_); | 84 &stats_instrumentation_); |
88 host_impl_->InitializeRenderer(CreateOutputSurface()); | 85 host_impl_->InitializeRenderer(CreateOutputSurface()); |
89 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 86 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
90 } | 87 } |
91 | 88 |
92 virtual void TearDown() OVERRIDE {} | 89 virtual void TearDown() OVERRIDE {} |
(...skipping 5648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5741 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | 5738 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); |
5742 host_impl_->DidDrawAllLayers(frame); | 5739 host_impl_->DidDrawAllLayers(frame); |
5743 } | 5740 } |
5744 } | 5741 } |
5745 | 5742 |
5746 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { | 5743 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { |
5747 public: | 5744 public: |
5748 CompositorFrameMetadataTest() | 5745 CompositorFrameMetadataTest() |
5749 : swap_buffers_complete_(0) {} | 5746 : swap_buffers_complete_(0) {} |
5750 | 5747 |
5751 virtual void OverrideSettings(LayerTreeSettings* settings) OVERRIDE { | |
5752 settings->compositor_frame_message = true; | |
5753 } | |
5754 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE { | 5748 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE { |
5755 swap_buffers_complete_++; | 5749 swap_buffers_complete_++; |
5756 } | 5750 } |
5757 | 5751 |
5758 int swap_buffers_complete_; | 5752 int swap_buffers_complete_; |
5759 }; | 5753 }; |
5760 | 5754 |
5761 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { | 5755 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { |
5762 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 5756 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
5763 { | 5757 { |
5764 LayerTreeHostImpl::FrameData frame; | 5758 LayerTreeHostImpl::FrameData frame; |
5765 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 5759 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
5766 host_impl_->DrawLayers(&frame, base::TimeTicks()); | 5760 host_impl_->DrawLayers(&frame, base::TimeTicks()); |
5767 host_impl_->DidDrawAllLayers(frame); | 5761 host_impl_->DidDrawAllLayers(frame); |
5768 } | 5762 } |
5769 CompositorFrameAck ack; | 5763 CompositorFrameAck ack; |
5770 host_impl_->OnSendFrameToParentCompositorAck(ack); | 5764 host_impl_->OnSwapBuffersComplete(&ack); |
5771 EXPECT_EQ(swap_buffers_complete_, 1); | 5765 EXPECT_EQ(swap_buffers_complete_, 1); |
5772 } | 5766 } |
5773 | 5767 |
5774 class CountingSoftwareDevice : public SoftwareOutputDevice { | 5768 class CountingSoftwareDevice : public SoftwareOutputDevice { |
5775 public: | 5769 public: |
5776 CountingSoftwareDevice() : frames_began_(0), frames_ended_(0) {} | 5770 CountingSoftwareDevice() : frames_began_(0), frames_ended_(0) {} |
5777 | 5771 |
5778 virtual SkCanvas* BeginPaint(gfx::Rect damage_rect) OVERRIDE { | 5772 virtual SkCanvas* BeginPaint(gfx::Rect damage_rect) OVERRIDE { |
5779 ++frames_began_; | 5773 ++frames_began_; |
5780 return SoftwareOutputDevice::BeginPaint(damage_rect); | 5774 return SoftwareOutputDevice::BeginPaint(damage_rect); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5873 EXPECT_FALSE(did_try_initialize_renderer_); | 5867 EXPECT_FALSE(did_try_initialize_renderer_); |
5874 host_impl_->DeferredInitialize(scoped_refptr<ContextProvider>()); | 5868 host_impl_->DeferredInitialize(scoped_refptr<ContextProvider>()); |
5875 EXPECT_TRUE(did_try_initialize_renderer_); | 5869 EXPECT_TRUE(did_try_initialize_renderer_); |
5876 | 5870 |
5877 // Defer intialized GL draw. | 5871 // Defer intialized GL draw. |
5878 DrawFrame(); | 5872 DrawFrame(); |
5879 } | 5873 } |
5880 | 5874 |
5881 } // namespace | 5875 } // namespace |
5882 } // namespace cc | 5876 } // namespace cc |
OLD | NEW |