Skip to content

Commit 6fea634

Browse files
committed
Sync latest axmol
1 parent 29ab7a1 commit 6fea634

9 files changed

+74
-74
lines changed

AttachmentVertices.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ namespace spine {
3838

3939
class SP_API AttachmentVertices {
4040
public:
41-
AttachmentVertices(cocos2d::Texture2D *texture, int verticesCount, unsigned short *triangles, int trianglesCount);
41+
AttachmentVertices(ax::Texture2D *texture, int verticesCount, unsigned short *triangles, int trianglesCount);
4242
virtual ~AttachmentVertices();
4343

44-
cocos2d::Texture2D *_texture;
45-
cocos2d::TrianglesCommand::Triangles *_triangles;
44+
ax::Texture2D *_texture;
45+
ax::TrianglesCommand::Triangles *_triangles;
4646
};
4747

4848
}// namespace spine

SkeletonAnimation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace spine {
142142
if (_postUpdateListener) _postUpdateListener(this);
143143
}
144144

145-
void SkeletonAnimation::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t transformFlags) {
145+
void SkeletonAnimation::draw(ax::Renderer *renderer, const ax::Mat4 &transform, uint32_t transformFlags) {
146146
if (_firstDraw) {
147147
_firstDraw = false;
148148
update(0);

SkeletonAnimation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class SP_API SkeletonAnimation: public SkeletonRenderer {
6767
}
6868

6969
virtual void update(float deltaTime) override;
70-
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t transformFlags) override;
70+
virtual void draw(ax::Renderer *renderer, const ax::Mat4 &transform, uint32_t transformFlags) override;
7171

7272
void setAnimationStateData(AnimationStateData *stateData);
7373
void setMix(const std::string &fromAnimation, const std::string &toAnimation, float duration);

SkeletonBatch.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,19 @@ void SkeletonBatch::update (float delta) {
114114
reset();
115115
}
116116

117-
cocos2d::V3F_C4B_T2F* SkeletonBatch::allocateVertices(uint32_t numVertices) {
117+
ax::V3F_C4B_T2F* SkeletonBatch::allocateVertices(uint32_t numVertices) {
118118
if (_vertices.size() - _numVertices < numVertices) {
119-
cocos2d::V3F_C4B_T2F* oldData = _vertices.data();
119+
ax::V3F_C4B_T2F* oldData = _vertices.data();
120120
_vertices.resize((_vertices.size() + numVertices) * 2 + 1);
121-
cocos2d::V3F_C4B_T2F* newData = _vertices.data();
121+
ax::V3F_C4B_T2F* newData = _vertices.data();
122122
for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
123123
SkeletonCommand* command = _commandsPool[i];
124124
SkeletonCommand::Triangles& triangles = (SkeletonCommand::Triangles&)command->getTriangles();
125125
triangles.verts = newData + (triangles.verts - oldData);
126126
}
127127
}
128128

129-
cocos2d::V3F_C4B_T2F* vertices = _vertices.data() + _numVertices;
129+
ax::V3F_C4B_T2F* vertices = _vertices.data() + _numVertices;
130130
_numVertices += numVertices;
131131
return vertices;
132132
}
@@ -161,9 +161,9 @@ void SkeletonBatch::deallocateIndices(uint32_t numIndices) {
161161
}
162162

163163

164-
cocos2d::TrianglesCommand* SkeletonBatch::addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, backend::ProgramState* programState, cocos2d::BlendFunc blendType, const cocos2d::TrianglesCommand::Triangles& triangles, const cocos2d::Mat4& mv, uint32_t flags) {
164+
ax::TrianglesCommand* SkeletonBatch::addCommand(ax::Renderer* renderer, float globalOrder, ax::Texture2D* texture, backend::ProgramState* programState, ax::BlendFunc blendType, const ax::TrianglesCommand::Triangles& triangles, const ax::Mat4& mv, uint32_t flags) {
165165
SkeletonCommand* command = nextFreeCommand();
166-
const cocos2d::Mat4& projectionMat = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
166+
const ax::Mat4& projectionMat = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
167167

168168
if (programState == nullptr)
169169
programState = _programState;

SkeletonBatch.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939

4040
namespace spine {
4141

42-
struct SkeletonCommand : public cocos2d::TrianglesCommand {
43-
cocos2d::backend::UniformLocation _locMVP;
44-
cocos2d::backend::UniformLocation _locTexture;
42+
struct SkeletonCommand : public ax::TrianglesCommand {
43+
ax::backend::UniformLocation _locMVP;
44+
ax::backend::UniformLocation _locTexture;
4545
};
4646

4747
class SP_API SkeletonBatch {
@@ -52,13 +52,13 @@ namespace spine {
5252

5353
void update (float delta);
5454

55-
cocos2d::V3F_C4B_T2F* allocateVertices(uint32_t numVertices);
55+
ax::V3F_C4B_T2F* allocateVertices(uint32_t numVertices);
5656
void deallocateVertices(uint32_t numVertices);
5757
unsigned short* allocateIndices(uint32_t numIndices);
5858
void deallocateIndices(uint32_t numVertices);
59-
cocos2d::TrianglesCommand* addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, cocos2d::backend::ProgramState* programState, cocos2d::BlendFunc blendType, const cocos2d::TrianglesCommand::Triangles& triangles, const cocos2d::Mat4& mv, uint32_t flags);
59+
ax::TrianglesCommand* addCommand(ax::Renderer* renderer, float globalOrder, ax::Texture2D* texture, ax::backend::ProgramState* programState, ax::BlendFunc blendType, const ax::TrianglesCommand::Triangles& triangles, const ax::Mat4& mv, uint32_t flags);
6060

61-
cocos2d::backend::ProgramState* updateCommandPipelinePS(SkeletonCommand* command, cocos2d::backend::ProgramState* programState);
61+
ax::backend::ProgramState* updateCommandPipelinePS(SkeletonCommand* command, ax::backend::ProgramState* programState);
6262

6363
protected:
6464
SkeletonBatch ();
@@ -70,14 +70,14 @@ namespace spine {
7070

7171
SkeletonCommand* newCommand();
7272

73-
cocos2d::backend::ProgramState* _programState; // The default program state
73+
ax::backend::ProgramState* _programState; // The default program state
7474

7575
// pool of commands
7676
std::vector<SkeletonCommand*> _commandsPool;
7777
uint32_t _nextFreeCommand;
7878

7979
// pool of vertices
80-
std::vector<cocos2d::V3F_C4B_T2F> _vertices;
80+
std::vector<ax::V3F_C4B_T2F> _vertices;
8181
uint32_t _numVertices;
8282

8383
// pool of indices

SkeletonRenderer.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ namespace spine {
4040
Cocos2dTextureLoader textureLoader;
4141

4242
int computeTotalCoordCount(Skeleton &skeleton, int startSlotIndex, int endSlotIndex);
43-
cocos2d::Rect computeBoundingRect(const float *coords, int vertexCount);
43+
ax::Rect computeBoundingRect(const float *coords, int vertexCount);
4444
void interleaveCoordinates(float *dst, const float *src, int vertexCount, int dstStride);
4545
BlendFunc makeBlendFunc(BlendMode blendMode, bool premultipliedAlpha);
4646
void transformWorldVertices(float *dstCoord, int coordCount, Skeleton &skeleton, int startSlotIndex, int endSlotIndex);
47-
bool cullRectangle(Renderer *renderer, const Mat4 &transform, const cocos2d::Rect &rect);
47+
bool cullRectangle(Renderer *renderer, const Mat4 &transform, const ax::Rect &rect);
4848
Color4B ColorToColor4B(const Color &color);
4949
bool slotIsOutRange(Slot &slot, int startSlotIndex, int endSlotIndex);
5050
bool nothingToDraw(Slot &slot, int startSlotIndex, int endSlotIndex);
@@ -268,7 +268,7 @@ namespace spine {
268268
transformWorldVertices(worldCoords, coordCount, *_skeleton, _startSlotIndex, _endSlotIndex);
269269

270270
#if CC_USE_CULLING
271-
const cocos2d::Rect bb = computeBoundingRect(worldCoords, coordCount / 2);
271+
const ax::Rect bb = computeBoundingRect(worldCoords, coordCount / 2);
272272

273273
if (cullRectangle(renderer, transform, bb)) {
274274
VLA_FREE(worldCoords);
@@ -306,7 +306,7 @@ namespace spine {
306306
continue;
307307
}
308308

309-
cocos2d::TrianglesCommand::Triangles triangles;
309+
ax::TrianglesCommand::Triangles triangles;
310310
TwoColorTriangles trianglesTwoColor;
311311

312312
if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
@@ -321,7 +321,7 @@ namespace spine {
321321
triangles.verts = batch->allocateVertices(attachmentVertices->_triangles->vertCount);
322322
triangles.vertCount = attachmentVertices->_triangles->vertCount;
323323
assert(triangles.vertCount == 4);
324-
memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(cocos2d::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
324+
memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(ax::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
325325
dstStride = sizeof(V3F_C4B_T2F) / sizeof(float);
326326
dstTriangleVertices = reinterpret_cast<float *>(triangles.verts);
327327
} else {
@@ -353,7 +353,7 @@ namespace spine {
353353
triangles.indexCount = attachmentVertices->_triangles->indexCount;
354354
triangles.verts = batch->allocateVertices(attachmentVertices->_triangles->vertCount);
355355
triangles.vertCount = attachmentVertices->_triangles->vertCount;
356-
memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(cocos2d::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
356+
memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(ax::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
357357
dstTriangleVertices = (float *) triangles.verts;
358358
dstStride = sizeof(V3F_C4B_T2F) / sizeof(float);
359359
dstVertexCount = triangles.vertCount;
@@ -408,14 +408,14 @@ namespace spine {
408408
color.b *= color.a;
409409
}
410410

411-
const cocos2d::Color4B color4B = ColorToColor4B(color);
412-
const cocos2d::Color4B darkColor4B = ColorToColor4B(darkColor);
411+
const ax::Color4B color4B = ColorToColor4B(color);
412+
const ax::Color4B darkColor4B = ColorToColor4B(darkColor);
413413
const BlendFunc blendFunc = makeBlendFunc(slot->getData().getBlendMode(), attachmentVertices->_texture->hasPremultipliedAlpha());
414414
_blendFunc = blendFunc;
415415

416416
if (hasSingleTint) {
417417
if (_clipper->isClipping()) {
418-
_clipper->clipTriangles((float *) &triangles.verts[0].vertices, triangles.indices, triangles.indexCount, (float *) &triangles.verts[0].texCoords, sizeof(cocos2d::V3F_C4B_T2F) / 4);
418+
_clipper->clipTriangles((float *) &triangles.verts[0].vertices, triangles.indices, triangles.indexCount, (float *) &triangles.verts[0].texCoords, sizeof(ax::V3F_C4B_T2F) / 4);
419419
batch->deallocateVertices(triangles.vertCount);
420420

421421
if (_clipper->getClippedTriangles().size() == 0) {
@@ -431,9 +431,9 @@ namespace spine {
431431
memcpy(triangles.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
432432

433433
#if COCOS2D_VERSION < 0x00040000
434-
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _glProgramState, blendFunc, triangles, transform, transformFlags);
434+
ax::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _glProgramState, blendFunc, triangles, transform, transformFlags);
435435
#else
436-
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, triangles, transform, transformFlags);
436+
ax::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, triangles, transform, transformFlags);
437437
#endif
438438

439439
const float *verts = _clipper->getClippedVertices().buffer();
@@ -463,9 +463,9 @@ namespace spine {
463463
} else {
464464
// Not clipping.
465465
#if COCOS2D_VERSION < 0x00040000
466-
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _glProgramState, blendFunc, triangles, transform, transformFlags);
466+
ax::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _glProgramState, blendFunc, triangles, transform, transformFlags);
467467
#else
468-
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, triangles, transform, transformFlags);
468+
ax::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, triangles, transform, transformFlags);
469469
#endif
470470

471471
if (_effect) {
@@ -574,7 +574,7 @@ namespace spine {
574574
if (!parent || parent->getChildrenCount() > 100 || getChildrenCount() != 0) {
575575
lastTwoColorTrianglesCommand->setForceFlush(true);
576576
} else {
577-
const cocos2d::Vector<Node *> &children = parent->getChildren();
577+
const ax::Vector<Node *> &children = parent->getChildren();
578578
Node *sibling = nullptr;
579579
for (ssize_t i = 0; i < children.size(); i++) {
580580
if (children.at(i) == this) {
@@ -626,7 +626,7 @@ namespace spine {
626626
#else
627627
drawNode->setLineWidth(2.0f);
628628
#endif
629-
const cocos2d::Rect brect = getBoundingBox();
629+
const ax::Rect brect = getBoundingBox();
630630
const Vec2 points[4] =
631631
{
632632
brect.origin,
@@ -728,12 +728,12 @@ namespace spine {
728728
#endif
729729
}
730730

731-
cocos2d::Rect SkeletonRenderer::getBoundingBox() const {
731+
ax::Rect SkeletonRenderer::getBoundingBox() const {
732732
const int coordCount = computeTotalCoordCount(*_skeleton, _startSlotIndex, _endSlotIndex);
733733
if (coordCount == 0) return {0, 0, 0, 0};
734734
VLA(float, worldCoords, coordCount);
735735
transformWorldVertices(worldCoords, coordCount, *_skeleton, _startSlotIndex, _endSlotIndex);
736-
const cocos2d::Rect bb = computeBoundingRect(worldCoords, coordCount / 2);
736+
const ax::Rect bb = computeBoundingRect(worldCoords, coordCount / 2);
737737
VLA_FREE(worldCoords);
738738
return bb;
739739
}
@@ -882,7 +882,7 @@ namespace spine {
882882
}
883883

884884
namespace {
885-
cocos2d::Rect computeBoundingRect(const float *coords, int vertexCount) {
885+
ax::Rect computeBoundingRect(const float *coords, int vertexCount) {
886886
assert(coords);
887887
assert(vertexCount > 0);
888888

@@ -1033,7 +1033,7 @@ namespace spine {
10331033
}
10341034

10351035

1036-
bool cullRectangle(Renderer *renderer, const Mat4 &transform, const cocos2d::Rect &rect) {
1036+
bool cullRectangle(Renderer *renderer, const Mat4 &transform, const ax::Rect &rect) {
10371037
if (Camera::getVisitingCamera() == nullptr)
10381038
return false;
10391039

SkeletonRenderer.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace spine {
3838
class AttachmentVertices;
3939

4040
/* Draws a skeleton. */
41-
class SP_API SkeletonRenderer: public cocos2d::Node, public cocos2d::BlendProtocol {
41+
class SP_API SkeletonRenderer: public ax::Node, public ax::BlendProtocol {
4242
public:
4343
CREATE_FUNC(SkeletonRenderer);
4444
static SkeletonRenderer *createWithSkeleton(Skeleton *skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false);
@@ -47,8 +47,8 @@ namespace spine {
4747
static SkeletonRenderer *createWithFile(const std::string &skeletonDataFile, const std::string &atlasFile, float scale = 1);
4848

4949
void update(float deltaTime) override;
50-
void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t transformFlags) override;
51-
cocos2d::Rect getBoundingBox() const override;
50+
void draw(ax::Renderer *renderer, const ax::Mat4 &transform, uint32_t transformFlags) override;
51+
ax::Rect getBoundingBox() const override;
5252
void onEnter() override;
5353
void onExit() override;
5454

@@ -109,8 +109,8 @@ namespace spine {
109109
void setSlotsRange(int startSlotIndex, int endSlotIndex);
110110

111111
// --- BlendProtocol
112-
void setBlendFunc(const cocos2d::BlendFunc &blendFunc) override;
113-
const cocos2d::BlendFunc &getBlendFunc() const override;
112+
void setBlendFunc(const ax::BlendFunc &blendFunc) override;
113+
const ax::BlendFunc &getBlendFunc() const override;
114114
void setOpacityModifyRGB(bool value) override;
115115
bool isOpacityModifyRGB() const override;
116116

@@ -134,15 +134,15 @@ namespace spine {
134134
protected:
135135
void setSkeletonData(SkeletonData *skeletonData, bool ownsSkeletonData);
136136
void setupGLProgramState(bool twoColorTintEnabled);
137-
virtual void drawDebug(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t transformFlags);
137+
virtual void drawDebug(ax::Renderer *renderer, const ax::Mat4 &transform, uint32_t transformFlags);
138138

139139
bool _ownsSkeletonData;
140140
bool _ownsSkeleton;
141141
bool _ownsAtlas = false;
142142
Atlas *_atlas;
143143
AttachmentLoader *_attachmentLoader;
144-
cocos2d::CustomCommand _debugCommand;
145-
cocos2d::BlendFunc _blendFunc;
144+
ax::CustomCommand _debugCommand;
145+
ax::BlendFunc _blendFunc;
146146
bool _premultipliedAlpha;
147147
Skeleton *_skeleton;
148148
float _timeScale;
@@ -152,7 +152,7 @@ namespace spine {
152152
bool _debugBoundingRect;
153153
SkeletonClipping *_clipper;
154154
VertexEffect *_effect;
155-
cocos2d::Rect _boundingRect;
155+
ax::Rect _boundingRect;
156156

157157
int _startSlotIndex;
158158
int _endSlotIndex;

SkeletonTwoColorBatch.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ namespace spine {
136136
_type = RenderCommand::Type::CUSTOM_COMMAND;
137137
}
138138

139-
void TwoColorTrianglesCommand::init(float globalOrder, cocos2d::Texture2D *texture, cocos2d::backend::ProgramState *programState, BlendFunc blendType, const TwoColorTriangles &triangles, const Mat4 &mv, uint32_t flags) {
139+
void TwoColorTrianglesCommand::init(float globalOrder, ax::Texture2D *texture, ax::backend::ProgramState *programState, BlendFunc blendType, const TwoColorTriangles &triangles, const Mat4 &mv, uint32_t flags) {
140140

141141
updateCommandPipelineDescriptor(programState);
142-
const cocos2d::Mat4 &projectionMat = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
142+
const ax::Mat4 &projectionMat = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
143143

144144
auto finalMatrix = projectionMat * mv;
145145

@@ -175,7 +175,7 @@ namespace spine {
175175
}
176176

177177

178-
void TwoColorTrianglesCommand::updateCommandPipelineDescriptor(cocos2d::backend::ProgramState *programState) {
178+
void TwoColorTrianglesCommand::updateCommandPipelineDescriptor(ax::backend::ProgramState *programState) {
179179
// OPTIMIZE ME: all commands belong a same Node should share a same programState like SkeletonBatch
180180
if (!__twoColorProgramState) {
181181
initTwoColorProgramState();
@@ -342,15 +342,15 @@ namespace spine {
342342
_indices.setSize(_indices.size() - numIndices, 0);
343343
}
344344

345-
TwoColorTrianglesCommand *SkeletonTwoColorBatch::addCommand(cocos2d::Renderer *renderer, float globalOrder, cocos2d::Texture2D *texture, backend::ProgramState *programState, cocos2d::BlendFunc blendType, const TwoColorTriangles &triangles, const cocos2d::Mat4 &mv, uint32_t flags) {
345+
TwoColorTrianglesCommand *SkeletonTwoColorBatch::addCommand(ax::Renderer *renderer, float globalOrder, ax::Texture2D *texture, backend::ProgramState *programState, ax::BlendFunc blendType, const TwoColorTriangles &triangles, const ax::Mat4 &mv, uint32_t flags) {
346346
TwoColorTrianglesCommand *command = nextFreeCommand();
347347
command->init(globalOrder, texture, programState, blendType, triangles, mv, flags);
348348
command->updateVertexAndIndexBuffer(renderer, triangles.verts, triangles.vertCount, triangles.indices, triangles.indexCount);
349349
renderer->addCommand(command);
350350
return command;
351351
}
352352

353-
void SkeletonTwoColorBatch::batch(cocos2d::Renderer *renderer, TwoColorTrianglesCommand *command) {
353+
void SkeletonTwoColorBatch::batch(ax::Renderer *renderer, TwoColorTrianglesCommand *command) {
354354
if (_numVerticesBuffer + command->getTriangles().vertCount >= MAX_VERTICES || _numIndicesBuffer + command->getTriangles().indexCount >= MAX_INDICES) {
355355
flush(renderer, _lastCommand);
356356
}
@@ -381,7 +381,7 @@ namespace spine {
381381
_lastCommand = command;
382382
}
383383

384-
void SkeletonTwoColorBatch::flush(cocos2d::Renderer *renderer, TwoColorTrianglesCommand *materialCommand) {
384+
void SkeletonTwoColorBatch::flush(ax::Renderer *renderer, TwoColorTrianglesCommand *materialCommand) {
385385
if (!materialCommand)
386386
return;
387387

0 commit comments

Comments
 (0)