| OLD | NEW |
| 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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 CVPixelBufferRef VideoFrame::cv_pixel_buffer() const { | 749 CVPixelBufferRef VideoFrame::cv_pixel_buffer() const { |
| 750 return cv_pixel_buffer_.get(); | 750 return cv_pixel_buffer_.get(); |
| 751 } | 751 } |
| 752 #endif | 752 #endif |
| 753 | 753 |
| 754 void VideoFrame::AddDestructionObserver(const base::Closure& callback) { | 754 void VideoFrame::AddDestructionObserver(const base::Closure& callback) { |
| 755 DCHECK(!callback.is_null()); | 755 DCHECK(!callback.is_null()); |
| 756 done_callbacks_.push_back(callback); | 756 done_callbacks_.push_back(callback); |
| 757 } | 757 } |
| 758 | 758 |
| 759 void VideoFrame::UpdateReleaseSyncPoint(SyncPointClient* client) { | 759 void VideoFrame::UpdateReleaseSyncToken(SyncTokenClient* client) { |
| 760 DCHECK(HasTextures()); | 760 DCHECK(HasTextures()); |
| 761 base::AutoLock locker(release_sync_point_lock_); | 761 base::AutoLock locker(release_sync_token_lock_); |
| 762 // Must wait on the previous sync point before inserting a new sync point so | 762 // Must wait on the previous sync point before inserting a new sync point so |
| 763 // that |mailbox_holders_release_cb_| guarantees the previous sync point | 763 // that |mailbox_holders_release_cb_| guarantees the previous sync point |
| 764 // occurred when it waits on |release_sync_point_|. | 764 // occurred when it waits on |release_sync_token_|. |
| 765 if (release_sync_point_) | 765 if (release_sync_token_.HasData()) |
| 766 client->WaitSyncPoint(release_sync_point_); | 766 client->WaitSyncToken(release_sync_token_); |
| 767 release_sync_point_ = client->InsertSyncPoint(); | 767 release_sync_token_ = gpu::SyncToken(client->InsertSyncPoint()); |
| 768 } | 768 } |
| 769 | 769 |
| 770 // static | 770 // static |
| 771 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage( | 771 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage( |
| 772 VideoPixelFormat format, | 772 VideoPixelFormat format, |
| 773 StorageType storage_type, | 773 StorageType storage_type, |
| 774 const gfx::Size& coded_size, | 774 const gfx::Size& coded_size, |
| 775 const gfx::Rect& visible_rect, | 775 const gfx::Rect& visible_rect, |
| 776 const gfx::Size& natural_size, | 776 const gfx::Size& natural_size, |
| 777 uint8* data, | 777 uint8* data, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 const gfx::Rect& visible_rect, | 818 const gfx::Rect& visible_rect, |
| 819 const gfx::Size& natural_size, | 819 const gfx::Size& natural_size, |
| 820 base::TimeDelta timestamp) | 820 base::TimeDelta timestamp) |
| 821 : format_(format), | 821 : format_(format), |
| 822 storage_type_(storage_type), | 822 storage_type_(storage_type), |
| 823 coded_size_(coded_size), | 823 coded_size_(coded_size), |
| 824 visible_rect_(visible_rect), | 824 visible_rect_(visible_rect), |
| 825 natural_size_(natural_size), | 825 natural_size_(natural_size), |
| 826 shared_memory_handle_(base::SharedMemory::NULLHandle()), | 826 shared_memory_handle_(base::SharedMemory::NULLHandle()), |
| 827 shared_memory_offset_(0), | 827 shared_memory_offset_(0), |
| 828 timestamp_(timestamp), | 828 timestamp_(timestamp) { |
| 829 release_sync_point_(0) { | |
| 830 DCHECK(IsValidConfig(format_, storage_type, coded_size_, visible_rect_, | 829 DCHECK(IsValidConfig(format_, storage_type, coded_size_, visible_rect_, |
| 831 natural_size_)); | 830 natural_size_)); |
| 832 memset(&mailbox_holders_, 0, sizeof(mailbox_holders_)); | 831 memset(&mailbox_holders_, 0, sizeof(mailbox_holders_)); |
| 833 memset(&strides_, 0, sizeof(strides_)); | 832 memset(&strides_, 0, sizeof(strides_)); |
| 834 memset(&data_, 0, sizeof(data_)); | 833 memset(&data_, 0, sizeof(data_)); |
| 835 } | 834 } |
| 836 | 835 |
| 837 VideoFrame::VideoFrame(VideoPixelFormat format, | 836 VideoFrame::VideoFrame(VideoPixelFormat format, |
| 838 StorageType storage_type, | 837 StorageType storage_type, |
| 839 const gfx::Size& coded_size, | 838 const gfx::Size& coded_size, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 866 coded_size, | 865 coded_size, |
| 867 visible_rect, | 866 visible_rect, |
| 868 natural_size, | 867 natural_size, |
| 869 timestamp) { | 868 timestamp) { |
| 870 memcpy(&mailbox_holders_, mailbox_holders, sizeof(mailbox_holders_)); | 869 memcpy(&mailbox_holders_, mailbox_holders, sizeof(mailbox_holders_)); |
| 871 mailbox_holders_release_cb_ = mailbox_holder_release_cb; | 870 mailbox_holders_release_cb_ = mailbox_holder_release_cb; |
| 872 } | 871 } |
| 873 | 872 |
| 874 VideoFrame::~VideoFrame() { | 873 VideoFrame::~VideoFrame() { |
| 875 if (!mailbox_holders_release_cb_.is_null()) { | 874 if (!mailbox_holders_release_cb_.is_null()) { |
| 876 uint32 release_sync_point; | 875 gpu::SyncToken release_sync_token; |
| 877 { | 876 { |
| 878 // To ensure that changes to |release_sync_point_| are visible on this | 877 // To ensure that changes to |release_sync_token_| are visible on this |
| 879 // thread (imply a memory barrier). | 878 // thread (imply a memory barrier). |
| 880 base::AutoLock locker(release_sync_point_lock_); | 879 base::AutoLock locker(release_sync_token_lock_); |
| 881 release_sync_point = release_sync_point_; | 880 release_sync_token = release_sync_token_; |
| 882 } | 881 } |
| 883 base::ResetAndReturn(&mailbox_holders_release_cb_).Run(release_sync_point); | 882 base::ResetAndReturn(&mailbox_holders_release_cb_).Run(release_sync_token); |
| 884 } | 883 } |
| 885 | 884 |
| 886 for (auto& callback : done_callbacks_) | 885 for (auto& callback : done_callbacks_) |
| 887 base::ResetAndReturn(&callback).Run(); | 886 base::ResetAndReturn(&callback).Run(); |
| 888 } | 887 } |
| 889 | 888 |
| 890 // static | 889 // static |
| 891 scoped_refptr<VideoFrame> VideoFrame::CreateFrameInternal( | 890 scoped_refptr<VideoFrame> VideoFrame::CreateFrameInternal( |
| 892 VideoPixelFormat format, | 891 VideoPixelFormat format, |
| 893 const gfx::Size& coded_size, | 892 const gfx::Size& coded_size, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 if (zero_initialize_memory) | 954 if (zero_initialize_memory) |
| 956 memset(data, 0, data_size); | 955 memset(data, 0, data_size); |
| 957 | 956 |
| 958 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 957 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
| 959 data_[plane] = data + offset[plane]; | 958 data_[plane] = data + offset[plane]; |
| 960 | 959 |
| 961 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 960 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
| 962 } | 961 } |
| 963 | 962 |
| 964 } // namespace media | 963 } // namespace media |
| OLD | NEW |