summaryrefslogtreecommitdiff
path: root/media/base/video_frame.cc
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-02-21 12:16:55 +0000
committerTorne (Richard Coles) <torne@google.com>2014-02-21 12:16:55 +0000
commit5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7 (patch)
tree5d4ae202b870bd86673f596f0d424bc4b3e55ebe /media/base/video_frame.cc
parente862bac9c33104a29d98631d62668ae7b6676510 (diff)
downloadchromium_org-5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7.tar.gz
Merge from Chromium at DEPS revision 251904
This commit was generated by merge_to_master.py. Change-Id: I1f9543259d7d2a57d81aa41a1b84f85837439d21
Diffstat (limited to 'media/base/video_frame.cc')
-rw-r--r--media/base/video_frame.cc58
1 files changed, 21 insertions, 37 deletions
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index 2593bf3349..7e654319c5 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/memory/aligned_memory.h"
#include "base/strings/string_piece.h"
+#include "gpu/command_buffer/common/mailbox_holder.h"
#include "media/base/limits.h"
#include "media/base/video_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -54,10 +55,10 @@ std::string VideoFrame::FormatToString(VideoFrame::Format format) {
return "I420";
case VideoFrame::NATIVE_TEXTURE:
return "NATIVE_TEXTURE";
-#if defined(GOOGLE_TV)
+#if defined(VIDEO_HOLE)
case VideoFrame::HOLE:
return "HOLE";
-#endif
+#endif // defined(VIDEO_HOLE)
case VideoFrame::YV12A:
return "YV12A";
case VideoFrame::YV12J:
@@ -91,24 +92,22 @@ bool VideoFrame::IsValidConfig(VideoFrame::Format format,
// static
scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture(
- scoped_ptr<MailboxHolder> mailbox_holder,
- uint32 texture_target,
+ scoped_ptr<gpu::MailboxHolder> mailbox_holder,
+ const ReleaseMailboxCB& mailbox_holder_release_cb,
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
base::TimeDelta timestamp,
- const ReadPixelsCB& read_pixels_cb,
- const base::Closure& no_longer_needed_cb) {
+ const ReadPixelsCB& read_pixels_cb) {
scoped_refptr<VideoFrame> frame(new VideoFrame(NATIVE_TEXTURE,
coded_size,
visible_rect,
natural_size,
timestamp,
false));
- frame->texture_mailbox_holder_ = mailbox_holder.Pass();
- frame->texture_target_ = texture_target;
+ frame->mailbox_holder_ = mailbox_holder.Pass();
+ frame->mailbox_holder_release_cb_ = mailbox_holder_release_cb;
frame->read_pixels_cb_ = read_pixels_cb;
- frame->no_longer_needed_cb_ = no_longer_needed_cb;
return frame;
}
@@ -227,8 +226,8 @@ scoped_refptr<VideoFrame> VideoFrame::CreateBlackFrame(const gfx::Size& size) {
return CreateColorFrame(size, kBlackY, kBlackUV, kBlackUV, kZero);
}
-#if defined(GOOGLE_TV)
-// This block and other blocks wrapped around #if defined(GOOGLE_TV) is not
+#if defined(VIDEO_HOLE)
+// This block and other blocks wrapped around #if defined(VIDEO_HOLE) is not
// maintained by the general compositor team. Please contact the following
// people instead:
//
@@ -243,15 +242,15 @@ scoped_refptr<VideoFrame> VideoFrame::CreateHoleFrame(
VideoFrame::HOLE, size, gfx::Rect(size), size, base::TimeDelta(), false));
return frame;
}
-#endif
+#endif // defined(VIDEO_HOLE)
// static
size_t VideoFrame::NumPlanes(Format format) {
switch (format) {
case VideoFrame::NATIVE_TEXTURE:
-#if defined(GOOGLE_TV)
+#if defined(VIDEO_HOLE)
case VideoFrame::HOLE:
-#endif
+#endif // defined(VIDEO_HOLE)
return 0;
case VideoFrame::YV12:
case VideoFrame::YV16:
@@ -328,9 +327,9 @@ size_t VideoFrame::PlaneAllocationSize(Format format,
case VideoFrame::UNKNOWN:
case VideoFrame::NATIVE_TEXTURE:
case VideoFrame::HISTOGRAM_MAX:
-#if defined(GOOGLE_TV)
+#if defined(VIDEO_HOLE)
case VideoFrame::HOLE:
-#endif
+#endif // defined(VIDEO_HOLE)
break;
}
NOTREACHED() << "Unsupported video frame format/plane: "
@@ -408,7 +407,6 @@ VideoFrame::VideoFrame(VideoFrame::Format format,
coded_size_(coded_size),
visible_rect_(visible_rect),
natural_size_(natural_size),
- texture_target_(0),
shared_memory_handle_(base::SharedMemory::NULLHandle()),
timestamp_(timestamp),
end_of_stream_(end_of_stream) {
@@ -417,6 +415,10 @@ VideoFrame::VideoFrame(VideoFrame::Format format,
}
VideoFrame::~VideoFrame() {
+ if (!mailbox_holder_release_cb_.is_null()) {
+ base::ResetAndReturn(&mailbox_holder_release_cb_)
+ .Run(mailbox_holder_.Pass());
+ }
if (!no_longer_needed_cb_.is_null())
base::ResetAndReturn(&no_longer_needed_cb_).Run();
}
@@ -487,14 +489,9 @@ uint8* VideoFrame::data(size_t plane) const {
return data_[plane];
}
-VideoFrame::MailboxHolder* VideoFrame::texture_mailbox() const {
- DCHECK_EQ(format_, NATIVE_TEXTURE);
- return texture_mailbox_holder_.get();
-}
-
-uint32 VideoFrame::texture_target() const {
+gpu::MailboxHolder* VideoFrame::mailbox_holder() const {
DCHECK_EQ(format_, NATIVE_TEXTURE);
- return texture_target_;
+ return mailbox_holder_.get();
}
base::SharedMemoryHandle VideoFrame::shared_memory_handle() const {
@@ -513,17 +510,4 @@ void VideoFrame::HashFrameForTesting(base::MD5Context* context) {
}
}
-VideoFrame::MailboxHolder::MailboxHolder(
- const gpu::Mailbox& mailbox,
- unsigned sync_point,
- const TextureNoLongerNeededCallback& release_callback)
- : mailbox_(mailbox),
- sync_point_(sync_point),
- release_callback_(release_callback) {}
-
-VideoFrame::MailboxHolder::~MailboxHolder() {
- if (!release_callback_.is_null())
- release_callback_.Run(sync_point_);
-}
-
} // namespace media