Blender V5.3
blender::draw::gpencil::blender Namespace Reference

Namespaces

namespace  blenlib_internal

Functions

template<class T, size_t N>
constexpr size_t ARRAY_SIZE (const T(&arg)[N]) noexcept
template<class T>
constexpr std::enable_if_t< blenlib_internal::IsBoundedArray< T >::value, size_t > BOUNDED_ARRAY_TYPE_SIZE () noexcept
Simple Math Macros
constexpr int64_t is_power_of_2 (const int64_t x)
constexpr int64_t log2_floor (const int64_t x)
constexpr int64_t log2_ceil (const int64_t x)
constexpr int64_t power_of_2_max (const int64_t x)
Struct After Macros

Typically used to copy/clear polymorphic structs which have a generic member at the start which needs to be left as-is.

constexpr bool memory_is_zero (const void *data, const size_t size)
template<typename T>
constexpr bool value_is_zero_memory (const T &value)

Function Documentation

◆ ARRAY_SIZE()

template<class T, size_t N>
size_t blender::draw::gpencil::blender::ARRAY_SIZE ( const T(&) arg[N])
constexprnoexcept

Size of a bounded array provided as an arg.

The arg must be a bounded array, such as int[7] or MyType[11]. Returns the number of elements in the array, known at the compile time.

Definition at line 608 of file gpencil_cache_utils.cc.

◆ BOUNDED_ARRAY_TYPE_SIZE()

template<class T>
std::enable_if_t< blenlib_internal::IsBoundedArray< T >::value, size_t > blender::draw::gpencil::blender::BOUNDED_ARRAY_TYPE_SIZE ( )
constexprnoexcept

Number of elements in a type which defines a bounded array.

For example, struct MyType { int array[12]; };

BOUNDED_ARRAY_TYPE_SIZE<decltype(MyType::array)> returns 12.

Definition at line 626 of file gpencil_cache_utils.cc.

◆ is_power_of_2()

int64_t blender::draw::gpencil::blender::is_power_of_2 ( const int64_t x)
constexpr

◆ log2_ceil()

int64_t blender::draw::gpencil::blender::log2_ceil ( const int64_t x)
constexpr

Definition at line 182 of file gpencil_cache_utils.cc.

◆ log2_floor()

int64_t blender::draw::gpencil::blender::log2_floor ( const int64_t x)
constexpr

Definition at line 176 of file gpencil_cache_utils.cc.

◆ memory_is_zero()

bool blender::draw::gpencil::blender::memory_is_zero ( const void * data,
const size_t size )
constexpr

Check if size bytes at data are all zero.

Warning
Every byte is compared, including any padding. Padding is indeterminate even when all struct members have been zeroed, so only buffers where every byte has been written are safe to pass in (memset or calloc for e.g.). For typed values prefer #value_is_zero which accounts for this.

Definition at line 375 of file gpencil_cache_utils.cc.

References blender::draw::gpencil::Instance::use_mask_fb.

◆ power_of_2_max()

int64_t blender::draw::gpencil::blender::power_of_2_max ( const int64_t x)
constexpr

Definition at line 188 of file gpencil_cache_utils.cc.

◆ value_is_zero_memory()

template<typename T>
bool blender::draw::gpencil::blender::value_is_zero_memory ( const T & value)
constexpr

Similar to memory_is_zero but is easier to see through for the compiler. This may return false even if the value is technically all zeroes in some cases, because reading from padding bits/bytes may cause undefined behavior.

This can be overloaded for custom types if an is-zero check is important for performance.

Definition at line 394 of file gpencil_cache_utils.cc.

References blender::DRW_STATE_BLEND_MUL, blender::DRW_STATE_BLEND_SUB, blender::GP_LAYER_BLEND_DIVIDE, blender::GP_LAYER_BLEND_HARDLIGHT, blender::GP_LAYER_BLEND_MULTIPLY, blender::GP_LAYER_BLEND_SUBTRACT, and state.