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" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 void VideoFrameProviderClientImpl::SetActiveVideoLayer( | 50 void VideoFrameProviderClientImpl::SetActiveVideoLayer( |
51 VideoLayerImpl* video_layer) { | 51 VideoLayerImpl* video_layer) { |
52 DCHECK(thread_checker_.CalledOnValidThread()); | 52 DCHECK(thread_checker_.CalledOnValidThread()); |
53 DCHECK(video_layer); | 53 DCHECK(video_layer); |
54 active_video_layer_ = video_layer; | 54 active_video_layer_ = video_layer; |
55 } | 55 } |
56 | 56 |
57 void VideoFrameProviderClientImpl::Stop() { | 57 void VideoFrameProviderClientImpl::Stop() { |
58 DCHECK(thread_checker_.CalledOnValidThread()); | 58 DCHECK(thread_checker_.CalledOnValidThread()); |
| 59 active_video_layer_ = nullptr; |
59 // It's called when the main thread is blocked, so lock isn't needed. | 60 // It's called when the main thread is blocked, so lock isn't needed. |
60 if (provider_) { | 61 if (provider_) { |
61 provider_->SetVideoFrameProviderClient(nullptr); | 62 provider_->SetVideoFrameProviderClient(nullptr); |
62 provider_ = nullptr; | 63 provider_ = nullptr; |
63 } | 64 } |
64 if (rendering_) | 65 if (rendering_) |
65 StopRendering(); | 66 StopRendering(); |
66 active_video_layer_ = nullptr; | |
67 stopped_ = true; | 67 stopped_ = true; |
68 } | 68 } |
69 | 69 |
70 bool VideoFrameProviderClientImpl::Stopped() const { | 70 bool VideoFrameProviderClientImpl::Stopped() const { |
71 DCHECK(thread_checker_.CalledOnValidThread()); | 71 DCHECK(thread_checker_.CalledOnValidThread()); |
72 return stopped_; | 72 return stopped_; |
73 } | 73 } |
74 | 74 |
75 scoped_refptr<media::VideoFrame> | 75 scoped_refptr<media::VideoFrame> |
76 VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() { | 76 VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 client_->AddVideoFrameController(this); | 120 client_->AddVideoFrameController(this); |
121 } | 121 } |
122 | 122 |
123 void VideoFrameProviderClientImpl::StopRendering() { | 123 void VideoFrameProviderClientImpl::StopRendering() { |
124 DCHECK(thread_checker_.CalledOnValidThread()); | 124 DCHECK(thread_checker_.CalledOnValidThread()); |
125 TRACE_EVENT0("cc", "VideoFrameProviderClientImpl::StopRendering"); | 125 TRACE_EVENT0("cc", "VideoFrameProviderClientImpl::StopRendering"); |
126 DCHECK(rendering_); | 126 DCHECK(rendering_); |
127 DCHECK(!stopped_); | 127 DCHECK(!stopped_); |
128 client_->RemoveVideoFrameController(this); | 128 client_->RemoveVideoFrameController(this); |
129 rendering_ = false; | 129 rendering_ = false; |
| 130 if (active_video_layer_) |
| 131 active_video_layer_->SetNeedsRedraw(); |
130 } | 132 } |
131 | 133 |
132 void VideoFrameProviderClientImpl::DidReceiveFrame() { | 134 void VideoFrameProviderClientImpl::DidReceiveFrame() { |
133 TRACE_EVENT1("cc", | 135 TRACE_EVENT1("cc", |
134 "VideoFrameProviderClientImpl::DidReceiveFrame", | 136 "VideoFrameProviderClientImpl::DidReceiveFrame", |
135 "active_video_layer", | 137 "active_video_layer", |
136 !!active_video_layer_); | 138 !!active_video_layer_); |
137 DCHECK(thread_checker_.CalledOnValidThread()); | 139 DCHECK(thread_checker_.CalledOnValidThread()); |
138 needs_put_current_frame_ = true; | 140 needs_put_current_frame_ = true; |
139 if (active_video_layer_) | 141 if (active_video_layer_) |
(...skipping 27 matching lines...) Expand all Loading... |
167 DCHECK(thread_checker_.CalledOnValidThread()); | 169 DCHECK(thread_checker_.CalledOnValidThread()); |
168 { | 170 { |
169 base::AutoLock locker(provider_lock_); | 171 base::AutoLock locker(provider_lock_); |
170 if (provider_ && needs_put_current_frame_) | 172 if (provider_ && needs_put_current_frame_) |
171 provider_->PutCurrentFrame(); | 173 provider_->PutCurrentFrame(); |
172 } | 174 } |
173 needs_put_current_frame_ = false; | 175 needs_put_current_frame_ = false; |
174 } | 176 } |
175 | 177 |
176 } // namespace cc | 178 } // namespace cc |
OLD | NEW |