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

Side by Side Diff: media/base/video_frame.cc

Issue 1427543002: Modified old wait sync point functions to also accept new sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « media/base/video_frame.h ('k') | media/base/video_frame_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/video_frame.h" 5 #include "media/base/video_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 CVPixelBufferRef VideoFrame::cv_pixel_buffer() const { 795 CVPixelBufferRef VideoFrame::cv_pixel_buffer() const {
796 return cv_pixel_buffer_.get(); 796 return cv_pixel_buffer_.get();
797 } 797 }
798 #endif 798 #endif
799 799
800 void VideoFrame::AddDestructionObserver(const base::Closure& callback) { 800 void VideoFrame::AddDestructionObserver(const base::Closure& callback) {
801 DCHECK(!callback.is_null()); 801 DCHECK(!callback.is_null());
802 done_callbacks_.push_back(callback); 802 done_callbacks_.push_back(callback);
803 } 803 }
804 804
805 void VideoFrame::UpdateReleaseSyncPoint(SyncPointClient* client) { 805 void VideoFrame::UpdateReleaseSyncToken(SyncTokenClient* client) {
806 DCHECK(HasTextures()); 806 DCHECK(HasTextures());
807 base::AutoLock locker(release_sync_point_lock_); 807 base::AutoLock locker(release_sync_token_lock_);
808 // Must wait on the previous sync point before inserting a new sync point so 808 // Must wait on the previous sync point before inserting a new sync point so
809 // that |mailbox_holders_release_cb_| guarantees the previous sync point 809 // that |mailbox_holders_release_cb_| guarantees the previous sync point
810 // occurred when it waits on |release_sync_point_|. 810 // occurred when it waits on |release_sync_token_|.
811 if (release_sync_point_) 811 if (release_sync_token_.HasData())
812 client->WaitSyncPoint(release_sync_point_); 812 client->WaitSyncToken(release_sync_token_);
813 release_sync_point_ = client->InsertSyncPoint(); 813 release_sync_token_ = gpu::SyncToken(client->InsertSyncPoint());
814 } 814 }
815 815
816 // static 816 // static
817 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage( 817 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage(
818 VideoPixelFormat format, 818 VideoPixelFormat format,
819 StorageType storage_type, 819 StorageType storage_type,
820 const gfx::Size& coded_size, 820 const gfx::Size& coded_size,
821 const gfx::Rect& visible_rect, 821 const gfx::Rect& visible_rect,
822 const gfx::Size& natural_size, 822 const gfx::Size& natural_size,
823 uint8* data, 823 uint8* data,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 const gfx::Rect& visible_rect, 864 const gfx::Rect& visible_rect,
865 const gfx::Size& natural_size, 865 const gfx::Size& natural_size,
866 base::TimeDelta timestamp) 866 base::TimeDelta timestamp)
867 : format_(format), 867 : format_(format),
868 storage_type_(storage_type), 868 storage_type_(storage_type),
869 coded_size_(coded_size), 869 coded_size_(coded_size),
870 visible_rect_(visible_rect), 870 visible_rect_(visible_rect),
871 natural_size_(natural_size), 871 natural_size_(natural_size),
872 shared_memory_handle_(base::SharedMemory::NULLHandle()), 872 shared_memory_handle_(base::SharedMemory::NULLHandle()),
873 shared_memory_offset_(0), 873 shared_memory_offset_(0),
874 timestamp_(timestamp), 874 timestamp_(timestamp) {
875 release_sync_point_(0) {
876 DCHECK(IsValidConfig(format_, storage_type, coded_size_, visible_rect_, 875 DCHECK(IsValidConfig(format_, storage_type, coded_size_, visible_rect_,
877 natural_size_)); 876 natural_size_));
878 memset(&mailbox_holders_, 0, sizeof(mailbox_holders_)); 877 memset(&mailbox_holders_, 0, sizeof(mailbox_holders_));
879 memset(&strides_, 0, sizeof(strides_)); 878 memset(&strides_, 0, sizeof(strides_));
880 memset(&data_, 0, sizeof(data_)); 879 memset(&data_, 0, sizeof(data_));
881 } 880 }
882 881
883 VideoFrame::VideoFrame(VideoPixelFormat format, 882 VideoFrame::VideoFrame(VideoPixelFormat format,
884 StorageType storage_type, 883 StorageType storage_type,
885 const gfx::Size& coded_size, 884 const gfx::Size& coded_size,
(...skipping 26 matching lines...) Expand all
912 coded_size, 911 coded_size,
913 visible_rect, 912 visible_rect,
914 natural_size, 913 natural_size,
915 timestamp) { 914 timestamp) {
916 memcpy(&mailbox_holders_, mailbox_holders, sizeof(mailbox_holders_)); 915 memcpy(&mailbox_holders_, mailbox_holders, sizeof(mailbox_holders_));
917 mailbox_holders_release_cb_ = mailbox_holder_release_cb; 916 mailbox_holders_release_cb_ = mailbox_holder_release_cb;
918 } 917 }
919 918
920 VideoFrame::~VideoFrame() { 919 VideoFrame::~VideoFrame() {
921 if (!mailbox_holders_release_cb_.is_null()) { 920 if (!mailbox_holders_release_cb_.is_null()) {
922 uint32 release_sync_point; 921 gpu::SyncToken release_sync_token;
923 { 922 {
924 // To ensure that changes to |release_sync_point_| are visible on this 923 // To ensure that changes to |release_sync_token_| are visible on this
925 // thread (imply a memory barrier). 924 // thread (imply a memory barrier).
926 base::AutoLock locker(release_sync_point_lock_); 925 base::AutoLock locker(release_sync_token_lock_);
927 release_sync_point = release_sync_point_; 926 release_sync_token = release_sync_token_;
928 } 927 }
929 base::ResetAndReturn(&mailbox_holders_release_cb_).Run(release_sync_point); 928 base::ResetAndReturn(&mailbox_holders_release_cb_).Run(release_sync_token);
930 } 929 }
931 930
932 for (auto& callback : done_callbacks_) 931 for (auto& callback : done_callbacks_)
933 base::ResetAndReturn(&callback).Run(); 932 base::ResetAndReturn(&callback).Run();
934 } 933 }
935 934
936 // static 935 // static
937 scoped_refptr<VideoFrame> VideoFrame::CreateFrameInternal( 936 scoped_refptr<VideoFrame> VideoFrame::CreateFrameInternal(
938 VideoPixelFormat format, 937 VideoPixelFormat format,
939 const gfx::Size& coded_size, 938 const gfx::Size& coded_size,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 if (zero_initialize_memory) 1000 if (zero_initialize_memory)
1002 memset(data, 0, data_size); 1001 memset(data, 0, data_size);
1003 1002
1004 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) 1003 for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
1005 data_[plane] = data + offset[plane]; 1004 data_[plane] = data + offset[plane];
1006 1005
1007 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); 1006 AddDestructionObserver(base::Bind(&base::AlignedFree, data));
1008 } 1007 }
1009 1008
1010 } // namespace media 1009 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.h ('k') | media/base/video_frame_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698