| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 : public RenderWidgetCompositorDelegate { | 36 : public RenderWidgetCompositorDelegate { |
| 37 public: | 37 public: |
| 38 // RenderWidgetCompositorDelegate implementation. | 38 // RenderWidgetCompositorDelegate implementation. |
| 39 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, | 39 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, |
| 40 const gfx::Vector2dF& outer_delta, | 40 const gfx::Vector2dF& outer_delta, |
| 41 const gfx::Vector2dF& elastic_overscroll_delta, | 41 const gfx::Vector2dF& elastic_overscroll_delta, |
| 42 float page_scale, | 42 float page_scale, |
| 43 float top_controls_delta) override {} | 43 float top_controls_delta) override {} |
| 44 void BeginMainFrame(double frame_time_sec) override {} | 44 void BeginMainFrame(double frame_time_sec) override {} |
| 45 std::unique_ptr<cc::CompositorFrameSink> CreateCompositorFrameSink( | 45 std::unique_ptr<cc::CompositorFrameSink> CreateCompositorFrameSink( |
| 46 const cc::FrameSinkId& frame_sink_id, |
| 46 bool fallback) override { | 47 bool fallback) override { |
| 47 return nullptr; | 48 return nullptr; |
| 48 } | 49 } |
| 49 void DidCommitAndDrawCompositorFrame() override {} | 50 void DidCommitAndDrawCompositorFrame() override {} |
| 50 void DidCommitCompositorFrame() override {} | 51 void DidCommitCompositorFrame() override {} |
| 51 void DidCompletePageScaleAnimation() override {} | 52 void DidCompletePageScaleAnimation() override {} |
| 52 void DidReceiveCompositorFrameAck() override {} | 53 void DidReceiveCompositorFrameAck() override {} |
| 53 void ForwardCompositorProto(const std::vector<uint8_t>& proto) override {} | 54 void ForwardCompositorProto(const std::vector<uint8_t>& proto) override {} |
| 54 bool IsClosing() const override { return false; } | 55 bool IsClosing() const override { return false; } |
| 55 void RequestScheduleAnimation() override {} | 56 void RequestScheduleAnimation() override {} |
| 56 void UpdateVisualState() override {} | 57 void UpdateVisualState() override {} |
| 57 void WillBeginCompositorFrame() override {} | 58 void WillBeginCompositorFrame() override {} |
| 58 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest( | 59 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest( |
| 59 std::unique_ptr<cc::CopyOutputRequest> request) override { | 60 std::unique_ptr<cc::CopyOutputRequest> request) override { |
| 60 return nullptr; | 61 return nullptr; |
| 61 } | 62 } |
| 62 }; | 63 }; |
| 63 | 64 |
| 64 class FakeRenderWidgetCompositorDelegate | 65 class FakeRenderWidgetCompositorDelegate |
| 65 : public StubRenderWidgetCompositorDelegate { | 66 : public StubRenderWidgetCompositorDelegate { |
| 66 public: | 67 public: |
| 67 FakeRenderWidgetCompositorDelegate() = default; | 68 FakeRenderWidgetCompositorDelegate() = default; |
| 68 | 69 |
| 69 std::unique_ptr<cc::CompositorFrameSink> CreateCompositorFrameSink( | 70 std::unique_ptr<cc::CompositorFrameSink> CreateCompositorFrameSink( |
| 71 const cc::FrameSinkId& frame_sink_id, |
| 70 bool fallback) override { | 72 bool fallback) override { |
| 71 EXPECT_EQ(num_requests_since_last_success_ > | 73 EXPECT_EQ(num_requests_since_last_success_ > |
| 72 RenderWidgetCompositor:: | 74 RenderWidgetCompositor:: |
| 73 COMPOSITOR_FRAME_SINK_RETRIES_BEFORE_FALLBACK, | 75 COMPOSITOR_FRAME_SINK_RETRIES_BEFORE_FALLBACK, |
| 74 fallback); | 76 fallback); |
| 75 last_create_was_fallback_ = fallback; | 77 last_create_was_fallback_ = fallback; |
| 76 | 78 |
| 77 bool success = num_failures_ >= num_failures_before_success_; | 79 bool success = num_failures_ >= num_failures_before_success_; |
| 78 if (!success && use_null_compositor_frame_sink_) | 80 if (!success && use_null_compositor_frame_sink_) |
| 79 return nullptr; | 81 return nullptr; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 293 |
| 292 TEST_F(RenderWidgetCompositorFrameSinkTest, FallbackSuccessNormalSuccess) { | 294 TEST_F(RenderWidgetCompositorFrameSinkTest, FallbackSuccessNormalSuccess) { |
| 293 // The first success is a fallback, but the next should not be a fallback. | 295 // The first success is a fallback, but the next should not be a fallback. |
| 294 RunTest(false, | 296 RunTest(false, |
| 295 RenderWidgetCompositor::COMPOSITOR_FRAME_SINK_RETRIES_BEFORE_FALLBACK, | 297 RenderWidgetCompositor::COMPOSITOR_FRAME_SINK_RETRIES_BEFORE_FALLBACK, |
| 296 1, 1); | 298 1, 1); |
| 297 } | 299 } |
| 298 | 300 |
| 299 } // namespace | 301 } // namespace |
| 300 } // namespace content | 302 } // namespace content |
| OLD | NEW |