Texture composition for text no longer on the render thread
Some checks failed
CI / React UI Build (push) Successful in 10s
CI / Native Windows Build And Tests (push) Failing after 2m9s
CI / Windows Release Package (push) Has been skipped

This commit is contained in:
2026-05-21 17:25:28 +10:00
parent 3fc78d5bb8
commit 5cf1a09e75
8 changed files with 330 additions and 235 deletions

View File

@@ -24,36 +24,9 @@ public:
static void AssignSamplerUniforms(GLuint program, const RuntimeShaderArtifact& artifact);
private:
struct Glyph
{
double advance = 0.0;
double planeLeft = 0.0;
double planeTop = 0.0;
double planeRight = 0.0;
double planeBottom = 0.0;
double atlasLeft = 0.0;
double atlasTop = 0.0;
double atlasRight = 0.0;
double atlasBottom = 0.0;
bool hasBounds = false;
};
struct Atlas
{
std::string fontId;
unsigned width = 0;
unsigned height = 0;
double ascender = -0.9;
double descender = 0.25;
double lineHeight = 1.2;
std::vector<unsigned char> rgbaPixels;
std::map<unsigned, Glyph> glyphsByCodepoint;
};
struct TextTexture
{
std::string parameterId;
std::string fontId;
std::string cachedText;
GLuint texture = 0;
unsigned width = 0;
@@ -62,16 +35,10 @@ private:
unsigned maxLength = 64;
};
bool LoadAtlas(const RenderCadenceCompositor::FontAtlasBuildOutput& output, Atlas& atlas, std::string& error) const;
bool EnsureTextTexture(TextTexture& texture);
std::vector<unsigned char> ComposeTextTexture(const Atlas& atlas, const TextTexture& texture, const std::string& text, unsigned& width, unsigned& height, unsigned& liveWidth) const;
const Atlas* FindAtlas(const std::string& fontId) const;
static const ShaderParameterValue* FindParameterValue(const RuntimeShaderArtifact& artifact, const std::string& parameterId);
static std::string DefaultTextValue(const RuntimeShaderArtifact& artifact, const std::string& parameterId);
static void SampleAtlasPixel(const Atlas& atlas, double x, double y, unsigned char* rgba);
const RuntimePreparedTextTexture* FindPreparedTexture(const std::string& parameterId) const;
static void DestroyTexture(TextTexture& texture);
RuntimeShaderArtifact mArtifact;
std::vector<Atlas> mAtlases;
std::vector<TextTexture> mTextTextures;
};