[cpp][flutter] Fix formatting.

This commit is contained in:
Mario Zechner 2023-01-16 15:02:43 +01:00
parent ba71af746b
commit e9c68326de
2 changed files with 29 additions and 28 deletions

View File

@ -1255,7 +1255,7 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
switch (timelineType) { switch (timelineType) {
case ATTACHMENT_DEFORM: { case ATTACHMENT_DEFORM: {
VertexAttachment *attachment = static_cast<VertexAttachment *>(baseAttachment); VertexAttachment *attachment = static_cast<VertexAttachment *>(baseAttachment);
bool weighted = attachment->_bones.size() > 0; bool weighted = attachment->_bones.size() > 0;
Vector<float> &vertices = attachment->_vertices; Vector<float> &vertices = attachment->_vertices;
int deformLength = weighted ? (int) vertices.size() / 3 * 2 : (int) vertices.size(); int deformLength = weighted ? (int) vertices.size() / 3 * 2 : (int) vertices.size();

View File

@ -37,7 +37,7 @@ using namespace spine;
struct Block { struct Block {
int size; int size;
int allocated; int allocated;
uint8_t* memory; uint8_t *memory;
int free() { int free() {
return size - allocated; return size - allocated;
@ -47,14 +47,14 @@ struct Block {
return free() >= numBytes; return free() >= numBytes;
} }
uint8_t* allocate(int numBytes) { uint8_t *allocate(int numBytes) {
uint8_t *ptr = memory + allocated; uint8_t *ptr = memory + allocated;
allocated += numBytes; allocated += numBytes;
return ptr; return ptr;
} }
}; };
class BlockAllocator : public SpineObject{ class BlockAllocator : public SpineObject {
int initialBlockSize; int initialBlockSize;
Vector<Block> blocks; Vector<Block> blocks;
@ -64,9 +64,9 @@ public:
} }
~BlockAllocator() { ~BlockAllocator() {
for (int i = 0; i < blocks.size(); i++) { for (int i = 0; i < blocks.size(); i++) {
SpineExtension::free(blocks[i].memory, __FILE__, __LINE__); SpineExtension::free(blocks[i].memory, __FILE__, __LINE__);
} }
} }
Block newBlock(int numBytes) { Block newBlock(int numBytes) {
@ -77,7 +77,7 @@ public:
template<typename T> template<typename T>
T *allocate(size_t num) { T *allocate(size_t num) {
return (T *) _allocate((int)(sizeof(T) * num)); return (T *) _allocate((int) (sizeof(T) * num));
} }
void compress() { void compress() {
@ -89,17 +89,18 @@ public:
blocks.clear(); blocks.clear();
blocks.add(newBlock(totalSize)); blocks.add(newBlock(totalSize));
} }
private: private:
void *_allocate(int numBytes) { void *_allocate(int numBytes) {
// 16-byte align allocations // 16-byte align allocations
int alignedNumBytes = numBytes + (numBytes % 16 != 0 ? 16 - (numBytes % 16) : 0); int alignedNumBytes = numBytes + (numBytes % 16 != 0 ? 16 - (numBytes % 16) : 0);
Block *block = &blocks[blocks.size() - 1]; Block *block = &blocks[blocks.size() - 1];
if (!block->canFit(alignedNumBytes)) { if (!block->canFit(alignedNumBytes)) {
blocks.add(newBlock(MathUtil::max(initialBlockSize, alignedNumBytes))); blocks.add(newBlock(MathUtil::max(initialBlockSize, alignedNumBytes)));
block = &blocks[blocks.size() - 1]; block = &blocks[blocks.size() - 1];
} }
return block->allocate(alignedNumBytes); return block->allocate(alignedNumBytes);
} }
}; };
struct AnimationStateEvent { struct AnimationStateEvent {
@ -187,19 +188,19 @@ static SpineExtension *defaultExtension = nullptr;
static DebugExtension *debugExtension = nullptr; static DebugExtension *debugExtension = nullptr;
static void initExtensions() { static void initExtensions() {
if (defaultExtension == nullptr) { if (defaultExtension == nullptr) {
defaultExtension = new DefaultSpineExtension(); defaultExtension = new DefaultSpineExtension();
debugExtension = new DebugExtension(defaultExtension); debugExtension = new DebugExtension(defaultExtension);
} }
} }
spine::SpineExtension *spine::getDefaultExtension() { spine::SpineExtension *spine::getDefaultExtension() {
initExtensions(); initExtensions();
return defaultExtension; return defaultExtension;
} }
void spine_enable_debug_extension(int32_t enable) { void spine_enable_debug_extension(int32_t enable) {
initExtensions(); initExtensions();
SpineExtension::setInstance(enable ? debugExtension : defaultExtension); SpineExtension::setInstance(enable ? debugExtension : defaultExtension);
} }
@ -212,7 +213,7 @@ int32_t spine_minor_version() {
} }
void spine_report_leaks() { void spine_report_leaks() {
initExtensions(); initExtensions();
debugExtension->reportLeaks(); debugExtension->reportLeaks();
fflush(stdout); fflush(stdout);
} }
@ -656,7 +657,7 @@ void spine_skeleton_drawable_dispose(spine_skeleton_drawable drawable) {
SpineExtension::free(drawable, __FILE__, __LINE__); SpineExtension::free(drawable, __FILE__, __LINE__);
} }
static _spine_render_command *batch_sub_commands(BlockAllocator &allocator, Vector<_spine_render_command*> &commands, int first, int last, int numVertices, int numIndices) { static _spine_render_command *batch_sub_commands(BlockAllocator &allocator, Vector<_spine_render_command *> &commands, int first, int last, int numVertices, int numIndices) {
_spine_render_command *batched = spine_render_command_create(allocator, numVertices, numIndices, commands[first]->blendMode, commands[first]->atlasPage); _spine_render_command *batched = spine_render_command_create(allocator, numVertices, numIndices, commands[first]->blendMode, commands[first]->atlasPage);
float *positions = batched->positions; float *positions = batched->positions;
float *uvs = batched->uvs; float *uvs = batched->uvs;
@ -679,7 +680,7 @@ static _spine_render_command *batch_sub_commands(BlockAllocator &allocator, Vect
return batched; return batched;
} }
static _spine_render_command *batch_commands(BlockAllocator &allocator, Vector<_spine_render_command*> &commands) { static _spine_render_command *batch_commands(BlockAllocator &allocator, Vector<_spine_render_command *> &commands) {
if (commands.size() == 0) return nullptr; if (commands.size() == 0) return nullptr;
_spine_render_command *root = nullptr; _spine_render_command *root = nullptr;
@ -1472,7 +1473,7 @@ spine_path_constraint spine_skeleton_find_path_constraint(spine_skeleton skeleto
} }
spine_bounds spine_skeleton_get_bounds(spine_skeleton skeleton) { spine_bounds spine_skeleton_get_bounds(spine_skeleton skeleton) {
_spine_bounds *bounds = (_spine_bounds*)malloc(sizeof(_spine_bounds)); _spine_bounds *bounds = (_spine_bounds *) malloc(sizeof(_spine_bounds));
if (skeleton == nullptr) return (spine_bounds) bounds; if (skeleton == nullptr) return (spine_bounds) bounds;
Skeleton *_skeleton = (Skeleton *) skeleton; Skeleton *_skeleton = (Skeleton *) skeleton;
Vector<float> vertices; Vector<float> vertices;