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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 CreateHostImpl(DefaultSettings(), CreateCompositorFrameSink()); | 126 CreateHostImpl(DefaultSettings(), CreateCompositorFrameSink()); |
127 } | 127 } |
128 | 128 |
129 void TearDown() override { | 129 void TearDown() override { |
130 if (host_impl_) | 130 if (host_impl_) |
131 host_impl_->ReleaseCompositorFrameSink(); | 131 host_impl_->ReleaseCompositorFrameSink(); |
132 } | 132 } |
133 | 133 |
134 void DidLoseCompositorFrameSinkOnImplThread() override {} | 134 void DidLoseCompositorFrameSinkOnImplThread() override {} |
135 void SetBeginFrameSource(BeginFrameSource* source) override {} | 135 void SetBeginFrameSource(BeginFrameSource* source) override {} |
136 void DidSwapBuffersCompleteOnImplThread() override {} | 136 void DidReceiveCompositorFrameAckOnImplThread() override {} |
137 void OnCanDrawStateChanged(bool can_draw) override { | 137 void OnCanDrawStateChanged(bool can_draw) override { |
138 on_can_draw_state_changed_called_ = true; | 138 on_can_draw_state_changed_called_ = true; |
139 } | 139 } |
140 void NotifyReadyToActivate() override { | 140 void NotifyReadyToActivate() override { |
141 did_notify_ready_to_activate_ = true; | 141 did_notify_ready_to_activate_ = true; |
142 host_impl_->ActivateSyncTree(); | 142 host_impl_->ActivateSyncTree(); |
143 } | 143 } |
144 void NotifyReadyToDraw() override {} | 144 void NotifyReadyToDraw() override {} |
145 void SetNeedsRedrawOnImplThread() override { did_request_redraw_ = true; } | 145 void SetNeedsRedrawOnImplThread() override { did_request_redraw_ = true; } |
146 void SetNeedsOneBeginImplFrameOnImplThread() override { | 146 void SetNeedsOneBeginImplFrameOnImplThread() override { |
(...skipping 7568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7715 GLRendererWithSetupQuadForAntialiasing::ShouldAntialiasQuad( | 7715 GLRendererWithSetupQuadForAntialiasing::ShouldAntialiasQuad( |
7716 device_layer_quad, clipped, force_aa); | 7716 device_layer_quad, clipped, force_aa); |
7717 EXPECT_FALSE(antialiased); | 7717 EXPECT_FALSE(antialiased); |
7718 | 7718 |
7719 host_impl_->DrawLayers(&frame); | 7719 host_impl_->DrawLayers(&frame); |
7720 host_impl_->DidDrawAllLayers(frame); | 7720 host_impl_->DidDrawAllLayers(frame); |
7721 } | 7721 } |
7722 | 7722 |
7723 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { | 7723 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { |
7724 public: | 7724 public: |
7725 CompositorFrameMetadataTest() | 7725 CompositorFrameMetadataTest() = default; |
7726 : swap_buffers_complete_(0) {} | |
7727 | 7726 |
7728 void DidSwapBuffersCompleteOnImplThread() override { | 7727 void DidReceiveCompositorFrameAckOnImplThread() override { acks_received_++; } |
7729 swap_buffers_complete_++; | |
7730 } | |
7731 | 7728 |
7732 int swap_buffers_complete_; | 7729 int acks_received_ = 0; |
7733 }; | 7730 }; |
7734 | 7731 |
7735 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { | 7732 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { |
7736 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 7733 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
7737 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7734 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
7738 { | 7735 { |
7739 LayerTreeHostImpl::FrameData frame; | 7736 LayerTreeHostImpl::FrameData frame; |
7740 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7737 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7741 host_impl_->DrawLayers(&frame); | 7738 host_impl_->DrawLayers(&frame); |
7742 host_impl_->DidDrawAllLayers(frame); | 7739 host_impl_->DidDrawAllLayers(frame); |
7743 } | 7740 } |
7744 host_impl_->ReclaimResources(ReturnedResourceArray()); | 7741 host_impl_->ReclaimResources(ReturnedResourceArray()); |
7745 host_impl_->DidSwapBuffersComplete(); | 7742 host_impl_->DidReceiveCompositorFrameAck(); |
7746 EXPECT_EQ(swap_buffers_complete_, 1); | 7743 EXPECT_EQ(acks_received_, 1); |
7747 } | 7744 } |
7748 | 7745 |
7749 class CountingSoftwareDevice : public SoftwareOutputDevice { | 7746 class CountingSoftwareDevice : public SoftwareOutputDevice { |
7750 public: | 7747 public: |
7751 CountingSoftwareDevice() : frames_began_(0), frames_ended_(0) {} | 7748 CountingSoftwareDevice() : frames_began_(0), frames_ended_(0) {} |
7752 | 7749 |
7753 SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override { | 7750 SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override { |
7754 ++frames_began_; | 7751 ++frames_began_; |
7755 return SoftwareOutputDevice::BeginPaint(damage_rect); | 7752 return SoftwareOutputDevice::BeginPaint(damage_rect); |
7756 } | 7753 } |
(...skipping 3453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11210 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11207 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11211 | 11208 |
11212 // Re-initialize with a software output surface. | 11209 // Re-initialize with a software output surface. |
11213 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); | 11210 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); |
11214 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 11211 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
11215 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11212 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
11216 } | 11213 } |
11217 | 11214 |
11218 } // namespace | 11215 } // namespace |
11219 } // namespace cc | 11216 } // namespace cc |
OLD | NEW |