Skip to content

Commit

Permalink
Lock on texture mutex when updating atlas reference counts
Browse files Browse the repository at this point in the history
  • Loading branch information
karimnaaji committed Dec 22, 2016
1 parent 75f31f2 commit 4f64a90
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 12 additions & 9 deletions core/src/text/fontContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,20 @@ bool FontContext::layoutText(TextStyle::Parameters& _params, const std::string&
(metrics.aabb.y + height * 0.5) * TextVertex::position_scale);


for (; it != _quads.end(); ++it) {
{
std::lock_guard<std::mutex> lock(m_textureMutex);
for (; it != _quads.end(); ++it) {

if (!_refs[it->atlas]) {
_refs[it->atlas] = true;
m_atlasRefCount[it->atlas]++;
}
if (!_refs[it->atlas]) {
_refs[it->atlas] = true;
m_atlasRefCount[it->atlas]++;
}

it->quad[0].pos -= offset;
it->quad[1].pos -= offset;
it->quad[2].pos -= offset;
it->quad[3].pos -= offset;
it->quad[0].pos -= offset;
it->quad[1].pos -= offset;
it->quad[2].pos -= offset;
it->quad[3].pos -= offset;
}
}

return true;
Expand Down
2 changes: 0 additions & 2 deletions core/src/text/fontContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ class FontContext : public alfons::TextureCallback {

void releaseAtlas(std::bitset<max_textures> _refs);

alfons::GlyphAtlas& atlas() { return m_atlas; }

/* Update all textures batches, uploads the data to the GPU */
void updateTextures(RenderState& rs);

Expand Down

0 comments on commit 4f64a90

Please sign in to comment.