- macOS backend update, plus moving base64.cpp around.

This commit is contained in:
Christoph Oelckers 2020-09-27 10:27:30 +02:00
parent 0795c79a3a
commit f8ae35f8a5
9 changed files with 93 additions and 48 deletions

View file

@ -761,7 +761,6 @@ set (PCH_SOURCES
glbackend/gl_palmanager.cpp
glbackend/gl_texture.cpp
thirdparty/src/base64.cpp
thirdparty/src/md4.cpp
# Todo: Split out the license-safe code from this.
@ -893,6 +892,7 @@ set (PCH_SOURCES
common/utility/zstrformat.cpp
common/utility/name.cpp
common/utility/r_memory.cpp
common/thirdparty/base64.cpp
common/thirdparty/md5.cpp
common/thirdparty/superfasthash.cpp
common/filesystem/filesystem.cpp

View file

@ -262,7 +262,7 @@ void DrawTextCommon(F2DDrawer *drawer, FFont *font, int normalcolor, double x, d
double scaley = parms.scaley * parms.patchscaley;
if (parms.celly == 0) parms.celly = font->GetHeight() + 1;
parms.celly *= scaley;
parms.celly = int (parms.celly * scaley);
bool palettetrans = (normalcolor == CR_UNDEFINED && parms.TranslationId != 0);

View file

@ -101,7 +101,9 @@ void I_DetectOS()
const char* name = "Unknown version";
if (10 == version.majorVersion) switch (version.minorVersion)
if (10 == version.majorVersion)
{
switch (version.minorVersion)
{
case 9: name = "OS X Mavericks"; break;
case 10: name = "OS X Yosemite"; break;
@ -110,6 +112,15 @@ void I_DetectOS()
case 13: name = "macOS High Sierra"; break;
case 14: name = "macOS Mojave"; break;
case 15: name = "macOS Catalina"; break;
case 16: name = "macOS Big Sur"; break;
}
}
else if (11 == version.majorVersion)
{
switch (version.minorVersion)
{
case 0: name = "macOS Big Sur"; break;
}
}
char release[16] = "unknown";
@ -125,6 +136,8 @@ void I_DetectOS()
"32-bit Intel";
#elif defined __x86_64__
"64-bit Intel";
#elif defined __aarch64__
"64-bit ARM";
#else
"Unknown";
#endif

View file

@ -102,6 +102,7 @@ EXTERN_CVAR(Int, vid_preferbackend)
EXTERN_CVAR(Bool, vk_debug)
CVAR(Bool, mvk_debug, false, 0)
CVAR(Bool, vid_nativefullscreen, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
@ -290,6 +291,7 @@ CocoaWindow* CreateWindow(const NSUInteger styleMask)
[window setOpaque:YES];
[window makeFirstResponder:appCtrl];
[window setAcceptsMouseMovedEvents:YES];
[window exitAppOnClose];
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
[nc addObserver:window
@ -633,7 +635,6 @@ void SystemBaseFrameBuffer::SetWindowedMode()
const NSRect frameSize = NSMakeRect(win_x, win_y, win_w, win_h);
[m_window setFrame:frameSize display:YES];
[m_window enterFullscreenOnZoom];
[m_window exitAppOnClose];
}
void SystemBaseFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI)
@ -650,7 +651,11 @@ void SystemBaseFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI)
[m_window.contentView layer].contentsScale = hiDPI ? m_window.screen.backingScaleFactor : 1.0;
}
if (fullscreen)
if (vid_nativefullscreen && fullscreen != m_fullscreen)
{
[m_window toggleFullScreen:(nil)];
}
else if (fullscreen)
{
SetFullscreenMode();
}
@ -742,7 +747,11 @@ void SystemGLFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI)
NSOpenGLView* const glView = [m_window contentView];
[glView setWantsBestResolutionOpenGLSurface:hiDPI];
if (fullscreen)
if (vid_nativefullscreen && fullscreen != m_fullscreen)
{
[m_window toggleFullScreen:(nil)];
}
else if (fullscreen)
{
SetFullscreenMode();
}

View file

@ -375,6 +375,8 @@ static NSString* GetArchitectureString()
return @"i386";
#elif defined __x86_64__
return @"x86_64";
#elif defined __aarch64__
return @"arm64";
#endif
}
@ -382,13 +384,6 @@ static void RestartWithParameters(const WadStuff& wad, NSString* parameters)
{
assert(nil != parameters);
defaultiwad = wad.Name;
GameConfig->ArchiveGlobalData();
GameConfig->WriteConfigFile();
delete GameConfig;
GameConfig = nullptr;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@try
@ -396,22 +391,14 @@ static void RestartWithParameters(const WadStuff& wad, NSString* parameters)
NSString* executablePath = [NSString stringWithUTF8String:Args->GetArg(0)];
NSMutableArray* const arguments = [[NSMutableArray alloc] init];
// The following value shoud be equal to NSAppKitVersionNumber10_5
// It's hard-coded in order to build with earlier SDKs
const bool canSelectArchitecture = NSAppKitVersionNumber >= 949;
if (canSelectArchitecture)
{
[arguments addObject:@"-arch"];
[arguments addObject:GetArchitectureString()];
[arguments addObject:executablePath];
executablePath = @"/usr/bin/arch";
}
[arguments addObject:@"-iwad"];
[arguments addObject:[NSString stringWithUTF8String:wad.Path]];
[arguments addObject:@"+defaultiwad"];
[arguments addObject:[NSString stringWithUTF8String:wad.Name]];
[arguments addObject:[NSString stringWithFormat:@"+osx_additional_parameters \"%@\"", parameters]];
for (int i = 1, count = Args->NumArgs(); i < count; ++i)
{
@ -433,7 +420,7 @@ static void RestartWithParameters(const WadStuff& wad, NSString* parameters)
wordfree(&expansion);
}
[NSTask launchedTaskWithLaunchPath:executablePath
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/arch"
arguments:arguments];
_exit(0); // to avoid atexit()'s functions
@ -454,11 +441,10 @@ int I_PickIWad_Cocoa (WadStuff *wads, int numwads, bool showwin, int defaultiwad
IWADPicker *picker = [IWADPicker alloc];
int ret = [picker pickIWad:wads num:numwads showWindow:showwin defaultWad:defaultiwad];
NSString* parametersToAppend = [picker commandLineParameters];
osx_additional_parameters = [parametersToAppend UTF8String];
if (ret >= 0)
{
NSString* parametersToAppend = [picker commandLineParameters];
if (0 != [parametersToAppend length])
{
RestartWithParameters(wads[ret], parametersToAppend);

View file

@ -54,6 +54,9 @@
#include "m_argv.h"
#include "i_sound.h"
#include "i_interface.h"
#include "v_font.h"
#include "c_cvars.h"
#include "palutil.h"
#ifndef NO_GTK
@ -65,6 +68,8 @@ int I_PickIWad_Cocoa (WadStuff *wads, int numwads, bool showwin, int defaultiwad
#endif
double PerfToSec, PerfToMillisec;
CVAR(Bool, con_printansi, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE);
CVAR(Bool, con_4bitansi, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE);
void I_SetIWADInfo()
{
@ -129,16 +134,47 @@ void CalculateCPUSpeed()
void I_PrintStr(const char *cp)
{
// Strip out any color escape sequences before writing to debug output
TArray<char> copy(strlen(cp) + 1, true);
const char * srcp = cp;
char * dstp = copy.Data();
FString printData = "";
while (*srcp != 0)
{
if (*srcp != 0x1c && *srcp != 0x1d && *srcp != 0x1e && *srcp != 0x1f)
if (*srcp == 0x1c && con_printansi)
{
*dstp++ = *srcp++;
srcp += 1;
EColorRange range = V_ParseFontColor((const uint8_t*&)srcp, CR_UNTRANSLATED, CR_YELLOW);
if (range != CR_UNDEFINED)
{
PalEntry color = V_LogColorFromColorRange(range);
if (con_4bitansi)
{
float h, s, v, r, g, b;
int attrib = 0;
RGBtoHSV(color.r / 255.f, color.g / 255.f, color.b / 255.f, &h, &s, &v);
if (s != 0)
{ // color
HSVtoRGB(&r, &g, &b, h, 1, 1);
if (r == 1) attrib = 0x1;
if (g == 1) attrib |= 0x2;
if (b == 1) attrib |= 0x4;
if (v > 0.6) attrib |= 0x8;
}
else
{ // gray
if (v < 0.33) attrib = 0x8;
else if (v < 0.90) attrib = 0x7;
else attrib = 0x15;
}
printData.AppendFormat("\033[%um",((attrib & 0x8) ? 90 : 30) + (attrib & 0x7));
}
else printData.AppendFormat("\033[38;2;%u;%u;%um",color.r,color.g,color.b);
}
}
else if (*srcp != 0x1c && *srcp != 0x1d && *srcp != 0x1e && *srcp != 0x1f)
{
printData += *srcp++;
}
else
{
@ -146,10 +182,9 @@ void I_PrintStr(const char *cp)
else break;
}
}
*dstp = 0;
fputs(copy.Data(), stdout);
fflush(stdout);
fputs(printData.GetChars(),stdout);
fputs("\033[0m",stdout);
}
int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad)

View file

@ -52,6 +52,7 @@
#include "printf.h"
#include "startupinfo.h"
#include "i_interface.h"
#include "texturemanager.h"
// MACROS ------------------------------------------------------------------
@ -607,6 +608,7 @@ int RunEndoom()
void ST_Endoom()
{
TexMan.DeleteAll();
int code = RunEndoom();
throw CExitEvent(code);