Skip to content

Commit

Permalink
Apply clang-format to objective c code
Browse files Browse the repository at this point in the history
  • Loading branch information
DDRBoxman committed Jul 9, 2019
1 parent 617086b commit ad85a9f
Show file tree
Hide file tree
Showing 14 changed files with 1,103 additions and 1,133 deletions.
3 changes: 2 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# please use clang-format version 8 or later

Language: Cpp
Standard: Cpp11
AccessModifierOffset: -8
AlignAfterOpenBracket: Align
Expand Down Expand Up @@ -104,3 +103,5 @@ TabWidth: 8
#TypenameMacros: # requires clang-format 9
# - 'DARRAY'
UseTab: ForContinuationAndIndentation
---
Language: ObjC
20 changes: 11 additions & 9 deletions UI/platform-osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool InitApplicationBundle()
throw "Could not change working directory to "
"bundle path";

} catch (const char* error) {
} catch (const char *error) {
blog(LOG_ERROR, "InitBundle: %s", error);
return false;
}
Expand All @@ -77,7 +77,7 @@ string GetDefaultVideoSavePath()
appropriateForURL:nil
create:true
error:nil];

if (!url)
return getenv("HOME");

Expand All @@ -97,7 +97,7 @@ string GetDefaultVideoSavePath()
return locale.first;

if (!lang_match.size() &&
locale.first.substr(0, 2) == lang.substr(0, 2))
locale.first.substr(0, 2) == lang.substr(0, 2))
lang_match = locale.first;
}

Expand Down Expand Up @@ -150,12 +150,13 @@ void EnableOSXVSync(bool enable)

if (!initialized) {
void *quartzCore = dlopen("/System/Library/Frameworks/"
"QuartzCore.framework/QuartzCore", RTLD_LAZY);
"QuartzCore.framework/QuartzCore",
RTLD_LAZY);
if (quartzCore) {
set_debug_options = (set_int_t)dlsym(quartzCore,
"CGSSetDebugOptions");
deferred_updates = (set_int_t)dlsym(quartzCore,
"CGSDeferredUpdates");
set_debug_options = (set_int_t)dlsym(
quartzCore, "CGSSetDebugOptions");
deferred_updates = (set_int_t)dlsym(
quartzCore, "CGSDeferredUpdates");

valid = set_debug_options && deferred_updates;
}
Expand All @@ -174,5 +175,6 @@ void EnableOSXDockIcon(bool enable)
if (enable)
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
else
[NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited];
[NSApp setActivationPolicy:
NSApplicationActivationPolicyProhibited];
}
25 changes: 11 additions & 14 deletions UI/sparkle-updater.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ static inline bool equali(NSString *a, NSString *b)
return a && b && [a caseInsensitiveCompare:b] == NSOrderedSame;
}

@interface OBSSparkleUpdateDelegate :
NSObject<SUUpdaterDelegate, SUVersionComparison>
{
@interface OBSSparkleUpdateDelegate
: NSObject <SUUpdaterDelegate, SUVersionComparison> {
}
@property (nonatomic) bool updateToUndeployed;
@end

@implementation OBSSparkleUpdateDelegate
{
@implementation OBSSparkleUpdateDelegate {
}

@synthesize updateToUndeployed;
Expand Down Expand Up @@ -50,21 +48,21 @@ - (SUAppcastItem *)bestValidUpdateWithDeltasInAppcast:(SUAppcast *)appcast
item = mpkg;

NSMutableDictionary *dict = [NSMutableDictionary
dictionaryWithDictionary:item.propertiesDictionary];
dictionaryWithDictionary:item.propertiesDictionary];
NSString *build = [host objectForInfoDictionaryKey:@"CFBundleVersion"];
NSString *url = dict[@"sparkle:releaseNotesLink"];
dict[@"sparkle:releaseNotesLink"] = [url stringByAppendingFormat:@"#%@",
build];
dict[@"sparkle:releaseNotesLink"] =
[url stringByAppendingFormat:@"#%@", build];

return [[SUAppcastItem alloc] initWithDictionary:dict];
}

- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast
forUpdater:(SUUpdater *)updater
{
SUAppcastItem *selected =
[self bestValidUpdateWithDeltasInAppcast:appcast
forUpdater:updater];
SUAppcastItem *selected = [self
bestValidUpdateWithDeltasInAppcast:appcast
forUpdater:updater];

NSBundle *host = updater.hostBundle;
NSString *build = [host objectForInfoDictionaryKey:@"CFBundleVersion"];
Expand All @@ -91,8 +89,8 @@ - (NSComparisonResult)compareVersion:(NSString *)versionA
return NSOrderedSame;
}

- (id <SUVersionComparison>)
versionComparatorForUpdater:(SUUpdater *)__unused updater
- (id<SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)__unused
updater
{
return self;
}
Expand Down Expand Up @@ -141,4 +139,3 @@ void trigger_sparkle_update()
{
[updater checkForUpdates:nil];
}

119 changes: 59 additions & 60 deletions libobs-opengl/gl-cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>


//#include "util/darray.h"


struct gl_windowinfo {
NSView *view;
};
Expand All @@ -37,9 +35,15 @@
{
unsigned attrib_count = 0;

#define ADD_ATTR(x) \
{ attributes[attrib_count++] = (NSOpenGLPixelFormatAttribute)x; }
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
#define ADD_ATTR(x) \
{ \
attributes[attrib_count++] = (NSOpenGLPixelFormatAttribute)x; \
}
#define ADD_ATTR2(x, y) \
{ \
ADD_ATTR(x); \
ADD_ATTR(y); \
}

NSOpenGLPixelFormatAttribute attributes[40];

Expand All @@ -52,15 +56,15 @@

NSOpenGLPixelFormat *pf;
pf = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
if(!pf) {
if (!pf) {
blog(LOG_ERROR, "Failed to create pixel format");
return NULL;
}

NSOpenGLContext *context;
context = [[NSOpenGLContext alloc] initWithFormat:pf shareContext:nil];
[pf release];
if(!context) {
if (!context) {
blog(LOG_ERROR, "Failed to create context");
return NULL;
}
Expand Down Expand Up @@ -98,7 +102,7 @@

void gl_platform_destroy(struct gl_platform *platform)
{
if(!platform)
if (!platform)
return;

[platform->context release];
Expand All @@ -121,10 +125,10 @@ void gl_platform_cleanup_swapchain(struct gs_swap_chain *swap)

struct gl_windowinfo *gl_windowinfo_create(const struct gs_init_data *info)
{
if(!info)
if (!info)
return NULL;

if(!info->window.view)
if (!info->window.view)
return NULL;

struct gl_windowinfo *wi = bzalloc(sizeof(struct gl_windowinfo));
Expand All @@ -137,7 +141,7 @@ void gl_platform_cleanup_swapchain(struct gs_swap_chain *swap)

void gl_windowinfo_destroy(struct gl_windowinfo *wi)
{
if(!wi)
if (!wi)
return;

wi->view = nil;
Expand All @@ -163,7 +167,7 @@ void device_leave_context(gs_device_t *device)

void device_load_swapchain(gs_device_t *device, gs_swapchain_t *swap)
{
if(device->cur_swap == swap)
if (device->cur_swap == swap)
return;

device->cur_swap = swap;
Expand All @@ -180,38 +184,40 @@ void device_present(gs_device_t *device)
}

void gl_getclientsize(const struct gs_swap_chain *swap, uint32_t *width,
uint32_t *height)
uint32_t *height)
{
if(width) *width = swap->info.cx;
if(height) *height = swap->info.cy;
if (width)
*width = swap->info.cx;
if (height)
*height = swap->info.cy;
}

gs_texture_t *device_texture_create_from_iosurface(gs_device_t *device,
void *iosurf)
void *iosurf)
{
IOSurfaceRef ref = (IOSurfaceRef)iosurf;
struct gs_texture_2d *tex = bzalloc(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);
pf >> 24, pf >> 16, pf >> 8, pf);

const enum gs_color_format color_format = GS_BGRA;

tex->base.device = device;
tex->base.type = GS_TEXTURE_2D;
tex->base.format = GS_BGRA;
tex->base.levels = 1;
tex->base.gl_format = convert_gs_format(color_format);
tex->base.device = device;
tex->base.type = GS_TEXTURE_2D;
tex->base.format = GS_BGRA;
tex->base.levels = 1;
tex->base.gl_format = convert_gs_format(color_format);
tex->base.gl_internal_format = convert_gs_internal_format(color_format);
tex->base.gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
tex->base.gl_target = GL_TEXTURE_RECTANGLE;
tex->base.is_dynamic = false;
tex->base.is_render_target = false;
tex->base.gen_mipmaps = false;
tex->width = IOSurfaceGetWidth(ref);
tex->height = IOSurfaceGetHeight(ref);
tex->base.gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
tex->base.gl_target = GL_TEXTURE_RECTANGLE;
tex->base.is_dynamic = false;
tex->base.is_render_target = false;
tex->base.gen_mipmaps = false;
tex->width = IOSurfaceGetWidth(ref);
tex->height = IOSurfaceGetHeight(ref);

if (!gl_gen_textures(1, &tex->base.texture))
goto fail;
Expand All @@ -220,34 +226,30 @@ void gl_getclientsize(const struct gs_swap_chain *swap, uint32_t *width,
goto fail;

CGLError err = CGLTexImageIOSurface2D(
[[NSOpenGLContext currentContext] CGLContextObj],
tex->base.gl_target,
tex->base.gl_internal_format,
tex->width, tex->height,
tex->base.gl_format,
tex->base.gl_type,
ref, 0);

if(err != kCGLNoError) {
blog(LOG_ERROR, "CGLTexImageIOSurface2D: %u, %s"
" (device_texture_create_from_iosurface)",
err, CGLErrorString(err));
[[NSOpenGLContext currentContext] CGLContextObj],
tex->base.gl_target, tex->base.gl_internal_format, tex->width,
tex->height, tex->base.gl_format, tex->base.gl_type, ref, 0);

if (err != kCGLNoError) {
blog(LOG_ERROR,
"CGLTexImageIOSurface2D: %u, %s"
" (device_texture_create_from_iosurface)",
err, CGLErrorString(err));

gl_success("CGLTexImageIOSurface2D");
goto fail;
}

if (!gl_tex_param_i(tex->base.gl_target,
GL_TEXTURE_MAX_LEVEL, 0))
if (!gl_tex_param_i(tex->base.gl_target, GL_TEXTURE_MAX_LEVEL, 0))
goto fail;

if (!gl_bind_texture(tex->base.gl_target, 0))
goto fail;

return (gs_texture_t*)tex;
return (gs_texture_t *)tex;

fail:
gs_texture_destroy((gs_texture_t*)tex);
gs_texture_destroy((gs_texture_t *)tex);
blog(LOG_ERROR, "device_texture_create_from_iosurface (GL) failed");
return NULL;
}
Expand All @@ -260,34 +262,31 @@ bool gs_texture_rebind_iosurface(gs_texture_t *texture, void *iosurf)
if (!iosurf)
return false;

struct gs_texture_2d *tex = (struct gs_texture_2d*)texture;
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);
pf >> 24, pf >> 16, pf >> 8, pf);

if (tex->width != IOSurfaceGetWidth(ref) ||
tex->height != IOSurfaceGetHeight(ref))
tex->height != IOSurfaceGetHeight(ref))
return false;

if (!gl_bind_texture(tex->base.gl_target, tex->base.texture))
return false;

CGLError err = CGLTexImageIOSurface2D(
[[NSOpenGLContext currentContext] CGLContextObj],
tex->base.gl_target,
tex->base.gl_internal_format,
tex->width, tex->height,
tex->base.gl_format,
tex->base.gl_type,
ref, 0);

if(err != kCGLNoError) {
blog(LOG_ERROR, "CGLTexImageIOSurface2D: %u, %s"
" (gs_texture_rebind_iosurface)",
err, CGLErrorString(err));
[[NSOpenGLContext currentContext] CGLContextObj],
tex->base.gl_target, tex->base.gl_internal_format, tex->width,
tex->height, tex->base.gl_format, tex->base.gl_type, ref, 0);

if (err != kCGLNoError) {
blog(LOG_ERROR,
"CGLTexImageIOSurface2D: %u, %s"
" (gs_texture_rebind_iosurface)",
err, CGLErrorString(err));

gl_success("CGLTexImageIOSurface2D");
return false;
Expand Down
2 changes: 1 addition & 1 deletion libobs/obs-module.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ MODULE_EXPORT void obs_module_free_locale(void);
void obs_module_free_locale(void) \
{ \
text_lookup_destroy(obs_module_lookup); \
obs_module_lookup = NULL; \
obs_module_lookup = NULL; \
}

/** Helper function for looking up locale if default locale handler was used */
Expand Down
Loading

0 comments on commit ad85a9f

Please sign in to comment.