Commit Graph
47 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 4c7dd44351 TextDrawer: Remove the current font and scale
Drawing now takes the style and scale too, like measuring, so the text
drawers have no font state left. UIContext keeps its current style and
passes it, and fills it in from the theme if nothing has set one yet.
PPGe passes its one font.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 11:54:10 +01:00
Henrik RydgårdandClaude Opus 5.5 dc1e9e50fc TextDrawer: Measure in a given style without switching fonts
Measuring took the current font and scale, so UIContext switched to the
style being measured and back. On first draw the font to switch back to
could be an empty one, which the UWP drawer asserts on.

MeasureString and MeasureStringRect now take the style and scale, and the
backends' MeasureStringInternal measures in the style it's given.
SetOrCreateFont, which sets the font drawing uses, is shared, and the
backends only implement EnsureFont, which creates a font if needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 11:45:04 +01:00
Henrik RydgårdandClaude Opus 5.5 e86113afa3 Fix the Windows build of draw_text.cpp
CommonWindows.h defines WIN32_LEAN_AND_MEAN, which leaves out what the
Direct2D/DirectWrite headers in draw_text_uwp.h need. Include
<windows.h> with just NOMINMAX instead, and keep std::max out of
DropShadow.h so it doesn't depend on which order windows.h comes in.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:04:18 +02:00
Henrik RydgårdandClaude Opus 5.5 dea182f1d8 Use one UI drop shadow for text and atlas images, fix Windows build
Text and the SVG button images are mixed on screen, so they now share
UIDropShadowParams (3 UI units of blur, 0.66 intensity, no offset, the
atlas's existing look) instead of the text having its own.

draw_text.cpp included <windows.h> directly, whose min/max macros broke
the std::max calls added here. Include CommonWindows.h instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 12:32:25 +02:00
Henrik RydgårdandClaude Opus 5.5 fcfac13643 Share the drop shadow code between the UI atlas and the text drawer
CompositeDropShadow in Common/Render/DropShadow.cpp blurs a premultiplied
RGBA image's alpha (with an optional offset) and composites the image
over it. The atlas's AddDropShadow and TextDrawer::AddDropShadow are now
thin wrappers that pick the parameters.

The blur scatters only the non-transparent texels, which makes atlas
shadows 3-7x faster than the old gather-with-clamping version. Atlas
output is unchanged apart from rounding (alpha differs by at most 1).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 11:56:24 +02:00
Henrik RydgårdandClaude Opus 5.5 352c0da492 TextDrawer: Add FLAG_DROP_SHADOW for a soft drop shadow under text
The backend rasterizes coverage (or color, for emoji) as usual, then a
shared CPU pass pads the bitmap, blurs an offset copy of the coverage
and composites the text over it as RGBA8888. Blur and offset scale with
the font size and with DPI. The flag is part of the string cache key,
and the text is still aligned by its own size, with the quad grown to
fit the shadow.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 11:51:18 +02:00
Henrik RydgårdandClaude Opus 5.5 02b688e4f3 TextDrawer: Cache wrapped text, hash the string caches
MeasureString was slow mostly because of wrapping: DrawStringRect and
MeasureStringRect re-ran the word wrapper every frame, and it measures
every prefix of every word. Wrapped strings are now cached. The caches
are unordered_maps with an xxhash of the key, and lookups reuse a key
buffer so a hit doesn't allocate. UIContext also skips switching fonts
when measuring in the current style. In a Mac debug build, 200 cached
measures go from 0.26 to 0.06 ms and 10 wrapped paragraphs from 2.1 to
0.01 ms per frame.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-22 10:11:42 +02:00
Henrik Rydgård 8cd7e1b2c0 Delete all support for Qt
Our Qt backend has long been left behind and doesn't even support Vulkan
currently. There would be a lot of work to make it viable, and I don't
think anyone is really interested.

ImGui on SDL will soon fulfill the need for a more classic user interface
with a menu bar on Linux, and on Mac we already have a native UI.
2026-08-08 18:18:28 +02:00
Henrik Rydgård 2b821037d7 SDL3_ttf work 2026-06-16 11:39:24 +02:00
Henrik Rydgård 8649fec2a6 Turn off color emoji (D2D text rendering) on Windows 7. See #21834 2026-06-15 08:37:09 +02:00
Kevin Reinholz d6060d4b3b Build fixes for clang on FreeBSD 2026-05-31 13:27:45 -07:00
Henrik Rydgård b2faec0533 Windows: Restore the GDI-based text drawer, use it if RenderDoc is attached
The D2D-based text renderer requires a D3D11 context, which confuses
RenderDoc (it doesn't permit multiple 3D APIs in the same process).

So, let's restore the old GDI renderer and use it if RenderDoc is attached.

See #21638
2026-05-20 10:25:29 +02:00
Henrik Rydgård 3aa4714ce0 Merge draw_text_win with draw_text_uwp. 2026-05-18 14:11:22 +02:00
Henrik Rydgård 8724f40c12 DrawText: Clamp strings to sane sizes. 2026-01-01 14:23:57 +01:00
Henrik Rydgård 1ea93e2913 Small refactor of text rect measurement. Add move/resize icons 2025-11-27 11:50:22 +01:00
Henrik Rydgård 59ab9e5682 Fix font loading in cocoa as well. 2025-11-09 08:52:21 +01:00
Henrik Rydgård 2fce2da709 Apply the font system rework to Android as well 2025-11-09 08:52:21 +01:00
Henrik Rydgård 4283e66a12 Font style rework: Windows part 2025-11-09 08:52:21 +01:00
Henrik Rydgård b082e94edb Initial work on using premultiplied alpha in the UI 2025-10-16 11:07:05 +02:00
Henrik Rydgård 09e067c6e1 Revert "Get rid of remains of support for non-square screen DPIs"
This reverts commit f206ed95eb.
2025-05-21 21:41:50 +02:00
Henrik Rydgård 531842f577 Add font cache stats to "internals" screen 2025-04-09 12:40:10 +02:00
Henrik Rydgård 1bd0ebd600 Code cleanup (remove .c_str()) 2025-03-29 18:48:35 +01:00
Henrik Rydgård f206ed95eb Get rid of remains of support for non-square screen DPIs 2025-02-20 11:14:26 -06:00
Henrik Rydgård 9ce9e43481 Make some uses of the erase-iter idiom safer and more consistent 2025-02-04 10:31:17 -06:00
Henrik Rydgård 68f61c2add ImGeDebugger: Highlight changes, show old value on hover 2024-12-14 11:03:18 +01:00
Henrik Rydgård a6a189c24d An old version of android had strict JNI validation of UTF-8 strings enabled. Let's pass it. 2024-10-22 11:02:26 +02:00
Henrik Rydgård e49d94ad11 Unify the MeasureString caching code 2024-10-16 14:39:21 +02:00
Henrik Rydgård ce980af01e TextDrawer: Improve performance for text wrapping (by measuring without wrapping first) 2024-10-16 13:35:32 +02:00
Henrik Rydgård eccd7f3767 More const/static-ification 2024-09-17 15:22:37 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Henrik Rydgård 81c642e2b2 Fix scaling issues in cocoa text drawer 2024-06-01 13:44:11 +02:00
Henrik Rydgård 28cf69f67e Remove duplicate code from the text rendering backends 2024-06-01 09:58:58 +02:00
Henrik Rydgård 4051f34758 Implement MeasureStringRect generically based on MeasureString 2024-05-31 21:11:48 +02:00
Henrik Rydgård 5b0007f391 Remove unused and broken text rotation code 2024-05-31 20:58:53 +02:00
Henrik Rydgård 2061f04885 Also remove DrawString in the SDL text backend 2024-05-31 19:08:25 +02:00
Henrik Rydgård 423f7620dd Also implement for Cocoa. 2024-05-31 19:00:23 +02:00
Henrik Rydgård 533f8f06be Unify DrawString between Windows, UWP and Android. More to come. 2024-05-31 17:27:59 +02:00
Henrik Rydgård 5f4257bf4a Get it to build and run on iOS too, not just Mac. There's some odd DPI issue though. 2024-05-29 18:52:39 +02:00
Henrik Rydgård 0bbaaef787 Seems to be working now, though need to figure out which font face we can use. 2024-05-29 18:52:39 +02:00
Henrik Rydgård 3965c1ae6b Start implementing cocoa-based text rendering. Doesn't work yet, renders garbage. 2024-05-29 18:52:39 +02:00
Henrik Rydgård ccbcf1369b Convert DrawString* functions to use std::string_view 2024-05-24 22:52:51 +02:00
Henrik Rydgård 804f31f424 Convert MeasureString* functions to use std::string_view 2024-05-24 14:16:40 +02:00
Henrik Rydgård 4b45bde38f Convert WordWrapper to use std::string_view 2024-05-24 13:39:49 +02:00
Henrik Rydgård f6ca8101e0 Start getting string_view into WordWrapper 2024-05-24 12:40:11 +02:00
Hoe Hao Cheng 2b826b5614 SDL: implement TextDrawer using SDL2_ttf 2023-07-25 13:05:32 +08:00
Henrik Rydgård 8b431b39ba Wrap the display globals in a struct (#16998)
* Wrap the display globals in a struct

Makes it easier to search/replace these, for future refactorings.

* Some renaming

* Qt buildfix, also fix the Qt build on Mac (got broken with battery changes)

* Attempt at buildfixing ios

* UWP buildfix
2023-02-25 13:09:44 +01:00
Henrik Rydgård 8761bf2bc9 Move text rendering to Common. 2020-10-05 00:05:28 +02:00