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) { | |
83 DCHECK(thread_checker_.CalledOnValidThread()); | 82 DCHECK(thread_checker_.CalledOnValidThread()); |
84 provider_lock_.AssertAcquired(); | 83 provider_lock_.AssertAcquired(); |
85 provider_->PutCurrentFrame(frame); | 84 provider_->PutCurrentFrame(); |
86 } | 85 } |
87 | 86 |
88 void VideoFrameProviderClientImpl::ReleaseLock() { | 87 void VideoFrameProviderClientImpl::ReleaseLock() { |
89 DCHECK(thread_checker_.CalledOnValidThread()); | 88 DCHECK(thread_checker_.CalledOnValidThread()); |
90 provider_lock_.AssertAcquired(); | 89 provider_lock_.AssertAcquired(); |
91 provider_lock_.Release(); | 90 provider_lock_.Release(); |
92 } | 91 } |
93 | 92 |
94 const gfx::Transform& VideoFrameProviderClientImpl::StreamTextureMatrix() | 93 const gfx::Transform& VideoFrameProviderClientImpl::StreamTextureMatrix() |
95 const { | 94 const { |
96 DCHECK(thread_checker_.CalledOnValidThread()); | 95 DCHECK(thread_checker_.CalledOnValidThread()); |
97 return stream_texture_matrix_; | 96 return stream_texture_matrix_; |
98 } | 97 } |
99 | 98 |
100 void VideoFrameProviderClientImpl::StopUsingProvider() { | 99 void VideoFrameProviderClientImpl::StopUsingProvider() { |
101 // Block the provider from shutting down until this client is done | 100 // Block the provider from shutting down until this client is done |
102 // using the frame. | 101 // using the frame. |
103 base::AutoLock locker(provider_lock_); | 102 base::AutoLock locker(provider_lock_); |
104 provider_ = nullptr; | 103 provider_ = nullptr; |
105 } | 104 } |
106 | 105 |
| 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 |
107 void VideoFrameProviderClientImpl::DidReceiveFrame() { | 116 void VideoFrameProviderClientImpl::DidReceiveFrame() { |
108 TRACE_EVENT1("cc", | 117 TRACE_EVENT1("cc", |
109 "VideoFrameProviderClientImpl::DidReceiveFrame", | 118 "VideoFrameProviderClientImpl::DidReceiveFrame", |
110 "active_video_layer", | 119 "active_video_layer", |
111 !!active_video_layer_); | 120 !!active_video_layer_); |
112 DCHECK(thread_checker_.CalledOnValidThread()); | 121 DCHECK(thread_checker_.CalledOnValidThread()); |
113 if (active_video_layer_) | 122 if (active_video_layer_) |
114 active_video_layer_->SetNeedsRedraw(); | 123 active_video_layer_->SetNeedsRedraw(); |
115 } | 124 } |
116 | 125 |
117 void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) { | 126 void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) { |
118 DCHECK(thread_checker_.CalledOnValidThread()); | 127 DCHECK(thread_checker_.CalledOnValidThread()); |
119 stream_texture_matrix_ = gfx::Transform( | 128 stream_texture_matrix_ = gfx::Transform( |
120 matrix[0], matrix[4], matrix[8], matrix[12], | 129 matrix[0], matrix[4], matrix[8], matrix[12], |
121 matrix[1], matrix[5], matrix[9], matrix[13], | 130 matrix[1], matrix[5], matrix[9], matrix[13], |
122 matrix[2], matrix[6], matrix[10], matrix[14], | 131 matrix[2], matrix[6], matrix[10], matrix[14], |
123 matrix[3], matrix[7], matrix[11], matrix[15]); | 132 matrix[3], matrix[7], matrix[11], matrix[15]); |
124 if (active_video_layer_) | 133 if (active_video_layer_) |
125 active_video_layer_->SetNeedsRedraw(); | 134 active_video_layer_->SetNeedsRedraw(); |
126 } | 135 } |
127 | 136 |
128 } // namespace cc | 137 } // namespace cc |
OLD | NEW |