diff options
author | Sebastian Pauka <spauka@gmail.com> | 2020-02-26 15:06:50 +1100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2020-03-30 08:25:14 +0200 |
commit | bd3a5876b0a730d4a5fc9e29a8446b7810c1697a (patch) | |
tree | 834ff9ab5025a5dd10666e78d45de8213b3e5f9b /src/video/cocoa | |
parent | 57553cd8098ac003b3d5df6b9778214e6933c5d7 (diff) | |
download | openttd-bd3a5876b0a730d4a5fc9e29a8446b7810c1697a.tar.xz |
Fix #7644: [Cocoa] Manually set colorspace to sRGB
Diffstat (limited to 'src/video/cocoa')
-rw-r--r-- | src/video/cocoa/cocoa_v.h | 1 | ||||
-rw-r--r-- | src/video/cocoa/wnd_quartz.mm | 22 |
2 files changed, 6 insertions, 17 deletions
diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h index 7535eaada..40646f887 100644 --- a/src/video/cocoa/cocoa_v.h +++ b/src/video/cocoa/cocoa_v.h @@ -84,6 +84,7 @@ public: int buffer_depth; ///< Colour depth of used frame buffer void *pixel_buffer; ///< used for direct pixel access void *window_buffer; ///< Colour translation from palette to screen + CGColorSpaceRef color_space; //< Window color space id window; ///< Pointer to window object # define MAX_DIRTY_RECTS 100 diff --git a/src/video/cocoa/wnd_quartz.mm b/src/video/cocoa/wnd_quartz.mm index d4c536941..c73dd32e7 100644 --- a/src/video/cocoa/wnd_quartz.mm +++ b/src/video/cocoa/wnd_quartz.mm @@ -346,6 +346,9 @@ bool WindowQuartzSubdriver::SetVideoMode(int width, int height, int bpp) [ this->window makeKeyAndOrderFront:nil ]; } + [this->window setColorSpace:[NSColorSpace sRGBColorSpace]]; + this->color_space = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); + bool ret = WindowResized(); this->UpdatePalette(0, 256); @@ -395,6 +398,7 @@ WindowQuartzSubdriver::~WindowQuartzSubdriver() CGContextRelease(this->cgcontext); + CGColorSpaceRelease(this->color_space); free(this->window_buffer); free(this->pixel_buffer); } @@ -565,21 +569,6 @@ bool WindowQuartzSubdriver::WindowResized() this->window_width = (int)newframe.size.width; this->window_height = (int)newframe.size.height; - /* Get screen colour space. */ - CGColorSpaceRef color_space = NULL; - -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) - if ([ this->window respondsToSelector:@selector(colorSpace) ]) { - color_space = [ [ this->window colorSpace ] CGColorSpace ]; - CGColorSpaceRetain(color_space); - } -#endif -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) - if (color_space == NULL && MacOSVersionIsAtLeast(10, 5, 0)) color_space = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); -#endif - if (color_space == NULL) color_space = CGColorSpaceCreateDeviceRGB(); - if (color_space == NULL) error("Could not get system colour space. You might need to recalibrate your monitor."); - /* Create Core Graphics Context */ free(this->window_buffer); this->window_buffer = (uint32*)malloc(this->window_width * this->window_height * 4); @@ -591,10 +580,9 @@ bool WindowQuartzSubdriver::WindowResized() this->window_height, // height 8, // bits per component this->window_width * 4, // bytes per row - color_space, // color space + this->color_space, // color space kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host ); - CGColorSpaceRelease(color_space); assert(this->cgcontext != NULL); CGContextSetShouldAntialias(this->cgcontext, FALSE); |