#include <SubRunAllocator.h>
Definition at line 34 of file SubRunAllocator.h.
◆ Storage
◆ BagOfBytes() [1/4]
sktext::gpu::BagOfBytes::BagOfBytes |
( |
char * |
block, |
|
|
size_t |
blockSize, |
|
|
size_t |
firstHeapAllocation |
|
) |
| |
Definition at line 20 of file SubRunAllocator.cpp.
21 : fFibProgression(
size, firstHeapAllocation) {
24
25 std::size_t space =
size;
26 void* ptr = bytes;
27 if (bytes && std::align(kMaxAlignment,
sizeof(
Block), ptr, space)) {
28 this->setupBytesAndCapacity(bytes,
size);
29 new (fEndByte)
Block(
nullptr,
nullptr);
30 }
31}
#define SkASSERT_RELEASE(cond)
◆ BagOfBytes() [2/4]
sktext::gpu::BagOfBytes::BagOfBytes |
( |
size_t |
firstHeapAllocation = 0 | ) |
|
|
explicit |
◆ BagOfBytes() [3/4]
sktext::gpu::BagOfBytes::BagOfBytes |
( |
const BagOfBytes & |
| ) |
|
|
delete |
◆ BagOfBytes() [4/4]
sktext::gpu::BagOfBytes::BagOfBytes |
( |
BagOfBytes && |
that | ) |
|
|
inline |
Definition at line 40 of file SubRunAllocator.h.
41 : fEndByte{std::exchange(that.fEndByte, nullptr)}
42 , fCapacity{that.fCapacity}
43 , fFibProgression{that.fFibProgression} {}
◆ ~BagOfBytes()
sktext::gpu::BagOfBytes::~BagOfBytes |
( |
| ) |
|
Definition at line 36 of file SubRunAllocator.cpp.
36 {
37 Block* cursor =
reinterpret_cast<Block*
>(fEndByte);
38 while (cursor != nullptr) {
39 char* toDelete = cursor->fBlockStart;
40 cursor = cursor->fPrevious;
41 delete [] toDelete;
42 }
43}
◆ alignedBytes()
void * sktext::gpu::BagOfBytes::alignedBytes |
( |
int |
unsafeSize, |
|
|
int |
unsafeAlignment |
|
) |
| |
Definition at line 49 of file SubRunAllocator.cpp.
49 {
53
54 return this->allocateBytes(
size, alignment);
55}
constexpr bool SkIsPow2(T value)
◆ allocateBytesFor()
char * sktext::gpu::BagOfBytes::allocateBytesFor |
( |
int |
n = 1 | ) |
|
|
inline |
Definition at line 108 of file SubRunAllocator.h.
108 {
109 static_assert(
alignof(
T) <= kMaxAlignment,
"Alignment is too big for arena");
110 static_assert(
sizeof(
T) < kMaxByteSize,
"Size is too big for arena");
112
113 int size = n ? n *
sizeof(
T) : 1;
114 return this->allocateBytes(
size,
alignof(
T));
115 }
◆ MinimumSizeWithOverhead()
static constexpr int sktext::gpu::BagOfBytes::MinimumSizeWithOverhead |
( |
int |
requestedSize, |
|
|
int |
assumedAlignment, |
|
|
int |
blockSize, |
|
|
int |
maxAlignment |
|
) |
| |
|
inlinestaticconstexpr |
Definition at line 59 of file SubRunAllocator.h.
60 {
63
64 const int minAlignment = std::min(maxAlignment, assumedAlignment);
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 int minimumSize =
SkToInt(AlignUp(requestedSize, minAlignment))
84 + blockSize
85 + maxAlignment - minAlignment;
86
87
88
89 constexpr int k32K = (1 << 15);
90 if (minimumSize >= k32K && minimumSize < std::numeric_limits<int>::max() - k4K) {
91 minimumSize =
SkToInt(AlignUp(minimumSize, k4K));
92 }
93
94 return minimumSize;
95 }
constexpr int SkToInt(S x)
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ PlatformMinimumSizeWithOverhead()
static constexpr int sktext::gpu::BagOfBytes::PlatformMinimumSizeWithOverhead |
( |
int |
requestedSize, |
|
|
int |
assumedAlignment |
|
) |
| |
|
inlinestaticconstexpr |
Definition at line 54 of file SubRunAllocator.h.
54 {
56 requestedSize, assumedAlignment,
sizeof(
Block), kMaxAlignment);
57 }
static constexpr int MinimumSizeWithOverhead(int requestedSize, int assumedAlignment, int blockSize, int maxAlignment)
◆ WillCountFit()
static bool sktext::gpu::BagOfBytes::WillCountFit |
( |
int |
n | ) |
|
|
inlinestatic |
Definition at line 102 of file SubRunAllocator.h.
102 {
103 constexpr int kMaxN = kMaxByteSize /
sizeof(
T);
104 return 0 <= n && n < kMaxN;
105 }
The documentation for this class was generated from the following files: