Merge branch 'master' into jgrpp-nrt

# Conflicts:
#	config.lib
#	src/core/bitmath_func.hpp
#	src/lang/korean.txt
#	src/main_gui.cpp
#	src/order_gui.cpp
#	src/script/api/script_object.cpp
#	src/station_cmd.cpp
#	src/video/cocoa/wnd_quartz.mm
This commit is contained in:
Jonathan G Rennison
2019-09-18 01:18:28 +01:00
54 changed files with 285 additions and 162 deletions

View File

@@ -271,6 +271,7 @@ uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_i
- (BOOL)windowShouldClose:(id)sender;
- (void)windowDidEnterFullScreen:(NSNotification *)aNotification;
- (void)windowDidChangeScreenProfile:(NSNotification *)aNotification;
@end

View File

@@ -1360,6 +1360,11 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count)
[ e release ];
}
}
/** The colour profile of the screen the window is on changed. */
- (void)windowDidChangeScreenProfile:(NSNotification *)aNotification
{
if (!driver->setup) driver->WindowResized();
}
@end

View File

@@ -106,35 +106,6 @@ public:
};
static CGColorSpaceRef QZ_GetCorrectColorSpace()
{
static CGColorSpaceRef colorSpace = nullptr;
if (colorSpace == nullptr) {
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
if (MacOSVersionIsAtLeast(10, 5, 0)) {
colorSpace = CGDisplayCopyColorSpace(CGMainDisplayID());
} else
#endif
{
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) && !defined(HAVE_OSX_1011_SDK)
CMProfileRef sysProfile;
if (CMGetSystemProfile(&sysProfile) == noErr) {
colorSpace = CGColorSpaceCreateWithPlatformColorSpace(sysProfile);
CMCloseProfile(sysProfile);
}
#endif
}
if (colorSpace == nullptr) colorSpace = CGColorSpaceCreateDeviceRGB();
if (colorSpace == nullptr) error("Could not get system colour space. You might need to recalibrate your monitor.");
}
return colorSpace;
}
@implementation OTTD_QuartzView
- (void)setDriver:(WindowQuartzSubdriver*)drv
@@ -596,20 +567,36 @@ 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);
CGContextRelease(this->cgcontext);
this->cgcontext = CGBitmapContextCreate(
this->window_buffer, // data
this->window_buffer, // data
this->window_width, // width
this->window_height, // height
8, // bits per component
this->window_width * 4, // bytes per row
QZ_GetCorrectColorSpace(), // color space
color_space, // color space
kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host
);
CGColorSpaceRelease(color_space);
assert(this->cgcontext != nullptr);
CGContextSetShouldAntialias(this->cgcontext, FALSE);