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 14 matching lines...) Expand all Loading... |
25 client_(client), | 25 client_(client), |
26 active_video_layer_(nullptr), | 26 active_video_layer_(nullptr), |
27 stopped_(false), | 27 stopped_(false), |
28 rendering_(false), | 28 rendering_(false), |
29 needs_put_current_frame_(false) { | 29 needs_put_current_frame_(false) { |
30 // This only happens during a commit on the compositor thread while the main | 30 // This only happens during a commit on the compositor thread while the main |
31 // thread is blocked. That makes this a thread-safe call to set the video | 31 // thread is blocked. That makes this a thread-safe call to set the video |
32 // frame provider client that does not require a lock. The same is true of | 32 // frame provider client that does not require a lock. The same is true of |
33 // the call to Stop(). | 33 // the call to Stop(). |
34 provider_->SetVideoFrameProviderClient(this); | 34 provider_->SetVideoFrameProviderClient(this); |
| 35 |
| 36 // This matrix is the default transformation for stream textures, and flips |
| 37 // on the Y axis. |
| 38 stream_texture_matrix_ = gfx::Transform( |
| 39 1.0, 0.0, 0.0, 0.0, |
| 40 0.0, -1.0, 0.0, 1.0, |
| 41 0.0, 0.0, 1.0, 0.0, |
| 42 0.0, 0.0, 0.0, 1.0); |
35 } | 43 } |
36 | 44 |
37 VideoFrameProviderClientImpl::~VideoFrameProviderClientImpl() { | 45 VideoFrameProviderClientImpl::~VideoFrameProviderClientImpl() { |
38 DCHECK(thread_checker_.CalledOnValidThread()); | 46 DCHECK(thread_checker_.CalledOnValidThread()); |
39 DCHECK(stopped_); | 47 DCHECK(stopped_); |
40 } | 48 } |
41 | 49 |
42 VideoLayerImpl* VideoFrameProviderClientImpl::ActiveVideoLayer() const { | 50 VideoLayerImpl* VideoFrameProviderClientImpl::ActiveVideoLayer() const { |
43 DCHECK(thread_checker_.CalledOnValidThread()); | 51 DCHECK(thread_checker_.CalledOnValidThread()); |
44 return active_video_layer_; | 52 return active_video_layer_; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 DCHECK(thread_checker_.CalledOnValidThread()); | 98 DCHECK(thread_checker_.CalledOnValidThread()); |
91 provider_lock_.AssertAcquired(); | 99 provider_lock_.AssertAcquired(); |
92 provider_lock_.Release(); | 100 provider_lock_.Release(); |
93 } | 101 } |
94 | 102 |
95 bool VideoFrameProviderClientImpl::HasCurrentFrame() { | 103 bool VideoFrameProviderClientImpl::HasCurrentFrame() { |
96 base::AutoLock locker(provider_lock_); | 104 base::AutoLock locker(provider_lock_); |
97 return provider_ && provider_->HasCurrentFrame(); | 105 return provider_ && provider_->HasCurrentFrame(); |
98 } | 106 } |
99 | 107 |
| 108 const gfx::Transform& VideoFrameProviderClientImpl::StreamTextureMatrix() |
| 109 const { |
| 110 DCHECK(thread_checker_.CalledOnValidThread()); |
| 111 return stream_texture_matrix_; |
| 112 } |
| 113 |
100 void VideoFrameProviderClientImpl::StopUsingProvider() { | 114 void VideoFrameProviderClientImpl::StopUsingProvider() { |
101 { | 115 { |
102 // Block the provider from shutting down until this client is done | 116 // Block the provider from shutting down until this client is done |
103 // using the frame. | 117 // using the frame. |
104 base::AutoLock locker(provider_lock_); | 118 base::AutoLock locker(provider_lock_); |
105 provider_ = nullptr; | 119 provider_ = nullptr; |
106 } | 120 } |
107 if (rendering_) | 121 if (rendering_) |
108 StopRendering(); | 122 StopRendering(); |
109 } | 123 } |
(...skipping 20 matching lines...) Expand all Loading... |
130 TRACE_EVENT1("cc", | 144 TRACE_EVENT1("cc", |
131 "VideoFrameProviderClientImpl::DidReceiveFrame", | 145 "VideoFrameProviderClientImpl::DidReceiveFrame", |
132 "active_video_layer", | 146 "active_video_layer", |
133 !!active_video_layer_); | 147 !!active_video_layer_); |
134 DCHECK(thread_checker_.CalledOnValidThread()); | 148 DCHECK(thread_checker_.CalledOnValidThread()); |
135 needs_put_current_frame_ = true; | 149 needs_put_current_frame_ = true; |
136 if (active_video_layer_) | 150 if (active_video_layer_) |
137 active_video_layer_->SetNeedsRedraw(); | 151 active_video_layer_->SetNeedsRedraw(); |
138 } | 152 } |
139 | 153 |
| 154 void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) { |
| 155 DCHECK(thread_checker_.CalledOnValidThread()); |
| 156 stream_texture_matrix_ = gfx::Transform( |
| 157 matrix[0], matrix[4], matrix[8], matrix[12], |
| 158 matrix[1], matrix[5], matrix[9], matrix[13], |
| 159 matrix[2], matrix[6], matrix[10], matrix[14], |
| 160 matrix[3], matrix[7], matrix[11], matrix[15]); |
| 161 if (active_video_layer_) |
| 162 active_video_layer_->SetNeedsRedraw(); |
| 163 } |
| 164 |
140 void VideoFrameProviderClientImpl::OnBeginFrame(const BeginFrameArgs& args) { | 165 void VideoFrameProviderClientImpl::OnBeginFrame(const BeginFrameArgs& args) { |
141 DCHECK(thread_checker_.CalledOnValidThread()); | 166 DCHECK(thread_checker_.CalledOnValidThread()); |
142 DCHECK(rendering_); | 167 DCHECK(rendering_); |
143 DCHECK(!stopped_); | 168 DCHECK(!stopped_); |
144 | 169 |
145 TRACE_EVENT0("cc", "VideoFrameProviderClientImpl::OnBeginFrame"); | 170 TRACE_EVENT0("cc", "VideoFrameProviderClientImpl::OnBeginFrame"); |
146 { | 171 { |
147 base::AutoLock locker(provider_lock_); | 172 base::AutoLock locker(provider_lock_); |
148 | 173 |
149 // We use frame_time + interval here because that is the estimated time at | 174 // We use frame_time + interval here because that is the estimated time at |
(...skipping 14 matching lines...) Expand all Loading... |
164 DCHECK(thread_checker_.CalledOnValidThread()); | 189 DCHECK(thread_checker_.CalledOnValidThread()); |
165 { | 190 { |
166 base::AutoLock locker(provider_lock_); | 191 base::AutoLock locker(provider_lock_); |
167 if (provider_ && needs_put_current_frame_) | 192 if (provider_ && needs_put_current_frame_) |
168 provider_->PutCurrentFrame(); | 193 provider_->PutCurrentFrame(); |
169 } | 194 } |
170 needs_put_current_frame_ = false; | 195 needs_put_current_frame_ = false; |
171 } | 196 } |
172 | 197 |
173 } // namespace cc | 198 } // namespace cc |
OLD | NEW |