5#ifndef FLUTTER_IMPELLER_BASE_ALLOCATION_H_
6#define FLUTTER_IMPELLER_BASE_ALLOCATION_H_
13#include "third_party/abseil-cpp/absl/status/statusor.h"
87 uint8_t* buffer_ =
nullptr;
91 [[nodiscard]]
bool Reserve(
Bytes reserved);
93 [[nodiscard]]
bool ReserveNPOT(
Bytes reserved);
125 const std::shared_ptr<Allocation>& allocation);
138 std::shared_ptr<const std::string>
string);
Describes an allocation on the heap.
uint8_t * GetBuffer() const
Gets the pointer to the start of the allocation.
Bytes GetReservedLength() const
Gets the reserved length of the allocation. Calls to truncate may be ignored till the length exceeds ...
static absl::StatusOr< uint64_t > NextPowerOfTwoSize(uint64_t x)
Gets the next power of two size.
~Allocation()
Destroys the allocation.
Allocation()
Constructs a new zero-sized allocation.
Bytes GetLength() const
Gets the length of the allocation.
bool Truncate(Bytes length, bool npot=true)
Resize the underlying allocation to at least given number of bytes.
std::shared_ptr< fml::Mapping > CreateMappingWithString(std::string string)
Creates a mapping with string data.
std::shared_ptr< fml::Mapping > CreateMappingWithCopy(const uint8_t *contents, Bytes length)
Creates a mapping with copy of the bytes.
std::shared_ptr< fml::Mapping > CreateMappingFromAllocation(const std::shared_ptr< Allocation > &allocation)
Creates a mapping from allocation.