Text rendering optimizations (#7497)
This commit is contained in:
parent
a2e1835993
commit
f07112bda6
@ -45,7 +45,7 @@ struct WindowTemplate
|
|||||||
struct Window
|
struct Window
|
||||||
{
|
{
|
||||||
struct WindowTemplate window;
|
struct WindowTemplate window;
|
||||||
u8 *tileData;
|
ALIGNED(4) u8 *tileData;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool32 InitWindows(const struct WindowTemplate *templates);
|
bool32 InitWindows(const struct WindowTemplate *templates);
|
||||||
|
|||||||
@ -220,7 +220,7 @@ void FillWindowTilesByRow(int windowId, int columnStart, int rowStart, int numFi
|
|||||||
|
|
||||||
fillSize = numFillTiles * TILE_SIZE_4BPP;
|
fillSize = numFillTiles * TILE_SIZE_4BPP;
|
||||||
windowRowSize = window->window.width * TILE_SIZE_4BPP;
|
windowRowSize = window->window.width * TILE_SIZE_4BPP;
|
||||||
windowTileData = window->tileData + (rowStart * windowRowSize) + (columnStart * TILE_SIZE_4BPP);
|
windowTileData = (u8 *)window->tileData + (rowStart * windowRowSize) + (columnStart * TILE_SIZE_4BPP);
|
||||||
if (numRows > 0)
|
if (numRows > 0)
|
||||||
{
|
{
|
||||||
for (i = numRows; i != 0; i--)
|
for (i = numRows; i != 0; i--)
|
||||||
|
|||||||
51
src/text.c
51
src/text.c
@ -427,6 +427,13 @@ void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor)
|
|||||||
|
|
||||||
u16 *current = sFontHalfRowLookupTable;
|
u16 *current = sFontHalfRowLookupTable;
|
||||||
|
|
||||||
|
if (fgColor == sLastTextFgColor
|
||||||
|
&& bgColor == sLastTextBgColor
|
||||||
|
&& shadowColor == sLastTextShadowColor)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sLastTextBgColor = bgColor;
|
sLastTextBgColor = bgColor;
|
||||||
sLastTextFgColor = fgColor;
|
sLastTextFgColor = fgColor;
|
||||||
sLastTextShadowColor = shadowColor;
|
sLastTextShadowColor = shadowColor;
|
||||||
@ -629,27 +636,35 @@ static u8 UNUSED GetLastTextColor(u8 colorType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u32 *glyphPixels, s32 width, s32 height)
|
inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 x0, u32 y0, u32 *glyphPixels, s32 width, s32 height)
|
||||||
{
|
{
|
||||||
u32 xAdd, yAdd, pixelData, bits, toOrr, dummyX;
|
if (width <= 0)
|
||||||
u8 *dst;
|
return;
|
||||||
|
|
||||||
xAdd = j + width;
|
u32 widthMask = (1 << (width * 4)) - 1;
|
||||||
yAdd = i + height;
|
|
||||||
dummyX = j;
|
u32 shift0 = (x0 % 8) * 4, shift8 = 32 - shift0;
|
||||||
for (; i < yAdd; i++)
|
|
||||||
|
u32 *alignedWindowTilesX = (u32 *)(windowTiles + ((x0 / 8) * TILE_SIZE_4BPP));
|
||||||
|
|
||||||
|
u32 y1 = y0 + height;
|
||||||
|
for (u32 y = y0; y < y1; y++)
|
||||||
{
|
{
|
||||||
pixelData = *glyphPixels++;
|
u32 pixels = *glyphPixels++ & widthMask;
|
||||||
for (j = dummyX; j < xAdd; j++)
|
|
||||||
{
|
u32 mask = pixels;
|
||||||
if ((toOrr = pixelData & 0xF))
|
mask = mask | (mask >> 2);
|
||||||
{
|
mask = mask | (mask >> 1);
|
||||||
dst = windowTiles + ((j / 8) * 32) + ((j % 8) / 2) + ((i / 8) * widthOffset) + ((i % 8) * 4);
|
mask = mask & 0x11111111;
|
||||||
bits = ((j & 1) * 4);
|
mask = mask * 0xF;
|
||||||
*dst = (toOrr << bits) | (*dst & (0xF0 >> bits));
|
|
||||||
}
|
u32 pixels0 = pixels << shift0, pixels8 = pixels >> shift8;
|
||||||
pixelData >>= 4;
|
u32 mask0 = mask << shift0, mask8 = mask >> shift8;
|
||||||
}
|
|
||||||
|
u32 *alignedWindowTiles = (u32 *)((u8 *)alignedWindowTilesX + ((y / 8) * widthOffset) + ((y % 8) * 4));
|
||||||
|
|
||||||
|
alignedWindowTiles[0] = (alignedWindowTiles[0] & ~mask0) | pixels0;
|
||||||
|
alignedWindowTiles[8] = (alignedWindowTiles[8] & ~mask8) | pixels8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user