Commit 9b53551e authored by Felix Paul Kühne's avatar Felix Paul Kühne

Windowless Mac Plugin: cache CGColorSpace

parent 9390b416
......@@ -27,6 +27,12 @@
VlcWindowlessMac::VlcWindowlessMac(NPP instance, NPuint16_t mode) :
VlcWindowlessBase(instance, mode)
{
colorspace = CGColorSpaceCreateDeviceRGB();
}
VlcWindowlessMac::~VlcWindowlessMac()
{
CGColorSpaceRelease(colorspace);
}
void VlcWindowlessMac::drawBackground(CGContextRef cgContext)
......@@ -192,7 +198,6 @@ bool VlcWindowlessMac::handle_event(void *event)
sizeof(m_frame_buf[0]),
kCFAllocatorNull);
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(dataRef);
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGImageRef image = CGImageCreate(m_media_width,
m_media_height,
kBitsPerComponent,
......@@ -205,7 +210,6 @@ bool VlcWindowlessMac::handle_event(void *event)
true,
kCGRenderingIntentPerceptual);
if (!image) {
CGColorSpaceRelease(colorspace);
CGImageRelease(image);
CGDataProviderRelease(dataProvider);
CGContextRestoreGState(cgContext);
......@@ -214,7 +218,6 @@ bool VlcWindowlessMac::handle_event(void *event)
CGRect rect = CGRectMake(left, top, m_media_width, m_media_height);
CGContextDrawImage(cgContext, rect, image);
CGColorSpaceRelease(colorspace);
CGImageRelease(image);
CGDataProviderRelease(dataProvider);
......
......@@ -30,6 +30,7 @@ class VlcWindowlessMac : public VlcWindowlessBase
{
public:
VlcWindowlessMac(NPP instance, NPuint16_t mode);
virtual ~VlcWindowlessMac();
bool handle_event(void *event);
NPError get_root_layer(void *value);
......@@ -37,6 +38,9 @@ public:
protected:
void drawBackground(CGContextRef cgContext);
void drawNoPlayback(CGContextRef cgContext);
private:
CGColorSpaceRef colorspace;
};
#endif /* __VLCWINDOWLESS_MAC_H__ */
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