|
Deki 0.19.0
Modular C++ 2D engine for embedded displays and desktop
|
Owning array of T, freed when it goes out of scope. More...
#include <deki/providers/Buffer.h>
Public Member Functions | |
| Buffer ()=default | |
| Buffer (size_t count, Memory::Region region, AllocContext ctx={}) | |
| Allocates count elements. Check the result with if (!buffer). | |
| ~Buffer () | |
| Buffer (Buffer &&other) noexcept | |
| Buffer & | operator= (Buffer &&other) noexcept |
| Buffer (const Buffer &)=delete | |
| Buffer & | operator= (const Buffer &)=delete |
| bool | Allocate (size_t count, Memory::Region region, AllocContext ctx={}) |
| Allocates count elements, replacing what it held. | |
| void | Reset () |
| Frees now rather than at scope exit. | |
| T * | Release () |
| Gives up ownership and returns the raw pointer, for handing the memory to something that frees it itself or outlives this object. | |
| operator bool () const | |
| True when this holds memory. The only check a caller needs. | |
| T * | Data () |
| const T * | Data () const |
| size_t | Count () const |
| Elements, not bytes. | |
| size_t | Bytes () const |
| bool | Empty () const |
| T & | operator[] (size_t i) |
| const T & | operator[] (size_t i) const |
| T * | begin () |
| T * | end () |
| const T * | begin () const |
| const T * | end () const |
Owning array of T, freed when it goes out of scope.
Move-only: a copy would need a second allocation that could fail, which a copy constructor cannot report.
For raw pixel, glyph and sample data handed to blitters and drivers. It never constructs or destroys elements (Memory returns them zeroed), so T must be trivially copyable and destructible; the static_asserts enforce it.
|
default |
|
inline |
Allocates count elements. Check the result with if (!buffer).
|
inline |
|
inlinenoexcept |
|
delete |
|
inlinenoexcept |
|
delete |
|
inline |
Allocates count elements, replacing what it held.
Returns false on failure.
The old contents are freed first, not copied: callers overwrite the buffer right away, and a copy would need both allocations at once. An unchanged count keeps the existing memory, so calling this every frame from a render path is cheap.
|
inline |
Frees now rather than at scope exit.
|
inline |
Gives up ownership and returns the raw pointer, for handing the memory to something that frees it itself or outlives this object.
The caller must then call Deki::Memory::Free. Rarely needed.
|
inlineexplicit |
True when this holds memory. The only check a caller needs.
|
inline |
|
inline |
|
inline |
Elements, not bytes.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |