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

Unified Diff: media/base/video_frame.cc

Issue 175223003: HW Video: Make media::VideoFrame handle the sync point of the compositor as well as webgl (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Focus on this CL's goal and remove wrong change Created 6 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: media/base/video_frame.cc
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index 64e898987d5d213e51f8cc90ef3ecf8bfda1dda2..3c382847a52bd9a36e74fc60b2385b92777434e1 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -106,6 +106,9 @@ scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture(
frame->mailbox_holder_ = mailbox_holder.Pass();
frame->mailbox_holder_release_cb_ = mailbox_holder_release_cb;
frame->read_pixels_cb_ = read_pixels_cb;
+#ifndef NDEBUG
+ frame->debug_initial_sync_point_ = frame->mailbox_holder_->sync_point;
+#endif
return frame;
}
@@ -406,6 +409,9 @@ VideoFrame::VideoFrame(VideoFrame::Format format,
coded_size_(coded_size),
visible_rect_(visible_rect),
natural_size_(natural_size),
+#ifndef NDEBUG
+ debug_initial_sync_point_(0),
+#endif
shared_memory_handle_(base::SharedMemory::NULLHandle()),
timestamp_(timestamp),
end_of_stream_(end_of_stream) {
@@ -415,8 +421,21 @@ VideoFrame::VideoFrame(VideoFrame::Format format,
VideoFrame::~VideoFrame() {
if (!mailbox_holder_release_cb_.is_null()) {
- base::ResetAndReturn(&mailbox_holder_release_cb_)
- .Run(mailbox_holder_.Pass());
+ std::vector<uint32> release_sync_points;
+ {
+ base::AutoLock locker(release_sync_point_lock_);
Ami GONE FROM CHROMIUM 2014/04/11 20:55:17 locking in a dtor is a code-smell. If anything ca
dshwang 2014/04/22 19:16:51 I reserve this code as I explained. IMO ensuring t
+ release_sync_points_.swap(release_sync_points);
+ }
+#ifndef NDEBUG
+ // VideoFrame doesn't use |mailbox_holder_->sync_point| as release sync
+ // point because VideoFrame can have multiple clients. i.e. the compositor,
+ // webgl. So VideoFrame uses |release_sync_points_| unlike webgl.
+ // mailbox_holder_->sync_point must be not changed by clients.
+ DCHECK_EQ(debug_initial_sync_point_, mailbox_holder_->sync_point);
Ami GONE FROM CHROMIUM 2014/04/11 20:55:17 This would be even easier to guarantee if nobody h
dshwang 2014/04/22 19:16:51 That's good idea. I make mailbox_holder const. And
+ for (size_t i = 0; i < release_sync_points.size(); i++)
+ DCHECK_NE(debug_initial_sync_point_, release_sync_points[i]);
Ami GONE FROM CHROMIUM 2014/04/11 20:55:17 What guarantees that wrap-around doesn't hit this?
+#endif
+ base::ResetAndReturn(&mailbox_holder_release_cb_).Run(release_sync_points);
}
if (!no_longer_needed_cb_.is_null())
base::ResetAndReturn(&no_longer_needed_cb_).Run();
@@ -497,6 +516,14 @@ base::SharedMemoryHandle VideoFrame::shared_memory_handle() const {
return shared_memory_handle_;
}
+void VideoFrame::AppendReleaseSyncPoint(uint32 sync_point) {
+ DCHECK_EQ(format_, NATIVE_TEXTURE);
+ if (!sync_point)
Ami GONE FROM CHROMIUM 2014/04/11 20:55:17 OOC where does it say that a sync_point of zero me
danakj 2014/04/14 13:19:31 Hm, it's a convention we follow to return 0 when w
dshwang 2014/04/22 19:16:51 Thank you for kind explanation. I agree, so I rese
+ return;
+ base::AutoLock locker(release_sync_point_lock_);
+ release_sync_points_.push_back(sync_point);
+}
+
void VideoFrame::HashFrameForTesting(base::MD5Context* context) {
for (int plane = 0; plane < kMaxPlanes; ++plane) {
if (!IsValidPlane(plane))

Powered by Google App Engine
This is Rietveld 408576698