mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Clean ups
This commit is contained in:
parent
99c08fced6
commit
90f2968865
@ -66,8 +66,6 @@ static void setAttachmentVertices(MeshAttachment* attachment) {
|
|||||||
Cocos2dAtlasAttachmentLoader::Cocos2dAtlasAttachmentLoader(Atlas* atlas): AtlasAttachmentLoader(atlas) {
|
Cocos2dAtlasAttachmentLoader::Cocos2dAtlasAttachmentLoader(Atlas* atlas): AtlasAttachmentLoader(atlas) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Cocos2dAtlasAttachmentLoader::~Cocos2dAtlasAttachmentLoader() { }
|
|
||||||
|
|
||||||
void Cocos2dAtlasAttachmentLoader::configureAttachment(Attachment* attachment) {
|
void Cocos2dAtlasAttachmentLoader::configureAttachment(Attachment* attachment) {
|
||||||
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
||||||
setAttachmentVertices((RegionAttachment*)attachment);
|
setAttachmentVertices((RegionAttachment*)attachment);
|
||||||
@ -102,34 +100,31 @@ GLuint filter (TextureFilter filter) {
|
|||||||
return GL_LINEAR;
|
return GL_LINEAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cocos2dTextureLoader::Cocos2dTextureLoader() : TextureLoader() { }
|
|
||||||
Cocos2dTextureLoader::~Cocos2dTextureLoader() { }
|
|
||||||
|
|
||||||
void Cocos2dTextureLoader::load(AtlasPage& page, const spine::String& path) {
|
void Cocos2dTextureLoader::load(AtlasPage& page, const spine::String& path) {
|
||||||
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path.buffer());
|
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path.buffer());
|
||||||
CCASSERT(texture != nullptr, "Invalid image");
|
CCASSERT(texture != nullptr, "Invalid image");
|
||||||
texture->retain();
|
if (texture)
|
||||||
|
{
|
||||||
Texture2D::TexParams textureParams = {filter(page.minFilter), filter(page.magFilter), wrap(page.uWrap), wrap(page.vWrap)};
|
texture->retain();
|
||||||
texture->setTexParameters(textureParams);
|
Texture2D::TexParams textureParams = { filter(page.minFilter), filter(page.magFilter), wrap(page.uWrap), wrap(page.vWrap) };
|
||||||
|
texture->setTexParameters(textureParams);
|
||||||
page.setRendererObject(texture);
|
page.setRendererObject(texture);
|
||||||
page.width = texture->getPixelsWide();
|
page.width = texture->getPixelsWide();
|
||||||
page.height = texture->getPixelsHigh();
|
page.height = texture->getPixelsHigh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cocos2dTextureLoader::unload(void* texture) {
|
void Cocos2dTextureLoader::unload(void* texture) {
|
||||||
((Texture2D*)texture)->release();
|
if (texture)
|
||||||
|
{
|
||||||
|
((Texture2D*)texture)->release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cocos2dExtension::Cocos2dExtension() : DefaultSpineExtension() { }
|
|
||||||
|
|
||||||
Cocos2dExtension::~Cocos2dExtension() { }
|
|
||||||
|
|
||||||
char *Cocos2dExtension::_readFile(const spine::String &path, int *length) {
|
char *Cocos2dExtension::_readFile(const spine::String &path, int *length) {
|
||||||
Data data = FileUtils::getInstance()->getDataFromFile(FileUtils::getInstance()->fullPathForFilename(path.buffer()));
|
Data data = FileUtils::getInstance()->getDataFromFile(FileUtils::getInstance()->fullPathForFilename(path.buffer()));
|
||||||
if (data.isNull()) return 0;
|
if (data.isNull()) return nullptr;
|
||||||
|
|
||||||
// avoid buffer overflow (int is shorter than ssize_t in certain platforms)
|
// avoid buffer overflow (int is shorter than ssize_t in certain platforms)
|
||||||
#if COCOS2D_VERSION >= 0x00031200
|
#if COCOS2D_VERSION >= 0x00031200
|
||||||
|
|||||||
@ -41,15 +41,11 @@ namespace spine {
|
|||||||
class Cocos2dAtlasAttachmentLoader: public AtlasAttachmentLoader {
|
class Cocos2dAtlasAttachmentLoader: public AtlasAttachmentLoader {
|
||||||
public:
|
public:
|
||||||
Cocos2dAtlasAttachmentLoader(Atlas* atlas);
|
Cocos2dAtlasAttachmentLoader(Atlas* atlas);
|
||||||
virtual ~Cocos2dAtlasAttachmentLoader();
|
|
||||||
virtual void configureAttachment(Attachment* attachment);
|
virtual void configureAttachment(Attachment* attachment);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Cocos2dTextureLoader: public TextureLoader {
|
class Cocos2dTextureLoader: public TextureLoader {
|
||||||
public:
|
public:
|
||||||
Cocos2dTextureLoader();
|
|
||||||
|
|
||||||
virtual ~Cocos2dTextureLoader();
|
|
||||||
|
|
||||||
virtual void load(AtlasPage& page, const String& path);
|
virtual void load(AtlasPage& page, const String& path);
|
||||||
|
|
||||||
@ -58,9 +54,6 @@ namespace spine {
|
|||||||
|
|
||||||
class Cocos2dExtension: public DefaultSpineExtension {
|
class Cocos2dExtension: public DefaultSpineExtension {
|
||||||
public:
|
public:
|
||||||
Cocos2dExtension();
|
|
||||||
|
|
||||||
virtual ~Cocos2dExtension();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual char *_readFile(const String &path, int *length);
|
virtual char *_readFile(const String &path, int *length);
|
||||||
|
|||||||
@ -77,10 +77,8 @@ public:
|
|||||||
|
|
||||||
explicit AtlasPage(const String &inName) : name(inName), format(Format_RGBA8888), minFilter(TextureFilter_Nearest),
|
explicit AtlasPage(const String &inName) : name(inName), format(Format_RGBA8888), minFilter(TextureFilter_Nearest),
|
||||||
magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge),
|
magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge),
|
||||||
vWrap(TextureWrap_ClampToEdge) {
|
vWrap(TextureWrap_ClampToEdge), width(0), height(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~AtlasPage() { }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SP_API AtlasRegion : public SpineObject {
|
class SP_API AtlasRegion : public SpineObject {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user