From b6eb3966266356f04d131c8dc2b70c5af60e4015 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 17 Dec 2025 07:36:40 +1100 Subject: [PATCH] macOS: Fix some small mistakes with reference counting --- src/Window_cocoa.m | 13 +++++++------ src/dreamcast/VertexClip2.S | 16 ++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/Window_cocoa.m b/src/Window_cocoa.m index 9168088d2..6bcba72c2 100644 --- a/src/Window_cocoa.m +++ b/src/Window_cocoa.m @@ -349,7 +349,8 @@ static void ApplyIcon(void) { img = [img initWithSize:NSMakeSize(CCIcon_Width, CCIcon_Height)]; [img addRepresentation:rep]; [appHandle setApplicationIconImage:img]; - //[img release]; + + [img release]; } static pascal OSErr HandleQuitMessage(const AppleEvent* ev, AppleEvent* reply, long handlerRefcon) { @@ -404,7 +405,6 @@ void Window_SetTitle(const cc_string* title) { str = [NSString stringWithUTF8String:raw]; [winHandle setTitle:str]; - [str release]; } // NOTE: Only defined since macOS 10.7 SDK @@ -781,7 +781,7 @@ static int SupportsModernFullscreen(void) { return [winHandle respondsToSelector:@selector(toggleFullScreen:)]; } -static NSOpenGLPixelFormat* MakePixelFormat(cc_bool fullscreen) { +static NSOpenGLPixelFormat* InitPixelFormat(cc_bool fullscreen) { // TODO: Is there a penalty for fullscreen contexts in 10.7 and later? // Need to test whether there is a performance penalty or not if (SupportsModernFullscreen()) fullscreen = false; @@ -800,11 +800,11 @@ static NSOpenGLPixelFormat* MakePixelFormat(cc_bool fullscreen) { void GLContext_Create(void) { NSOpenGLPixelFormat* fmt; - fmt = MakePixelFormat(true); + fmt = InitPixelFormat(true); if (!fmt) { Platform_LogConst("Failed to create full screen pixel format."); Platform_LogConst("Trying again to create a non-fullscreen pixel format."); - fmt = MakePixelFormat(false); + fmt = InitPixelFormat(false); } if (!fmt) Process_Abort("Choosing pixel format"); @@ -813,9 +813,10 @@ void GLContext_Create(void) { if (!ctxHandle) Process_Abort("Failed to create OpenGL context"); [ctxHandle setView:viewHandle]; - [fmt release]; [ctxHandle makeCurrentContext]; [ctxHandle update]; + + [fmt release]; } void GLContext_Update(void) { diff --git a/src/dreamcast/VertexClip2.S b/src/dreamcast/VertexClip2.S index b2cce54f8..2228a6590 100644 --- a/src/dreamcast/VertexClip2.S +++ b/src/dreamcast/VertexClip2.S @@ -22,17 +22,17 @@ ! Final calculation: ! out->c = type << 24 -! out->x = ((v2->x - v1->x) + v1->x) * 1/zNear -! out->y = ((v2->y - v1->y) + v1->y) * 1/zNear +! out->x = (t * (v2->x - v1->x) + v1->x) * 1/zNear +! out->y = (t * (v2->y - v1->y) + v1->y) * 1/zNear ! out->w = 1/zNear ! -! out->u = (v2->u - v1->u) + v1->u; -! out->v = (v2->v - v1->v) + v1->v; +! out->u = t * (v2->u - v1->u) + v1->u; +! out->v = t * (v2->v - v1->v) + v1->v; ! -! out->b = (v2->b - v1->b) + v1->b; -! out->g = (v2->g - v1->g) + v1->g; -! out->r = (v2->r - v1->r) + v1->r; -! out->a = (v2->a - v1->a) + v1->a; +! out->b = t * (v2->b - v1->b) + v1->b; +! out->g = t * (v2->g - v1->g) + v1->g; +! out->r = t * (v2->r - v1->r) + v1->r; +! out->a = t * (v2->a - v1->a) + v1->a; ! INPUT ARGUMENTS #define IN1 r4 // input vertex 1