@@ -282,13 +282,26 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
282
282
283
283
std::pair<EFontGlyphType, S32> bitmap_entry = std::make_pair (EFontGlyphType::Grayscale, -1 );
284
284
U32 glyph_count = 0 ;
285
+ auto draw_queued_glyphs = [&]()
286
+ {
287
+ if (glyph_count)
288
+ {
289
+ gGL .begin (LLRender::TRIANGLES);
290
+ {
291
+ gGL .vertexBatchPreTransformed (vertices, uvs, colors, glyph_count * 6 );
292
+ }
293
+ gGL .end ();
294
+ glyph_count = 0 ;
295
+ }
296
+ };
297
+
285
298
for (i = begin_offset; i < begin_offset + length; i++)
286
299
{
287
300
llwchar wch = wstr[i];
288
301
289
302
const LLFontGlyphInfo* fgi = next_glyph;
290
303
next_glyph = NULL ;
291
- if (!fgi)
304
+ if (!fgi)
292
305
{
293
306
fgi = mFontFreetype ->getGlyphInfo (wch, (!use_color) ? EFontGlyphType::Grayscale : EFontGlyphType::Color);
294
307
}
@@ -303,15 +316,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
303
316
{
304
317
// Actually draw the queued glyphs before switching their texture;
305
318
// otherwise the queued glyphs will be taken from wrong textures.
306
- if (glyph_count > 0 )
307
- {
308
- gGL .begin (LLRender::TRIANGLES);
309
- {
310
- gGL .vertexBatchPreTransformed (vertices, uvs, colors, glyph_count * 6 );
311
- }
312
- gGL .end ();
313
- glyph_count = 0 ;
314
- }
319
+ draw_queued_glyphs ();
315
320
316
321
bitmap_entry = next_bitmap_entry;
317
322
LLImageGL* font_image = font_bitmap_cache->getImageGL (bitmap_entry.first , bitmap_entry.second );
@@ -336,16 +341,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
336
341
(F32)ll_round (cur_render_x + (F32)fgi->mXBearing ) + (F32)fgi->mWidth ,
337
342
(F32)ll_round (cur_render_y + (F32)fgi->mYBearing ) - (F32)fgi->mHeight );
338
343
339
- if (glyph_count >= GLYPH_BATCH_SIZE)
340
- {
341
- gGL .begin (LLRender::TRIANGLES);
342
- {
343
- gGL .vertexBatchPreTransformed (vertices, uvs, colors, glyph_count * 6 );
344
- }
345
- gGL .end ();
346
-
347
- glyph_count = 0 ;
348
- }
344
+ draw_queued_glyphs ();
349
345
350
346
const LLColor4U& col =
351
347
bitmap_entry.first == EFontGlyphType::Grayscale ? text_color
@@ -376,12 +372,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
376
372
cur_render_y = cur_y;
377
373
}
378
374
379
- gGL .begin (LLRender::TRIANGLES);
380
- {
381
- gGL .vertexBatchPreTransformed (vertices, uvs, colors, glyph_count * 6 );
382
- }
383
- gGL .end ();
384
-
375
+ draw_queued_glyphs ();
385
376
386
377
if (right_x)
387
378
{
0 commit comments