Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(933)

Unified Diff: cc/layers/video_frame_provider_client_impl.h

Issue 1033563002: cc: Various code safety improvements in video compositing code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/layers/video_frame_provider_client_impl.h
diff --git a/cc/layers/video_frame_provider_client_impl.h b/cc/layers/video_frame_provider_client_impl.h
index 39f66fb009db00e81960b3099c243495f8f58f02..2688ad25d8cb8332986348274a451d3cc531a607 100644
--- a/cc/layers/video_frame_provider_client_impl.h
+++ b/cc/layers/video_frame_provider_client_impl.h
@@ -8,6 +8,7 @@
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
+#include "cc/base/cc_export.h"
#include "cc/layers/video_frame_provider.h"
#include "ui/gfx/transform.h"
@@ -16,42 +17,53 @@ namespace media { class VideoFrame; }
namespace cc {
class VideoLayerImpl;
-class VideoFrameProviderClientImpl
+// VideoFrameProviderClientImpl liasons with the VideoFrameProvider and the
+// VideoLayer. It receives updates from the provider and updates the layer as a
+// result. It also allows the layer to access the video frame that the provider
+// has.
+class CC_EXPORT VideoFrameProviderClientImpl
: public VideoFrameProvider::Client,
public base::RefCounted<VideoFrameProviderClientImpl> {
public:
+ // Must be created on the impl thread while the main thread is blocked.
static scoped_refptr<VideoFrameProviderClientImpl> Create(
VideoFrameProvider* provider);
- VideoLayerImpl* active_video_layer() { return active_video_layer_; }
+ VideoLayerImpl* ActiveVideoLayer() const;
void SetActiveVideoLayer(VideoLayerImpl* video_layer);
+ bool Stopped() const;
+ // Must be called on the impl thread while the main thread is blocked.
void Stop();
- bool Stopped();
scoped_refptr<media::VideoFrame> AcquireLockAndCurrentFrame();
void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame);
void ReleaseLock();
- const gfx::Transform& stream_texture_matrix() const {
- return stream_texture_matrix_;
- }
- // VideoFrameProvider::Client implementation. These methods are all callable
- // on any thread.
+ const gfx::Transform& StreamTextureMatrix() const;
+
+ // VideoFrameProvider::Client implementation.
+ // Called on the main thread.
void StopUsingProvider() override;
+ // Called on the impl thread.
void DidReceiveFrame() override;
void DidUpdateMatrix(const float* matrix) override;
private:
- explicit VideoFrameProviderClientImpl(VideoFrameProvider* provider);
friend class base::RefCounted<VideoFrameProviderClientImpl>;
+
+ explicit VideoFrameProviderClientImpl(VideoFrameProvider* provider);
~VideoFrameProviderClientImpl() override;
+ VideoFrameProvider* provider_;
VideoLayerImpl* active_video_layer_;
+ bool stopped_;
- // Guards the destruction of provider_ and the frame that it provides
+ // Since the provider lives on another thread, it can be destroyed while the
+ // frame controller are accessing its frame. Before being destroyed the
+ // provider calls StopUsingProvider. provider_lock_ blocks StopUsingProvider
+ // from returning until the frame controller is done using the frame.
base::Lock provider_lock_;
- VideoFrameProvider* provider_;
base::ThreadChecker thread_checker_;
gfx::Transform stream_texture_matrix_;

Powered by Google App Engine
This is Rietveld 408576698