mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[flutter] Closes #2383, fix allocations of temp structs for Windows.
Dart FFIs MallocAllocator does in fact not use malloc... # Conflicts: # spine-flutter/lib/assets/libspine_flutter.wasm
This commit is contained in:
parent
68c87192f8
commit
b89d550711
Binary file not shown.
@ -807,7 +807,6 @@ class Bone {
|
||||
Vec2 worldToLocal(double worldX, double worldY) {
|
||||
final local = _bindings.spine_bone_world_to_local(_bone, worldX, worldY);
|
||||
final result = Vec2(_bindings.spine_vector_get_x(local), _bindings.spine_vector_get_y(local));
|
||||
_allocator.free(local);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -815,7 +814,6 @@ class Bone {
|
||||
Vec2 localToWorld(double localX, double localY) {
|
||||
final world = _bindings.spine_bone_local_to_world(_bone, localX, localY);
|
||||
final result = Vec2(_bindings.spine_vector_get_x(world), _bindings.spine_vector_get_y(world));
|
||||
_allocator.free(world);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1871,7 +1869,6 @@ class PointAttachment extends Attachment<spine_point_attachment> {
|
||||
Vec2 computeWorldPosition(Bone bone) {
|
||||
final position = _bindings.spine_point_attachment_compute_world_position(_attachment, bone._bone);
|
||||
final result = Vec2(_bindings.spine_vector_get_x(position), _bindings.spine_vector_get_y(position));
|
||||
_allocator.free(position);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2888,7 +2885,6 @@ class Skeleton {
|
||||
final nativeBounds = _bindings.spine_skeleton_get_bounds(_skeleton);
|
||||
final bounds = Bounds(_bindings.spine_bounds_get_x(nativeBounds), _bindings.spine_bounds_get_y(nativeBounds),
|
||||
_bindings.spine_bounds_get_width(nativeBounds), _bindings.spine_bounds_get_height(nativeBounds));
|
||||
_allocator.free(nativeBounds);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
|
||||
@ -1473,8 +1473,9 @@ spine_path_constraint spine_skeleton_find_path_constraint(spine_skeleton skeleto
|
||||
return (spine_path_constraint) _skeleton->findPathConstraint(constraintName);
|
||||
}
|
||||
|
||||
_spine_bounds tmp_bounds;
|
||||
spine_bounds spine_skeleton_get_bounds(spine_skeleton skeleton) {
|
||||
_spine_bounds *bounds = (_spine_bounds *) malloc(sizeof(_spine_bounds));
|
||||
_spine_bounds *bounds = &tmp_bounds;
|
||||
if (skeleton == nullptr) return (spine_bounds) bounds;
|
||||
Skeleton *_skeleton = (Skeleton *) skeleton;
|
||||
Vector<float> vertices;
|
||||
@ -2128,8 +2129,9 @@ void spine_bone_set_to_setup_pose(spine_bone bone) {
|
||||
_bone->setToSetupPose();
|
||||
}
|
||||
|
||||
_spine_vector tmp_vector;
|
||||
spine_vector spine_bone_world_to_local(spine_bone bone, float worldX, float worldY) {
|
||||
_spine_vector *coords = SpineExtension::calloc<_spine_vector>(1, __FILE__, __LINE__);
|
||||
_spine_vector *coords = &tmp_vector;
|
||||
if (bone == nullptr) return (spine_vector) coords;
|
||||
Bone *_bone = (Bone *) bone;
|
||||
_bone->worldToLocal(worldX, worldY, coords->x, coords->y);
|
||||
@ -2137,7 +2139,7 @@ spine_vector spine_bone_world_to_local(spine_bone bone, float worldX, float worl
|
||||
}
|
||||
|
||||
spine_vector spine_bone_local_to_world(spine_bone bone, float localX, float localY) {
|
||||
_spine_vector *coords = SpineExtension::calloc<_spine_vector>(1, __FILE__, __LINE__);
|
||||
_spine_vector *coords = &tmp_vector;
|
||||
if (bone == nullptr) return (spine_vector) coords;
|
||||
Bone *_bone = (Bone *) bone;
|
||||
_bone->localToWorld(localX, localY, coords->x, coords->y);
|
||||
@ -2521,7 +2523,7 @@ void spine_attachment_dispose(spine_attachment attachment) {
|
||||
|
||||
// PointAttachment
|
||||
spine_vector spine_point_attachment_compute_world_position(spine_point_attachment attachment, spine_bone bone) {
|
||||
_spine_vector *result = SpineExtension::calloc<_spine_vector>(1, __FILE__, __LINE__);
|
||||
_spine_vector *result = &tmp_vector;
|
||||
if (attachment == nullptr) return (spine_vector) result;
|
||||
PointAttachment *_attachment = (PointAttachment *) attachment;
|
||||
_attachment->computeWorldPosition(*(Bone *) bone, result->x, result->y);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user