diff options
-rw-r--r-- | res/about/version.gmi | 2 | ||||
-rw-r--r-- | src/app.c | 8 | ||||
-rw-r--r-- | src/app.h | 3 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 2 | ||||
-rw-r--r-- | src/ui/window.c | 27 |
5 files changed, 30 insertions, 12 deletions
diff --git a/res/about/version.gmi b/res/about/version.gmi index aa3d759a..ebdd7b60 100644 --- a/res/about/version.gmi +++ b/res/about/version.gmi | |||
@@ -7,6 +7,8 @@ | |||
7 | # Release notes | 7 | # Release notes |
8 | 8 | ||
9 | ## 0.2 | 9 | ## 0.2 |
10 | * Fall back to software rendering automatically if accelerated graphics are not available. | ||
11 | * Added --sw option to force software rendering. | ||
10 | 12 | ||
11 | ## 0.1.1 | 13 | ## 0.1.1 |
12 | * Fixed a potential crash at startup. | 14 | * Fixed a potential crash at startup. |
@@ -98,6 +98,7 @@ struct Impl_App { | |||
98 | float uiScale; | 98 | float uiScale; |
99 | int zoomPercent; | 99 | int zoomPercent; |
100 | iBool forceWrap; | 100 | iBool forceWrap; |
101 | iBool forceSoftwareRender; | ||
101 | enum iColorTheme theme; | 102 | enum iColorTheme theme; |
102 | iBool useSystemTheme; | 103 | iBool useSystemTheme; |
103 | iString gopherProxy; | 104 | iString gopherProxy; |
@@ -304,6 +305,7 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
304 | d->pendingRefresh = iFalse; | 305 | d->pendingRefresh = iFalse; |
305 | d->zoomPercent = 100; | 306 | d->zoomPercent = 100; |
306 | d->forceWrap = iFalse; | 307 | d->forceWrap = iFalse; |
308 | d->forceSoftwareRender = checkArgument_CommandLine(&d->args, "sw") != NULL; | ||
307 | d->certs = new_GmCerts(dataDir_App_); | 309 | d->certs = new_GmCerts(dataDir_App_); |
308 | d->visited = new_Visited(); | 310 | d->visited = new_Visited(); |
309 | d->bookmarks = new_Bookmarks(); | 311 | d->bookmarks = new_Bookmarks(); |
@@ -531,10 +533,14 @@ int zoom_App(void) { | |||
531 | return app_.zoomPercent; | 533 | return app_.zoomPercent; |
532 | } | 534 | } |
533 | 535 | ||
534 | iBool isLineWrapForced_App(void) { | 536 | iBool forceLineWrap_App(void) { |
535 | return app_.forceWrap; | 537 | return app_.forceWrap; |
536 | } | 538 | } |
537 | 539 | ||
540 | iBool forceSoftwareRender_App(void) { | ||
541 | return app_.forceSoftwareRender; | ||
542 | } | ||
543 | |||
538 | enum iColorTheme colorTheme_App(void) { | 544 | enum iColorTheme colorTheme_App(void) { |
539 | return app_.theme; | 545 | return app_.theme; |
540 | } | 546 | } |
@@ -58,7 +58,8 @@ iBool isRefreshPending_App (void); | |||
58 | uint32_t elapsedSinceLastTicker_App (void); /* milliseconds */ | 58 | uint32_t elapsedSinceLastTicker_App (void); /* milliseconds */ |
59 | 59 | ||
60 | int zoom_App (void); | 60 | int zoom_App (void); |
61 | iBool isLineWrapForced_App(void); | 61 | iBool forceLineWrap_App (void); |
62 | iBool forceSoftwareRender_App(void); | ||
62 | enum iColorTheme colorTheme_App (void); | 63 | enum iColorTheme colorTheme_App (void); |
63 | const iString * schemeProxy_App (iRangecc scheme); | 64 | const iString * schemeProxy_App (iRangecc scheme); |
64 | 65 | ||
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index fce548b4..ab8af9b8 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -269,7 +269,7 @@ static iRect documentBounds_DocumentWidget_(const iDocumentWidget *d) { | |||
269 | } | 269 | } |
270 | 270 | ||
271 | static int forceBreakWidth_DocumentWidget_(const iDocumentWidget *d) { | 271 | static int forceBreakWidth_DocumentWidget_(const iDocumentWidget *d) { |
272 | if (isLineWrapForced_App()) { | 272 | if (forceLineWrap_App()) { |
273 | const iRect bounds = bounds_Widget(constAs_Widget(d)); | 273 | const iRect bounds = bounds_Widget(constAs_Widget(d)); |
274 | const iRect docBounds = documentBounds_DocumentWidget_(d); | 274 | const iRect docBounds = documentBounds_DocumentWidget_(d); |
275 | return right_Rect(bounds) - left_Rect(docBounds) - gap_UI * d->pageMargin; | 275 | return right_Rect(bounds) - left_Rect(docBounds) - gap_UI * d->pageMargin; |
diff --git a/src/ui/window.c b/src/ui/window.c index 0a63a941..38df42e0 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -477,26 +477,35 @@ static void drawBlank_Window_(iWindow *d) { | |||
477 | SDL_RenderPresent(d->render); | 477 | SDL_RenderPresent(d->render); |
478 | } | 478 | } |
479 | 479 | ||
480 | // #define ENABLE_SWRENDER | 480 | iBool create_Window_(iWindow *d, iRect rect, uint32_t flags) { |
481 | flags |= SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; | ||
482 | if (SDL_CreateWindowAndRenderer( | ||
483 | width_Rect(rect), height_Rect(rect), flags, &d->win, &d->render)) { | ||
484 | return iFalse; | ||
485 | } | ||
486 | return iTrue; | ||
487 | } | ||
481 | 488 | ||
482 | void init_Window(iWindow *d, iRect rect) { | 489 | void init_Window(iWindow *d, iRect rect) { |
483 | theWindow_ = d; | 490 | theWindow_ = d; |
484 | iZap(d->cursors); | 491 | iZap(d->cursors); |
485 | d->pendingCursor = NULL; | 492 | d->pendingCursor = NULL; |
486 | d->isDrawFrozen = iTrue; | 493 | d->isDrawFrozen = iTrue; |
487 | uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; | 494 | uint32_t flags = 0; |
488 | #if defined (ENABLE_SWRENDER) | 495 | #if defined (iPlatformApple) |
489 | SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software"); | ||
490 | #elif defined (iPlatformApple) | ||
491 | SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal"); | 496 | SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal"); |
492 | #else | 497 | #else |
493 | flags |= SDL_WINDOW_OPENGL; | 498 | flags |= SDL_WINDOW_OPENGL; |
494 | #endif | 499 | #endif |
495 | SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1"); | 500 | SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1"); |
496 | if (SDL_CreateWindowAndRenderer( | 501 | /* First try SDL's default renderer that should be the best option. */ |
497 | width_Rect(rect), height_Rect(rect), flags, &d->win, &d->render)) { | 502 | if (forceSoftwareRender_App() || !create_Window_(d, rect, flags)) { |
498 | fprintf(stderr, "Error when creating window: %s\n", SDL_GetError()); | 503 | /* No luck, maybe software only? This should always work as long as there is a display. */ |
499 | exit(-2); | 504 | SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software"); |
505 | if (!create_Window_(d, rect, 0)) { | ||
506 | fprintf(stderr, "Error when creating window: %s\n", SDL_GetError()); | ||
507 | exit(-2); | ||
508 | } | ||
500 | } | 509 | } |
501 | if (left_Rect(rect) >= 0) { | 510 | if (left_Rect(rect) >= 0) { |
502 | SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); | 511 | SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); |