Skip to content

Commit

Permalink
Text: Clear glyph cache when it fills up
Browse files Browse the repository at this point in the history
We can use a smaller glyph cache if we clear it when it fills up. Even a large cache would eventually fill up, so clearing is a good strategy anyway. Clears occur still rather infrequently.

# Conflicts:
#	src/ui/text.c
  • Loading branch information
skyjake committed Jan 12, 2021
1 parent 5314388 commit 15263b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ui/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ static void initCache_Text_(iText *d) {
init_Array(&d->cacheRows, sizeof(iCacheRow));
const int textSize = d->contentFontSize * fontSize_UI;
iAssert(textSize > 0);
const iInt2 cacheDims = init_I2(16, 80);
const iInt2 cacheDims = init_I2(16, 40);
d->cacheSize = mul_I2(cacheDims, init1_I2(iMax(textSize, fontSize_UI)));
SDL_RendererInfo renderInfo;
SDL_GetRendererInfo(d->render, &renderInfo);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ void draw_Window(iWindow *d) {
#if 0
/* Text cache debugging. */ {
SDL_Texture *cache = glyphCache_Text();
SDL_Rect rect = { d->root->rect.size.x - 640, 0, 640, 5 * 640 };
SDL_Rect rect = { d->root->rect.size.x - 640, 0, 640, 2.5 * 640 };
SDL_SetRenderDrawColor(d->render, 0, 0, 0, 255);
SDL_RenderFillRect(d->render, &rect);
SDL_RenderCopy(d->render, glyphCache_Text(), NULL, &rect);
Expand Down

0 comments on commit 15263b2

Please sign in to comment.