OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/video_frame_provider_client_impl.h" | 5 #include "cc/layers/video_frame_provider_client_impl.h" |
6 | 6 |
7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/layers/video_layer_impl.h" | 9 #include "cc/layers/video_layer_impl.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 | 13 |
14 // static | 14 // static |
15 scoped_refptr<VideoFrameProviderClientImpl> | 15 scoped_refptr<VideoFrameProviderClientImpl> |
16 VideoFrameProviderClientImpl::Create(VideoFrameProvider* provider) { | 16 VideoFrameProviderClientImpl::Create(VideoFrameProvider* provider, |
17 return make_scoped_refptr(new VideoFrameProviderClientImpl(provider)); | 17 VideoFrameControllerClient* client) { |
| 18 return make_scoped_refptr(new VideoFrameProviderClientImpl(provider, client)); |
18 } | 19 } |
19 | 20 |
20 VideoFrameProviderClientImpl::VideoFrameProviderClientImpl( | 21 VideoFrameProviderClientImpl::VideoFrameProviderClientImpl( |
21 VideoFrameProvider* provider) | 22 VideoFrameProvider* provider, |
22 : provider_(provider), active_video_layer_(nullptr), stopped_(false) { | 23 VideoFrameControllerClient* client) |
| 24 : provider_(provider), |
| 25 client_(client), |
| 26 active_video_layer_(nullptr), |
| 27 stopped_(false) { |
23 // This only happens during a commit on the compositor thread while the main | 28 // This only happens during a commit on the compositor thread while the main |
24 // thread is blocked. That makes this a thread-safe call to set the video | 29 // thread is blocked. That makes this a thread-safe call to set the video |
25 // frame provider client that does not require a lock. The same is true of | 30 // frame provider client that does not require a lock. The same is true of |
26 // the call to Stop(). | 31 // the call to Stop(). |
27 provider_->SetVideoFrameProviderClient(this); | 32 provider_->SetVideoFrameProviderClient(this); |
28 | 33 |
29 // This matrix is the default transformation for stream textures, and flips | 34 // This matrix is the default transformation for stream textures, and flips |
30 // on the Y axis. | 35 // on the Y axis. |
31 stream_texture_matrix_ = gfx::Transform( | 36 stream_texture_matrix_ = gfx::Transform( |
32 1.0, 0.0, 0.0, 0.0, | 37 1.0, 0.0, 0.0, 0.0, |
(...skipping 19 matching lines...) Expand all Loading... |
52 active_video_layer_ = video_layer; | 57 active_video_layer_ = video_layer; |
53 } | 58 } |
54 | 59 |
55 void VideoFrameProviderClientImpl::Stop() { | 60 void VideoFrameProviderClientImpl::Stop() { |
56 DCHECK(thread_checker_.CalledOnValidThread()); | 61 DCHECK(thread_checker_.CalledOnValidThread()); |
57 // It's called when the main thread is blocked, so lock isn't needed. | 62 // It's called when the main thread is blocked, so lock isn't needed. |
58 if (provider_) { | 63 if (provider_) { |
59 provider_->SetVideoFrameProviderClient(nullptr); | 64 provider_->SetVideoFrameProviderClient(nullptr); |
60 provider_ = nullptr; | 65 provider_ = nullptr; |
61 } | 66 } |
| 67 client_->RemoveVideoFrameController(this); |
62 active_video_layer_ = nullptr; | 68 active_video_layer_ = nullptr; |
63 stopped_ = true; | 69 stopped_ = true; |
64 } | 70 } |
65 | 71 |
66 bool VideoFrameProviderClientImpl::Stopped() const { | 72 bool VideoFrameProviderClientImpl::Stopped() const { |
67 DCHECK(thread_checker_.CalledOnValidThread()); | 73 DCHECK(thread_checker_.CalledOnValidThread()); |
68 return stopped_; | 74 return stopped_; |
69 } | 75 } |
70 | 76 |
71 scoped_refptr<media::VideoFrame> | 77 scoped_refptr<media::VideoFrame> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 DCHECK(thread_checker_.CalledOnValidThread()); | 124 DCHECK(thread_checker_.CalledOnValidThread()); |
119 stream_texture_matrix_ = gfx::Transform( | 125 stream_texture_matrix_ = gfx::Transform( |
120 matrix[0], matrix[4], matrix[8], matrix[12], | 126 matrix[0], matrix[4], matrix[8], matrix[12], |
121 matrix[1], matrix[5], matrix[9], matrix[13], | 127 matrix[1], matrix[5], matrix[9], matrix[13], |
122 matrix[2], matrix[6], matrix[10], matrix[14], | 128 matrix[2], matrix[6], matrix[10], matrix[14], |
123 matrix[3], matrix[7], matrix[11], matrix[15]); | 129 matrix[3], matrix[7], matrix[11], matrix[15]); |
124 if (active_video_layer_) | 130 if (active_video_layer_) |
125 active_video_layer_->SetNeedsRedraw(); | 131 active_video_layer_->SetNeedsRedraw(); |
126 } | 132 } |
127 | 133 |
| 134 void VideoFrameProviderClientImpl::OnBeginFrame(const BeginFrameArgs& args) { |
| 135 DCHECK(thread_checker_.CalledOnValidThread()); |
| 136 NOTIMPLEMENTED(); |
| 137 } |
| 138 |
128 } // namespace cc | 139 } // namespace cc |
OLD | NEW |