[engine] [cocos2d-x] [jsb-adapter] 适配引擎 v2.4.13 版本

This commit is contained in:
SmallMain
2024-10-16 16:23:25 +08:00
parent 7f956acda7
commit 887d4a96c9
61 changed files with 1313 additions and 981 deletions

View File

@@ -32,7 +32,7 @@ NS_CC_BEGIN
CC_DLL const char* cocos2dVersion()
{
return "2.4.12";
return "2.4.13";
}
NS_CC_END

View File

@@ -34,7 +34,7 @@ DRAGONBONES_NAMESPACE_BEGIN
class CacheModeAttachUtil;
class CCArmatureCacheDisplay : public cocos2d::middleware::IMiddleware, public cocos2d::Ref
class CCArmatureCacheDisplay : public cocos2d::Ref, public cocos2d::middleware::IMiddleware
{
public:
CCArmatureCacheDisplay(const std::string& armatureName, const std::string& armatureKey, const std::string& atlasUUID, bool isShare);

View File

@@ -106,7 +106,7 @@ enum EmitterMode
RADIUS = 1
};
class ParticleSimulator : public cocos2d::middleware::IMiddleware, public cocos2d::Ref {
class ParticleSimulator : public cocos2d::Ref, public cocos2d::middleware::IMiddleware {
//* @enum
enum {

View File

@@ -130,6 +130,10 @@ SkeletonAnimation::SkeletonAnimation ()
}
SkeletonAnimation::~SkeletonAnimation () {
SkeletonAnimation::destroy();
}
void SkeletonAnimation::destroy() {
_startListener = nullptr;
_interruptListener = nullptr;
_endListener = nullptr;
@@ -139,9 +143,12 @@ SkeletonAnimation::~SkeletonAnimation () {
if (_state) {
clearTracks();
if (_ownsAnimationStateData) delete _state->getData();
delete _state;
if (_ownsAnimationStateData) {
delete _state->getData();
}
CC_SAFE_DELETE(_state);
}
SkeletonRenderer::destroy();
}
void SkeletonAnimation::update (float deltaTime) {

View File

@@ -92,6 +92,7 @@ public:
virtual void onAnimationStateEvent (TrackEntry* entry, EventType type, Event* event);
virtual void onTrackEntryEvent (TrackEntry* entry, EventType type, Event* event);
virtual void destroy();
AnimationState* getState() const;

View File

@@ -76,7 +76,7 @@ namespace spine {
bool inEffect = false;
std::vector<TextureMultiData> textureDatas;
};
struct BoneData {
cocos2d::Mat4 globalTransformMatrix;
};

View File

@@ -63,6 +63,11 @@ namespace spine {
}
SkeletonCacheAnimation::~SkeletonCacheAnimation () {
destroy();
}
void SkeletonCacheAnimation::destroy() {
stopSchedule();
if (_skeletonCache) {
_skeletonCache->release();
_skeletonCache = nullptr;
@@ -73,9 +78,8 @@ namespace spine {
delete ani;
}
CC_SAFE_RELEASE_NULL(_attachUtil);
CC_SAFE_RELEASE(_nodeProxy);
CC_SAFE_RELEASE(_effect);
stopSchedule();
CC_SAFE_RELEASE_NULL(_nodeProxy);
CC_SAFE_RELEASE_NULL(_effect);
}
void SkeletonCacheAnimation::update(float dt) {
@@ -207,13 +211,13 @@ namespace spine {
return multiSegments;
}
void SkeletonCacheAnimation::render(float dt) {
if (_useMulti) {
renderMulti(dt);
return;
}
if (!_nodeProxy || !_effect) {
return;
}
@@ -826,7 +830,7 @@ namespace spine {
void SkeletonCacheAnimation::setUseMulti(bool enabled) {
_useMulti = enabled;
}
void SkeletonCacheAnimation::setAnimation (const std::string& name, bool loop) {
_playTimes = loop ? 0 : 1;
_animationName = name;

View File

@@ -39,7 +39,7 @@ namespace spine {
class CacheModeAttachUtil;
class SkeletonCacheAnimation : public cocos2d::middleware::IMiddleware, public cocos2d::Ref {
class SkeletonCacheAnimation : public cocos2d::Ref, public cocos2d::middleware::IMiddleware {
public:
SkeletonCacheAnimation (const std::string& uuid, bool isShare);
virtual ~SkeletonCacheAnimation ();
@@ -47,7 +47,7 @@ namespace spine {
virtual void update(float dt) override;
virtual void render(float dt) override;
virtual uint32_t getRenderOrder() const override;
void renderMulti(float dt);
std::vector<spine::SkeletonCache::SegmentMultiData> toMultiSegments(
const std::vector<spine::SkeletonCache::SegmentData*>& segments);
@@ -83,7 +83,7 @@ namespace spine {
void onDisable();
void setUseTint(bool enabled);
void setUseMulti(bool enabled);
void setAnimation (const std::string& name, bool loop);
void addAnimation (const std::string& name, bool loop, float delay = 0);
Animation* findAnimation(const std::string& name) const;
@@ -98,6 +98,7 @@ namespace spine {
void setToSetupPose ();
void setBonesToSetupPose ();
void setSlotsToSetupPose ();
void destroy();
private:
float _timeScale = 1;
bool _paused = false;
@@ -124,7 +125,7 @@ namespace spine {
std::string _animationName = "";
bool _useTint = false;
bool _useMulti = false;
struct AniQueueData {
std::string animationName = "";
bool loop = false;

View File

@@ -151,23 +151,37 @@ SkeletonRenderer::SkeletonRenderer (const std::string& skeletonDataFile, const s
}
SkeletonRenderer::~SkeletonRenderer () {
CC_SAFE_RELEASE(_effectDelegate);
if (_ownsSkeletonData) delete _skeleton->getData();
if (_ownsSkeleton) delete _skeleton;
if (_ownsAtlas && _atlas) delete _atlas;
if (_attachmentLoader) delete _attachmentLoader;
if (_uuid != "") SkeletonDataMgr::getInstance()->releaseByUUID(_uuid);
if (_clipper) delete _clipper;
if (_debugBuffer) {
delete _debugBuffer;
_debugBuffer = nullptr;
}
CC_SAFE_RELEASE(_attachUtil);
CC_SAFE_RELEASE(_nodeProxy);
CC_SAFE_RELEASE(_effect);
SkeletonRenderer::destroy();
}
void SkeletonRenderer::destroy() {
stopSchedule();
CC_SAFE_RELEASE_NULL(_effectDelegate);
if (_ownsSkeletonData) {
if (_skeleton) {
delete _skeleton->getData();
}
_ownsSkeletonData = false;
}
if (_ownsSkeleton) {
CC_SAFE_DELETE(_skeleton);
}
if (_ownsAtlas && _atlas) {
CC_SAFE_DELETE(_atlas);
}
_skeleton = nullptr;
_atlas = nullptr;
CC_SAFE_DELETE(_attachmentLoader);
if (_uuid != "") {
SkeletonDataMgr::getInstance()->releaseByUUID(_uuid);
_uuid = "";
}
CC_SAFE_DELETE(_clipper);
CC_SAFE_DELETE(_debugBuffer);
CC_SAFE_RELEASE_NULL(_attachUtil);
CC_SAFE_RELEASE_NULL(_nodeProxy);
CC_SAFE_RELEASE_NULL(_effect);
}
void SkeletonRenderer::initWithUUID(const std::string& uuid) {
@@ -298,7 +312,7 @@ void SkeletonRenderer::render (float deltaTime) {
// vertex size int bytes with one color
int vbs1 = _useMulti ? sizeof(V2F_T2F_C4B_T1F) : sizeof(V2F_T2F_C4B);
// vertex size in floats with one color
// vertex size in floats with one color
int vs1 = vbs1 / sizeof(float);
// vertex size int bytes with two color
int vbs2 = _useMulti ? sizeof(V2F_T2F_C4B_C4B_T1F) :sizeof(V2F_T2F_C4B_C4B);
@@ -315,11 +329,11 @@ void SkeletonRenderer::render (float deltaTime) {
int preBlendMode = -1;
GLuint preTextureIndex = -1;
GLuint curTextureIndex = -1;
float curTextureId = -1;
bool texInEffect = false;
int preISegWritePos = -1;
int preISegWritePos = -1;
int curISegLen = 0;
int materialLen = 0;
@@ -361,7 +375,7 @@ void SkeletonRenderer::render (float deltaTime) {
curBlendSrc = _premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA;
curBlendDst = BlendFactor::ONE_MINUS_SRC_ALPHA;
}
double curHash =
(_useMulti && texInEffect)
? ((curBlendMode << 16) + ((int)_useTint << 24) +
@@ -470,34 +484,34 @@ void SkeletonRenderer::render (float deltaTime) {
}
if (!_useMulti) {
if (!_useTint) {
triangles.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = triangles.vertCount * sizeof(V2F_T2F_C4B);
isFull |= vb.checkSpace(vbSize, true);
triangles.verts = (V2F_T2F_C4B*)vb.getCurBuffer();
memcpy(triangles.verts, attachmentVertices->_triangles->verts, vbSize);
attachment->computeWorldVertices(slot->getBone(), (float*)triangles.verts, 0, vs1);
if (!_useTint) {
triangles.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = triangles.vertCount * sizeof(V2F_T2F_C4B);
isFull |= vb.checkSpace(vbSize, true);
triangles.verts = (V2F_T2F_C4B*)vb.getCurBuffer();
memcpy(triangles.verts, attachmentVertices->_triangles->verts, vbSize);
attachment->computeWorldVertices(slot->getBone(), (float*)triangles.verts, 0, vs1);
triangles.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = triangles.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
triangles.indices = (unsigned short*)ib.getCurBuffer();
memcpy(triangles.indices, attachmentVertices->_triangles->indices, ibSize);
} else {
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4B_C4B);
isFull |= vb.checkSpace(vbSize, true);
trianglesTwoColor.verts = (V2F_T2F_C4B_C4B*)vb.getCurBuffer();
for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++) {
trianglesTwoColor.verts[ii].texCoord = attachmentVertices->_triangles->verts[ii].texCoord;
}
attachment->computeWorldVertices(slot->getBone(), (float*)trianglesTwoColor.verts, 0, vs2);
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
trianglesTwoColor.indices = (unsigned short*)ib.getCurBuffer();
memcpy(trianglesTwoColor.indices, attachmentVertices->_triangles->indices, ibSize);
triangles.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = triangles.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
triangles.indices = (unsigned short*)ib.getCurBuffer();
memcpy(triangles.indices, attachmentVertices->_triangles->indices, ibSize);
} else {
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4B_C4B);
isFull |= vb.checkSpace(vbSize, true);
trianglesTwoColor.verts = (V2F_T2F_C4B_C4B*)vb.getCurBuffer();
for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++) {
trianglesTwoColor.verts[ii].texCoord = attachmentVertices->_triangles->verts[ii].texCoord;
}
attachment->computeWorldVertices(slot->getBone(), (float*)trianglesTwoColor.verts, 0, vs2);
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
trianglesTwoColor.indices = (unsigned short*)ib.getCurBuffer();
memcpy(trianglesTwoColor.indices, attachmentVertices->_triangles->indices, ibSize);
}
} else {
if (!_useTint) {
@@ -565,34 +579,34 @@ void SkeletonRenderer::render (float deltaTime) {
}
if (!_useMulti) {
if (!_useTint) {
triangles.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = triangles.vertCount * sizeof(V2F_T2F_C4B);
isFull |= vb.checkSpace(vbSize, true);
triangles.verts = (V2F_T2F_C4B*)vb.getCurBuffer();
memcpy(triangles.verts, attachmentVertices->_triangles->verts, vbSize);
attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), (float*)triangles.verts, 0, vs1);
if (!_useTint) {
triangles.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = triangles.vertCount * sizeof(V2F_T2F_C4B);
isFull |= vb.checkSpace(vbSize, true);
triangles.verts = (V2F_T2F_C4B*)vb.getCurBuffer();
memcpy(triangles.verts, attachmentVertices->_triangles->verts, vbSize);
attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), (float*)triangles.verts, 0, vs1);
triangles.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = triangles.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
triangles.indices = (unsigned short*)ib.getCurBuffer();
memcpy(triangles.indices, attachmentVertices->_triangles->indices, ibSize);
} else {
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4B_C4B);
isFull |= vb.checkSpace(vbSize, true);
trianglesTwoColor.verts = (V2F_T2F_C4B_C4B*)vb.getCurBuffer();
for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++) {
trianglesTwoColor.verts[ii].texCoord = attachmentVertices->_triangles->verts[ii].texCoord;
}
attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), (float*)trianglesTwoColor.verts, 0, vs2);
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
trianglesTwoColor.indices = (unsigned short*)ib.getCurBuffer();
memcpy(trianglesTwoColor.indices, attachmentVertices->_triangles->indices, ibSize);
triangles.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = triangles.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
triangles.indices = (unsigned short*)ib.getCurBuffer();
memcpy(triangles.indices, attachmentVertices->_triangles->indices, ibSize);
} else {
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4B_C4B);
isFull |= vb.checkSpace(vbSize, true);
trianglesTwoColor.verts = (V2F_T2F_C4B_C4B*)vb.getCurBuffer();
for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++) {
trianglesTwoColor.verts[ii].texCoord = attachmentVertices->_triangles->verts[ii].texCoord;
}
attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), (float*)trianglesTwoColor.verts, 0, vs2);
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
trianglesTwoColor.indices = (unsigned short*)ib.getCurBuffer();
memcpy(trianglesTwoColor.indices, attachmentVertices->_triangles->indices, ibSize);
}
} else {
if (!_useTint) {
@@ -650,7 +664,7 @@ void SkeletonRenderer::render (float deltaTime) {
: (float*)trianglesTexId.verts)
: (_useTint ? (float*)trianglesTwoColor.verts
: (float*)triangles.verts);
int stride = _useTint ? vs2 : vs1;
_debugBuffer->writeFloat32(DebugType::Mesh);
_debugBuffer->writeFloat32(indexCount * 2);
@@ -702,217 +716,217 @@ void SkeletonRenderer::render (float deltaTime) {
darkColor.b = 0;
}
darkColor.a = _premultipliedAlpha ? 255 : 0;
if (!_useMulti) {
// One color tint logic
if (!_useTint) {
// Cliping logic
if (_clipper->isClipping()) {
_clipper->clipTriangles((float*)&triangles.verts[0].vertex, triangles.indices, triangles.indexCount, (float*)&triangles.verts[0].texCoord, vs1);
if (_clipper->getClippedTriangles().size() == 0) {
_clipper->clipEnd(*slot);
continue;
// One color tint logic
if (!_useTint) {
// Cliping logic
if (_clipper->isClipping()) {
_clipper->clipTriangles((float*)&triangles.verts[0].vertex, triangles.indices, triangles.indexCount, (float*)&triangles.verts[0].texCoord, vs1);
if (_clipper->getClippedTriangles().size() == 0) {
_clipper->clipEnd(*slot);
continue;
}
triangles.vertCount = (int)_clipper->getClippedVertices().size() >> 1;
vbSize = triangles.vertCount * sizeof(V2F_T2F_C4B);
isFull |= vb.checkSpace(vbSize, true);
triangles.verts = (V2F_T2F_C4B*)vb.getCurBuffer();
triangles.indexCount = (int)_clipper->getClippedTriangles().size();
ibSize = triangles.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
triangles.indices = (unsigned short*)ib.getCurBuffer();
memcpy(triangles.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
float* verts = _clipper->getClippedVertices().buffer();
float* uvs = _clipper->getClippedUVs().buffer();
if (effect) {
Color light;
Color dark;
light.r = color.r / 255.0f;
light.g = color.g / 255.0f;
light.b = color.b / 255.0f;
light.a = color.a / 255.0f;
dark.r = dark.g = dark.b = dark.a = 0;
for (int v = 0, vn = triangles.vertCount, vv = 0; v < vn; ++v, vv+=2) {
V2F_T2F_C4B* vertex = triangles.verts + v;
Color lightCopy = light;
Color darkCopy = dark;
vertex->vertex.x = verts[vv];
vertex->vertex.y = verts[vv + 1];
vertex->texCoord.u = uvs[vv];
vertex->texCoord.v = uvs[vv + 1];
effect->transform(vertex->vertex.x, vertex->vertex.y, vertex->texCoord.u, vertex->texCoord.v, lightCopy, darkCopy);
vertex->color.r = (GLubyte)(lightCopy.r * 255);
vertex->color.g = (GLubyte)(lightCopy.g * 255);
vertex->color.b = (GLubyte)(lightCopy.b * 255);
vertex->color.a = (GLubyte)(lightCopy.a * 255);
}
triangles.vertCount = (int)_clipper->getClippedVertices().size() >> 1;
vbSize = triangles.vertCount * sizeof(V2F_T2F_C4B);
isFull |= vb.checkSpace(vbSize, true);
triangles.verts = (V2F_T2F_C4B*)vb.getCurBuffer();
triangles.indexCount = (int)_clipper->getClippedTriangles().size();
ibSize = triangles.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
triangles.indices = (unsigned short*)ib.getCurBuffer();
memcpy(triangles.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
float* verts = _clipper->getClippedVertices().buffer();
float* uvs = _clipper->getClippedUVs().buffer();
if (effect) {
Color light;
Color dark;
light.r = color.r / 255.0f;
light.g = color.g / 255.0f;
light.b = color.b / 255.0f;
light.a = color.a / 255.0f;
dark.r = dark.g = dark.b = dark.a = 0;
for (int v = 0, vn = triangles.vertCount, vv = 0; v < vn; ++v, vv+=2) {
V2F_T2F_C4B* vertex = triangles.verts + v;
Color lightCopy = light;
Color darkCopy = dark;
vertex->vertex.x = verts[vv];
vertex->vertex.y = verts[vv + 1];
vertex->texCoord.u = uvs[vv];
vertex->texCoord.v = uvs[vv + 1];
effect->transform(vertex->vertex.x, vertex->vertex.y, vertex->texCoord.u, vertex->texCoord.v, lightCopy, darkCopy);
vertex->color.r = (GLubyte)(lightCopy.r * 255);
vertex->color.g = (GLubyte)(lightCopy.g * 255);
vertex->color.b = (GLubyte)(lightCopy.b * 255);
vertex->color.a = (GLubyte)(lightCopy.a * 255);
}
} else {
for (int v = 0, vn = triangles.vertCount, vv = 0; v < vn; ++v, vv+=2) {
V2F_T2F_C4B* vertex = triangles.verts + v;
vertex->vertex.x = verts[vv];
vertex->vertex.y = verts[vv + 1];
vertex->texCoord.u = uvs[vv];
vertex->texCoord.v = uvs[vv + 1];
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
}
}
// No cliping logic
} else {
if (effect) {
Color light;
Color dark;
light.r = color.r / 255.0f;
light.g = color.g / 255.0f;
light.b = color.b / 255.0f;
light.a = color.a / 255.0f;
dark.r = dark.g = dark.b = dark.a = 0;
for (int v = 0, vn = triangles.vertCount; v < vn; ++v) {
V2F_T2F_C4B* vertex = triangles.verts + v;
Color lightCopy = light;
Color darkCopy = dark;
effect->transform(vertex->vertex.x, vertex->vertex.y, vertex->texCoord.u, vertex->texCoord.v, lightCopy, darkCopy);
vertex->color.r = (GLubyte)(lightCopy.r * 255);
vertex->color.g = (GLubyte)(lightCopy.g * 255);
vertex->color.b = (GLubyte)(lightCopy.b * 255);
vertex->color.a = (GLubyte)(lightCopy.a * 255);
}
} else {
for (int v = 0, vn = triangles.vertCount; v < vn; ++v) {
V2F_T2F_C4B* vertex = triangles.verts + v;
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
}
for (int v = 0, vn = triangles.vertCount, vv = 0; v < vn; ++v, vv+=2) {
V2F_T2F_C4B* vertex = triangles.verts + v;
vertex->vertex.x = verts[vv];
vertex->vertex.y = verts[vv + 1];
vertex->texCoord.u = uvs[vv];
vertex->texCoord.v = uvs[vv + 1];
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
}
}
// No cliping logic
} else {
if (effect) {
Color light;
Color dark;
light.r = color.r / 255.0f;
light.g = color.g / 255.0f;
light.b = color.b / 255.0f;
light.a = color.a / 255.0f;
dark.r = dark.g = dark.b = dark.a = 0;
for (int v = 0, vn = triangles.vertCount; v < vn; ++v) {
V2F_T2F_C4B* vertex = triangles.verts + v;
Color lightCopy = light;
Color darkCopy = dark;
effect->transform(vertex->vertex.x, vertex->vertex.y, vertex->texCoord.u, vertex->texCoord.v, lightCopy, darkCopy);
vertex->color.r = (GLubyte)(lightCopy.r * 255);
vertex->color.g = (GLubyte)(lightCopy.g * 255);
vertex->color.b = (GLubyte)(lightCopy.b * 255);
vertex->color.a = (GLubyte)(lightCopy.a * 255);
}
} else {
for (int v = 0, vn = triangles.vertCount; v < vn; ++v) {
V2F_T2F_C4B* vertex = triangles.verts + v;
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
}
}
}
// Two color tint logic
else {
if (_clipper->isClipping()) {
_clipper->clipTriangles((float*)&trianglesTwoColor.verts[0].vertex, trianglesTwoColor.indices, trianglesTwoColor.indexCount, (float*)&trianglesTwoColor.verts[0].texCoord, vs2);
if (_clipper->getClippedTriangles().size() == 0) {
_clipper->clipEnd(*slot);
continue;
}
trianglesTwoColor.vertCount = (int)_clipper->getClippedVertices().size() >> 1;
vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4B_C4B);
isFull |= vb.checkSpace(vbSize, true);
trianglesTwoColor.verts = (V2F_T2F_C4B_C4B*)vb.getCurBuffer();
trianglesTwoColor.indexCount = (int)_clipper->getClippedTriangles().size();
ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short);
trianglesTwoColor.indices = (unsigned short*)ib.getCurBuffer();
memcpy(trianglesTwoColor.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
float* verts = _clipper->getClippedVertices().buffer();
float* uvs = _clipper->getClippedUVs().buffer();
if (effect) {
Color light;
Color dark;
light.r = color.r / 255.0f;
light.g = color.g / 255.0f;
light.b = color.b / 255.0f;
light.a = color.a / 255.0f;
dark.r = darkColor.r / 255.0f;
dark.g = darkColor.g / 255.0f;
dark.b = darkColor.b / 255.0f;
dark.a = darkColor.a / 255.0f;
for (int v = 0, vn = trianglesTwoColor.vertCount, vv = 0; v < vn; ++v, vv += 2) {
V2F_T2F_C4B_C4B* vertex = trianglesTwoColor.verts + v;
Color lightCopy = light;
Color darkCopy = dark;
vertex->vertex.x = verts[vv];
vertex->vertex.y = verts[vv + 1];
vertex->texCoord.u = uvs[vv];
vertex->texCoord.v = uvs[vv + 1];
effect->transform(vertex->vertex.x, vertex->vertex.y, vertex->texCoord.u, vertex->texCoord.v, lightCopy, darkCopy);
vertex->color.r = (GLubyte)(lightCopy.r * 255);
vertex->color.g = (GLubyte)(lightCopy.g * 255);
vertex->color.b = (GLubyte)(lightCopy.b * 255);
vertex->color.a = (GLubyte)(lightCopy.a * 255);
vertex->color2.r = (GLubyte)(darkCopy.r * 255);
vertex->color2.g = (GLubyte)(darkCopy.g * 255);
vertex->color2.b = (GLubyte)(darkCopy.b * 255);
vertex->color2.a = (GLubyte)darkColor.a;
}
} else {
for (int v = 0, vn = trianglesTwoColor.vertCount, vv = 0; v < vn; ++v, vv += 2) {
V2F_T2F_C4B_C4B* vertex = trianglesTwoColor.verts + v;
vertex->vertex.x = verts[vv];
vertex->vertex.y = verts[vv + 1];
vertex->texCoord.u = uvs[vv];
vertex->texCoord.v = uvs[vv + 1];
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
vertex->color2.r = (GLubyte)darkColor.r;
vertex->color2.g = (GLubyte)darkColor.g;
vertex->color2.b = (GLubyte)darkColor.b;
vertex->color2.a = (GLubyte)darkColor.a;
}
}
// Two color tint logic
else {
if (_clipper->isClipping()) {
_clipper->clipTriangles((float*)&trianglesTwoColor.verts[0].vertex, trianglesTwoColor.indices, trianglesTwoColor.indexCount, (float*)&trianglesTwoColor.verts[0].texCoord, vs2);
if (_clipper->getClippedTriangles().size() == 0) {
_clipper->clipEnd(*slot);
continue;
}
trianglesTwoColor.vertCount = (int)_clipper->getClippedVertices().size() >> 1;
vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4B_C4B);
isFull |= vb.checkSpace(vbSize, true);
trianglesTwoColor.verts = (V2F_T2F_C4B_C4B*)vb.getCurBuffer();
trianglesTwoColor.indexCount = (int)_clipper->getClippedTriangles().size();
ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short);
trianglesTwoColor.indices = (unsigned short*)ib.getCurBuffer();
memcpy(trianglesTwoColor.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
float* verts = _clipper->getClippedVertices().buffer();
float* uvs = _clipper->getClippedUVs().buffer();
if (effect) {
Color light;
Color dark;
light.r = color.r / 255.0f;
light.g = color.g / 255.0f;
light.b = color.b / 255.0f;
light.a = color.a / 255.0f;
dark.r = darkColor.r / 255.0f;
dark.g = darkColor.g / 255.0f;
dark.b = darkColor.b / 255.0f;
dark.a = darkColor.a / 255.0f;
for (int v = 0, vn = trianglesTwoColor.vertCount, vv = 0; v < vn; ++v, vv += 2) {
V2F_T2F_C4B_C4B* vertex = trianglesTwoColor.verts + v;
Color lightCopy = light;
Color darkCopy = dark;
vertex->vertex.x = verts[vv];
vertex->vertex.y = verts[vv + 1];
vertex->texCoord.u = uvs[vv];
vertex->texCoord.v = uvs[vv + 1];
effect->transform(vertex->vertex.x, vertex->vertex.y, vertex->texCoord.u, vertex->texCoord.v, lightCopy, darkCopy);
vertex->color.r = (GLubyte)(lightCopy.r * 255);
vertex->color.g = (GLubyte)(lightCopy.g * 255);
vertex->color.b = (GLubyte)(lightCopy.b * 255);
vertex->color.a = (GLubyte)(lightCopy.a * 255);
vertex->color2.r = (GLubyte)(darkCopy.r * 255);
vertex->color2.g = (GLubyte)(darkCopy.g * 255);
vertex->color2.b = (GLubyte)(darkCopy.b * 255);
vertex->color2.a = (GLubyte)darkColor.a;
}
} else {
if (effect) {
Color light;
Color dark;
light.r = color.r / 255.0f;
light.g = color.g / 255.0f;
light.b = color.b / 255.0f;
light.a = color.a / 255.0f;
dark.r = darkColor.r / 255.0f;
dark.g = darkColor.g / 255.0f;
dark.b = darkColor.b / 255.0f;
dark.a = darkColor.a / 255.0f;
for (int v = 0, vn = trianglesTwoColor.vertCount; v < vn; ++v) {
V2F_T2F_C4B_C4B* vertex = trianglesTwoColor.verts + v;
Color lightCopy = light;
Color darkCopy = dark;
effect->transform(vertex->vertex.x, vertex->vertex.y, vertex->texCoord.u, vertex->texCoord.v, lightCopy, darkCopy);
vertex->color.r = (GLubyte)(lightCopy.r * 255);
vertex->color.g = (GLubyte)(lightCopy.g * 255);
vertex->color.b = (GLubyte)(lightCopy.b * 255);
vertex->color.a = (GLubyte)(lightCopy.a * 255);
vertex->color2.r = (GLubyte)(darkCopy.r * 255);
vertex->color2.g = (GLubyte)(darkCopy.g * 255);
vertex->color2.b = (GLubyte)(darkCopy.b * 255);
vertex->color2.a = (GLubyte)darkColor.a;
}
} else {
for (int v = 0, vn = trianglesTwoColor.vertCount; v < vn; ++v) {
V2F_T2F_C4B_C4B* vertex = trianglesTwoColor.verts + v;
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
vertex->color2.r = (GLubyte)darkColor.r;
vertex->color2.g = (GLubyte)darkColor.g;
vertex->color2.b = (GLubyte)darkColor.b;
vertex->color2.a = (GLubyte)darkColor.a;
}
for (int v = 0, vn = trianglesTwoColor.vertCount, vv = 0; v < vn; ++v, vv += 2) {
V2F_T2F_C4B_C4B* vertex = trianglesTwoColor.verts + v;
vertex->vertex.x = verts[vv];
vertex->vertex.y = verts[vv + 1];
vertex->texCoord.u = uvs[vv];
vertex->texCoord.v = uvs[vv + 1];
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
vertex->color2.r = (GLubyte)darkColor.r;
vertex->color2.g = (GLubyte)darkColor.g;
vertex->color2.b = (GLubyte)darkColor.b;
vertex->color2.a = (GLubyte)darkColor.a;
}
}
} else {
if (effect) {
Color light;
Color dark;
light.r = color.r / 255.0f;
light.g = color.g / 255.0f;
light.b = color.b / 255.0f;
light.a = color.a / 255.0f;
dark.r = darkColor.r / 255.0f;
dark.g = darkColor.g / 255.0f;
dark.b = darkColor.b / 255.0f;
dark.a = darkColor.a / 255.0f;
for (int v = 0, vn = trianglesTwoColor.vertCount; v < vn; ++v) {
V2F_T2F_C4B_C4B* vertex = trianglesTwoColor.verts + v;
Color lightCopy = light;
Color darkCopy = dark;
effect->transform(vertex->vertex.x, vertex->vertex.y, vertex->texCoord.u, vertex->texCoord.v, lightCopy, darkCopy);
vertex->color.r = (GLubyte)(lightCopy.r * 255);
vertex->color.g = (GLubyte)(lightCopy.g * 255);
vertex->color.b = (GLubyte)(lightCopy.b * 255);
vertex->color.a = (GLubyte)(lightCopy.a * 255);
vertex->color2.r = (GLubyte)(darkCopy.r * 255);
vertex->color2.g = (GLubyte)(darkCopy.g * 255);
vertex->color2.b = (GLubyte)(darkCopy.b * 255);
vertex->color2.a = (GLubyte)darkColor.a;
}
} else {
for (int v = 0, vn = trianglesTwoColor.vertCount; v < vn; ++v) {
V2F_T2F_C4B_C4B* vertex = trianglesTwoColor.verts + v;
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
vertex->color2.r = (GLubyte)darkColor.r;
vertex->color2.g = (GLubyte)darkColor.g;
vertex->color2.b = (GLubyte)darkColor.b;
vertex->color2.a = (GLubyte)darkColor.a;
}
}
}
texture = attachmentVertices->_texture;
}
texture = attachmentVertices->_texture;
curTextureIndex =
attachmentVertices->_texture->getNativeTexture()->getHandle();
// If texture or blendMode change,will change material.
// If texture or blendMode change,will change material.
if (preTextureIndex != curTextureIndex ||
preBlendMode != slot->getData().getBlendMode() || isFull) {
flush();
flush();
}
}
else {

View File

@@ -50,7 +50,7 @@ namespace spine {
/** Draws a skeleton.
*/
class SkeletonRenderer: public cocos2d::middleware::IMiddleware, public cocos2d::Ref {
class SkeletonRenderer: public cocos2d::Ref, public cocos2d::middleware::IMiddleware {
public:
static SkeletonRenderer* create ();
static SkeletonRenderer* createWithSkeleton(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false);
@@ -99,7 +99,7 @@ namespace spine {
void setUseTint(bool enabled);
void setUseMulti(bool enabled);
/* Sets the vertex effect to be used, set to 0 to disable vertex effects */
void setVertexEffectDelegate(VertexEffectDelegate* effectDelegate);
/* Sets the range of slots that should be rendered. Use -1, -1 to clear the range */
@@ -126,6 +126,7 @@ namespace spine {
virtual void stopSchedule();
void onEnable();
void onDisable();
virtual void destroy();
CC_CONSTRUCTOR_ACCESS:
SkeletonRenderer ();

View File

@@ -273,19 +273,31 @@ void OpenHarmonyPlatform::onSurfaceChanged(OH_NativeXComponent* component, void*
void OpenHarmonyPlatform::onSurfaceDestroyed(OH_NativeXComponent* component, void* window) {
}
void OpenHarmonyPlatform::tick() {
static std::chrono::steady_clock::time_point prevTime;
static std::chrono::steady_clock::time_point now;
static float dt = 0.f;
static float dtSum = 0.f;
static uint32_t jsbInvocationTotalCount = 0;
static uint32_t jsbInvocationTotalFrames = 0;
std::shared_ptr<Scheduler> scheduler = g_app->getScheduler();
scheduler->update(dt);
EventDispatcher::dispatchTickEvent(dt);
PoolManager::getInstance()->getCurrentPool()->clear();
now = std::chrono::steady_clock::now();
dt = std::chrono::duration_cast<std::chrono::microseconds>(now - prevTime).count() / 1000000.f;
prevTime = std::chrono::steady_clock::now();
void OpenHarmonyPlatform::setPreferedFramePersecond(int fps) {
if (fps == 0) {
return;
}
_prefererredNanosecondsPerFrame = static_cast<long>(1.0 / fps * NANOSECONDS_PER_SECOND); // NOLINT(google-runtime-int)
}
void OpenHarmonyPlatform::tick() {
static std::chrono::steady_clock::time_point prevTime;
static std::chrono::steady_clock::time_point now;
static float dt = 0.f;
static double dtNS = NANOSECONDS_60FPS;
if (dtNS < static_cast<double>(_prefererredNanosecondsPerFrame)) {
std::this_thread::sleep_for(std::chrono::nanoseconds(
_prefererredNanosecondsPerFrame - static_cast<int64_t>(dtNS)));
dtNS = static_cast<double>(_prefererredNanosecondsPerFrame);
}
prevTime = std::chrono::steady_clock::now();
std::shared_ptr<Scheduler> scheduler = g_app->getScheduler();
scheduler->update(dt);
EventDispatcher::dispatchTickEvent(dt);
PoolManager::getInstance()->getCurrentPool()->clear();
now = std::chrono::steady_clock::now();
dtNS = dtNS * 0.1 + 0.9 * static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(now - prevTime).count());
dt = static_cast<float>(dtNS) / NANOSECONDS_PER_SECOND;
}
}; // namespace cc

View File

@@ -78,7 +78,9 @@ public:
static void onMessageCallback(const uv_async_t* req);
static void timerCb(uv_timer_t* handle);
void tick();
void setPreferedFramePersecond(int fps);
int64_t _prefererredNanosecondsPerFrame{NANOSECONDS_60FPS};
OH_NativeXComponent* _component{nullptr};
OH_NativeXComponent_Callback _callback;
uv_timer_t _timerHandle;

View File

@@ -121,7 +121,8 @@ void Application::onResume()
void Application::setPreferredFramesPerSecond(int fps)
{
_fps = fps;
// setPreferredFramesPerSecondJNI(_fps);
cocos2d::OpenHarmonyPlatform* platform = cocos2d::OpenHarmonyPlatform::getInstance();
platform->setPreferedFramePersecond(_fps);
}
bool Application::isDisplayStats() {

View File

@@ -13203,6 +13203,21 @@ static bool js_cocos2dx_spine_SkeletonRenderer_paused(se::State& s)
}
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonRenderer_paused)
static bool js_cocos2dx_spine_SkeletonRenderer_destroy(se::State& s)
{
spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_cocos2dx_spine_SkeletonRenderer_destroy : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
if (argc == 0) {
cobj->destroy();
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
return false;
}
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonRenderer_destroy)
static bool js_cocos2dx_spine_SkeletonRenderer_setAttachment(se::State& s)
{
CC_UNUSED bool ok = true;
@@ -14133,6 +14148,7 @@ bool js_register_cocos2dx_spine_SkeletonRenderer(se::Object* obj)
cls->defineFunction("setAttachUtil", _SE(js_cocos2dx_spine_SkeletonRenderer_setAttachUtil));
cls->defineFunction("setOpacityModifyRGB", _SE(js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB));
cls->defineFunction("paused", _SE(js_cocos2dx_spine_SkeletonRenderer_paused));
cls->defineFunction("destroy", _SE(js_cocos2dx_spine_SkeletonRenderer_destroy));
cls->defineFunction("setAttachment", _SE(js_cocos2dx_spine_SkeletonRenderer_setAttachment));
cls->defineFunction("setBonesToSetupPose", _SE(js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose));
cls->defineFunction("onEnable", _SE(js_cocos2dx_spine_SkeletonRenderer_onEnable));
@@ -14600,6 +14616,21 @@ static bool js_cocos2dx_spine_SkeletonAnimation_setEndListener(se::State& s)
}
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonAnimation_setEndListener)
static bool js_cocos2dx_spine_SkeletonAnimation_destroy(se::State& s)
{
spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_cocos2dx_spine_SkeletonAnimation_destroy : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
if (argc == 0) {
cobj->destroy();
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
return false;
}
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonAnimation_destroy)
static bool js_cocos2dx_spine_SkeletonAnimation_getState(se::State& s)
{
spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation*)s.nativeThisObject();
@@ -15284,6 +15315,7 @@ bool js_register_cocos2dx_spine_SkeletonAnimation(se::Object* obj)
cls->defineFunction("setTrackCompleteListenerNative", _SE(js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener));
cls->defineFunction("setAnimationStateData", _SE(js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData));
cls->defineFunction("setEndListener", _SE(js_cocos2dx_spine_SkeletonAnimation_setEndListener));
cls->defineFunction("destroy", _SE(js_cocos2dx_spine_SkeletonAnimation_destroy));
cls->defineFunction("getState", _SE(js_cocos2dx_spine_SkeletonAnimation_getState));
cls->defineFunction("setCompleteListenerNative", _SE(js_cocos2dx_spine_SkeletonAnimation_setCompleteListener));
cls->defineFunction("setTrackDisposeListener", _SE(js_cocos2dx_spine_SkeletonAnimation_setTrackDisposeListener));
@@ -15652,6 +15684,21 @@ static bool js_cocos2dx_spine_SkeletonCacheAnimation_paused(se::State& s)
}
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_paused)
static bool js_cocos2dx_spine_SkeletonCacheAnimation_destroy(se::State& s)
{
spine::SkeletonCacheAnimation* cobj = (spine::SkeletonCacheAnimation*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_cocos2dx_spine_SkeletonCacheAnimation_destroy : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
if (argc == 0) {
cobj->destroy();
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
return false;
}
SE_BIND_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_destroy)
static bool js_cocos2dx_spine_SkeletonCacheAnimation_setAttachment(se::State& s)
{
CC_UNUSED bool ok = true;
@@ -16334,6 +16381,7 @@ bool js_register_cocos2dx_spine_SkeletonCacheAnimation(se::Object* obj)
cls->defineFunction("findAnimation", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_findAnimation));
cls->defineFunction("setAttachUtil", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachUtil));
cls->defineFunction("paused", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_paused));
cls->defineFunction("destroy", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_destroy));
cls->defineFunction("setAttachment", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachment));
cls->defineFunction("setAnimation", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setAnimation));
cls->defineFunction("setBonesToSetupPose", _SE(js_cocos2dx_spine_SkeletonCacheAnimation_setBonesToSetupPose));

View File

@@ -923,6 +923,7 @@ SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_initWithUUID);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setAttachUtil);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_paused);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_destroy);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setAttachment);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonRenderer_onEnable);
@@ -973,6 +974,7 @@ SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setTrackInterruptListener);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setEndListener);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_destroy);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_getState);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setCompleteListener);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonAnimation_setTrackDisposeListener);
@@ -1022,6 +1024,7 @@ SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setTimeScale);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_findAnimation);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachUtil);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_paused);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_destroy);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setAttachment);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setAnimation);
SE_DECLARE_FUNC(js_cocos2dx_spine_SkeletonCacheAnimation_setBonesToSetupPose);

View File

@@ -509,10 +509,9 @@ void Object::setPrivateData(void* data){
//issue https://github.com/nodejs/node/issues/23999
auto tmpThis = _objRef.getValue(_env);
//_objRef.deleteRef();
napi_ref result = nullptr;
NODE_API_CALL(status, _env,
napi_wrap(_env, tmpThis, data, weakCallback,
(void*)this /* finalize_hint */, &result));
(void*)this /* finalize_hint */, nullptr));
//_objRef.setWeakref(_env, result);
setProperty("__native_ptr__", se::Value(static_cast<long>(reinterpret_cast<uintptr_t>(data))));
}

View File

@@ -180,13 +180,13 @@ bool jsb_register_all_modules()
se->addRegisterCallback(register_all_video);
#endif
#if USE_WEBVIEW
#if USE_WEB_VIEW
se->addRegisterCallback(register_all_webview);
#endif
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_OPENHARMONY)
#if USE_WEBVIEW
#if USE_WEB_VIEW
se->addRegisterCallback(register_all_webview);
#endif

View File

@@ -379,6 +379,12 @@ void XMLHttpRequest::getHeader(const std::string& header)
// Transform field name to lower case as they are case-insensitive
std::transform(http_field.begin(), http_field.end(), http_field.begin(), ::tolower);
if (CC_TARGET_PLATFORM == CC_PLATFORM_OPENHARMONY && _httpHeader.find(http_field) != _httpHeader.end()) {
_httpHeader[http_field].insert(strlen(_httpHeader[http_field].c_str()) - 1, ",");
_httpHeader[http_field].insert(strlen(_httpHeader[http_field].c_str()) - 1, http_value);
http_value = _httpHeader[http_field];
}
_httpHeader[http_field] = http_value;
}