mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
cd7d2c3446
The NameAllocator class is not only about Textures, so let's change a comment being related to it.
35 lines
791 B
C++
35 lines
791 B
C++
/*
|
|
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibGL/NameAllocator.h>
|
|
|
|
namespace GL {
|
|
|
|
void NameAllocator::allocate(GLsizei count, GLuint* names)
|
|
{
|
|
for (auto i = 0; i < count; ++i) {
|
|
if (!m_free_names.is_empty()) {
|
|
names[i] = m_free_names.top();
|
|
m_free_names.pop();
|
|
} else {
|
|
// We're out of free previously allocated names. Let's allocate a new contiguous amount from the
|
|
// last known id
|
|
names[i] = m_last_id++;
|
|
}
|
|
}
|
|
}
|
|
|
|
void NameAllocator::free(GLuint name)
|
|
{
|
|
m_free_names.push(name);
|
|
}
|
|
|
|
bool NameAllocator::has_allocated_name(GLuint name) const
|
|
{
|
|
return name < m_last_id && !m_free_names.contains_slow(name);
|
|
}
|
|
|
|
}
|