| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/simple_test_tick_clock.h" | 9 #include "base/test/simple_test_tick_clock.h" |
| 10 #include "cc/layers/video_frame_provider.h" | 10 #include "cc/layers/video_frame_provider.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 base::Bind(&VideoFrameCompositorTest::NaturalSizeChanged, | 34 base::Bind(&VideoFrameCompositorTest::NaturalSizeChanged, |
| 35 base::Unretained(this)), | 35 base::Unretained(this)), |
| 36 base::Bind(&VideoFrameCompositorTest::OpacityChanged, | 36 base::Bind(&VideoFrameCompositorTest::OpacityChanged, |
| 37 base::Unretained(this)))), | 37 base::Unretained(this)))), |
| 38 did_receive_frame_count_(0), | 38 did_receive_frame_count_(0), |
| 39 natural_size_changed_count_(0), | 39 natural_size_changed_count_(0), |
| 40 opacity_changed_count_(0), | 40 opacity_changed_count_(0), |
| 41 opaque_(false) { | 41 opaque_(false) { |
| 42 compositor_->SetVideoFrameProviderClient(this); | 42 compositor_->SetVideoFrameProviderClient(this); |
| 43 compositor_->set_tick_clock_for_testing( | 43 compositor_->set_tick_clock_for_testing( |
| 44 scoped_ptr<base::TickClock>(tick_clock_)); | 44 std::unique_ptr<base::TickClock>(tick_clock_)); |
| 45 // Disable background rendering by default. | 45 // Disable background rendering by default. |
| 46 compositor_->set_background_rendering_for_testing(false); | 46 compositor_->set_background_rendering_for_testing(false); |
| 47 } | 47 } |
| 48 | 48 |
| 49 ~VideoFrameCompositorTest() override { | 49 ~VideoFrameCompositorTest() override { |
| 50 compositor_->SetVideoFrameProviderClient(nullptr); | 50 compositor_->SetVideoFrameProviderClient(nullptr); |
| 51 } | 51 } |
| 52 | 52 |
| 53 scoped_refptr<VideoFrame> CreateOpaqueFrame() { | 53 scoped_refptr<VideoFrame> CreateOpaqueFrame() { |
| 54 gfx::Size size(8, 8); | 54 gfx::Size size(8, 8); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 message_loop.RunUntilIdle(); | 107 message_loop.RunUntilIdle(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void RenderFrame() { | 110 void RenderFrame() { |
| 111 compositor()->GetCurrentFrame(); | 111 compositor()->GetCurrentFrame(); |
| 112 compositor()->PutCurrentFrame(); | 112 compositor()->PutCurrentFrame(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 base::MessageLoop message_loop; | 115 base::MessageLoop message_loop; |
| 116 base::SimpleTestTickClock* tick_clock_; // Owned by |compositor_| | 116 base::SimpleTestTickClock* tick_clock_; // Owned by |compositor_| |
| 117 scoped_ptr<VideoFrameCompositor> compositor_; | 117 std::unique_ptr<VideoFrameCompositor> compositor_; |
| 118 | 118 |
| 119 int did_receive_frame_count_; | 119 int did_receive_frame_count_; |
| 120 int natural_size_changed_count_; | 120 int natural_size_changed_count_; |
| 121 gfx::Size natural_size_; | 121 gfx::Size natural_size_; |
| 122 int opacity_changed_count_; | 122 int opacity_changed_count_; |
| 123 bool opaque_; | 123 bool opaque_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositorTest); | 125 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositorTest); |
| 126 }; | 126 }; |
| 127 | 127 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 425 |
| 426 // Advancing the tick clock should allow a new frame to be requested. | 426 // Advancing the tick clock should allow a new frame to be requested. |
| 427 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); | 427 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); |
| 428 ASSERT_EQ(opaque_frame_2, compositor()->GetCurrentFrameAndUpdateIfStale()); | 428 ASSERT_EQ(opaque_frame_2, compositor()->GetCurrentFrameAndUpdateIfStale()); |
| 429 | 429 |
| 430 // Background rendering should tick another render callback. | 430 // Background rendering should tick another render callback. |
| 431 StopVideoRendererSink(false); | 431 StopVideoRendererSink(false); |
| 432 } | 432 } |
| 433 | 433 |
| 434 } // namespace media | 434 } // namespace media |
| OLD | NEW |