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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::UpdateReleaseSyncPoint(SyncPointClient* client) { |
760 DCHECK(HasTextures()); | 760 DCHECK(HasTextures()); |
761 base::AutoLock locker(release_sync_point_lock_); | 761 base::AutoLock locker(release_sync_point_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_point_|. |
765 if (release_sync_point_) | 765 if (release_sync_point_) |
766 client->WaitSyncPoint(release_sync_point_); | 766 client->WaitSyncPoint(release_sync_point_, release_sync_token_); |
767 release_sync_point_ = client->InsertSyncPoint(); | 767 release_sync_point_ = 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, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 visible_rect, | 867 visible_rect, |
868 natural_size, | 868 natural_size, |
869 timestamp) { | 869 timestamp) { |
870 memcpy(&mailbox_holders_, mailbox_holders, sizeof(mailbox_holders_)); | 870 memcpy(&mailbox_holders_, mailbox_holders, sizeof(mailbox_holders_)); |
871 mailbox_holders_release_cb_ = mailbox_holder_release_cb; | 871 mailbox_holders_release_cb_ = mailbox_holder_release_cb; |
872 } | 872 } |
873 | 873 |
874 VideoFrame::~VideoFrame() { | 874 VideoFrame::~VideoFrame() { |
875 if (!mailbox_holders_release_cb_.is_null()) { | 875 if (!mailbox_holders_release_cb_.is_null()) { |
876 uint32 release_sync_point; | 876 uint32 release_sync_point; |
| 877 gpu::SyncToken release_sync_token; |
877 { | 878 { |
878 // To ensure that changes to |release_sync_point_| are visible on this | 879 // To ensure that changes to |release_sync_point_| are visible on this |
879 // thread (imply a memory barrier). | 880 // thread (imply a memory barrier). |
880 base::AutoLock locker(release_sync_point_lock_); | 881 base::AutoLock locker(release_sync_point_lock_); |
881 release_sync_point = release_sync_point_; | 882 release_sync_point = release_sync_point_; |
| 883 release_sync_token = release_sync_token_; |
882 } | 884 } |
883 base::ResetAndReturn(&mailbox_holders_release_cb_).Run(release_sync_point); | 885 base::ResetAndReturn(&mailbox_holders_release_cb_) |
| 886 .Run(release_sync_point, release_sync_token); |
884 } | 887 } |
885 | 888 |
886 for (auto& callback : done_callbacks_) | 889 for (auto& callback : done_callbacks_) |
887 base::ResetAndReturn(&callback).Run(); | 890 base::ResetAndReturn(&callback).Run(); |
888 } | 891 } |
889 | 892 |
890 // static | 893 // static |
891 scoped_refptr<VideoFrame> VideoFrame::CreateFrameInternal( | 894 scoped_refptr<VideoFrame> VideoFrame::CreateFrameInternal( |
892 VideoPixelFormat format, | 895 VideoPixelFormat format, |
893 const gfx::Size& coded_size, | 896 const gfx::Size& coded_size, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 if (zero_initialize_memory) | 958 if (zero_initialize_memory) |
956 memset(data, 0, data_size); | 959 memset(data, 0, data_size); |
957 | 960 |
958 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 961 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
959 data_[plane] = data + offset[plane]; | 962 data_[plane] = data + offset[plane]; |
960 | 963 |
961 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 964 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
962 } | 965 } |
963 | 966 |
964 } // namespace media | 967 } // namespace media |
OLD | NEW |