| Index: media/base/video_frame.h
|
| diff --git a/media/base/video_frame.h b/media/base/video_frame.h
|
| index 6cd5a0f7f7ccd7af2b49eb0c57c3341409c11c65..bfde2ef8b812c724acc8b08e142e667a4b186f6e 100644
|
| --- a/media/base/video_frame.h
|
| +++ b/media/base/video_frame.h
|
| @@ -7,6 +7,7 @@
|
|
|
| #include "base/callback.h"
|
| #include "base/md5.h"
|
| +#include "gpu/command_buffer/common/mailbox.h"
|
| #include "media/base/buffers.h"
|
| #include "ui/gfx/rect.h"
|
| #include "ui/gfx/size.h"
|
| @@ -51,6 +52,37 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
|
| YV12A = 14, // 20bpp YUVA planar 1x1 Y, 2x2 VU, 1x1 A samples.
|
| };
|
|
|
| + // This class calls the TextureNoLongerNeededCallback when the last reference
|
| + // on the class is destroyed. The VideoFrame holds a reference to the mailbox
|
| + // but anyone else who queries the mailbox should also hold a reference while
|
| + // it is uses the mailbox, to ensure it remains valid. When finished with the
|
| + // mailbox, call Return() with a new sync point, to ensure the mailbox remains
|
| + // valid for the issued commands.
|
| + class MEDIA_EXPORT MailboxHolder
|
| + : public base::RefCountedThreadSafe<MailboxHolder> {
|
| + public:
|
| + typedef base::Callback<void(uint32 sync_point)>
|
| + TextureNoLongerNeededCallback;
|
| +
|
| + MailboxHolder(const gpu::Mailbox& mailbox,
|
| + unsigned sync_point,
|
| + const TextureNoLongerNeededCallback& release_callback);
|
| +
|
| + const gpu::Mailbox& mailbox() const { return mailbox_; }
|
| + unsigned sync_point() const { return sync_point_; }
|
| +
|
| + void Return(unsigned sync_point) { sync_point_ = sync_point; }
|
| +
|
| + private:
|
| + friend class base::RefCountedThreadSafe<MailboxHolder>;
|
| + ~MailboxHolder();
|
| +
|
| + gpu::Mailbox mailbox_;
|
| + unsigned sync_point_;
|
| + TextureNoLongerNeededCallback release_callback_;
|
| + };
|
| +
|
| +
|
| // Creates a new frame in system memory with given parameters. Buffers for
|
| // the frame are allocated but not initialized.
|
| // |coded_size| is the width and height of the frame data in pixels.
|
| @@ -87,7 +119,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
|
| // |read_pixels_cb| may be used to do (slow!) readbacks from the
|
| // texture to main memory.
|
| static scoped_refptr<VideoFrame> WrapNativeTexture(
|
| - uint32 texture_id,
|
| + const scoped_refptr<MailboxHolder>& mailbox_holder,
|
| uint32 texture_target,
|
| const gfx::Size& coded_size,
|
| const gfx::Rect& visible_rect,
|
| @@ -158,9 +190,10 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
|
| // VideoFrame object and must not be freed by the caller.
|
| uint8* data(size_t plane) const;
|
|
|
| - // Returns the ID of the native texture wrapped by this frame. Only valid to
|
| - // call if this is a NATIVE_TEXTURE frame.
|
| - uint32 texture_id() const;
|
| + // Returns the mailbox of the native texture wrapped by this frame. Only
|
| + // valid to call if this is a NATIVE_TEXTURE frame. Before using the
|
| + // mailbox, the caller must wait for the included sync point.
|
| + const scoped_refptr<MailboxHolder>& texture_mailbox() const;
|
|
|
| // Returns the texture target. Only valid for NATIVE_TEXTURE frames.
|
| uint32 texture_target() const;
|
| @@ -217,8 +250,8 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
|
| // Array of data pointers to each plane.
|
| uint8* data_[kMaxPlanes];
|
|
|
| - // Native texture ID, if this is a NATIVE_TEXTURE frame.
|
| - uint32 texture_id_;
|
| + // Native texture mailbox, if this is a NATIVE_TEXTURE frame.
|
| + scoped_refptr<MailboxHolder> texture_mailbox_holder_;
|
| uint32 texture_target_;
|
| ReadPixelsCB read_pixels_cb_;
|
|
|
|
|