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); | |
46 } | 38 } |
47 | 39 |
48 VideoFrameProviderClientImpl::~VideoFrameProviderClientImpl() { | 40 VideoFrameProviderClientImpl::~VideoFrameProviderClientImpl() { |
49 DCHECK(thread_checker_.CalledOnValidThread()); | 41 DCHECK(thread_checker_.CalledOnValidThread()); |
50 DCHECK(stopped_); | 42 DCHECK(stopped_); |
51 } | 43 } |
52 | 44 |
53 VideoLayerImpl* VideoFrameProviderClientImpl::ActiveVideoLayer() const { | 45 VideoLayerImpl* VideoFrameProviderClientImpl::ActiveVideoLayer() const { |
54 DCHECK(thread_checker_.CalledOnValidThread()); | 46 DCHECK(thread_checker_.CalledOnValidThread()); |
55 return active_video_layer_; | 47 return active_video_layer_; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 DCHECK(thread_checker_.CalledOnValidThread()); | 93 DCHECK(thread_checker_.CalledOnValidThread()); |
102 provider_lock_.AssertAcquired(); | 94 provider_lock_.AssertAcquired(); |
103 provider_lock_.Release(); | 95 provider_lock_.Release(); |
104 } | 96 } |
105 | 97 |
106 bool VideoFrameProviderClientImpl::HasCurrentFrame() { | 98 bool VideoFrameProviderClientImpl::HasCurrentFrame() { |
107 base::AutoLock locker(provider_lock_); | 99 base::AutoLock locker(provider_lock_); |
108 return provider_ && provider_->HasCurrentFrame(); | 100 return provider_ && provider_->HasCurrentFrame(); |
109 } | 101 } |
110 | 102 |
111 const gfx::Transform& VideoFrameProviderClientImpl::StreamTextureMatrix() | |
112 const { | |
113 DCHECK(thread_checker_.CalledOnValidThread()); | |
114 return stream_texture_matrix_; | |
115 } | |
116 | |
117 void VideoFrameProviderClientImpl::StopUsingProvider() { | 103 void VideoFrameProviderClientImpl::StopUsingProvider() { |
118 { | 104 { |
119 // Block the provider from shutting down until this client is done | 105 // Block the provider from shutting down until this client is done |
120 // using the frame. | 106 // using the frame. |
121 base::AutoLock locker(provider_lock_); | 107 base::AutoLock locker(provider_lock_); |
122 provider_ = nullptr; | 108 provider_ = nullptr; |
123 } | 109 } |
124 if (rendering_) | 110 if (rendering_) |
125 StopRendering(); | 111 StopRendering(); |
126 } | 112 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 DCHECK(thread_checker_.CalledOnValidThread()); | 167 DCHECK(thread_checker_.CalledOnValidThread()); |
182 { | 168 { |
183 base::AutoLock locker(provider_lock_); | 169 base::AutoLock locker(provider_lock_); |
184 if (provider_ && needs_put_current_frame_) | 170 if (provider_ && needs_put_current_frame_) |
185 provider_->PutCurrentFrame(); | 171 provider_->PutCurrentFrame(); |
186 } | 172 } |
187 needs_put_current_frame_ = false; | 173 needs_put_current_frame_ = false; |
188 } | 174 } |
189 | 175 |
190 } // namespace cc | 176 } // namespace cc |
OLD | NEW |