diff --git a/ChangeLog b/ChangeLog index 2554e4fad7..d7e6893e10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,7 @@ Unreleased Version 2.2.2-pre * Feature: Allow assigning keyboard shortcuts to brushes. Assigning the same shortcut to multiple brushes will toggle through them. Thanks annoy for suggesting. * Fix: Make user interface scaling not round to multiple of 100% anymore. Thanks blau, Buch, Chryssabliss and ShotgunnerFox for reporting. * Fix: Don't use system message boxes on Android, since they behave in various broken and nonsensical ways, like showing you a yes button three times. Thanks Hopfel for reporting. + * Feature: Use hardware renderer on Android by default. 2024-08-09 Version 2.2.2-beta.3 * Fix: Use more accurate timers for performance profiles if the platform supports it. diff --git a/src/desktop/main.cpp b/src/desktop/main.cpp index 34f45254a7..7449533be9 100644 --- a/src/desktop/main.cpp +++ b/src/desktop/main.cpp @@ -389,11 +389,7 @@ int DrawpileApp::getCanvasImplementationFor(int canvasImplementation) case int(CanvasImplementation::Software): return canvasImplementation; default: -#ifdef __EMSCRIPTEN__ - return int(CanvasImplementation::OpenGl); -#else - return int(CanvasImplementation::GraphicsView); -#endif + return int(CANVAS_IMPLEMENTATION_DEFAULT); } } diff --git a/src/desktop/view/glcanvas.cpp b/src/desktop/view/glcanvas.cpp index 7ca06fab81..627f287548 100644 --- a/src/desktop/view/glcanvas.cpp +++ b/src/desktop/view/glcanvas.cpp @@ -994,27 +994,24 @@ void GlCanvas::initializeGL() } d->initialized = true; -#ifndef __EMSCRIPTEN__ +#ifdef CANVAS_IMPLEMENTATION_FALLBACK // Calling OpenGL functions can crash if the driver is sufficiently bad. // Set it to the default renderer temporarily so the user doesn't get stuck. desktop::settings::Settings *settings = nullptr; int originalRenderCanvas = -1; if(dpApp().isCanvasImplementationFromSettings()) { - constexpr int DEFAULT_RENDER_CANVAS = - int(libclient::settings::CanvasImplementation::Default); + constexpr int fallback = int(CANVAS_IMPLEMENTATION_FALLBACK); settings = &dpApp().settings(); originalRenderCanvas = settings->renderCanvas(); - if(originalRenderCanvas == DEFAULT_RENDER_CANVAS) { + if(originalRenderCanvas == fallback) { qCWarning( - lcDpGlCanvas, - "Canvas implementation is already set to the default %d", - DEFAULT_RENDER_CANVAS); + lcDpGlCanvas, "Canvas implementation is already set to %d", + fallback); } else { qCDebug( - lcDpGlCanvas, - "Reverting canvas implementation from %d to default %d", - originalRenderCanvas, DEFAULT_RENDER_CANVAS); - settings->setRenderCanvas(DEFAULT_RENDER_CANVAS); + lcDpGlCanvas, "Reverting canvas implementation from %d to %d", + originalRenderCanvas, fallback); + settings->setRenderCanvas(fallback); settings->trySubmit(); } } @@ -1121,7 +1118,7 @@ void GlCanvas::initializeGL() d->dirty = Private::Dirty(); -#ifndef __EMSCRIPTEN__ +#ifdef CANVAS_IMPLEMENTATION_FALLBACK if(settings && originalRenderCanvas >= 0) { qCDebug( lcDpGlCanvas, "Restoring canvas implementation to %d", diff --git a/src/libclient/settings.h b/src/libclient/settings.h index ed3ab0ed29..42dd73f746 100644 --- a/src/libclient/settings.h +++ b/src/libclient/settings.h @@ -43,6 +43,22 @@ enum class CanvasImplementation : int { }; Q_ENUM_NS(CanvasImplementation) +#if defined(__EMSCRIPTEN__) +# define CANVAS_IMPLEMENTATION_DEFAULT \ + ::libclient::settings::CanvasImplementation::OpenGl +# undef CANVAS_IMPLEMENTATION_FALLBACK +#elif defined(Q_OS_ANDROID) +# define CANVAS_IMPLEMENTATION_DEFAULT \ + ::libclient::settings::CanvasImplementation::OpenGl +# define CANVAS_IMPLEMENTATION_FALLBACK \ + ::libclient::settings::CanvasImplementation::GraphicsView +#else +# define CANVAS_IMPLEMENTATION_DEFAULT \ + ::libclient::settings::CanvasImplementation::GraphicsView +# define CANVAS_IMPLEMENTATION_FALLBACK \ + ::libclient::settings::CanvasImplementation::Default +#endif + // On most platforms, tablet input comes at a very high precision and frequency, // so some smoothing is sensible by default. On Android (at least on a Samsung // Galaxy S6 Lite, a Samsung Galaxy S8 Ultra and reports from unknown devices)