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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 scoped_refptr<media::VideoFrame> | 71 scoped_refptr<media::VideoFrame> |
72 VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() { | 72 VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() { |
73 DCHECK(thread_checker_.CalledOnValidThread()); | 73 DCHECK(thread_checker_.CalledOnValidThread()); |
74 provider_lock_.Acquire(); // Balanced by call to ReleaseLock(). | 74 provider_lock_.Acquire(); // Balanced by call to ReleaseLock(). |
75 if (!provider_) | 75 if (!provider_) |
76 return nullptr; | 76 return nullptr; |
77 | 77 |
78 return provider_->GetCurrentFrame(); | 78 return provider_->GetCurrentFrame(); |
79 } | 79 } |
80 | 80 |
81 void VideoFrameProviderClientImpl::PutCurrentFrame() { | 81 void VideoFrameProviderClientImpl::PutCurrentFrame( |
| 82 const scoped_refptr<media::VideoFrame>& frame) { |
82 DCHECK(thread_checker_.CalledOnValidThread()); | 83 DCHECK(thread_checker_.CalledOnValidThread()); |
83 provider_lock_.AssertAcquired(); | 84 provider_lock_.AssertAcquired(); |
84 provider_->PutCurrentFrame(); | 85 provider_->PutCurrentFrame(frame); |
85 } | 86 } |
86 | 87 |
87 void VideoFrameProviderClientImpl::ReleaseLock() { | 88 void VideoFrameProviderClientImpl::ReleaseLock() { |
88 DCHECK(thread_checker_.CalledOnValidThread()); | 89 DCHECK(thread_checker_.CalledOnValidThread()); |
89 provider_lock_.AssertAcquired(); | 90 provider_lock_.AssertAcquired(); |
90 provider_lock_.Release(); | 91 provider_lock_.Release(); |
91 } | 92 } |
92 | 93 |
93 const gfx::Transform& VideoFrameProviderClientImpl::StreamTextureMatrix() | 94 const gfx::Transform& VideoFrameProviderClientImpl::StreamTextureMatrix() |
94 const { | 95 const { |
95 DCHECK(thread_checker_.CalledOnValidThread()); | 96 DCHECK(thread_checker_.CalledOnValidThread()); |
96 return stream_texture_matrix_; | 97 return stream_texture_matrix_; |
97 } | 98 } |
98 | 99 |
99 void VideoFrameProviderClientImpl::StopUsingProvider() { | 100 void VideoFrameProviderClientImpl::StopUsingProvider() { |
100 // Block the provider from shutting down until this client is done | 101 // Block the provider from shutting down until this client is done |
101 // using the frame. | 102 // using the frame. |
102 base::AutoLock locker(provider_lock_); | 103 base::AutoLock locker(provider_lock_); |
103 provider_ = nullptr; | 104 provider_ = nullptr; |
104 } | 105 } |
105 | 106 |
106 void VideoFrameProviderClientImpl::StartRendering() { | |
107 // TODO(dalecurtis, sunnyps): Hook this method up to control when to start | |
108 // observing vsync intervals. http://crbug.com/336733 | |
109 } | |
110 | |
111 void VideoFrameProviderClientImpl::StopRendering() { | |
112 // TODO(dalecurtis, sunnyps): Hook this method up to control when to stop | |
113 // observing vsync intervals. http://crbug.com/336733 | |
114 } | |
115 | |
116 void VideoFrameProviderClientImpl::DidReceiveFrame() { | 107 void VideoFrameProviderClientImpl::DidReceiveFrame() { |
117 TRACE_EVENT1("cc", | 108 TRACE_EVENT1("cc", |
118 "VideoFrameProviderClientImpl::DidReceiveFrame", | 109 "VideoFrameProviderClientImpl::DidReceiveFrame", |
119 "active_video_layer", | 110 "active_video_layer", |
120 !!active_video_layer_); | 111 !!active_video_layer_); |
121 DCHECK(thread_checker_.CalledOnValidThread()); | 112 DCHECK(thread_checker_.CalledOnValidThread()); |
122 if (active_video_layer_) | 113 if (active_video_layer_) |
123 active_video_layer_->SetNeedsRedraw(); | 114 active_video_layer_->SetNeedsRedraw(); |
124 } | 115 } |
125 | 116 |
126 void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) { | 117 void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) { |
127 DCHECK(thread_checker_.CalledOnValidThread()); | 118 DCHECK(thread_checker_.CalledOnValidThread()); |
128 stream_texture_matrix_ = gfx::Transform( | 119 stream_texture_matrix_ = gfx::Transform( |
129 matrix[0], matrix[4], matrix[8], matrix[12], | 120 matrix[0], matrix[4], matrix[8], matrix[12], |
130 matrix[1], matrix[5], matrix[9], matrix[13], | 121 matrix[1], matrix[5], matrix[9], matrix[13], |
131 matrix[2], matrix[6], matrix[10], matrix[14], | 122 matrix[2], matrix[6], matrix[10], matrix[14], |
132 matrix[3], matrix[7], matrix[11], matrix[15]); | 123 matrix[3], matrix[7], matrix[11], matrix[15]); |
133 if (active_video_layer_) | 124 if (active_video_layer_) |
134 active_video_layer_->SetNeedsRedraw(); | 125 active_video_layer_->SetNeedsRedraw(); |
135 } | 126 } |
136 | 127 |
137 } // namespace cc | 128 } // namespace cc |
OLD | NEW |