Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / cc / layers / video_frame_provider_client_impl.h
blob2688ad25d8cb8332986348274a451d3cc531a607
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.
5 #ifndef CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_
6 #define CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/synchronization/lock.h"
10 #include "base/threading/thread_checker.h"
11 #include "cc/base/cc_export.h"
12 #include "cc/layers/video_frame_provider.h"
13 #include "ui/gfx/transform.h"
15 namespace media { class VideoFrame; }
17 namespace cc {
18 class VideoLayerImpl;
20 // VideoFrameProviderClientImpl liasons with the VideoFrameProvider and the
21 // VideoLayer. It receives updates from the provider and updates the layer as a
22 // result. It also allows the layer to access the video frame that the provider
23 // has.
24 class CC_EXPORT VideoFrameProviderClientImpl
25 : public VideoFrameProvider::Client,
26 public base::RefCounted<VideoFrameProviderClientImpl> {
27 public:
28 // Must be created on the impl thread while the main thread is blocked.
29 static scoped_refptr<VideoFrameProviderClientImpl> Create(
30 VideoFrameProvider* provider);
32 VideoLayerImpl* ActiveVideoLayer() const;
33 void SetActiveVideoLayer(VideoLayerImpl* video_layer);
35 bool Stopped() const;
36 // Must be called on the impl thread while the main thread is blocked.
37 void Stop();
39 scoped_refptr<media::VideoFrame> AcquireLockAndCurrentFrame();
40 void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame);
41 void ReleaseLock();
43 const gfx::Transform& StreamTextureMatrix() const;
45 // VideoFrameProvider::Client implementation.
46 // Called on the main thread.
47 void StopUsingProvider() override;
48 // Called on the impl thread.
49 void DidReceiveFrame() override;
50 void DidUpdateMatrix(const float* matrix) override;
52 private:
53 friend class base::RefCounted<VideoFrameProviderClientImpl>;
55 explicit VideoFrameProviderClientImpl(VideoFrameProvider* provider);
56 ~VideoFrameProviderClientImpl() override;
58 VideoFrameProvider* provider_;
59 VideoLayerImpl* active_video_layer_;
60 bool stopped_;
62 // Since the provider lives on another thread, it can be destroyed while the
63 // frame controller are accessing its frame. Before being destroyed the
64 // provider calls StopUsingProvider. provider_lock_ blocks StopUsingProvider
65 // from returning until the frame controller is done using the frame.
66 base::Lock provider_lock_;
67 base::ThreadChecker thread_checker_;
69 gfx::Transform stream_texture_matrix_;
71 DISALLOW_COPY_AND_ASSIGN(VideoFrameProviderClientImpl);
74 } // namespace cc
76 #endif // CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_