Improve macOS Retina UI clarity and bundle HD assets

This commit is contained in:
shen
2026-09-30 16:13:31 -07:00
parent 905f23f135
commit d1f8d3dddd
26 changed files with 505 additions and 134 deletions
+39
View File
@@ -132,6 +132,45 @@ int main()
}
CHECK(inked);
// PORT: changing monitors must rebuild glyph rasters, not text layout. Existing
// CGraphicTextInstance objects retain pointers into the character-info map.
auto* font = text->GetFontTexturePointer();
auto* glyph = font->GetCharacterInfomation(1252, L'H');
const auto original_glyph = *glyph;
int page_width = 0, page_height = 0;
for (const auto& command : UIRenderCommands()) {
UIMemoryTexture page;
if (UIRenderMemoryTexture(command.text, &page)) {
page_width = page.width; page_height = page.height; break;
}
}
CHECK(page_width > 0);
for (int scale : {2, 3, 1, 2}) {
UISetFontOversample(scale);
CHECK(UIFontOversample() == scale);
CHECK(font->GetCharacterInfomation(1252, L'H') == glyph);
CHECK(glyph->width == original_glyph.width && glyph->height == original_glyph.height &&
glyph->advance == original_glyph.advance);
UIRenderBeginFrame();
instance.Render(); // use the already cached glyph pointers
CHECK(glyph_quads(&left, &right) == 5);
int new_width = 0, new_height = 0;
instance.GetTextSize(&new_width, &new_height);
CHECK(new_width == width && new_height == height);
bool sized = false, fine_coverage = false;
for (const auto& command : UIRenderCommands()) {
UIMemoryTexture page;
if (!UIRenderMemoryTexture(command.text, &page)) continue;
sized |= page.width == page_width * scale && page.height == page_height * scale;
for (auto argb : page.argb) {
const auto alpha = argb >> 24;
fine_coverage |= alpha > 0 && alpha < 255 && alpha % 17 != 0;
}
}
CHECK(sized);
if (scale > 1) CHECK(fine_coverage); // 8-bit alpha, not the old 4-bit quantisation
}
instance.Destroy();
text->Release();