mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +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() { }
|
||||
|
||||
void Cocos2dAtlasAttachmentLoader::configureAttachment(Attachment* attachment) {
|
||||
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
||||
setAttachmentVertices((RegionAttachment*)attachment);
|
||||
@ -102,34 +100,31 @@ GLuint filter (TextureFilter filter) {
|
||||
return GL_LINEAR;
|
||||
}
|
||||
|
||||
Cocos2dTextureLoader::Cocos2dTextureLoader() : TextureLoader() { }
|
||||
Cocos2dTextureLoader::~Cocos2dTextureLoader() { }
|
||||
|
||||
void Cocos2dTextureLoader::load(AtlasPage& page, const spine::String& path) {
|
||||
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path.buffer());
|
||||
CCASSERT(texture != nullptr, "Invalid image");
|
||||
texture->retain();
|
||||
|
||||
Texture2D::TexParams textureParams = {filter(page.minFilter), filter(page.magFilter), wrap(page.uWrap), wrap(page.vWrap)};
|
||||
texture->setTexParameters(textureParams);
|
||||
|
||||
page.setRendererObject(texture);
|
||||
page.width = texture->getPixelsWide();
|
||||
page.height = texture->getPixelsHigh();
|
||||
if (texture)
|
||||
{
|
||||
texture->retain();
|
||||
Texture2D::TexParams textureParams = { filter(page.minFilter), filter(page.magFilter), wrap(page.uWrap), wrap(page.vWrap) };
|
||||
texture->setTexParameters(textureParams);
|
||||
page.setRendererObject(texture);
|
||||
page.width = texture->getPixelsWide();
|
||||
page.height = texture->getPixelsHigh();
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
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)
|
||||
#if COCOS2D_VERSION >= 0x00031200
|
||||
|
||||
@ -41,15 +41,11 @@ namespace spine {
|
||||
class Cocos2dAtlasAttachmentLoader: public AtlasAttachmentLoader {
|
||||
public:
|
||||
Cocos2dAtlasAttachmentLoader(Atlas* atlas);
|
||||
virtual ~Cocos2dAtlasAttachmentLoader();
|
||||
virtual void configureAttachment(Attachment* attachment);
|
||||
};
|
||||
|
||||
class Cocos2dTextureLoader: public TextureLoader {
|
||||
public:
|
||||
Cocos2dTextureLoader();
|
||||
|
||||
virtual ~Cocos2dTextureLoader();
|
||||
|
||||
virtual void load(AtlasPage& page, const String& path);
|
||||
|
||||
@ -58,9 +54,6 @@ namespace spine {
|
||||
|
||||
class Cocos2dExtension: public DefaultSpineExtension {
|
||||
public:
|
||||
Cocos2dExtension();
|
||||
|
||||
virtual ~Cocos2dExtension();
|
||||
|
||||
protected:
|
||||
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),
|
||||
magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge),
|
||||
vWrap(TextureWrap_ClampToEdge) {
|
||||
vWrap(TextureWrap_ClampToEdge), width(0), height(0) {
|
||||
}
|
||||
|
||||
virtual ~AtlasPage() { }
|
||||
};
|
||||
|
||||
class SP_API AtlasRegion : public SpineObject {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user