OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "cc/video_frame_provider_client_impl.h" | |
6 | |
7 #include "cc/math_util.h" | |
8 #include "cc/video_layer_impl.h" | |
9 | |
10 namespace cc { | |
11 | |
12 // static | |
13 scoped_refptr<VideoFrameProviderClientImpl> | |
14 VideoFrameProviderClientImpl::Create( | |
15 VideoFrameProvider* provider) { | |
16 return make_scoped_refptr( | |
17 new VideoFrameProviderClientImpl(provider)); | |
18 } | |
19 | |
20 VideoFrameProviderClientImpl::~VideoFrameProviderClientImpl() {} | |
21 | |
22 VideoFrameProviderClientImpl::VideoFrameProviderClientImpl( | |
23 VideoFrameProvider* provider) | |
24 : provider_(provider) { | |
25 // This only happens during a commit on the compositor thread while the main | |
enne (OOO)
2013/01/17 23:34:55
Can we assert that the main thread is blocked here
jamesr
2013/01/18 01:16:42
Not without plumbing a pointer to the cc::Proxy do
| |
26 // thread is blocked. That makes this a thread-safe call to set the video | |
27 // frame provider client that does not require a lock. The same is true of | |
28 // the call to Stop(). | |
29 provider_->SetVideoFrameProviderClient(this); | |
30 | |
31 // This matrix is the default transformation for stream textures, and flips | |
32 // on the Y axis. | |
33 stream_texture_matrix_ = gfx::Transform( | |
34 1.0, 0.0, 0.0, 0.0, | |
35 0.0, -1.0, 0.0, 1.0, | |
36 0.0, 0.0, 1.0, 0.0, | |
37 0.0, 0.0, 0.0, 1.0); | |
38 } | |
39 | |
40 void VideoFrameProviderClientImpl::Stop() { | |
41 if (!provider_) | |
42 return; | |
43 provider_->SetVideoFrameProviderClient(0); | |
danakj
2013/01/18 00:06:13
nit: s/0/NULL/. also on next line.
jamesr
2013/01/18 01:16:42
Done.
| |
44 provider_ = 0; | |
45 } | |
46 | |
47 media::VideoFrame* VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() { | |
48 provider_lock_.Acquire(); // Balanced by call to ReleaseLock(). | |
49 if (!provider_) | |
50 return NULL; | |
51 | |
52 return provider_->GetCurrentFrame(); | |
53 } | |
54 | |
55 void VideoFrameProviderClientImpl::PutCurrentFrame(media::VideoFrame* frame) { | |
56 provider_lock_.AssertAcquired(); | |
57 provider_->PutCurrentFrame(frame); | |
58 } | |
59 | |
60 void VideoFrameProviderClientImpl::ReleaseLock() { | |
61 provider_lock_.AssertAcquired(); | |
62 provider_lock_.Release(); | |
63 } | |
64 | |
65 void VideoFrameProviderClientImpl::StopUsingProvider() { | |
66 // Block the provider from shutting down until this client is done | |
67 // using the frame. | |
68 base::AutoLock locker(provider_lock_); | |
69 provider_ = 0; | |
70 } | |
71 | |
72 void VideoFrameProviderClientImpl::DidReceiveFrame() { | |
73 if (active_video_layer_) | |
74 active_video_layer_->setNeedsRedraw(); | |
75 } | |
76 | |
77 void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) { | |
enne (OOO)
2013/01/17 23:34:55
What was the issue with the intermittently incorre
| |
78 stream_texture_matrix_ = gfx::Transform( | |
79 matrix[0], matrix[4], matrix[8], matrix[12], | |
80 matrix[1], matrix[5], matrix[9], matrix[13], | |
81 matrix[2], matrix[6], matrix[10], matrix[14], | |
82 matrix[3], matrix[7], matrix[11], matrix[15]); | |
83 if (active_video_layer_) | |
84 active_video_layer_->setNeedsRedraw(); | |
85 } | |
86 | |
87 } // namespace cc | |
OLD | NEW |