From be7c9b0f72f0178b1433104a76dcf1ffe6bc744d Mon Sep 17 00:00:00 2001 From: nigel <> Date: Tue, 25 Mar 2003 01:46:45 +0000 Subject: [PATCH] When in CGIMAGEREF windowed mode; cleanup when changing modes, future mask generation code. --- BasiliskII/src/MacOSX/video_macosx.mm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/BasiliskII/src/MacOSX/video_macosx.mm b/BasiliskII/src/MacOSX/video_macosx.mm index 62e9fcce..054a4c08 100644 --- a/BasiliskII/src/MacOSX/video_macosx.mm +++ b/BasiliskII/src/MacOSX/video_macosx.mm @@ -563,6 +563,12 @@ OSX_monitor::init_window(const video_mode &mode) #ifdef CG_USE_ALPHA mask_buffer(the_buffer, x, the_buffer_size); + +/* Create an image mask with this call? */ +//CG_EXTERN CGImageRef +//CGImageMaskCreate(size_t width, size_t height, size_t bitsPerComponent, +// size_t bitsPerPixel, size_t bytesPerRow, +// CGDataProviderRef provider, const float decode[], bool shouldInterpolate); #endif return true; @@ -1020,6 +1026,24 @@ OSX_monitor::switch_to_current_mode(void) failure = "Could not get base address of screen"; } + // Clean up the old CGImageRef stuff + else if ( display_type == DISPLAY_WINDOW && imageRef ) + { + CGImageRef oldImageRef = imageRef; + CGColorSpaceRef oldColourSpace = colourSpace; + CGDataProviderRef oldProvider = provider; + void *oldBuffer = the_buffer; + + if ( video_open(mode) ) + { + CGImageRelease(oldImageRef); + CGColorSpaceRelease(oldColourSpace); + CGDataProviderRelease(oldProvider); + free(oldBuffer); + } + else + failure = "Could not video_open() requested mode"; + } else if ( ! video_open(mode) ) failure = "Could not video_open() requested mode";