Changed defaults
This commit is contained in:
@@ -102,11 +102,20 @@ void RuntimeTextTextureCache::UpdateArtifactState(const RuntimeShaderArtifact& a
|
||||
mArtifact.parameterValues = artifact.parameterValues;
|
||||
}
|
||||
|
||||
void RuntimeTextTextureCache::RefreshTextTextures()
|
||||
void RuntimeTextTextureCache::RefreshTextTextures(RuntimeShaderArtifact* artifactState)
|
||||
{
|
||||
if (artifactState)
|
||||
artifactState->textTextureWidthScales.clear();
|
||||
for (TextTexture& textTexture : mTextTextures)
|
||||
{
|
||||
EnsureTextTexture(textTexture);
|
||||
if (artifactState)
|
||||
{
|
||||
const float scale = textTexture.width == 0
|
||||
? 1.0f
|
||||
: static_cast<float>(textTexture.liveWidth) / static_cast<float>(textTexture.width);
|
||||
artifactState->textTextureWidthScales[textTexture.parameterId] = scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,7 +335,8 @@ bool RuntimeTextTextureCache::EnsureTextTexture(TextTexture& texture)
|
||||
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
std::vector<unsigned char> pixels = ComposeTextMask(*atlas, texture, text, width, height);
|
||||
unsigned liveWidth = 1;
|
||||
std::vector<unsigned char> pixels = ComposeTextMask(*atlas, texture, text, width, height, liveWidth);
|
||||
if (pixels.empty() || width == 0 || height == 0)
|
||||
return false;
|
||||
|
||||
@@ -356,10 +366,11 @@ bool RuntimeTextTextureCache::EnsureTextTexture(TextTexture& texture)
|
||||
texture.cachedText = text;
|
||||
texture.width = width;
|
||||
texture.height = height;
|
||||
texture.liveWidth = liveWidth;
|
||||
return texture.texture != 0;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> RuntimeTextTextureCache::ComposeTextMask(const Atlas& atlas, const TextTexture& texture, const std::string& text, unsigned& width, unsigned& height) const
|
||||
std::vector<unsigned char> RuntimeTextTextureCache::ComposeTextMask(const Atlas& atlas, const TextTexture& texture, const std::string& text, unsigned& width, unsigned& height, unsigned& liveWidth) const
|
||||
{
|
||||
double advance = 0.0;
|
||||
for (unsigned char character : text)
|
||||
@@ -370,7 +381,8 @@ std::vector<unsigned char> RuntimeTextTextureCache::ComposeTextMask(const Atlas&
|
||||
}
|
||||
|
||||
const unsigned fixedWidth = static_cast<unsigned>(std::ceil(static_cast<double>(texture.maxLength) * kFontPixelsPerEm * 0.9)) + kTextTexturePadding * 2u;
|
||||
width = (std::max)(fixedWidth, static_cast<unsigned>(std::ceil(advance * kFontPixelsPerEm)) + kTextTexturePadding * 2u);
|
||||
liveWidth = (std::max)(1u, static_cast<unsigned>(std::ceil(advance * kFontPixelsPerEm)) + kTextTexturePadding * 2u);
|
||||
width = (std::max)(fixedWidth, liveWidth);
|
||||
height = kTextTextureHeight;
|
||||
std::vector<unsigned char> mask(static_cast<std::size_t>(width) * height, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user