| 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 <algorithm> | 5 #include <algorithm> |
| 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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | |
| 14 #include "base/logging.h" | 13 #include "base/logging.h" |
| 15 #include "base/mac/mac_logging.h" | 14 #include "base/mac/mac_logging.h" |
| 16 #include "base/macros.h" | 15 #include "base/macros.h" |
| 17 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 18 #include "base/sys_byteorder.h" | 17 #include "base/sys_byteorder.h" |
| 19 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
| 20 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
| 21 #include "base/version.h" | 20 #include "base/version.h" |
| 22 #include "content/common/gpu/media/vt_video_decode_accelerator_mac.h" | 21 #include "content/common/gpu/media/vt_video_decode_accelerator_mac.h" |
| 23 #include "content/public/common/content_switches.h" | |
| 24 #include "media/base/limits.h" | 22 #include "media/base/limits.h" |
| 25 #include "ui/gl/gl_context.h" | 23 #include "ui/gl/gl_context.h" |
| 26 #include "ui/gl/gl_image_io_surface.h" | 24 #include "ui/gl/gl_image_io_surface.h" |
| 27 #include "ui/gl/gl_implementation.h" | 25 #include "ui/gl/gl_implementation.h" |
| 28 #include "ui/gl/scoped_binders.h" | 26 #include "ui/gl/scoped_binders.h" |
| 29 | 27 |
| 30 using content_common_gpu_media::kModuleVt; | 28 using content_common_gpu_media::kModuleVt; |
| 31 using content_common_gpu_media::InitializeStubs; | 29 using content_common_gpu_media::InitializeStubs; |
| 32 using content_common_gpu_media::IsVtInitialized; | 30 using content_common_gpu_media::IsVtInitialized; |
| 33 using content_common_gpu_media::StubPathMap; | 31 using content_common_gpu_media::StubPathMap; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 return true; | 170 return true; |
| 173 } | 171 } |
| 174 | 172 |
| 175 // The purpose of this function is to preload the generic and hardware-specific | 173 // The purpose of this function is to preload the generic and hardware-specific |
| 176 // libraries required by VideoToolbox before the GPU sandbox is enabled. | 174 // libraries required by VideoToolbox before the GPU sandbox is enabled. |
| 177 // VideoToolbox normally loads the hardware-specific libraries lazily, so we | 175 // VideoToolbox normally loads the hardware-specific libraries lazily, so we |
| 178 // must actually create a decompression session. If creating a decompression | 176 // must actually create a decompression session. If creating a decompression |
| 179 // session fails, hardware decoding will be disabled (Initialize() will always | 177 // session fails, hardware decoding will be disabled (Initialize() will always |
| 180 // return false). | 178 // return false). |
| 181 static bool InitializeVideoToolboxInternal() { | 179 static bool InitializeVideoToolboxInternal() { |
| 182 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 183 switches::kDisableAcceleratedVideoDecode)) { | |
| 184 return false; | |
| 185 } | |
| 186 | |
| 187 if (!IsVtInitialized()) { | 180 if (!IsVtInitialized()) { |
| 188 // CoreVideo is also required, but the loader stops after the first path is | 181 // CoreVideo is also required, but the loader stops after the first path is |
| 189 // loaded. Instead we rely on the transitive dependency from VideoToolbox to | 182 // loaded. Instead we rely on the transitive dependency from VideoToolbox to |
| 190 // CoreVideo. | 183 // CoreVideo. |
| 191 StubPathMap paths; | 184 StubPathMap paths; |
| 192 paths[kModuleVt].push_back(FILE_PATH_LITERAL( | 185 paths[kModuleVt].push_back(FILE_PATH_LITERAL( |
| 193 "/System/Library/Frameworks/VideoToolbox.framework/VideoToolbox")); | 186 "/System/Library/Frameworks/VideoToolbox.framework/VideoToolbox")); |
| 194 if (!InitializeStubs(paths)) { | 187 if (!InitializeStubs(paths)) { |
| 195 LOG(WARNING) << "Failed to initialize VideoToolbox framework. " | 188 LOG(WARNING) << "Failed to initialize VideoToolbox framework. " |
| 196 << "Hardware accelerated video decoding will be disabled."; | 189 << "Hardware accelerated video decoding will be disabled."; |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 SupportedProfile profile; | 1157 SupportedProfile profile; |
| 1165 profile.profile = supported_profile; | 1158 profile.profile = supported_profile; |
| 1166 profile.min_resolution.SetSize(16, 16); | 1159 profile.min_resolution.SetSize(16, 16); |
| 1167 profile.max_resolution.SetSize(4096, 2160); | 1160 profile.max_resolution.SetSize(4096, 2160); |
| 1168 profiles.push_back(profile); | 1161 profiles.push_back(profile); |
| 1169 } | 1162 } |
| 1170 return profiles; | 1163 return profiles; |
| 1171 } | 1164 } |
| 1172 | 1165 |
| 1173 } // namespace content | 1166 } // namespace content |
| OLD | NEW |