| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gpu/vt_video_decode_accelerator_mac.h" | 5 #include "media/gpu/vt_video_decode_accelerator_mac.h" |
| 6 | 6 |
| 7 #include <CoreVideo/CoreVideo.h> | 7 #include <CoreVideo/CoreVideo.h> |
| 8 #include <OpenGL/CGLIOSurface.h> | 8 #include <OpenGL/CGLIOSurface.h> |
| 9 #include <OpenGL/gl.h> | 9 #include <OpenGL/gl.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 // Pictures are not marked as uncleared until after this method returns, and | 859 // Pictures are not marked as uncleared until after this method returns, and |
| 860 // they will be broken if they are used before that happens. So, schedule | 860 // they will be broken if they are used before that happens. So, schedule |
| 861 // future work after that happens. | 861 // future work after that happens. |
| 862 gpu_task_runner_->PostTask( | 862 gpu_task_runner_->PostTask( |
| 863 FROM_HERE, | 863 FROM_HERE, |
| 864 base::Bind(&VTVideoDecodeAccelerator::ProcessWorkQueues, weak_this_)); | 864 base::Bind(&VTVideoDecodeAccelerator::ProcessWorkQueues, weak_this_)); |
| 865 } | 865 } |
| 866 | 866 |
| 867 void VTVideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_id) { | 867 void VTVideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_id) { |
| 868 DCHECK(gpu_thread_checker_.CalledOnValidThread()); | 868 DCHECK(gpu_thread_checker_.CalledOnValidThread()); |
| 869 DCHECK(picture_info_map_.count(picture_id)); | |
| 870 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get(); | |
| 871 picture_info->cv_image.reset(); | |
| 872 picture_info->gl_image->Destroy(false); | |
| 873 picture_info->gl_image = nullptr; | |
| 874 | 869 |
| 875 if (assigned_picture_ids_.count(picture_id) != 0) { | 870 auto it = picture_info_map_.find(picture_id); |
| 871 if (it != picture_info_map_.end()) { |
| 872 PictureInfo* picture_info = it->second.get(); |
| 873 picture_info->cv_image.reset(); |
| 874 picture_info->gl_image->Destroy(false); |
| 875 picture_info->gl_image = nullptr; |
| 876 } |
| 877 |
| 878 if (assigned_picture_ids_.count(picture_id)) { |
| 876 available_picture_ids_.push_back(picture_id); | 879 available_picture_ids_.push_back(picture_id); |
| 877 ProcessWorkQueues(); | 880 ProcessWorkQueues(); |
| 878 } else { | 881 } else { |
| 879 client_->DismissPictureBuffer(picture_id); | 882 client_->DismissPictureBuffer(picture_id); |
| 880 } | 883 } |
| 881 } | 884 } |
| 882 | 885 |
| 883 void VTVideoDecodeAccelerator::ProcessWorkQueues() { | 886 void VTVideoDecodeAccelerator::ProcessWorkQueues() { |
| 884 DCHECK(gpu_thread_checker_.CalledOnValidThread()); | 887 DCHECK(gpu_thread_checker_.CalledOnValidThread()); |
| 885 switch (state_) { | 888 switch (state_) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 } | 1020 } |
| 1018 | 1021 |
| 1019 bool VTVideoDecodeAccelerator::SendFrame(const Frame& frame) { | 1022 bool VTVideoDecodeAccelerator::SendFrame(const Frame& frame) { |
| 1020 DCHECK(gpu_thread_checker_.CalledOnValidThread()); | 1023 DCHECK(gpu_thread_checker_.CalledOnValidThread()); |
| 1021 DCHECK_EQ(state_, STATE_DECODING); | 1024 DCHECK_EQ(state_, STATE_DECODING); |
| 1022 | 1025 |
| 1023 if (available_picture_ids_.empty()) | 1026 if (available_picture_ids_.empty()) |
| 1024 return false; | 1027 return false; |
| 1025 | 1028 |
| 1026 int32_t picture_id = available_picture_ids_.back(); | 1029 int32_t picture_id = available_picture_ids_.back(); |
| 1027 DCHECK(picture_info_map_.count(picture_id)); | 1030 auto it = picture_info_map_.find(picture_id); |
| 1028 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get(); | 1031 DCHECK(it != picture_info_map_.end()); |
| 1032 PictureInfo* picture_info = it->second.get(); |
| 1029 DCHECK(!picture_info->cv_image); | 1033 DCHECK(!picture_info->cv_image); |
| 1030 DCHECK(!picture_info->gl_image); | 1034 DCHECK(!picture_info->gl_image); |
| 1031 | 1035 |
| 1032 if (!make_context_current_cb_.Run()) { | 1036 if (!make_context_current_cb_.Run()) { |
| 1033 DLOG(ERROR) << "Failed to make GL context current"; | 1037 DLOG(ERROR) << "Failed to make GL context current"; |
| 1034 NotifyError(PLATFORM_FAILURE, SFT_PLATFORM_ERROR); | 1038 NotifyError(PLATFORM_FAILURE, SFT_PLATFORM_ERROR); |
| 1035 return false; | 1039 return false; |
| 1036 } | 1040 } |
| 1037 | 1041 |
| 1038 scoped_refptr<gl::GLImageIOSurface> gl_image( | 1042 scoped_refptr<gl::GLImageIOSurface> gl_image( |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 SupportedProfile profile; | 1143 SupportedProfile profile; |
| 1140 profile.profile = supported_profile; | 1144 profile.profile = supported_profile; |
| 1141 profile.min_resolution.SetSize(16, 16); | 1145 profile.min_resolution.SetSize(16, 16); |
| 1142 profile.max_resolution.SetSize(4096, 2160); | 1146 profile.max_resolution.SetSize(4096, 2160); |
| 1143 profiles.push_back(profile); | 1147 profiles.push_back(profile); |
| 1144 } | 1148 } |
| 1145 return profiles; | 1149 return profiles; |
| 1146 } | 1150 } |
| 1147 | 1151 |
| 1148 } // namespace media | 1152 } // namespace media |
| OLD | NEW |