#include <SubRunAllocator.h>
|
| SubRunAllocator (char *block, int blockSize, int firstHeapAllocation) |
|
| SubRunAllocator (int firstHeapAllocation=0) |
|
| SubRunAllocator (const SubRunAllocator &)=delete |
|
SubRunAllocator & | operator= (const SubRunAllocator &)=delete |
|
| SubRunAllocator (SubRunAllocator &&)=default |
|
SubRunAllocator & | operator= (SubRunAllocator &&)=default |
|
template<typename T , typename... Args> |
T * | makePOD (Args &&... args) |
|
template<typename T , typename... Args> |
std::unique_ptr< T, Destroyer > | makeUnique (Args &&... args) |
|
template<typename T > |
T * | makePODArray (int n) |
|
template<typename T > |
SkSpan< T > | makePODSpan (SkSpan< const T > s) |
|
template<typename T , typename Src , typename Map > |
SkSpan< T > | makePODArray (const Src &src, Map map) |
|
template<typename T > |
std::unique_ptr< T[], ArrayDestroyer > | makeUniqueArray (int n) |
|
template<typename T , typename I > |
std::unique_ptr< T[], ArrayDestroyer > | makeUniqueArray (int n, I initializer) |
|
template<typename T , typename U , typename Map > |
std::unique_ptr< T[], ArrayDestroyer > | makeUniqueArray (SkSpan< const U > src, Map map) |
|
void * | alignedBytes (int size, int alignment) |
|
|
template<class T > |
static constexpr bool | HasNoDestructor = std::is_trivially_destructible<T>::value |
|
Definition at line 208 of file SubRunAllocator.h.
◆ SubRunAllocator() [1/4]
sktext::gpu::SubRunAllocator::SubRunAllocator |
( |
char * |
block, |
|
|
int |
blockSize, |
|
|
int |
firstHeapAllocation |
|
) |
| |
Definition at line 83 of file SubRunAllocator.cpp.
84 : fAlloc{bytes, SkTo<size_t>(
size), SkTo<size_t>(firstHeapAllocation)} {
87}
#define SkASSERT_RELEASE(cond)
◆ SubRunAllocator() [2/4]
sktext::gpu::SubRunAllocator::SubRunAllocator |
( |
int |
firstHeapAllocation = 0 | ) |
|
|
explicit |
◆ SubRunAllocator() [3/4]
◆ SubRunAllocator() [4/4]
◆ alignedBytes()
void * sktext::gpu::SubRunAllocator::alignedBytes |
( |
int |
size, |
|
|
int |
alignment |
|
) |
| |
Definition at line 92 of file SubRunAllocator.cpp.
92 {
94}
void * alignedBytes(int unsafeSize, int unsafeAlignment)
◆ AllocateClassMemoryAndArena()
Definition at line 235 of file SubRunAllocator.h.
235 {
237
239
240
242 int totalMemorySize =
sizeof(
T) + extraSize;
243
244 void* memory = ::operator new (totalMemorySize);
245 SubRunAllocator alloc{SkTAddOffset<char>(memory,
sizeof(
T)), extraSize, extraSize/2};
246 return {memory, totalMemorySize, std::move(alloc)};
247 }
static constexpr int PlatformMinimumSizeWithOverhead(int requestedSize, int assumedAlignment)
◆ makePOD()
template<typename
T , typename... Args>
T * sktext::gpu::SubRunAllocator::makePOD |
( |
Args &&... |
args | ) |
|
|
inline |
Definition at line 249 of file SubRunAllocator.h.
249 {
250 static_assert(HasNoDestructor<T>, "This is not POD. Use makeUnique.");
251 char* bytes = fAlloc.template allocateBytesFor<T>();
252 return new (bytes)
T(std::forward<Args>(
args)...);
253 }
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
◆ makePODArray() [1/2]
template<typename
T , typename Src , typename Map >
SkSpan< T > sktext::gpu::SubRunAllocator::makePODArray |
( |
const Src & |
src, |
|
|
Map |
map |
|
) |
| |
|
inline |
Definition at line 280 of file SubRunAllocator.h.
280 {
281 static_assert(HasNoDestructor<T>, "This is not POD. Use makeUniqueArray.");
282 int size = SkTo<int>(
src.size());
284 for (
int i = 0; i <
size; i++) {
286 }
288 }
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
◆ makePODArray() [2/2]
T * sktext::gpu::SubRunAllocator::makePODArray |
( |
int |
n | ) |
|
|
inline |
Definition at line 262 of file SubRunAllocator.h.
262 {
263 static_assert(HasNoDestructor<T>, "This is not POD. Use makeUniqueArray.");
264 return reinterpret_cast<T*
>(fAlloc.template allocateBytesFor<T>(n));
265 }
◆ makePODSpan()
SkSpan< T > sktext::gpu::SubRunAllocator::makePODSpan |
( |
SkSpan< const T > |
s | ) |
|
|
inline |
Definition at line 268 of file SubRunAllocator.h.
268 {
269 static_assert(HasNoDestructor<T>, "This is not POD. Use makeUniqueArray.");
272 }
273
274 T*
result = this->makePODArray<T>(SkTo<int>(
s.size()));
275 memcpy(
result,
s.data(),
s.size_bytes());
277 }
◆ makeUnique()
template<typename
T , typename... Args>
std::unique_ptr< T, Destroyer > sktext::gpu::SubRunAllocator::makeUnique |
( |
Args &&... |
args | ) |
|
|
inline |
Definition at line 256 of file SubRunAllocator.h.
256 {
257 static_assert(!HasNoDestructor<T>, "This is POD. Use makePOD.");
258 char* bytes = fAlloc.template allocateBytesFor<T>();
259 return std::unique_ptr<T, Destroyer>{
new (bytes)
T(std::forward<Args>(
args)...)};
260 }
◆ makeUniqueArray() [1/3]
std::unique_ptr< T[], ArrayDestroyer > sktext::gpu::SubRunAllocator::makeUniqueArray |
( |
int |
n | ) |
|
|
inline |
Definition at line 291 of file SubRunAllocator.h.
291 {
292 static_assert(!HasNoDestructor<T>, "This is POD. Use makePODArray.");
293 T* array =
reinterpret_cast<T*
>(fAlloc.template allocateBytesFor<T>(n));
294 for (int i = 0; i < n; i++) {
296 }
297 return std::unique_ptr<T[], ArrayDestroyer>{array, ArrayDestroyer{n}};
298 }
◆ makeUniqueArray() [2/3]
template<typename
T , typename
I >
std::unique_ptr< T[], ArrayDestroyer > sktext::gpu::SubRunAllocator::makeUniqueArray |
( |
int |
n, |
|
|
I |
initializer |
|
) |
| |
|
inline |
Definition at line 301 of file SubRunAllocator.h.
301 {
302 static_assert(!HasNoDestructor<T>, "This is POD. Use makePODArray.");
303 T* array =
reinterpret_cast<T*
>(fAlloc.template allocateBytesFor<T>(n));
304 for (int i = 0; i < n; i++) {
306 }
307 return std::unique_ptr<T[], ArrayDestroyer>{array, ArrayDestroyer{n}};
308 }
static struct Initializer initializer
◆ makeUniqueArray() [3/3]
template<typename
T , typename U , typename Map >
std::unique_ptr< T[], ArrayDestroyer > sktext::gpu::SubRunAllocator::makeUniqueArray |
( |
SkSpan< const U > |
src, |
|
|
Map |
map |
|
) |
| |
|
inline |
Definition at line 311 of file SubRunAllocator.h.
311 {
312 static_assert(!HasNoDestructor<T>, "This is POD. Use makePODArray.");
314 T* array =
reinterpret_cast<T*
>(fAlloc.template allocateBytesFor<T>(
src.size()));
315 for (
int i = 0; i <
count; ++i) {
316 new (&array[i])
T(
map(src[i]));
317 }
318 return std::unique_ptr<T[], ArrayDestroyer>{array, ArrayDestroyer{
count}};
319 }
constexpr int SkCount(const Container &c)
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ HasNoDestructor
constexpr bool sktext::gpu::SubRunAllocator::HasNoDestructor = std::is_trivially_destructible<T>::value |
|
inlinestaticconstexpr |
The documentation for this class was generated from the following files: