Chromium Code Reviews| Index: media/base/video_frame.h |
| diff --git a/media/base/video_frame.h b/media/base/video_frame.h |
| index 6cd5a0f7f7ccd7af2b49eb0c57c3341409c11c65..851daf6afc9fda1ed3ba5c4bf51722d99041ee4c 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,8 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { |
| YV12A = 14, // 20bpp YUVA planar 1x1 Y, 2x2 VU, 1x1 A samples. |
| }; |
| + typedef base::Callback<void(uint32 sync_point)> TextureNoLongerNeededCallback; |
| + |
| // 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,13 +90,15 @@ 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 gpu::Mailbox& texture_mailbox, |
|
scherkus (not reviewing)
2013/06/17 20:20:37
thoughts on replacing the 3 args with a MailboxHol
danakj
2013/06/18 00:45:05
Hm... I think that sounds like a good idea. Will d
danakj
2013/06/18 16:54:12
Done.
|
| + uint32 texture_mailbox_sync_point, |
| uint32 texture_target, |
| const gfx::Size& coded_size, |
| const gfx::Rect& visible_rect, |
| const gfx::Size& natural_size, |
| base::TimeDelta timestamp, |
| const ReadPixelsCB& read_pixels_cb, |
| + const TextureNoLongerNeededCallback& texture_no_longer_needed_cb, |
| const base::Closure& no_longer_needed_cb); |
| // Read pixels from the native texture backing |*this| and write |
| @@ -158,9 +163,30 @@ 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; |
| + class MailboxHolder : public base::RefCountedThreadSafe<MailboxHolder> { |
| + public: |
| + 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_; |
| + }; |
| + |
| + // 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 +243,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_; |