Skip to content

Conversation

@j-jorge
Copy link
Contributor

@j-jorge j-jorge commented Dec 3, 2025

First commit: the blending loops were processing the bitmap column-major, but the bitmap is actually stored row-major. I've switched the loops to have a more cache-friendly iteration.

Second commit: multiple dynamic allocations were done for the bitmap buffers when using a font with an outline. This commit adds a pool of buffers to recycle for new allocations.

Copy link
Collaborator

@halx99 halx99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@j-jorge
Copy link
Contributor Author

j-jorge commented Dec 4, 2025

Please don't reformat full-file, refer: https://github.com/axmolengine/axmol?tab=readme-ov-file#-branches

Done, with my apologies.

@rh101
Copy link
Contributor

rh101 commented Dec 4, 2025

Multi-line blocks should be surrounded by curly brackets, such as this code in the current PR:

for (BufferPool& p : _availableBuffers)
    if (p.capacity == it->second)
    {
        p.buffers.emplace_back(buffer);
        break;
    }

should be:

for (BufferPool& p : _availableBuffers)
{
    if (p.capacity == it->second)
    {
        p.buffers.emplace_back(buffer);
        break;
    }
}

Same goes for this, where the comment block is below the conditional statement:

if ((new_pool_index == n) || (_availableBuffers[new_pool_index].capacity != size))
    // Either all pools have capacities smaller than the requested size, or else
    // We have pools with capacity larger than the requested size but none had
    // an available buffer. We create a new pool for the requested size so
    // we'll be ready to receive the buffer in releaseBuffer.
    _availableBuffers.emplace(_availableBuffers.begin() + new_pool_index)->capacity = size;

where it should be:

if ((new_pool_index == n) || (_availableBuffers[new_pool_index].capacity != size))
{
    // Either all pools have capacities smaller than the requested size, or else
    // We have pools with capacity larger than the requested size but none had
    // an available buffer. We create a new pool for the requested size so
    // we'll be ready to receive the buffer in releaseBuffer.
    _availableBuffers.emplace(_availableBuffers.begin() + new_pool_index)->capacity = size;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants