[vlc-devel] [PATCH 1/5] VLCKit: migrate VLCVideoView to ARC
Florent Pillet
fpillet at gmail.com
Mon Jul 7 20:47:03 CEST 2014
---
Headers/Public/VLCVideoView.h | 8 ++--
Sources/VLCVideoView.m | 108 ++++++++----------------------------------
2 files changed, 24 insertions(+), 92 deletions(-)
diff --git a/Headers/Public/VLCVideoView.h b/Headers/Public/VLCVideoView.h
index baf2e23..43a9136 100644
--- a/Headers/Public/VLCVideoView.h
+++ b/Headers/Public/VLCVideoView.h
@@ -26,9 +26,11 @@
#import <QuartzCore/QuartzCore.h>
@interface VLCVideoView : NSView
+
/* 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 15eb184..5be5aeb 100644
--- a/Sources/VLCVideoView.m
+++ b/Sources/VLCVideoView.m
@@ -48,34 +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 ()
-{
- id delegate;
- NSColor * backColor;
- BOOL stretchesVideo;
- id layoutManager;
- BOOL hasVideo;
-}
-/* Proeprties */
- at property (readwrite) BOOL hasVideo;
@end
/******************************************************************************
@@ -89,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.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];
}
@@ -123,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;
}
@@ -171,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