summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-08-15 08:45:12 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-08-15 08:45:12 +0300
commit20f118801d8b18b0dd77ae35c8049ca5d6d9ad44 (patch)
treecf49f555fd6263f212568bfa61547fab4bf31e9a
parent6a99b9b889eb949e029506b3e85e0126edfe60d7 (diff)
SDL 2.0.16 line drawing regression (OpenGL renderer)
This is not specific to macOS, but seems to affect OpenGL rendering on all platforms.
-rw-r--r--src/macos.m1
-rw-r--r--src/ui/labelwidget.c11
-rw-r--r--src/ui/paint.c12
-rw-r--r--src/ui/window.c7
-rw-r--r--src/ui/window.h2
5 files changed, 23 insertions, 10 deletions
diff --git a/src/macos.m b/src/macos.m
index 6bec3c12..d588fa4a 100644
--- a/src/macos.m
+++ b/src/macos.m
@@ -60,6 +60,7 @@ static NSString *currentSystemAppearance_(void) {
60} 60}
61 61
62iBool shouldDefaultToMetalRenderer_MacOS(void) { 62iBool shouldDefaultToMetalRenderer_MacOS(void) {
63 /* TODO: Test if SDL 2.0.16 works better (no stutters with Metal?). */
63 return iFalse; /* 64 return iFalse; /*
64 const iInt2 ver = macVer_(); 65 const iInt2 ver = macVer_();
65 return ver.x > 10 || ver.y > 13;*/ 66 return ver.x > 10 || ver.y > 13;*/
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index d6cc31cb..edc36a49 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -300,14 +300,15 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
300 bottomLeft_Rect(frameRect), 300 bottomLeft_Rect(frameRect),
301 topLeft_Rect(frameRect), 301 topLeft_Rect(frameRect),
302 topRight_Rect(frameRect), 302 topRight_Rect(frameRect),
303#if SDL_VERSION_ATLEAST(2, 0, 16) && defined (iPlatformApple)
304 /* A very curious regression in SDL 2.0.16 on macOS. */
305 addX_I2(bottomRight_Rect(frameRect), -1),
306#else
307 bottomRight_Rect(frameRect), 303 bottomRight_Rect(frameRect),
308#endif
309 bottomLeft_Rect(frameRect) 304 bottomLeft_Rect(frameRect)
310 }; 305 };
306#if SDL_VERSION_ATLEAST(2, 0, 16)
307 if (isOpenGLRenderer_Window()) {
308 /* A very curious regression in SDL 2.0.16. */
309 points[3].x--;
310 }
311#endif
311 drawLines_Paint(&p, points + 2, 3, frame2); 312 drawLines_Paint(&p, points + 2, 3, frame2);
312 drawLines_Paint( 313 drawLines_Paint(
313 &p, points, !isHover && flags & d->flags.noTopFrame ? 2 : 3, frame); 314 &p, points, !isHover && flags & d->flags.noTopFrame ? 2 : 3, frame);
diff --git a/src/ui/paint.c b/src/ui/paint.c
index 869238d5..79adb7d1 100644
--- a/src/ui/paint.c
+++ b/src/ui/paint.c
@@ -89,17 +89,19 @@ void drawRect_Paint(const iPaint *d, iRect rect, int color) {
89 /* Keep the right/bottom edge visible in the window. */ 89 /* Keep the right/bottom edge visible in the window. */
90 if (br.x == d->dst->size.x) br.x--; 90 if (br.x == d->dst->size.x) br.x--;
91 if (br.y == d->dst->size.y) br.y--; 91 if (br.y == d->dst->size.y) br.y--;
92 const SDL_Point edges[] = { 92 SDL_Point edges[] = {
93 { left_Rect(rect), top_Rect(rect) }, 93 { left_Rect(rect), top_Rect(rect) },
94 { br.x, top_Rect(rect) }, 94 { br.x, top_Rect(rect) },
95 { br.x, br.y }, 95 { br.x, br.y },
96#if SDL_VERSION_ATLEAST(2, 0, 16) && defined (iPlatformApple)
97 { left_Rect(rect), br.y - 1 }, /* regression in SDL 2.0.16? */
98#else
99 { left_Rect(rect), br.y }, 96 { left_Rect(rect), br.y },
100#endif
101 { left_Rect(rect), top_Rect(rect) } 97 { left_Rect(rect), top_Rect(rect) }
102 }; 98 };
99#if SDL_VERSION_ATLEAST(2, 0, 16)
100 if (isOpenGLRenderer_Window()) {
101 /* A very curious regression in SDL 2.0.16. */
102 edges[3].y--;
103 }
104#endif
103 setColor_Paint_(d, color); 105 setColor_Paint_(d, color);
104 SDL_RenderDrawLines(renderer_Paint_(d), edges, iElemCount(edges)); 106 SDL_RenderDrawLines(renderer_Paint_(d), edges, iElemCount(edges));
105} 107}
diff --git a/src/ui/window.c b/src/ui/window.c
index 6b8abb4d..86d22b1c 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -65,6 +65,8 @@ static float initialUiScale_ = 1.0f;
65static float initialUiScale_ = 1.1f; 65static float initialUiScale_ = 1.1f;
66#endif 66#endif
67 67
68static iBool isOpenGLRenderer_;
69
68iDefineTypeConstructionArgs(Window, (iRect rect), rect) 70iDefineTypeConstructionArgs(Window, (iRect rect), rect)
69 71
70/* TODO: Define menus per platform. */ 72/* TODO: Define menus per platform. */
@@ -446,6 +448,7 @@ void init_Window(iWindow *d, iRect rect) {
446 /* Some info. */ { 448 /* Some info. */ {
447 SDL_RendererInfo info; 449 SDL_RendererInfo info;
448 SDL_GetRendererInfo(d->render, &info); 450 SDL_GetRendererInfo(d->render, &info);
451 isOpenGLRenderer_ = !iCmpStr(info.name, "opengl");
449 printf("[window] renderer: %s%s\n", info.name, 452 printf("[window] renderer: %s%s\n", info.name,
450 info.flags & SDL_RENDERER_ACCELERATED ? " (accelerated)" : ""); 453 info.flags & SDL_RENDERER_ACCELERATED ? " (accelerated)" : "");
451#if !defined (NDEBUG) 454#if !defined (NDEBUG)
@@ -1187,6 +1190,10 @@ iWindow *get_Window(void) {
1187 return theWindow_; 1190 return theWindow_;
1188} 1191}
1189 1192
1193iBool isOpenGLRenderer_Window(void) {
1194 return isOpenGLRenderer_;
1195}
1196
1190void setKeyboardHeight_Window(iWindow *d, int height) { 1197void setKeyboardHeight_Window(iWindow *d, int height) {
1191 if (d->keyboardHeight != height) { 1198 if (d->keyboardHeight != height) {
1192 d->keyboardHeight = height; 1199 d->keyboardHeight = height;
diff --git a/src/ui/window.h b/src/ui/window.h
index bb98dbe9..63f7e5f2 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -137,6 +137,8 @@ iRoot * findRoot_Window (const iWindow *, const iWidget *widget);
137iRoot * otherRoot_Window (const iWindow *, iRoot *root); 137iRoot * otherRoot_Window (const iWindow *, iRoot *root);
138iWindow * get_Window (void); 138iWindow * get_Window (void);
139 139
140iBool isOpenGLRenderer_Window (void);
141
140#if defined (LAGRANGE_ENABLE_CUSTOM_FRAME) 142#if defined (LAGRANGE_ENABLE_CUSTOM_FRAME)
141SDL_HitTestResult hitTest_Window(const iWindow *d, iInt2 pos); 143SDL_HitTestResult hitTest_Window(const iWindow *d, iInt2 pos);
142#endif 144#endif