Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Friends | List of all members
SkContainerAllocator Class Reference

#include <SkContainers.h>

Public Member Functions

 SkContainerAllocator (size_t sizeOfT, int maxCapacity)
 
SkSpan< std::byte > allocate (int capacity, double growthFactor=1.0)
 

Static Public Member Functions

template<typename T >
static constexpr size_t RoundUp (size_t capacity)
 

Friends

struct SkContainerAllocatorTestingPeer
 

Detailed Description

Definition at line 14 of file SkContainers.h.

Constructor & Destructor Documentation

◆ SkContainerAllocator()

SkContainerAllocator::SkContainerAllocator ( size_t  sizeOfT,
int  maxCapacity 
)
inline

Definition at line 16 of file SkContainers.h.

17 : fSizeOfT{sizeOfT}
18 , fMaxCapacity{maxCapacity} {}

Member Function Documentation

◆ allocate()

SkSpan< std::byte > SkContainerAllocator::allocate ( int  capacity,
double  growthFactor = 1.0 
)

Definition at line 27 of file SkContainers.cpp.

27 {
28 SkASSERT(capacity >= 0);
29 SkASSERT(growthFactor >= 1.0);
30 SkASSERT_RELEASE(capacity <= fMaxCapacity);
31
32 if (growthFactor > 1.0 && capacity > 0) {
33 capacity = this->growthFactorCapacity(capacity, growthFactor);
34 }
35
36 return sk_allocate_throw(capacity * fSizeOfT);
37}
#define SkASSERT_RELEASE(cond)
Definition: SkAssert.h:100
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkSpan< std::byte > sk_allocate_throw(size_t size)

◆ RoundUp()

template<typename T >
static constexpr size_t SkContainerAllocator::RoundUp ( size_t  capacity)
inlinestaticconstexpr

Definition at line 26 of file SkContainers.h.

26 {
27 return SkAlignTo(capacity * sizeof(T), kCapacityMultiple) / sizeof(T);
28 }
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
Definition: SkAlign.h:33
#define T
Definition: precompiler.cc:65

Friends And Related Function Documentation

◆ SkContainerAllocatorTestingPeer

friend struct SkContainerAllocatorTestingPeer
friend

Definition at line 31 of file SkContainers.h.


The documentation for this class was generated from the following files: