[Commits] SDL: Minor cleanup

libsdl.org revision control commits-owner at libsdl.org
Fri Dec 8 12:02:26 PST 2017


details:   https://hg.libsdl.org/SDL/rev/e7d5d4ae2e73
changeset: 11741:e7d5d4ae2e73
user:      Sam Lantinga <slouken at libsdl.org>
date:      Fri Dec 08 12:02:23 2017 -0800
description:
Minor cleanup

diffstat:

 src/render/metal/SDL_render_metal.m |  30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diffs (58 lines):

diff -r 24c1d2de7a09 -r e7d5d4ae2e73 src/render/metal/SDL_render_metal.m
--- a/src/render/metal/SDL_render_metal.m	Fri Dec 08 11:35:19 2017 -0800
+++ b/src/render/metal/SDL_render_metal.m	Fri Dec 08 12:02:23 2017 -0800
@@ -726,20 +726,18 @@
 {
     METAL_ActivateRenderer(renderer);
     METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata;
-    id<CAMetalDrawable> mtlbackbuffer = data.mtlbackbuffer;
 
     [data.mtlcmdencoder endEncoding];
-    [data.mtlcmdbuffer presentDrawable:mtlbackbuffer];
-#if !__has_feature(objc_arc)
-    [data.mtlcmdbuffer addCompletedHandler:^(id <MTLCommandBuffer> mtlcmdbuffer) {
-        [mtlbackbuffer release];
-    }];
-#endif
+    [data.mtlcmdbuffer presentDrawable:data.mtlbackbuffer];
     [data.mtlcmdbuffer commit];
 #if !__has_feature(objc_arc)
     [data.mtlcmdencoder release];
     [data.mtlcmdbuffer release];
+    [data.mtlbackbuffer release];
 #endif
+    data.mtlcmdencoder = nil;
+    data.mtlcmdbuffer = nil;
+    data.mtlbackbuffer = nil;
     data.beginScene = YES;
 }
 
@@ -760,15 +758,23 @@
         METAL_RenderData *data = CFBridgingRelease(renderer->driverdata);
 
 #if !__has_feature(objc_arc)
-        int i;
-        [data.mtlcmdencoder endEncoding];
-        [data.mtlcmdencoder release];
-        [data.mtlcmdbuffer release];
+        if (data.mtlbackbuffer != nil) {
+            [data.mtlbackbuffer release];
+        }
+        if (data.mtlcmdencoder != nil) {
+            [data.mtlcmdencoder endEncoding];
+            [data.mtlcmdencoder release];
+        }
+        if (data.mtlcmdbuffer != nil) {
+            [data.mtlcmdbuffer release];
+        }
         [data.mtlcmdqueue release];
-        for (i = 0; i < 4; i++) {
+        for (int i = 0; i < 4; i++) {
             [data.mtlpipelineprims[i] release];
             [data.mtlpipelinecopy[i] release];
         }
+        [data.mtlpipelineprims release];
+        [data.mtlpipelinecopy release];
         [data.mtlbufclearverts release];
         [data.mtllibrary release];
         [data.mtldevice release];


More information about the commits mailing list