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 17 matching lines...) Expand all Loading... |
28 rendering_(false), | 28 rendering_(false), |
29 needs_put_current_frame_(false) { | 29 needs_put_current_frame_(false) { |
30 // |provider_| may be null if destructed before the layer. | 30 // |provider_| may be null if destructed before the layer. |
31 if (provider_) { | 31 if (provider_) { |
32 // This only happens during a commit on the compositor thread while the main | 32 // This only happens during a commit on the compositor thread while the main |
33 // thread is blocked. That makes this a thread-safe call to set the video | 33 // thread is blocked. That makes this a thread-safe call to set the video |
34 // frame provider client that does not require a lock. The same is true of | 34 // frame provider client that does not require a lock. The same is true of |
35 // the call to Stop(). | 35 // the call to Stop(). |
36 provider_->SetVideoFrameProviderClient(this); | 36 provider_->SetVideoFrameProviderClient(this); |
37 } | 37 } |
| 38 |
| 39 // This matrix is the default transformation for stream textures, and flips |
| 40 // on the Y axis. |
| 41 stream_texture_matrix_ = gfx::Transform( |
| 42 1.0, 0.0, 0.0, 0.0, |
| 43 0.0, -1.0, 0.0, 1.0, |
| 44 0.0, 0.0, 1.0, 0.0, |
| 45 0.0, 0.0, 0.0, 1.0); |
38 } | 46 } |
39 | 47 |
40 VideoFrameProviderClientImpl::~VideoFrameProviderClientImpl() { | 48 VideoFrameProviderClientImpl::~VideoFrameProviderClientImpl() { |
41 DCHECK(thread_checker_.CalledOnValidThread()); | 49 DCHECK(thread_checker_.CalledOnValidThread()); |
42 DCHECK(stopped_); | 50 DCHECK(stopped_); |
43 } | 51 } |
44 | 52 |
45 VideoLayerImpl* VideoFrameProviderClientImpl::ActiveVideoLayer() const { | 53 VideoLayerImpl* VideoFrameProviderClientImpl::ActiveVideoLayer() const { |
46 DCHECK(thread_checker_.CalledOnValidThread()); | 54 DCHECK(thread_checker_.CalledOnValidThread()); |
47 return active_video_layer_; | 55 return active_video_layer_; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 DCHECK(thread_checker_.CalledOnValidThread()); | 101 DCHECK(thread_checker_.CalledOnValidThread()); |
94 provider_lock_.AssertAcquired(); | 102 provider_lock_.AssertAcquired(); |
95 provider_lock_.Release(); | 103 provider_lock_.Release(); |
96 } | 104 } |
97 | 105 |
98 bool VideoFrameProviderClientImpl::HasCurrentFrame() { | 106 bool VideoFrameProviderClientImpl::HasCurrentFrame() { |
99 base::AutoLock locker(provider_lock_); | 107 base::AutoLock locker(provider_lock_); |
100 return provider_ && provider_->HasCurrentFrame(); | 108 return provider_ && provider_->HasCurrentFrame(); |
101 } | 109 } |
102 | 110 |
| 111 const gfx::Transform& VideoFrameProviderClientImpl::StreamTextureMatrix() |
| 112 const { |
| 113 DCHECK(thread_checker_.CalledOnValidThread()); |
| 114 return stream_texture_matrix_; |
| 115 } |
| 116 |
103 void VideoFrameProviderClientImpl::StopUsingProvider() { | 117 void VideoFrameProviderClientImpl::StopUsingProvider() { |
104 { | 118 { |
105 // Block the provider from shutting down until this client is done | 119 // Block the provider from shutting down until this client is done |
106 // using the frame. | 120 // using the frame. |
107 base::AutoLock locker(provider_lock_); | 121 base::AutoLock locker(provider_lock_); |
108 provider_ = nullptr; | 122 provider_ = nullptr; |
109 } | 123 } |
110 if (rendering_) | 124 if (rendering_) |
111 StopRendering(); | 125 StopRendering(); |
112 } | 126 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 DCHECK(thread_checker_.CalledOnValidThread()); | 181 DCHECK(thread_checker_.CalledOnValidThread()); |
168 { | 182 { |
169 base::AutoLock locker(provider_lock_); | 183 base::AutoLock locker(provider_lock_); |
170 if (provider_ && needs_put_current_frame_) | 184 if (provider_ && needs_put_current_frame_) |
171 provider_->PutCurrentFrame(); | 185 provider_->PutCurrentFrame(); |
172 } | 186 } |
173 needs_put_current_frame_ = false; | 187 needs_put_current_frame_ = false; |
174 } | 188 } |
175 | 189 |
176 } // namespace cc | 190 } // namespace cc |
OLD | NEW |