Commit 9390b416 authored by Felix Paul Kühne's avatar Felix Paul Kühne

windowed mac plugin: cache CGColorSpace

parent da726fb5
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
@end @end
@interface VLCPlaybackLayer : CALayer { @interface VLCPlaybackLayer : CALayer {
CGColorSpaceRef _colorspace;
VlcPluginMac *_cppPlugin; VlcPluginMac *_cppPlugin;
} }
@property (readwrite) VlcPluginMac * cppPlugin; @property (readwrite) VlcPluginMac * cppPlugin;
...@@ -440,11 +441,19 @@ bool VlcPluginMac::handle_event(void *event) ...@@ -440,11 +441,19 @@ bool VlcPluginMac::handle_event(void *event)
if (self = [super init]) { if (self = [super init]) {
self.needsDisplayOnBoundsChange = YES; self.needsDisplayOnBoundsChange = YES;
self.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable; self.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
_colorspace = CGColorSpaceCreateDeviceRGB();
} }
return self; return self;
} }
- (void)dealloc
{
CGColorSpaceRelease(_colorspace);
[super dealloc];
}
- (void)drawInContext:(CGContextRef)cgContext - (void)drawInContext:(CGContextRef)cgContext
{ {
if (!cgContext) if (!cgContext)
...@@ -498,20 +507,19 @@ bool VlcPluginMac::handle_event(void *event) ...@@ -498,20 +507,19 @@ bool VlcPluginMac::handle_event(void *event)
sizeof([self cppPlugin]->m_frame_buf[0]), sizeof([self cppPlugin]->m_frame_buf[0]),
kCFAllocatorNull); kCFAllocatorNull);
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(dataRef); CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(dataRef);
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGImageRef image = CGImageCreate(media_width, CGImageRef image = CGImageCreate(media_width,
media_height, media_height,
kBitsPerComponent, kBitsPerComponent,
kBitsPerComponent * kComponentsPerPixel, kBitsPerComponent * kComponentsPerPixel,
kComponentsPerPixel * media_width, kComponentsPerPixel * media_width,
colorspace, _colorspace,
kCGBitmapByteOrder16Big, kCGBitmapByteOrder16Big,
dataProvider, dataProvider,
NULL, NULL,
true, true,
kCGRenderingIntentPerceptual); kCGRenderingIntentPerceptual);
if (!image) { if (!image) {
CGColorSpaceRelease(colorspace);
CGImageRelease(image); CGImageRelease(image);
CGDataProviderRelease(dataProvider); CGDataProviderRelease(dataProvider);
CGContextRestoreGState(cgContext); CGContextRestoreGState(cgContext);
...@@ -520,7 +528,6 @@ bool VlcPluginMac::handle_event(void *event) ...@@ -520,7 +528,6 @@ bool VlcPluginMac::handle_event(void *event)
CGRect rect = CGRectMake(left, top, display_width, display_height); CGRect rect = CGRectMake(left, top, display_width, display_height);
CGContextDrawImage(cgContext, rect, image); CGContextDrawImage(cgContext, rect, image);
CGColorSpaceRelease(colorspace);
CGImageRelease(image); CGImageRelease(image);
CGDataProviderRelease(dataProvider); CGDataProviderRelease(dataProvider);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment