diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-09-07 17:18:13 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-09-08 07:20:03 +0200 |
commit | 6cf4c5b98fb0e3f30379d79003ab587aadebbce7 (patch) | |
tree | eaefb97f24b520b29fa10d4bcc497147d4e73139 /src/gui/text/coretext/qfontengine_coretext.mm | |
parent | c8fb928029d92f78ecfd70f9c3bf7efc41fe7485 (diff) |
CoreText: Resolve color scheme (dark mode) via the platform theme
We might be drawing glyphs outside the main thread, which triggers
the main thread checker for our access to NSApplication from
qt_mac_applicationIsInDarkMode().
Change the CoreText font engine to pull out this information from
the theme instead, and teach the theme to only updates its color
scheme on the main thread.
Pick-to: 6.6
Change-Id: I02be713d9705c6e0c21107db7f7de039182f601d
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/gui/text/coretext/qfontengine_coretext.mm')
-rw-r--r-- | src/gui/text/coretext/qfontengine_coretext.mm | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gui/text/coretext/qfontengine_coretext.mm b/src/gui/text/coretext/qfontengine_coretext.mm index 599a7f08c3..6cdba2609d 100644 --- a/src/gui/text/coretext/qfontengine_coretext.mm +++ b/src/gui/text/coretext/qfontengine_coretext.mm @@ -12,6 +12,8 @@ #include <QtGui/qpainterpath.h> #include <private/qcoregraphics_p.h> #include <private/qimage_p.h> +#include <private/qguiapplication_p.h> +#include <qpa/qplatformtheme.h> #include <cmath> @@ -716,10 +718,12 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, const QFixedPoint &subP // draw with white or black fill, and then invert the glyph image in the latter case, // producing an alpha map. This covers the most common use-cases, but longer term we // should propagate the fill color all the way from the paint engine, and include it - //in the key for the glyph cache. + // in the key for the glyph cache. - if (!qt_mac_applicationIsInDarkMode()) - return kCGColorBlack; + if (auto *platformTheme = QGuiApplicationPrivate::platformTheme()) { + if (platformTheme->colorScheme() != Qt::ColorScheme::Dark) + return kCGColorBlack; + } } return kCGColorWhite; }(); |