[vlc-commits] windowed mac plugin: cache CGColorSpace
Felix Paul Kühne
git at videolan.org
Wed Jan 16 02:29:21 CET 2013
npapi-vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Wed Jan 16 02:28:29 2013 +0100| [9390b4169cb96134bb0d0f485563e715d1f616d3] | committer: Felix Paul Kühne
windowed mac plugin: cache CGColorSpace
> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=9390b4169cb96134bb0d0f485563e715d1f616d3
---
npapi/vlcplugin_mac.mm | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/npapi/vlcplugin_mac.mm b/npapi/vlcplugin_mac.mm
index 3efc763..910b371 100644
--- a/npapi/vlcplugin_mac.mm
+++ b/npapi/vlcplugin_mac.mm
@@ -39,6 +39,7 @@
@end
@interface VLCPlaybackLayer : CALayer {
+ CGColorSpaceRef _colorspace;
VlcPluginMac *_cppPlugin;
}
@property (readwrite) VlcPluginMac * cppPlugin;
@@ -440,11 +441,19 @@ bool VlcPluginMac::handle_event(void *event)
if (self = [super init]) {
self.needsDisplayOnBoundsChange = YES;
self.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
+
+ _colorspace = CGColorSpaceCreateDeviceRGB();
}
return self;
}
+- (void)dealloc
+{
+ CGColorSpaceRelease(_colorspace);
+ [super dealloc];
+}
+
- (void)drawInContext:(CGContextRef)cgContext
{
if (!cgContext)
@@ -498,20 +507,19 @@ bool VlcPluginMac::handle_event(void *event)
sizeof([self cppPlugin]->m_frame_buf[0]),
kCFAllocatorNull);
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(dataRef);
- CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
+
CGImageRef image = CGImageCreate(media_width,
media_height,
kBitsPerComponent,
kBitsPerComponent * kComponentsPerPixel,
kComponentsPerPixel * media_width,
- colorspace,
+ _colorspace,
kCGBitmapByteOrder16Big,
dataProvider,
NULL,
true,
kCGRenderingIntentPerceptual);
if (!image) {
- CGColorSpaceRelease(colorspace);
CGImageRelease(image);
CGDataProviderRelease(dataProvider);
CGContextRestoreGState(cgContext);
@@ -520,7 +528,6 @@ bool VlcPluginMac::handle_event(void *event)
CGRect rect = CGRectMake(left, top, display_width, display_height);
CGContextDrawImage(cgContext, rect, image);
- CGColorSpaceRelease(colorspace);
CGImageRelease(image);
CGDataProviderRelease(dataProvider);
More information about the vlc-commits
mailing list