From 63f85f6b07f3b7b1148dc525e4776ed4304fdf1f Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 2 Apr 2017 10:11:41 +0300 Subject: [PATCH 1/8] Fixed compilation of Cocoa backend Use the same member names in framebuffer class for all backends --- src/posix/cocoa/i_video.mm | 32 ++++++++++++++++---------------- src/posix/cocoa/sdlglvideo.h | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index e11a7c7f5..00b39639f 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -339,7 +339,7 @@ private: PalEntry m_flashColor; int m_flashAmount; - bool m_isUpdatePending; + bool UpdatePending; uint8_t* m_pixelBuffer; GLuint m_texture; @@ -881,7 +881,7 @@ CocoaFrameBuffer::CocoaFrameBuffer(int width, int height, bool bgra, bool fullsc , m_gamma(0.0f) , m_needGammaUpdate(false) , m_flashAmount(0) -, m_isUpdatePending(false) +, UpdatePending(false) , m_pixelBuffer(new uint8_t[width * height * BYTES_PER_PIXEL]) , m_texture(0) { @@ -945,7 +945,7 @@ bool CocoaFrameBuffer::Lock(bool buffered) void CocoaFrameBuffer::Unlock() { - if (m_isUpdatePending && LockCount == 1) + if (UpdatePending && LockCount == 1) { Update(); } @@ -962,7 +962,7 @@ void CocoaFrameBuffer::Update() { if (LockCount > 0) { - m_isUpdatePending = true; + UpdatePending = true; --LockCount; } return; @@ -972,7 +972,7 @@ void CocoaFrameBuffer::Update() Buffer = NULL; LockCount = 0; - m_isUpdatePending = false; + UpdatePending = false; BlitCycles.Reset(); FlipCycles.Reset(); @@ -1146,8 +1146,8 @@ void CocoaFrameBuffer::Flip() SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool fullscreen, bool bgra) : DFrameBuffer(width, height, bgra) -, m_lock(0) -, m_isUpdatePending(false) +, m_Lock(0) +, UpdatePending(false) { CGGammaValue gammaTable[GAMMA_TABLE_SIZE]; uint32_t actualChannelSize; @@ -1176,7 +1176,7 @@ SDLGLFB::~SDLGLFB() bool SDLGLFB::Lock(bool buffered) { - m_lock++; + m_Lock++; Buffer = MemBuffer; @@ -1185,19 +1185,19 @@ bool SDLGLFB::Lock(bool buffered) void SDLGLFB::Unlock() { - if (m_isUpdatePending && 1 == m_lock) + if (UpdatePending && 1 == m_Lock) { Update(); } - else if (--m_lock <= 0) + else if (--m_Lock <= 0) { - m_lock = 0; + m_Lock = 0; } } bool SDLGLFB::IsLocked() { - return m_lock > 0; + return m_Lock > 0; } @@ -1225,12 +1225,12 @@ void SDLGLFB::InitializeState() bool SDLGLFB::CanUpdate() { - if (m_lock != 1) + if (m_Lock != 1) { - if (m_lock > 0) + if (m_Lock > 0) { - m_isUpdatePending = true; - --m_lock; + UpdatePending = true; + --m_Lock; } return false; diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h index b0076f11b..6fd5fd72a 100644 --- a/src/posix/cocoa/sdlglvideo.h +++ b/src/posix/cocoa/sdlglvideo.h @@ -66,8 +66,8 @@ public: int GetClientHeight(); protected: - int m_lock; - bool m_isUpdatePending; + int m_Lock; + bool UpdatePending; static const uint32_t GAMMA_CHANNEL_SIZE = 256; static const uint32_t GAMMA_CHANNEL_COUNT = 3; From 659f75c84abaa0f6d939eb5c6ffd9da5dfd67ac7 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 2 Apr 2017 10:13:25 +0300 Subject: [PATCH 2/8] Avoid duplication of member in OpenGL software framebuffer class --- src/gl/system/gl_swframebuffer.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index c37cf6bf0..0f9c0a0ef 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -454,7 +454,9 @@ private: int TrueHeight; int PixelDoubling; float Gamma; +#ifdef _WIN32 bool UpdatePending; +#endif // _WIN32 bool NeedPalUpdate; bool NeedGammaUpdate; LTRBRect BlendingRect; From 5187acd44fa7983676c4f2d20c6f9a2e070893d0 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 2 Apr 2017 11:38:59 +0300 Subject: [PATCH 3/8] Fixed undefined behavior in drawing of status bar graphics Debug configuration built with Apple's Clang had bogus render styles applied to graphics in status bar --- src/g_statusbar/shared_sbar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 6a3bdfd55..3b3a900b1 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -1592,7 +1592,8 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla DTA_ColorOverlay, (flags & DI_DIM) ? MAKEARGB(170, 0, 0, 0) : 0, DTA_Alpha, Alpha, DTA_AlphaChannel, !!(flags & DI_ALPHAMAPPED), - DTA_FillColor, (flags & DI_ALPHAMAPPED) ? 0 : -1); + DTA_FillColor, (flags & DI_ALPHAMAPPED) ? 0 : -1, + TAG_DONE); } From bb9cd1b1593898c0f1a6919222913e3db6a30aeb Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 2 Apr 2017 11:41:04 +0300 Subject: [PATCH 4/8] Removed special initialization of legacy render styles Workaround for Apple's GCC 4.0.1 is now completely pointless --- src/r_data/renderstyle.cpp | 39 -------------------------------------- 1 file changed, 39 deletions(-) diff --git a/src/r_data/renderstyle.cpp b/src/r_data/renderstyle.cpp index 49628c881..987de82b9 100644 --- a/src/r_data/renderstyle.cpp +++ b/src/r_data/renderstyle.cpp @@ -42,9 +42,6 @@ CVAR (Int, r_drawfuzz, 1, CVAR_ARCHIVE) // Convert legacy render styles to flexible render styles. -// Apple's GCC 4.0.1 apparently wants to initialize the AsDWORD member of FRenderStyle -// rather than the struct before it, which goes against the standard. -#ifndef __APPLE__ FRenderStyle LegacyRenderStyles[STYLE_Count] = { { { STYLEOP_None, STYLEALPHA_Zero, STYLEALPHA_Zero, 0 } }, /* STYLE_None */ @@ -62,42 +59,6 @@ FRenderStyle LegacyRenderStyles[STYLE_Count] = { { STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_One, STYLEF_ColorIsFixed } }, /* STYLE_AddStencil */ { { STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_One, STYLEF_RedIsAlpha | STYLEF_ColorIsFixed } }, /* STYLE_AddShaded */ }; -#else -FRenderStyle LegacyRenderStyles[STYLE_Count]; - -static const uint8_t Styles[STYLE_Count * 4] = -{ - STYLEOP_None, STYLEALPHA_Zero, STYLEALPHA_Zero, 0, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_Alpha1, - STYLEOP_Fuzz, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_TransSoulsAlpha, - STYLEOP_FuzzOrAdd, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_Alpha1 | STYLEF_ColorIsFixed, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_One, 0, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_RedIsAlpha | STYLEF_ColorIsFixed, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_ColorIsFixed, - STYLEOP_Shadow, 0, 0, 0, - STYLEOP_RevSub, STYLEALPHA_Src, STYLEALPHA_One, 0, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_One, STYLEF_Alpha1 | STYLEF_ColorIsFixed, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_One, STYLEF_RedIsAlpha | STYLEF_ColorIsFixed, -}; - -static struct LegacyInit -{ - LegacyInit() - { - for (int i = 0; i < STYLE_Count; ++i) - { - LegacyRenderStyles[i].BlendOp = Styles[i*4]; - LegacyRenderStyles[i].SrcAlpha = Styles[i*4+1]; - LegacyRenderStyles[i].DestAlpha = Styles[i*4+2]; - LegacyRenderStyles[i].Flags = Styles[i*4+3]; - } - } -} DoLegacyInit; - -#endif double GetAlpha(int type, double alpha) { From 1033976158094aeb65b14791930d57827d3271c4 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 2 Apr 2017 11:47:10 +0300 Subject: [PATCH 5/8] Fixed typo in status bar function name https://mantis.zdoom.org/view.php?id=519 --- wadsrc/static/zscript/statusbar/statusbar.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index 434d4bd6a..7ea4ca39d 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -580,7 +580,7 @@ class BaseStatusBar native ui // //============================================================================ - bool CheckDiplayName(String displayname) + bool CheckDisplayName(String displayname) { if (CPlayer == null) return false; return displayname == PlayerPawn.GetPrintableDisplayName(CPlayer.mo.GetClass()); From 4cf3e1be2c4cda353e602a82630b506dcfbd14ad Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 2 Apr 2017 11:51:58 +0300 Subject: [PATCH 6/8] Removed obsolete workaround for Apple's GCC 4.x from node builder --- src/nodebuild_utility.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/nodebuild_utility.cpp b/src/nodebuild_utility.cpp index f27b95485..754e3519c 100644 --- a/src/nodebuild_utility.cpp +++ b/src/nodebuild_utility.cpp @@ -71,13 +71,7 @@ static const int PO_LINE_EXPLICIT = 5; angle_t FNodeBuilder::PointToAngle (fixed_t x, fixed_t y) { const double rad2bam = double(1<<30) / M_PI; -#if defined __APPLE__ && !defined __llvm__ - // Work-around for vectorization issue in Apple's GCC 4.x - // See https://gcc.gnu.org/wiki/Math_Optimization_Flags for details - long double ang = atan2l (double(y), double(x)); -#else // !__APPLE__ || __llvm__ double ang = g_atan2 (double(y), double(x)); -#endif // __APPLE__ && !__llvm__ // Convert to signed first since negative double to unsigned is undefined. return angle_t(int(ang * rad2bam)) << 1; } From e074c75609e6083c691d6a59d78212a72b73ab17 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 Apr 2017 12:56:26 +0200 Subject: [PATCH 7/8] - added a generic TransformRect to the status bar so that the proper transformations can be applied to draw operations that require special parameters not supported by the stock functions. --- src/g_statusbar/sbar.h | 1 + src/g_statusbar/shared_sbar.cpp | 86 ++++++++----------- wadsrc/static/zscript/statusbar/statusbar.txt | 1 + 3 files changed, 37 insertions(+), 51 deletions(-) diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index fd200c8d8..e4ca894ac 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -396,6 +396,7 @@ public: void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY); void DrawString(FFont *font, const FString &cstring, double x, double y, int flags, double Alpha, int translation, int spacing, bool monospaced, int shadowX, int shadowY); + void TransformRect(double &x, double &y, double &w, double &h, int flags = 0); void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0); void SetClipRect(double x, double y, double w, double h, int flags = 0); diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 3b3a900b1..2514cd8d2 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -1847,7 +1847,7 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, DrawString) // //============================================================================ -void DBaseStatusBar::Fill(PalEntry color, double x, double y, double w, double h, int flags) +void DBaseStatusBar::TransformRect(double &x, double &y, double &w, double &h, int flags) { // resolve auto-alignment before making any adjustments to the position values. if (!(flags & DI_SCREEN_MANUAL_ALIGN)) @@ -1858,8 +1858,6 @@ void DBaseStatusBar::Fill(PalEntry color, double x, double y, double w, double h else flags |= DI_SCREEN_TOP; } - double Alpha = color.a * this->Alpha / 255; - if (Alpha <= 0) return; x += drawOffset.X; y += drawOffset.Y; @@ -1897,10 +1895,42 @@ void DBaseStatusBar::Fill(PalEntry color, double x, double y, double w, double h x += orgx; y += orgy; } +} + + +DEFINE_ACTION_FUNCTION(DBaseStatusBar, TransformRect) +{ + PARAM_SELF_PROLOGUE(DBaseStatusBar); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(w); + PARAM_FLOAT(h); + PARAM_INT_DEF(flags); + self->TransformRect(x, y, w, h, flags); + if (numret > 0) ret[0].SetFloat(x); + if (numret > 1) ret[1].SetFloat(y); + if (numret > 2) ret[2].SetFloat(w); + if (numret > 3) ret[3].SetFloat(h); + return MIN(4, numret); +} + +//============================================================================ +// +// draw stuff +// +//============================================================================ + +void DBaseStatusBar::Fill(PalEntry color, double x, double y, double w, double h, int flags) +{ + double Alpha = color.a * this->Alpha / 255; + if (Alpha <= 0) return; + + TransformRect(x, y, w, h, flags); + int x1 = int(x); int y1 = int(y); int ww = int(x + w - x1); // account for scaling to non-integers. Truncating the values separately would fail for cases like - int hh = int(y + h - y1); // y=3.5, height = 5.5 where adding both values gives a larger integer than adding the two integers. + int hh = int(y + h - y1); // y=3.5, height = 5.5 where adding both values gives a larger integer than adding the two integers. screen->Dim(color, float(Alpha), x1, y1, ww, hh); } @@ -1928,57 +1958,11 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, Fill) void DBaseStatusBar::SetClipRect(double x, double y, double w, double h, int flags) { - // resolve auto-alignment before making any adjustments to the position values. - if (!(flags & DI_SCREEN_MANUAL_ALIGN)) - { - if (x < 0) flags |= DI_SCREEN_RIGHT; - else flags |= DI_SCREEN_LEFT; - if (y < 0) flags |= DI_SCREEN_BOTTOM; - else flags |= DI_SCREEN_TOP; - } - - x += drawOffset.X; - y += drawOffset.Y; - - if (!fullscreenOffsets) - { - StatusbarToRealCoords(x, y, w, h); - } - else - { - double orgx, orgy; - - switch (flags & DI_SCREEN_HMASK) - { - default: orgx = 0; break; - case DI_SCREEN_HCENTER: orgx = screen->GetWidth() / 2; break; - case DI_SCREEN_RIGHT: orgx = screen->GetWidth(); break; - } - - switch (flags & DI_SCREEN_VMASK) - { - default: orgy = 0; break; - case DI_SCREEN_VCENTER: orgy = screen->GetHeight() / 2; break; - case DI_SCREEN_BOTTOM: orgy = screen->GetHeight(); break; - } - - // move stuff in the top right corner a bit down if the fps counter is on. - if ((flags & (DI_SCREEN_HMASK | DI_SCREEN_VMASK)) == DI_SCREEN_RIGHT_TOP && vid_fps) y += 10; - - DVector2 Scale = GetHUDScale(); - - x *= Scale.X; - y *= Scale.Y; - w *= Scale.X; - h *= Scale.Y; - x += orgx; - y += orgy; - } + TransformRect(x, y, w, h, flags); int x1 = int(x); int y1 = int(y); int ww = int(x + w - x1); // account for scaling to non-integers. Truncating the values separately would fail for cases like int hh = int(y + h - y1); // y=3.5, height = 5.5 where adding both values gives a larger integer than adding the two integers. - screen->SetClipRect(x1, y1, ww, hh); } diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index 7ea4ca39d..789e3cd8d 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -323,6 +323,7 @@ class BaseStatusBar native ui native void DrawTexture(TextureID texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1)); native void DrawImage(String texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1)); native void DrawString(HUDFont font, String string, Vector2 pos, int flags = 0, int translation = Font.CR_UNTRANSLATED, double Alpha = 1., int wrapwidth = -1, int linespacing = 4); + native double, double, double, double TransformRect(double x, double y, double w, double h, int flags = 0); native void Fill(Color col, double x, double y, double w, double h, int flags = 0); native static String FormatNumber(int number, int minsize = 0, int maxsize = 0, int format = 0, String prefix = ""); native double, double, double, double StatusbarToRealCoords(double x, double y=0, double w=0, double h=0); From 73c14510483abd802c6a7844b3d32dac7122f863 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sun, 2 Apr 2017 11:43:13 -0500 Subject: [PATCH 8/8] - fixed: The functionality for AddEventHandlers and EventHandlers were backwards. --- src/gi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gi.cpp b/src/gi.cpp index ce0aada05..ac4f5117c 100644 --- a/src/gi.cpp +++ b/src/gi.cpp @@ -352,8 +352,8 @@ void FMapInfoParser::ParseGameInfo() GAMEINFOKEY_STRINGARRAY(PrecachedClasses, "precacheclasses", 0, false) GAMEINFOKEY_STRINGARRAY(PrecachedTextures, "precachetextures", 0, false) GAMEINFOKEY_SOUNDARRAY(PrecachedSounds, "precachesounds", 0, false) - GAMEINFOKEY_STRINGARRAY(EventHandlers, "addeventhandlers", 0, true) - GAMEINFOKEY_STRINGARRAY(EventHandlers, "eventhandlers", 0, false) + GAMEINFOKEY_STRINGARRAY(EventHandlers, "addeventhandlers", 0, false) + GAMEINFOKEY_STRINGARRAY(EventHandlers, "eventhandlers", 0, true) GAMEINFOKEY_STRING(PauseSign, "pausesign") GAMEINFOKEY_STRING(quitSound, "quitSound") GAMEINFOKEY_STRING(BorderFlat, "borderFlat")