Some rendering optimizations.

This commit is contained in:
Martín Lucas Golini
2026-05-05 01:42:54 -03:00
parent 336afe90d7
commit dc603d4275
4 changed files with 20 additions and 13 deletions

View File

@@ -1336,7 +1336,7 @@ Int32 Text::findCharacterFromPos( const Vector2i& pos, bool returnNearest, Font*
};
if ( fpos.y >= charTop && fpos.y <= charBottom ) {
auto findNextInsertionIndex = [&layout, sg, i, sgs, tSize, sp]() -> Int32 {
auto findNextInsertionIndex = [&]() -> Int32 {
if ( layout->isRTL() ) {
if ( i > 0 ) {
for ( auto j = i - 1; j >= 0; j-- ) {

View File

@@ -13,7 +13,7 @@
namespace EE::Graphics {
using LRULayoutCache = LRUCache<2048, Uint64, TextLayout::Cache>;
using LRULayoutCache = LRUCache<8192, Uint64, TextLayout::Cache>;
#ifdef EE_TEXT_SHAPER_ENABLED

View File

@@ -4212,6 +4212,7 @@ void UICodeEditor::drawLineText( const Int64& line, Vector2f position, const Flo
}
}
} else {
bool getChunkHints = !Text::canSkipShaping( drawHints ) && tokens.size() > 8192;
for ( const auto& token : tokens ) {
String::View text = strLine.view();
if ( pos < strLine.size() && !( pos == 0 && text.size() == token.len ) ) {
@@ -4281,28 +4282,35 @@ void UICodeEditor::drawLineText( const Int64& line, Vector2f position, const Flo
Int64 totalChars = curCharsWidth - start;
Int64 end = eemin( totalChars, minimumCharsToCoverScreen );
if ( curCharsWidth >= charsToVisible ) {
String::View subText( text.substr( start, end ) );
size = Text::draw(
text.substr( start, end ),
subText,
{ position.x + start * getGlyphWidth(), position.y + lineOffset },
fontStyle, mTabWidth, drawHints, mTextDirection,
whitespaceDisplayConfig );
fontStyle, mTabWidth,
getChunkHints ? String::getTextHints( subText ) : drawHints,
mTextDirection, whitespaceDisplayConfig );
if ( minimumCharsToCoverScreen == end )
break;
}
} else {
size = Text::draw( text.substr( 0, eemin( curCharsWidth, maxWidth ) ),
{ position.x, position.y + lineOffset }, fontStyle,
mTabWidth, drawHints, mTextDirection,
whitespaceDisplayConfig );
String::View subText( text.substr( 0, eemin( curCharsWidth, maxWidth ) ) );
size = Text::draw(
subText, { position.x, position.y + lineOffset }, fontStyle, mTabWidth,
getChunkHints ? String::getTextHints( subText ) : drawHints,
mTextDirection, whitespaceDisplayConfig );
}
} else {
size =
Text::draw( text, { position.x, position.y + lineOffset }, fontStyle,
mTabWidth, drawHints, mTextDirection, whitespaceDisplayConfig );
size = Text::draw( text, { position.x, position.y + lineOffset }, fontStyle,
mTabWidth,
getChunkHints ? String::getTextHints( text ) : drawHints,
mTextDirection, whitespaceDisplayConfig );
}
if ( !isMonospace )
textWidth = size.getWidth();
if ( position.x > mScreenPos.x + mSize.getWidth() )
break;
} else if ( position.x > mScreenPos.x + mSize.getWidth() ) {
break;
}

View File

@@ -2,7 +2,6 @@
#include <eepp/window/backend/SDL3/joystickmanagersdl3.hpp>
#include <eepp/window/backend/SDL3/windowsdl3.hpp>
#include <eepp/window/engine.hpp>
#include <limits>
#ifdef EE_BACKEND_SDL3