diff options
author | Pierre Ossman <ossman@cendio.se> | 2012-08-17 13:37:42 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2012-08-17 13:37:42 +0000 |
commit | cb9eefabc58f276a17ffc96b755a7ef0f4b44433 (patch) | |
tree | 6b49287a6d6678b335c4053c129ace2511e0dee5 | |
parent | f7957546bb08d339c4a7aafa62fe5ac8e45b950f (diff) | |
download | tigervnc-cb9eefabc58f276a17ffc96b755a7ef0f4b44433.tar.gz tigervnc-cb9eefabc58f276a17ffc96b755a7ef0f4b44433.zip |
A CGImage is read-only, but it just happened to work anyway. Until 10.8
that is. Do it the documented way by having a CGBitmapContext instead.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4956 3789f03b-4d11-0410-bbf8-ca57d06f2519
-rw-r--r-- | vncviewer/OSXPixelBuffer.cxx | 20 | ||||
-rw-r--r-- | vncviewer/OSXPixelBuffer.h | 4 |
2 files changed, 11 insertions, 13 deletions
diff --git a/vncviewer/OSXPixelBuffer.cxx b/vncviewer/OSXPixelBuffer.cxx index 77b435dd..0e03fc98 100644 --- a/vncviewer/OSXPixelBuffer.cxx +++ b/vncviewer/OSXPixelBuffer.cxx @@ -40,29 +40,24 @@ PlatformPixelBuffer::PlatformPixelBuffer(int width, int height) : ManagedPixelBuffer(rfb::PixelFormat(32, 24, false, true, 255, 255, 255, 16, 8, 0), width, height), - image(NULL) + bitmap(NULL) { CGColorSpaceRef lut; - CGDataProviderRef provider; lut = CGColorSpaceCreateDeviceRGB(); assert(lut); - provider = CGDataProviderCreateWithData(NULL, data, datasize, NULL); - assert(provider); - image = CGImageCreate(width, height, 8, 32, width*4, lut, - kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, - provider, NULL, false, kCGRenderingIntentDefault); - assert(image); + bitmap = CGBitmapContextCreate(data, width, height, 8, width*4, lut, + kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little); + assert(bitmap); - CGDataProviderRelease(provider); CGColorSpaceRelease(lut); } PlatformPixelBuffer::~PlatformPixelBuffer() { - CGImageRelease((CGImageRef)image); + CFRelease((CGContextRef)bitmap); } @@ -71,6 +66,7 @@ void PlatformPixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h) CGRect rect; CGContextRef gc; CGAffineTransform at; + CGImageRef image; gc = (CGContextRef)fl_gc; @@ -102,7 +98,9 @@ void PlatformPixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h) rect.size.width = width(); rect.size.height = -height(); // Negative height does _not_ flip the image - CGContextDrawImage(gc, rect, (CGImageRef)image); + image = CGBitmapContextCreateImage((CGContextRef)bitmap); + CGContextDrawImage(gc, rect, image); + CGImageRelease(image); CGContextRestoreGState(gc); } diff --git a/vncviewer/OSXPixelBuffer.h b/vncviewer/OSXPixelBuffer.h index a74830c2..e59015e5 100644 --- a/vncviewer/OSXPixelBuffer.h +++ b/vncviewer/OSXPixelBuffer.h @@ -29,8 +29,8 @@ public: void draw(int src_x, int src_y, int x, int y, int w, int h); protected: - // This is really a CGImageRerf, but Apple headers conflict with FLTK - void *image; + // This is really a CGContextRef, but Apple headers conflict with FLTK + void *bitmap; }; |