|
Porytiles
|
Manages allocation of hardware palette indexes with stack-based checkout semantics. More...
#include <palette_pool.hpp>
Public Member Functions | |
| PalettePool (std::bitset< pal::num_pals > available_indexes) | |
| Constructs a PalettePool with the specified available indexes. | |
| bool | has_available_pal () const |
| Checks if there is at least one available pal that can be checked out. | |
| bool | is_available (std::size_t hardware_index) const |
| Checks if a specific index is available for checkout. | |
| std::size_t | checkout () |
| Checks out the next available hardware palette index. | |
| void | checkout (std::size_t index) |
| Checks out a specific hardware palette index. | |
| void | checkin () |
| Returns the most recently checked-out hardware palette index index to the pool. | |
Manages allocation of hardware palette indexes with stack-based checkout semantics.
PalettePool tracks which hardware palette slots (0-15) are available for use and which have been "checked out" by the packing algorithm. The pool is initialized with a bitset indicating which slots are available (on bits). Indexes can be checked out via check_out() and returned via checkin() in LIFO (stack) order.
Definition at line 22 of file palette_pool.hpp.
|
explicit |
Constructs a PalettePool with the specified available indexes.
The available_indexes bitset determines which hardware palette slots can be used. Only indexes with their corresponding bit set to 1 can be checked out.
| available_indexes | Bitset where on-bits indicate available palette slots |
Definition at line 7 of file palette_pool.cpp.
| void porytiles::PalettePool::checkin | ( | ) |
Returns the most recently checked-out hardware palette index index to the pool.
Pops the most recent hardware palette index from the internal checkout stack and marks it as no longer checked out. This enables LIFO (stack) semantics for index management.
Definition at line 49 of file palette_pool.cpp.
| std::size_t porytiles::PalettePool::checkout | ( | ) |
Checks out the next available hardware palette index.
Finds the lowest available hardware palette index that hasn't been checked out, marks it as checked out, and returns it. The index is pushed onto an internal stack to support LIFO checkin behavior.
Definition at line 20 of file palette_pool.cpp.
| void porytiles::PalettePool::checkout | ( | std::size_t | index | ) |
Checks out a specific hardware palette index.
Marks the specified hardware palette index as checked out and pushes it onto the checkout stack. Use this when a specific palette index is required (e.g., prefilled palettes).
| index | The hardware palette index to check out |
Definition at line 39 of file palette_pool.cpp.
|
inline |
Checks if there is at least one available pal that can be checked out.
Definition at line 40 of file palette_pool.hpp.
| bool porytiles::PalettePool::is_available | ( | std::size_t | hardware_index | ) | const |
Checks if a specific index is available for checkout.
| hardware_index | The hardware palette index to check |
Definition at line 12 of file palette_pool.cpp.