| 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 "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
| 8 #include "cc/layers/video_layer_impl.h" | 8 #include "cc/layers/video_layer_impl.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 0.0, 0.0, 0.0, 1.0); | 37 0.0, 0.0, 0.0, 1.0); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void VideoFrameProviderClientImpl::Stop() { | 40 void VideoFrameProviderClientImpl::Stop() { |
| 41 if (!provider_) | 41 if (!provider_) |
| 42 return; | 42 return; |
| 43 provider_->SetVideoFrameProviderClient(NULL); | 43 provider_->SetVideoFrameProviderClient(NULL); |
| 44 provider_ = NULL; | 44 provider_ = NULL; |
| 45 } | 45 } |
| 46 | 46 |
| 47 media::VideoFrame* VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() { | 47 scoped_refptr<media::VideoFrame> |
| 48 VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() { |
| 48 provider_lock_.Acquire(); // Balanced by call to ReleaseLock(). | 49 provider_lock_.Acquire(); // Balanced by call to ReleaseLock(). |
| 49 if (!provider_) | 50 if (!provider_) |
| 50 return NULL; | 51 return NULL; |
| 51 | 52 |
| 52 return provider_->GetCurrentFrame(); | 53 return provider_->GetCurrentFrame(); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void VideoFrameProviderClientImpl::PutCurrentFrame(media::VideoFrame* frame) { | 56 void VideoFrameProviderClientImpl::PutCurrentFrame( |
| 57 const scoped_refptr<media::VideoFrame>& frame) { |
| 56 provider_lock_.AssertAcquired(); | 58 provider_lock_.AssertAcquired(); |
| 57 provider_->PutCurrentFrame(frame); | 59 provider_->PutCurrentFrame(frame); |
| 58 } | 60 } |
| 59 | 61 |
| 60 void VideoFrameProviderClientImpl::ReleaseLock() { | 62 void VideoFrameProviderClientImpl::ReleaseLock() { |
| 61 provider_lock_.AssertAcquired(); | 63 provider_lock_.AssertAcquired(); |
| 62 provider_lock_.Release(); | 64 provider_lock_.Release(); |
| 63 } | 65 } |
| 64 | 66 |
| 65 void VideoFrameProviderClientImpl::StopUsingProvider() { | 67 void VideoFrameProviderClientImpl::StopUsingProvider() { |
| 66 // Block the provider from shutting down until this client is done | 68 // Block the provider from shutting down until this client is done |
| 67 // using the frame. | 69 // using the frame. |
| 68 base::AutoLock locker(provider_lock_); | 70 base::AutoLock locker(provider_lock_); |
| 69 provider_ = 0; | 71 provider_ = NULL; |
| 70 } | 72 } |
| 71 | 73 |
| 72 void VideoFrameProviderClientImpl::DidReceiveFrame() { | 74 void VideoFrameProviderClientImpl::DidReceiveFrame() { |
| 73 if (active_video_layer_) | 75 if (active_video_layer_) |
| 74 active_video_layer_->SetNeedsRedraw(); | 76 active_video_layer_->SetNeedsRedraw(); |
| 75 } | 77 } |
| 76 | 78 |
| 77 void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) { | 79 void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) { |
| 78 stream_texture_matrix_ = gfx::Transform( | 80 stream_texture_matrix_ = gfx::Transform( |
| 79 matrix[0], matrix[4], matrix[8], matrix[12], | 81 matrix[0], matrix[4], matrix[8], matrix[12], |
| 80 matrix[1], matrix[5], matrix[9], matrix[13], | 82 matrix[1], matrix[5], matrix[9], matrix[13], |
| 81 matrix[2], matrix[6], matrix[10], matrix[14], | 83 matrix[2], matrix[6], matrix[10], matrix[14], |
| 82 matrix[3], matrix[7], matrix[11], matrix[15]); | 84 matrix[3], matrix[7], matrix[11], matrix[15]); |
| 83 if (active_video_layer_) | 85 if (active_video_layer_) |
| 84 active_video_layer_->SetNeedsRedraw(); | 86 active_video_layer_->SetNeedsRedraw(); |
| 85 } | 87 } |
| 86 | 88 |
| 87 } // namespace cc | 89 } // namespace cc |
| OLD | NEW |