From d9e1362cceaa053ebc1baeed137f15939cc1f172 Mon Sep 17 00:00:00 2001 From: Palana Date: Tue, 24 Dec 2013 17:07:58 +0100 Subject: [PATCH] add pixel format check for iosurfaces --- libobs-opengl/gl-cocoa.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libobs-opengl/gl-cocoa.m b/libobs-opengl/gl-cocoa.m index bf80b4fc0..213cac4d5 100644 --- a/libobs-opengl/gl-cocoa.m +++ b/libobs-opengl/gl-cocoa.m @@ -259,6 +259,11 @@ texture_t texture_create_from_iosurface(device_t device, void *iosurf) struct gs_texture_2d *tex = bmalloc(sizeof(struct gs_texture_2d)); memset(tex, 0, sizeof(struct gs_texture_2d)); + OSType pf = IOSurfaceGetPixelFormat(ref); + if (pf != 'BGRA') + blog(LOG_ERROR, "Unexpected pixel format: %d (%c%c%c%c)", pf, + pf >> 24, pf >> 16, pf >> 8, pf); + const enum gs_color_format color_format = GS_BGRA; tex->base.device = device; @@ -325,6 +330,11 @@ bool texture_rebind_iosurface(texture_t texture, void *iosurf) struct gs_texture_2d *tex = (struct gs_texture_2d*)texture; IOSurfaceRef ref = (IOSurfaceRef)iosurf; + OSType pf = IOSurfaceGetPixelFormat(ref); + if (pf != 'BGRA') + blog(LOG_ERROR, "Unexpected pixel format: %d (%c%c%c%c)", pf, + pf >> 24, pf >> 16, pf >> 8, pf); + if (tex->width != IOSurfaceGetWidth(ref) || tex->height != IOSurfaceGetHeight(ref)) return false;