Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
bofeng-song committed Dec 11, 2024
1 parent ee848be commit d171fc9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cocos/spine/skeleton-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class SkeletonData extends Asset {
} else {
const rawData = new Uint8Array(this._nativeAsset);
const byteSize = rawData.length;
const ptr = spine.wasmUtil.queryStoreMemory(byteSize);
const ptr = spine.wasmUtil.createStoreMemory(byteSize);
const wasmMem = spine.wasmUtil.wasm.HEAPU8.subarray(ptr, ptr + byteSize);
wasmMem.set(rawData);
this._skeletonCache = spine.wasmUtil.createSpineSkeletonDataWithBinary(byteSize, this._atlasText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ EMSCRIPTEN_BINDINGS(cocos_spine) {
class_<SpineWasmUtil>("SpineWasmUtil")
.class_function("spineWasmInit", &SpineWasmUtil::spineWasmInit)
.class_function("spineWasmDestroy", &SpineWasmUtil::spineWasmDestroy)
.class_function("queryStoreMemory", &SpineWasmUtil::queryStoreMemory)
.class_function("createStoreMemory", &SpineWasmUtil::createStoreMemory)
.class_function("freeStoreMemory", &SpineWasmUtil::freeStoreMemory)
.class_function("querySpineSkeletonDataByUUID", &SpineWasmUtil::querySpineSkeletonDataByUUID, allow_raw_pointers())
.class_function("createSpineSkeletonDataWithJson", &SpineWasmUtil::createSpineSkeletonDataWithJson, allow_raw_pointers())
Expand Down
5 changes: 1 addition & 4 deletions native/cocos/editor-support/spine-wasm/spine-wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ EventType SpineWasmUtil::s_currentType = EventType_Event;
TrackEntry* SpineWasmUtil::s_currentEntry = nullptr;
Event* SpineWasmUtil::s_currentEvent = nullptr;
uint8_t* SpineWasmUtil::s_mem = nullptr;
uint32_t SpineWasmUtil::s_memSize = 0;

void SpineWasmUtil::spineWasmInit() {
// LogUtil::Initialize();
Expand Down Expand Up @@ -95,9 +94,8 @@ void SpineWasmUtil::destroySpineSkeleton(Skeleton* skeleton) {
}
}

uint32_t SpineWasmUtil::queryStoreMemory(uint32_t size) {
uint32_t SpineWasmUtil::createStoreMemory(uint32_t size) {
s_mem = new uint8_t[size];
s_memSize = size;

return (uint32_t)s_mem;
}
Expand All @@ -107,7 +105,6 @@ void SpineWasmUtil::freeStoreMemory() {
delete[] s_mem;
s_mem = nullptr;
}
s_memSize = 0;
}

uint32_t SpineWasmUtil::getCurrentListenerID() {
Expand Down
3 changes: 1 addition & 2 deletions native/cocos/editor-support/spine-wasm/spine-wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SpineWasmUtil {
public:
static void spineWasmInit();
static void spineWasmDestroy();
static uint32_t queryStoreMemory(uint32_t size);
static uint32_t createStoreMemory(uint32_t size);
static void freeStoreMemory();

static spine::SkeletonData* querySpineSkeletonDataByUUID(const spine::String& uuid);
Expand All @@ -28,5 +28,4 @@ class SpineWasmUtil {
static spine::Event* s_currentEvent;

static uint8_t* s_mem;
static uint32_t s_memSize;
};

0 comments on commit d171fc9

Please sign in to comment.