mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-16 02:59:49 +01:00
UI: Rounded rectangles from precomputed atlas corners
UIAtlas generates an antialiased white corner for each radius in ROUND_RECT_RADII (8, 16, 24, 32 UI units) and each style (filled, and thin/medium/thick outlines from ROUND_RECT_THICKNESS) at the atlas DPI. DrawBuffer::DrawRoundRect mirrors the corner into all four corners and stretches the corner's last texel row/column along the edges, so a round rect is 9 quads (8 for outlines). Other radii use the nearest corner, scaled. The LogoScreen temporarily draws some for testing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
42bb9b134b
commit
110fb7fd6a
5 files changed
+182
-2
No files matched your search
+28
-1
@@ -468,7 +468,34 @@ void LogoScreen::DrawForeground(UIContext &dc) {
|
||||
alphaText = 3.0f - t;
|
||||
uint32_t textColor = colorAlpha(dc.GetTheme().infoStyle.fgColor, alphaText);
|
||||
|
||||
auto cr = GetI18NCategory(I18NCat::PSPCREDITS);
|
||||
// TEMPORARY: Round rect test. Fixed seed so they stay put between frames.
|
||||
{
|
||||
uint32_t seed = 12345;
|
||||
auto rnd = [&seed]() {
|
||||
seed = seed * 1664525 + 1013904223;
|
||||
return (float)(seed >> 8) * (1.0f / 16777216.0f);
|
||||
};
|
||||
for (int i = 0; i < 24; i++) {
|
||||
const float w = 20.0f + rnd() * 200.0f;
|
||||
const float h = 20.0f + rnd() * 120.0f;
|
||||
const float x = bounds.x + rnd() * (bounds.w - w);
|
||||
const float y = bounds.y + rnd() * (bounds.h - h);
|
||||
const float radius = 2.0f + rnd() * 20.0f;
|
||||
const RoundRectStyle style = (RoundRectStyle)(int)(rnd() * (float)RoundRectStyle::COUNT);
|
||||
const uint32_t color = 0x80000000 | ((uint32_t)(rnd() * 16777215.0f) & 0xFFFFFF);
|
||||
dc.Draw()->DrawRoundRect(x, y, x + w, y + h, radius, color, style);
|
||||
}
|
||||
// Every precomputed corner at its native size.
|
||||
for (int r = 0; r < ROUND_RECT_RADIUS_COUNT; r++) {
|
||||
for (int s = 0; s < (int)RoundRectStyle::COUNT; s++) {
|
||||
const float x = bounds.x + 10.0f + s * 130.0f;
|
||||
const float y = bounds.y + 10.0f + r * 90.0f;
|
||||
dc.Draw()->DrawRoundRect(x, y, x + 120.0f, y + 80.0f, ROUND_RECT_RADII[r], 0xFFFFFFFF, (RoundRectStyle)s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto cr =GetI18NCategory(I18NCat::PSPCREDITS);
|
||||
auto gr = GetI18NCategory(I18NCat::GRAPHICS);
|
||||
char temp[256];
|
||||
|
||||
|
||||
Reference in new issue
Block a user