[vlc-devel] [PATCH 03/13] VLCKit: migrate VLCVideoView to ARC

Florent Pillet fpillet at gmail.com
Mon Jul 7 12:41:18 CEST 2014


---
 Headers/Public/VLCVideoView.h |  14 ++----
 Sources/VLCVideoView.m        | 103 ++++++++----------------------------------
 2 files changed, 23 insertions(+), 94 deletions(-)

diff --git a/Headers/Public/VLCVideoView.h b/Headers/Public/VLCVideoView.h
index 72c6037..6743c16 100644
--- a/Headers/Public/VLCVideoView.h
+++ b/Headers/Public/VLCVideoView.h
@@ -25,17 +25,9 @@
 #import <QuartzCore/QuartzCore.h>
 
 @interface VLCVideoView : NSView
-{
-    id delegate;
-    NSColor * backColor;
-    BOOL stretchesVideo;
-    id layoutManager;
-    BOOL hasVideo;
-}
 
-/* Properties */
- at property (assign) id delegate;
- at property (copy) NSColor *backColor;
+ at property (nonatomic, weak) id delegate;
+ at property (nonatomic, copy) NSColor *backColor;
 @property BOOL fillScreen;
- at property (readonly) BOOL hasVideo;
+ at property (nonatomic, readonly) BOOL hasVideo;
 @end
diff --git a/Sources/VLCVideoView.m b/Sources/VLCVideoView.m
index 8435389..a677176 100644
--- a/Sources/VLCVideoView.m
+++ b/Sources/VLCVideoView.m
@@ -48,27 +48,17 @@
 - (void)detachFromVout;
 @end
 
-/* Depreacted methods */
- at interface VLCVideoView (Deprecated)
-- (void)setStretchesVideo:(BOOL)value;
-- (BOOL)stretchesVideo;
-
-- (void)addVoutSubview:(NSView *)aView;  /* (Scheduled to deletion) */
-- (void)removeVoutSubview:(NSView *)aView;  /* (Scheduled to deletion) */
- at end
-
 /******************************************************************************
  * VLCVideoView (Private)
  */
 
- at interface VLCVideoView (Private)
-/* Method */
+ at interface VLCVideoView ()
+
+ at property (nonatomic, readwrite) BOOL hasVideo;
+ at property (nonatomic, retain) VLCVideoLayoutManager *layoutManager;
+
 - (void)addVoutLayer:(CALayer *)aLayer;
- at end
 
- at interface VLCVideoView ()
-/* Proeprties */
- at property (readwrite) BOOL hasVideo;
 @end
 
 /******************************************************************************
@@ -82,31 +72,18 @@
 {
     if (self = [super initWithFrame:rect])
     {
-        self.delegate = nil;
-        self.backColor = [NSColor blackColor];
-        self.fillScreen = NO;
-        self.hasVideo = NO;
-
-        [self setStretchesVideo:NO];
-        [self setAutoresizesSubviews:YES];
-        layoutManager = [[VLCVideoLayoutManager layoutManager] retain];
+		self.backColor = [NSColor blackColor];
+		self.autoresizesSubviews = YES;
+        self.layoutManager = [VLCVideoLayoutManager layoutManager];
     }
     return self;
 }
 
-- (void)dealloc
-{
-    self.delegate = nil;
-    self.backColor = nil;
-    [layoutManager release];
-    [super dealloc];
-}
-
 /* NSView Overrides */
 - (void)drawRect:(NSRect)aRect
 {
     [self lockFocus];
-    [backColor set];
+    [self.backColor set];
     NSRectFill(aRect);
     [self unlockFocus];
 }
@@ -116,46 +93,40 @@
     return YES;
 }
 
-/* Properties */
- at synthesize delegate;
- at synthesize backColor;
- at synthesize hasVideo;
-
 - (BOOL)fillScreen
 {
-    return [layoutManager fillScreenEntirely];
+    return [self.layoutManager fillScreenEntirely];
 }
 
 - (void)setFillScreen:(BOOL)fillScreen
 {
-    [(VLCVideoLayoutManager *)layoutManager setFillScreenEntirely:fillScreen];
-    [[self layer] setNeedsLayout];
+    [self.layoutManager setFillScreenEntirely:fillScreen];
+    [self.layer setNeedsLayout];
 }
- at end
 
 /******************************************************************************
  * Implementation VLCVideoView  (Private)
  */
 
- at implementation VLCVideoView (Private)
-
 /* This is called by the libvlc module 'opengllayer' as soon as there is one
  * vout available
  */
 - (void)addVoutLayer:(CALayer *)aLayer
 {
+    aLayer.name = @"vlcopengllayer";
+
     [CATransaction begin];
-    [self setWantsLayer: YES];
-    CALayer * rootLayer = [self layer];
 
-    aLayer.name = @"vlcopengllayer";
+	self.wantsLayer = YES;
+    CALayer * rootLayer = self.layer;
 
-    [layoutManager setOriginalVideoSize:aLayer.bounds.size];
-    [rootLayer setLayoutManager:layoutManager];
+    [self.layoutManager setOriginalVideoSize:aLayer.bounds.size];
+    [rootLayer setLayoutManager:self.layoutManager];
     [rootLayer insertSublayer:aLayer atIndex:0];
     [aLayer setNeedsDisplayOnBoundsChange:YES];
 
     [CATransaction commit];
+
     self.hasVideo = YES;
 }
 
@@ -164,43 +135,9 @@
     [CATransaction begin];
     [voutLayer removeFromSuperlayer];
     [CATransaction commit];
+
     self.hasVideo = NO;
 }
 
 @end
 
-/******************************************************************************
- * Implementation VLCVideoView  (Deprecated)
- */
-
- at implementation VLCVideoView (Deprecated)
-
-- (void)setStretchesVideo:(BOOL)value
-{
-    stretchesVideo = value;
-}
-
-- (BOOL)stretchesVideo
-{
-    return stretchesVideo;
-}
-
-/* This is called by the libvlc module 'minimal_macosx' as soon as there is one
- * vout available
- */
-- (void)addVoutSubview:(NSView *)aView /* (Scheduled to deletion) */
-{
-    [aView setFrame:[self bounds]];
-
-    [self addSubview:aView];
-
-    // TODO: Should we let the media player specify these values?
-    [aView setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
-}
-
-- (void)removeVoutSubview:(NSView *)view /* (Scheduled to deletion) */
-{
-    // Should we do something?  I don't know, however the protocol requires
-    // this to be implemented
-}
- at end
-- 
1.8.5.2 (Apple Git-48)




More information about the vlc-devel mailing list