| 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 <dlfcn.h> | 5 #include <dlfcn.h> |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "ui/gl/io_surface_support_mac.h" | 8 #include "ui/gl/io_surface_support_mac.h" |
| 9 | 9 |
| 10 typedef CFTypeRef (*IOSurfaceCreateProcPtr)(CFDictionaryRef properties); | 10 typedef CFTypeRef (*IOSurfaceCreateProcPtr)(CFDictionaryRef properties); |
| 11 typedef uint32 (*IOSurfaceGetIDProcPtr)(CFTypeRef io_surface); | 11 typedef uint32 (*IOSurfaceGetIDProcPtr)(CFTypeRef io_surface); |
| 12 typedef CFTypeRef (*IOSurfaceLookupProcPtr)(uint32 io_surface_id); | 12 typedef CFTypeRef (*IOSurfaceLookupProcPtr)(uint32 io_surface_id); |
| 13 typedef mach_port_t (*IOSurfaceCreateMachPortProcPtr)(CFTypeRef io_surface); | 13 typedef mach_port_t (*IOSurfaceCreateMachPortProcPtr)(CFTypeRef io_surface); |
| 14 typedef CFTypeRef (*IOSurfaceLookupFromMachPortProcPtr)(mach_port_t port); | 14 typedef CFTypeRef (*IOSurfaceLookupFromMachPortProcPtr)(mach_port_t port); |
| 15 typedef size_t (*IOSurfaceGetWidthPtr)(CFTypeRef io_surface); | 15 typedef size_t (*IOSurfaceGetWidthPtr)(CFTypeRef io_surface); |
| 16 typedef size_t (*IOSurfaceGetHeightPtr)(CFTypeRef io_surface); | 16 typedef size_t (*IOSurfaceGetHeightPtr)(CFTypeRef io_surface); |
| 17 typedef size_t (*IOSurfaceGetBytesPerRowPtr)(CFTypeRef io_surface); |
| 18 typedef void* (*IOSurfaceGetBaseAddressPtr)(CFTypeRef io_surface); |
| 19 typedef IOReturn (*IOSurfaceLockPtr)(CFTypeRef io_surface, |
| 20 uint32 options, |
| 21 uint32* seed); |
| 22 typedef IOReturn (*IOSurfaceUnlockPtr)(CFTypeRef io_surface, |
| 23 uint32 options, |
| 24 uint32* seed); |
| 25 |
| 17 typedef CGLError (*CGLTexImageIOSurface2DProcPtr)(CGLContextObj ctx, | 26 typedef CGLError (*CGLTexImageIOSurface2DProcPtr)(CGLContextObj ctx, |
| 18 GLenum target, | 27 GLenum target, |
| 19 GLenum internal_format, | 28 GLenum internal_format, |
| 20 GLsizei width, | 29 GLsizei width, |
| 21 GLsizei height, | 30 GLsizei height, |
| 22 GLenum format, | 31 GLenum format, |
| 23 GLenum type, | 32 GLenum type, |
| 24 CFTypeRef io_surface, | 33 CFTypeRef io_surface, |
| 25 GLuint plane); | 34 GLuint plane); |
| 26 typedef CFTypeRef (*CVPixelBufferGetIOSurfaceProcPtr)( | 35 typedef CFTypeRef (*CVPixelBufferGetIOSurfaceProcPtr)( |
| 27 CVPixelBufferRef pixel_buffer); | 36 CVPixelBufferRef pixel_buffer); |
| 28 | 37 |
| 29 class IOSurfaceSupportImpl : public IOSurfaceSupport { | 38 class IOSurfaceSupportImpl : public IOSurfaceSupport { |
| 30 public: | 39 public: |
| 31 static IOSurfaceSupportImpl* GetInstance(); | 40 static IOSurfaceSupportImpl* GetInstance(); |
| 32 | 41 |
| 33 bool InitializedSuccessfully() { | 42 bool InitializedSuccessfully() { |
| 34 return initialized_successfully_; | 43 return initialized_successfully_; |
| 35 } | 44 } |
| 36 | 45 |
| 37 virtual CFStringRef GetKIOSurfaceWidth() OVERRIDE; | 46 virtual CFStringRef GetKIOSurfaceWidth() OVERRIDE; |
| 38 virtual CFStringRef GetKIOSurfaceHeight() OVERRIDE; | 47 virtual CFStringRef GetKIOSurfaceHeight() OVERRIDE; |
| 39 virtual CFStringRef GetKIOSurfaceBytesPerElement() OVERRIDE; | 48 virtual CFStringRef GetKIOSurfaceBytesPerElement() OVERRIDE; |
| 49 virtual CFStringRef GetKIOSurfacePixelFormat() OVERRIDE; |
| 40 virtual CFStringRef GetKIOSurfaceIsGlobal() OVERRIDE; | 50 virtual CFStringRef GetKIOSurfaceIsGlobal() OVERRIDE; |
| 41 | 51 |
| 42 virtual CFTypeRef IOSurfaceCreate(CFDictionaryRef properties) OVERRIDE; | 52 virtual CFTypeRef IOSurfaceCreate(CFDictionaryRef properties) OVERRIDE; |
| 43 virtual uint32 IOSurfaceGetID(CFTypeRef io_surface) OVERRIDE; | 53 virtual uint32 IOSurfaceGetID(CFTypeRef io_surface) OVERRIDE; |
| 44 virtual CFTypeRef IOSurfaceLookup(uint32 io_surface_id) OVERRIDE; | 54 virtual CFTypeRef IOSurfaceLookup(uint32 io_surface_id) OVERRIDE; |
| 45 virtual mach_port_t IOSurfaceCreateMachPort(CFTypeRef io_surface) OVERRIDE; | 55 virtual mach_port_t IOSurfaceCreateMachPort(CFTypeRef io_surface) OVERRIDE; |
| 46 virtual CFTypeRef IOSurfaceLookupFromMachPort(mach_port_t port) OVERRIDE; | 56 virtual CFTypeRef IOSurfaceLookupFromMachPort(mach_port_t port) OVERRIDE; |
| 47 | 57 |
| 48 virtual size_t IOSurfaceGetWidth(CFTypeRef io_surface) OVERRIDE; | 58 virtual size_t IOSurfaceGetWidth(CFTypeRef io_surface) OVERRIDE; |
| 49 virtual size_t IOSurfaceGetHeight(CFTypeRef io_surface) OVERRIDE; | 59 virtual size_t IOSurfaceGetHeight(CFTypeRef io_surface) OVERRIDE; |
| 60 virtual size_t IOSurfaceGetBytesPerRow(CFTypeRef io_surface) OVERRIDE; |
| 61 virtual void* IOSurfaceGetBaseAddress(CFTypeRef io_surface) OVERRIDE; |
| 62 |
| 63 virtual IOReturn IOSurfaceLock(CFTypeRef io_surface, |
| 64 uint32 options, |
| 65 uint32* seed) OVERRIDE; |
| 66 virtual IOReturn IOSurfaceUnlock(CFTypeRef io_surface, |
| 67 uint32 options, |
| 68 uint32* seed) OVERRIDE; |
| 50 | 69 |
| 51 virtual CGLError CGLTexImageIOSurface2D(CGLContextObj ctx, | 70 virtual CGLError CGLTexImageIOSurface2D(CGLContextObj ctx, |
| 52 GLenum target, | 71 GLenum target, |
| 53 GLenum internal_format, | 72 GLenum internal_format, |
| 54 GLsizei width, | 73 GLsizei width, |
| 55 GLsizei height, | 74 GLsizei height, |
| 56 GLenum format, | 75 GLenum format, |
| 57 GLenum type, | 76 GLenum type, |
| 58 CFTypeRef io_surface, | 77 CFTypeRef io_surface, |
| 59 GLuint plane) OVERRIDE; | 78 GLuint plane) OVERRIDE; |
| 60 | 79 |
| 61 virtual CFTypeRef CVPixelBufferGetIOSurface( | 80 virtual CFTypeRef CVPixelBufferGetIOSurface( |
| 62 CVPixelBufferRef pixel_buffer) OVERRIDE; | 81 CVPixelBufferRef pixel_buffer) OVERRIDE; |
| 63 | 82 |
| 64 private: | 83 private: |
| 65 IOSurfaceSupportImpl(); | 84 IOSurfaceSupportImpl(); |
| 66 virtual ~IOSurfaceSupportImpl(); | 85 virtual ~IOSurfaceSupportImpl(); |
| 67 | 86 |
| 68 void CloseLibraryHandles(); | 87 void CloseLibraryHandles(); |
| 69 | 88 |
| 70 void* iosurface_handle_; | 89 void* iosurface_handle_; |
| 71 void* opengl_handle_; | 90 void* opengl_handle_; |
| 72 void* core_video_handle_; | 91 void* core_video_handle_; |
| 73 CFStringRef k_io_surface_width_; | 92 CFStringRef k_io_surface_width_; |
| 74 CFStringRef k_io_surface_height_; | 93 CFStringRef k_io_surface_height_; |
| 75 CFStringRef k_io_surface_bytes_per_element_; | 94 CFStringRef k_io_surface_bytes_per_element_; |
| 95 CFStringRef k_io_surface_pixel_format_; |
| 76 CFStringRef k_io_surface_is_global_; | 96 CFStringRef k_io_surface_is_global_; |
| 77 IOSurfaceCreateProcPtr io_surface_create_; | 97 IOSurfaceCreateProcPtr io_surface_create_; |
| 78 IOSurfaceGetIDProcPtr io_surface_get_id_; | 98 IOSurfaceGetIDProcPtr io_surface_get_id_; |
| 79 IOSurfaceLookupProcPtr io_surface_lookup_; | 99 IOSurfaceLookupProcPtr io_surface_lookup_; |
| 80 IOSurfaceCreateMachPortProcPtr io_surface_create_mach_port_; | 100 IOSurfaceCreateMachPortProcPtr io_surface_create_mach_port_; |
| 81 IOSurfaceLookupFromMachPortProcPtr io_surface_lookup_from_mach_port_; | 101 IOSurfaceLookupFromMachPortProcPtr io_surface_lookup_from_mach_port_; |
| 82 IOSurfaceGetWidthPtr io_surface_get_width_; | 102 IOSurfaceGetWidthPtr io_surface_get_width_; |
| 83 IOSurfaceGetHeightPtr io_surface_get_height_; | 103 IOSurfaceGetHeightPtr io_surface_get_height_; |
| 104 IOSurfaceGetBytesPerRowPtr io_surface_get_bytes_per_row_; |
| 105 IOSurfaceGetBaseAddressPtr io_surface_get_base_address_; |
| 106 IOSurfaceLockPtr io_surface_lock_; |
| 107 IOSurfaceUnlockPtr io_surface_unlock_; |
| 84 CGLTexImageIOSurface2DProcPtr cgl_tex_image_io_surface_2d_; | 108 CGLTexImageIOSurface2DProcPtr cgl_tex_image_io_surface_2d_; |
| 85 CVPixelBufferGetIOSurfaceProcPtr cv_pixel_buffer_get_io_surface_; | 109 CVPixelBufferGetIOSurfaceProcPtr cv_pixel_buffer_get_io_surface_; |
| 86 bool initialized_successfully_; | 110 bool initialized_successfully_; |
| 87 | 111 |
| 88 friend struct DefaultSingletonTraits<IOSurfaceSupportImpl>; | 112 friend struct DefaultSingletonTraits<IOSurfaceSupportImpl>; |
| 89 DISALLOW_COPY_AND_ASSIGN(IOSurfaceSupportImpl); | 113 DISALLOW_COPY_AND_ASSIGN(IOSurfaceSupportImpl); |
| 90 }; | 114 }; |
| 91 | 115 |
| 92 IOSurfaceSupportImpl* IOSurfaceSupportImpl::GetInstance() { | 116 IOSurfaceSupportImpl* IOSurfaceSupportImpl::GetInstance() { |
| 93 IOSurfaceSupportImpl* impl = Singleton<IOSurfaceSupportImpl>::get(); | 117 IOSurfaceSupportImpl* impl = Singleton<IOSurfaceSupportImpl>::get(); |
| 94 if (impl->InitializedSuccessfully()) | 118 if (impl->InitializedSuccessfully()) |
| 95 return impl; | 119 return impl; |
| 96 return NULL; | 120 return NULL; |
| 97 } | 121 } |
| 98 | 122 |
| 99 CFStringRef IOSurfaceSupportImpl::GetKIOSurfaceWidth() { | 123 CFStringRef IOSurfaceSupportImpl::GetKIOSurfaceWidth() { |
| 100 return k_io_surface_width_; | 124 return k_io_surface_width_; |
| 101 } | 125 } |
| 102 | 126 |
| 103 CFStringRef IOSurfaceSupportImpl::GetKIOSurfaceHeight() { | 127 CFStringRef IOSurfaceSupportImpl::GetKIOSurfaceHeight() { |
| 104 return k_io_surface_height_; | 128 return k_io_surface_height_; |
| 105 } | 129 } |
| 106 | 130 |
| 107 CFStringRef IOSurfaceSupportImpl::GetKIOSurfaceBytesPerElement() { | 131 CFStringRef IOSurfaceSupportImpl::GetKIOSurfaceBytesPerElement() { |
| 108 return k_io_surface_bytes_per_element_; | 132 return k_io_surface_bytes_per_element_; |
| 109 } | 133 } |
| 110 | 134 |
| 135 CFStringRef IOSurfaceSupportImpl::GetKIOSurfacePixelFormat() { |
| 136 return k_io_surface_pixel_format_; |
| 137 } |
| 138 |
| 111 CFStringRef IOSurfaceSupportImpl::GetKIOSurfaceIsGlobal() { | 139 CFStringRef IOSurfaceSupportImpl::GetKIOSurfaceIsGlobal() { |
| 112 return k_io_surface_is_global_; | 140 return k_io_surface_is_global_; |
| 113 } | 141 } |
| 114 | 142 |
| 115 CFTypeRef IOSurfaceSupportImpl::IOSurfaceCreate(CFDictionaryRef properties) { | 143 CFTypeRef IOSurfaceSupportImpl::IOSurfaceCreate(CFDictionaryRef properties) { |
| 116 return io_surface_create_(properties); | 144 return io_surface_create_(properties); |
| 117 } | 145 } |
| 118 | 146 |
| 119 uint32 IOSurfaceSupportImpl::IOSurfaceGetID( | 147 uint32 IOSurfaceSupportImpl::IOSurfaceGetID( |
| 120 CFTypeRef io_surface) { | 148 CFTypeRef io_surface) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 135 } | 163 } |
| 136 | 164 |
| 137 size_t IOSurfaceSupportImpl::IOSurfaceGetWidth(CFTypeRef io_surface) { | 165 size_t IOSurfaceSupportImpl::IOSurfaceGetWidth(CFTypeRef io_surface) { |
| 138 return io_surface_get_width_(io_surface); | 166 return io_surface_get_width_(io_surface); |
| 139 } | 167 } |
| 140 | 168 |
| 141 size_t IOSurfaceSupportImpl::IOSurfaceGetHeight(CFTypeRef io_surface) { | 169 size_t IOSurfaceSupportImpl::IOSurfaceGetHeight(CFTypeRef io_surface) { |
| 142 return io_surface_get_height_(io_surface); | 170 return io_surface_get_height_(io_surface); |
| 143 } | 171 } |
| 144 | 172 |
| 173 size_t IOSurfaceSupportImpl::IOSurfaceGetBytesPerRow(CFTypeRef io_surface) { |
| 174 return io_surface_get_bytes_per_row_(io_surface); |
| 175 } |
| 176 |
| 177 void* IOSurfaceSupportImpl::IOSurfaceGetBaseAddress(CFTypeRef io_surface) { |
| 178 return io_surface_get_base_address_(io_surface); |
| 179 } |
| 180 |
| 181 IOReturn IOSurfaceSupportImpl::IOSurfaceLock(CFTypeRef io_surface, |
| 182 uint32 options, |
| 183 uint32* seed) { |
| 184 return io_surface_lock_(io_surface, options, seed); |
| 185 } |
| 186 |
| 187 IOReturn IOSurfaceSupportImpl::IOSurfaceUnlock(CFTypeRef io_surface, |
| 188 uint32 options, |
| 189 uint32* seed) { |
| 190 return io_surface_unlock_(io_surface, options, seed); |
| 191 } |
| 145 | 192 |
| 146 CGLError IOSurfaceSupportImpl::CGLTexImageIOSurface2D(CGLContextObj ctx, | 193 CGLError IOSurfaceSupportImpl::CGLTexImageIOSurface2D(CGLContextObj ctx, |
| 147 GLenum target, | 194 GLenum target, |
| 148 GLenum internal_format, | 195 GLenum internal_format, |
| 149 GLsizei width, | 196 GLsizei width, |
| 150 GLsizei height, | 197 GLsizei height, |
| 151 GLenum format, | 198 GLenum format, |
| 152 GLenum type, | 199 GLenum type, |
| 153 CFTypeRef io_surface, | 200 CFTypeRef io_surface, |
| 154 GLuint plane) { | 201 GLuint plane) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 168 return cv_pixel_buffer_get_io_surface_(pixel_buffer); | 215 return cv_pixel_buffer_get_io_surface_(pixel_buffer); |
| 169 } | 216 } |
| 170 | 217 |
| 171 IOSurfaceSupportImpl::IOSurfaceSupportImpl() | 218 IOSurfaceSupportImpl::IOSurfaceSupportImpl() |
| 172 : iosurface_handle_(NULL), | 219 : iosurface_handle_(NULL), |
| 173 opengl_handle_(NULL), | 220 opengl_handle_(NULL), |
| 174 core_video_handle_(NULL), | 221 core_video_handle_(NULL), |
| 175 k_io_surface_width_(NULL), | 222 k_io_surface_width_(NULL), |
| 176 k_io_surface_height_(NULL), | 223 k_io_surface_height_(NULL), |
| 177 k_io_surface_bytes_per_element_(NULL), | 224 k_io_surface_bytes_per_element_(NULL), |
| 225 k_io_surface_pixel_format_(NULL), |
| 178 k_io_surface_is_global_(NULL), | 226 k_io_surface_is_global_(NULL), |
| 179 io_surface_create_(NULL), | 227 io_surface_create_(NULL), |
| 180 io_surface_get_id_(NULL), | 228 io_surface_get_id_(NULL), |
| 181 io_surface_lookup_(NULL), | 229 io_surface_lookup_(NULL), |
| 182 io_surface_create_mach_port_(NULL), | 230 io_surface_create_mach_port_(NULL), |
| 183 io_surface_lookup_from_mach_port_(NULL), | 231 io_surface_lookup_from_mach_port_(NULL), |
| 184 io_surface_get_width_(NULL), | 232 io_surface_get_width_(NULL), |
| 185 io_surface_get_height_(NULL), | 233 io_surface_get_height_(NULL), |
| 234 io_surface_get_bytes_per_row_(NULL), |
| 235 io_surface_get_base_address_(NULL), |
| 236 io_surface_lock_(NULL), |
| 237 io_surface_unlock_(NULL), |
| 186 cgl_tex_image_io_surface_2d_(NULL), | 238 cgl_tex_image_io_surface_2d_(NULL), |
| 187 cv_pixel_buffer_get_io_surface_(NULL), | 239 cv_pixel_buffer_get_io_surface_(NULL), |
| 188 initialized_successfully_(false) { | 240 initialized_successfully_(false) { |
| 189 iosurface_handle_ = dlopen( | 241 iosurface_handle_ = dlopen( |
| 190 "/System/Library/Frameworks/IOSurface.framework/IOSurface", | 242 "/System/Library/Frameworks/IOSurface.framework/IOSurface", |
| 191 RTLD_LAZY | RTLD_LOCAL); | 243 RTLD_LAZY | RTLD_LOCAL); |
| 192 opengl_handle_ = dlopen( | 244 opengl_handle_ = dlopen( |
| 193 "/System/Library/Frameworks/OpenGL.framework/OpenGL", | 245 "/System/Library/Frameworks/OpenGL.framework/OpenGL", |
| 194 RTLD_LAZY | RTLD_LOCAL); | 246 RTLD_LAZY | RTLD_LOCAL); |
| 195 core_video_handle_ = dlopen( | 247 core_video_handle_ = dlopen( |
| 196 "/System/Library/Frameworks/CoreVideo.framework/CoreVideo", | 248 "/System/Library/Frameworks/CoreVideo.framework/CoreVideo", |
| 197 RTLD_LAZY | RTLD_LOCAL); | 249 RTLD_LAZY | RTLD_LOCAL); |
| 198 if (!iosurface_handle_ || | 250 if (!iosurface_handle_ || |
| 199 !opengl_handle_ || | 251 !opengl_handle_ || |
| 200 !core_video_handle_) { | 252 !core_video_handle_) { |
| 201 CloseLibraryHandles(); | 253 CloseLibraryHandles(); |
| 202 return; | 254 return; |
| 203 } | 255 } |
| 204 | 256 |
| 205 void* surface_width_ptr = dlsym(iosurface_handle_, "kIOSurfaceWidth"); | 257 void* surface_width_ptr = dlsym(iosurface_handle_, "kIOSurfaceWidth"); |
| 206 void* surface_height_ptr = dlsym(iosurface_handle_, "kIOSurfaceHeight"); | 258 void* surface_height_ptr = dlsym(iosurface_handle_, "kIOSurfaceHeight"); |
| 207 void* surface_bytes_per_element_ptr = | 259 void* surface_bytes_per_element_ptr = |
| 208 dlsym(iosurface_handle_, "kIOSurfaceBytesPerElement"); | 260 dlsym(iosurface_handle_, "kIOSurfaceBytesPerElement"); |
| 261 void* surface_pixel_format_ptr = |
| 262 dlsym(iosurface_handle_, "kIOSurfacePixelFormat"); |
| 209 void* surface_is_global_ptr = | 263 void* surface_is_global_ptr = |
| 210 dlsym(iosurface_handle_, "kIOSurfaceIsGlobal"); | 264 dlsym(iosurface_handle_, "kIOSurfaceIsGlobal"); |
| 211 void* surface_create_ptr = dlsym(iosurface_handle_, "IOSurfaceCreate"); | 265 void* surface_create_ptr = dlsym(iosurface_handle_, "IOSurfaceCreate"); |
| 212 void* surface_get_id_ptr = dlsym(iosurface_handle_, "IOSurfaceGetID"); | 266 void* surface_get_id_ptr = dlsym(iosurface_handle_, "IOSurfaceGetID"); |
| 213 void* surface_lookup_ptr = dlsym(iosurface_handle_, "IOSurfaceLookup"); | 267 void* surface_lookup_ptr = dlsym(iosurface_handle_, "IOSurfaceLookup"); |
| 214 void* surface_create_mach_port_ptr = | 268 void* surface_create_mach_port_ptr = |
| 215 dlsym(iosurface_handle_, "IOSurfaceCreateMachPort"); | 269 dlsym(iosurface_handle_, "IOSurfaceCreateMachPort"); |
| 216 void* surface_lookup_from_mach_port_ptr = | 270 void* surface_lookup_from_mach_port_ptr = |
| 217 dlsym(iosurface_handle_, "IOSurfaceLookupFromMachPort"); | 271 dlsym(iosurface_handle_, "IOSurfaceLookupFromMachPort"); |
| 218 void* io_surface_get_width_ptr = | 272 void* io_surface_get_width_ptr = |
| 219 dlsym(iosurface_handle_, "IOSurfaceGetWidth"); | 273 dlsym(iosurface_handle_, "IOSurfaceGetWidth"); |
| 220 void* io_surface_get_height_ptr = | 274 void* io_surface_get_height_ptr = |
| 221 dlsym(iosurface_handle_, "IOSurfaceGetHeight"); | 275 dlsym(iosurface_handle_, "IOSurfaceGetHeight"); |
| 276 void* io_surface_get_bytes_per_row_ptr = |
| 277 dlsym(iosurface_handle_, "IOSurfaceGetBytesPerRow"); |
| 278 void* io_surface_get_base_address_ptr = |
| 279 dlsym(iosurface_handle_, "IOSurfaceGetBaseAddress"); |
| 280 void* io_surface_lock_ptr = dlsym(iosurface_handle_, "IOSurfaceLock"); |
| 281 void* io_surface_unlock_ptr = dlsym(iosurface_handle_, "IOSurfaceUnlock"); |
| 222 void* tex_image_io_surface_2d_ptr = | 282 void* tex_image_io_surface_2d_ptr = |
| 223 dlsym(opengl_handle_, "CGLTexImageIOSurface2D"); | 283 dlsym(opengl_handle_, "CGLTexImageIOSurface2D"); |
| 224 void* cv_pixel_buffer_get_io_surface = | 284 void* cv_pixel_buffer_get_io_surface = |
| 225 dlsym(core_video_handle_, "CVPixelBufferGetIOSurface"); | 285 dlsym(core_video_handle_, "CVPixelBufferGetIOSurface"); |
| 226 if (!surface_width_ptr || | 286 if (!surface_width_ptr || |
| 227 !surface_height_ptr || | 287 !surface_height_ptr || |
| 228 !surface_bytes_per_element_ptr || | 288 !surface_bytes_per_element_ptr || |
| 289 !surface_pixel_format_ptr || |
| 229 !surface_is_global_ptr || | 290 !surface_is_global_ptr || |
| 230 !surface_create_ptr || | 291 !surface_create_ptr || |
| 231 !surface_get_id_ptr || | 292 !surface_get_id_ptr || |
| 232 !surface_lookup_ptr || | 293 !surface_lookup_ptr || |
| 233 !surface_create_mach_port_ptr || | 294 !surface_create_mach_port_ptr || |
| 234 !surface_lookup_from_mach_port_ptr || | 295 !surface_lookup_from_mach_port_ptr || |
| 235 !io_surface_get_width_ptr || | 296 !io_surface_get_width_ptr || |
| 236 !io_surface_get_height_ptr || | 297 !io_surface_get_height_ptr || |
| 298 !io_surface_get_bytes_per_row_ptr || |
| 299 !io_surface_get_base_address_ptr || |
| 300 !io_surface_lock_ptr || |
| 301 !io_surface_unlock_ptr || |
| 237 !tex_image_io_surface_2d_ptr || | 302 !tex_image_io_surface_2d_ptr || |
| 238 !cv_pixel_buffer_get_io_surface) { | 303 !cv_pixel_buffer_get_io_surface) { |
| 239 CloseLibraryHandles(); | 304 CloseLibraryHandles(); |
| 240 return; | 305 return; |
| 241 } | 306 } |
| 242 | 307 |
| 243 k_io_surface_width_ = *static_cast<CFStringRef*>(surface_width_ptr); | 308 k_io_surface_width_ = *static_cast<CFStringRef*>(surface_width_ptr); |
| 244 k_io_surface_height_ = *static_cast<CFStringRef*>(surface_height_ptr); | 309 k_io_surface_height_ = *static_cast<CFStringRef*>(surface_height_ptr); |
| 245 k_io_surface_bytes_per_element_ = | 310 k_io_surface_bytes_per_element_ = |
| 246 *static_cast<CFStringRef*>(surface_bytes_per_element_ptr); | 311 *static_cast<CFStringRef*>(surface_bytes_per_element_ptr); |
| 312 k_io_surface_pixel_format_ = |
| 313 *static_cast<CFStringRef*>(surface_pixel_format_ptr); |
| 247 k_io_surface_is_global_ = *static_cast<CFStringRef*>(surface_is_global_ptr); | 314 k_io_surface_is_global_ = *static_cast<CFStringRef*>(surface_is_global_ptr); |
| 248 io_surface_create_ = reinterpret_cast<IOSurfaceCreateProcPtr>( | 315 io_surface_create_ = reinterpret_cast<IOSurfaceCreateProcPtr>( |
| 249 surface_create_ptr); | 316 surface_create_ptr); |
| 250 io_surface_get_id_ = | 317 io_surface_get_id_ = |
| 251 reinterpret_cast<IOSurfaceGetIDProcPtr>(surface_get_id_ptr); | 318 reinterpret_cast<IOSurfaceGetIDProcPtr>(surface_get_id_ptr); |
| 252 io_surface_lookup_ = | 319 io_surface_lookup_ = |
| 253 reinterpret_cast<IOSurfaceLookupProcPtr>(surface_lookup_ptr); | 320 reinterpret_cast<IOSurfaceLookupProcPtr>(surface_lookup_ptr); |
| 254 io_surface_create_mach_port_ = | 321 io_surface_create_mach_port_ = |
| 255 reinterpret_cast<IOSurfaceCreateMachPortProcPtr>( | 322 reinterpret_cast<IOSurfaceCreateMachPortProcPtr>( |
| 256 surface_create_mach_port_ptr); | 323 surface_create_mach_port_ptr); |
| 257 io_surface_lookup_from_mach_port_ = | 324 io_surface_lookup_from_mach_port_ = |
| 258 reinterpret_cast<IOSurfaceLookupFromMachPortProcPtr>( | 325 reinterpret_cast<IOSurfaceLookupFromMachPortProcPtr>( |
| 259 surface_lookup_from_mach_port_ptr); | 326 surface_lookup_from_mach_port_ptr); |
| 260 io_surface_get_width_ = | 327 io_surface_get_width_ = |
| 261 reinterpret_cast<IOSurfaceGetWidthPtr>( | 328 reinterpret_cast<IOSurfaceGetWidthPtr>( |
| 262 io_surface_get_width_ptr); | 329 io_surface_get_width_ptr); |
| 263 io_surface_get_height_ = | 330 io_surface_get_height_ = |
| 264 reinterpret_cast<IOSurfaceGetHeightPtr>( | 331 reinterpret_cast<IOSurfaceGetHeightPtr>( |
| 265 io_surface_get_height_ptr); | 332 io_surface_get_height_ptr); |
| 333 io_surface_get_bytes_per_row_ = |
| 334 reinterpret_cast<IOSurfaceGetBytesPerRowPtr>( |
| 335 io_surface_get_bytes_per_row_ptr); |
| 336 io_surface_get_base_address_ = |
| 337 reinterpret_cast<IOSurfaceGetBaseAddressPtr>( |
| 338 io_surface_get_base_address_ptr); |
| 339 io_surface_lock_ = reinterpret_cast<IOSurfaceLockPtr>(io_surface_lock_ptr); |
| 340 io_surface_unlock_ = reinterpret_cast<IOSurfaceUnlockPtr>( |
| 341 io_surface_unlock_ptr); |
| 266 cgl_tex_image_io_surface_2d_ = | 342 cgl_tex_image_io_surface_2d_ = |
| 267 reinterpret_cast<CGLTexImageIOSurface2DProcPtr>( | 343 reinterpret_cast<CGLTexImageIOSurface2DProcPtr>( |
| 268 tex_image_io_surface_2d_ptr); | 344 tex_image_io_surface_2d_ptr); |
| 269 cv_pixel_buffer_get_io_surface_ = | 345 cv_pixel_buffer_get_io_surface_ = |
| 270 reinterpret_cast<CVPixelBufferGetIOSurfaceProcPtr>( | 346 reinterpret_cast<CVPixelBufferGetIOSurfaceProcPtr>( |
| 271 cv_pixel_buffer_get_io_surface); | 347 cv_pixel_buffer_get_io_surface); |
| 272 initialized_successfully_ = true; | 348 initialized_successfully_ = true; |
| 273 } | 349 } |
| 274 | 350 |
| 275 IOSurfaceSupportImpl::~IOSurfaceSupportImpl() { | 351 IOSurfaceSupportImpl::~IOSurfaceSupportImpl() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 294 IOSurfaceSupport* IOSurfaceSupport::Initialize() { | 370 IOSurfaceSupport* IOSurfaceSupport::Initialize() { |
| 295 return IOSurfaceSupportImpl::GetInstance(); | 371 return IOSurfaceSupportImpl::GetInstance(); |
| 296 } | 372 } |
| 297 | 373 |
| 298 IOSurfaceSupport::IOSurfaceSupport() { | 374 IOSurfaceSupport::IOSurfaceSupport() { |
| 299 } | 375 } |
| 300 | 376 |
| 301 IOSurfaceSupport::~IOSurfaceSupport() { | 377 IOSurfaceSupport::~IOSurfaceSupport() { |
| 302 } | 378 } |
| 303 | 379 |
| OLD | NEW |