summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-12 23:14:40 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-12 23:14:40 +0300
commit2b231bb52d7daea0e8921c7bbd7bdd932fd7912c (patch)
tree90125c406d63a8ff0edf3de870bece2674b7ccb1 /src
parentba8e8eb4219c3ad3b9b87c0a6800ef2d26b6c964 (diff)
Text: Slightly fewer render target switches
Diffstat (limited to 'src')
-rw-r--r--src/ui/text.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index f0fc9976..3de1c83b 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -369,11 +369,8 @@ static void cache_Font_(iFont *d, iGlyph *glyph, int hoff) {
369 } 369 }
370 /* Determine placement in the glyph cache texture, advancing in rows. */ 370 /* Determine placement in the glyph cache texture, advancing in rows. */
371 glRect->pos = assignCachePos_Text_(txt, glRect->size); 371 glRect->pos = assignCachePos_Text_(txt, glRect->size);
372 SDL_Texture *oldTarget = SDL_GetRenderTarget(render);
373 SDL_SetRenderTarget(render, txt->cache);
374 const SDL_Rect dstRect = sdlRect_(*glRect); 372 const SDL_Rect dstRect = sdlRect_(*glRect);
375 SDL_RenderCopy(render, tex, &(SDL_Rect){ 0, 0, dstRect.w, dstRect.h }, &dstRect); 373 SDL_RenderCopy(render, tex, &(SDL_Rect){ 0, 0, dstRect.w, dstRect.h }, &dstRect);
376 SDL_SetRenderTarget(render, oldTarget);
377 if (tex) { 374 if (tex) {
378 SDL_DestroyTexture(tex); 375 SDL_DestroyTexture(tex);
379 iAssert(surface); 376 iAssert(surface);
@@ -409,8 +406,11 @@ static const iGlyph *glyph_Font_(iFont *d, iChar ch) {
409 iGlyph *glyph = new_Glyph(ch); 406 iGlyph *glyph = new_Glyph(ch);
410 glyph->glyphIndex = glyphIndex; 407 glyph->glyphIndex = glyphIndex;
411 glyph->font = font; 408 glyph->font = font;
409 SDL_Texture *oldTarget = SDL_GetRenderTarget(text_.render);
410 SDL_SetRenderTarget(text_.render, text_.cache);
412 cache_Font_(font, glyph, 0); 411 cache_Font_(font, glyph, 0);
413 cache_Font_(font, glyph, 1); /* half-pixel offset */ 412 cache_Font_(font, glyph, 1); /* half-pixel offset */
413 SDL_SetRenderTarget(text_.render, oldTarget);
414 insert_Hash(&font->glyphs, &glyph->node); 414 insert_Hash(&font->glyphs, &glyph->node);
415 return glyph; 415 return glyph;
416} 416}