mirror of https://github.com/axmolengine/axmol.git
from spine source code (#16330)
Related to: * Github issue #16263 * Github issue #16294
This commit is contained in:
parent
f7464f8de5
commit
e5b14733c8
|
@ -62,6 +62,7 @@ GLuint filter (spAtlasFilter filter) {
|
|||
|
||||
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
|
||||
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path);
|
||||
CCASSERT(texture != nullptr, "Invalid image");
|
||||
texture->retain();
|
||||
|
||||
Texture2D::TexParams textureParams = {filter(self->minFilter), filter(self->magFilter), wrap(self->uWrap), wrap(self->vWrap)};
|
||||
|
@ -77,11 +78,19 @@ void _spAtlasPage_disposeTexture (spAtlasPage* self) {
|
|||
}
|
||||
|
||||
char* _spUtil_readFile (const char* path, int* length) {
|
||||
Data data = FileUtils::getInstance()->getDataFromFile(
|
||||
FileUtils::getInstance()->fullPathForFilename(path).c_str());
|
||||
if (data.isNull()) return 0;
|
||||
*length = static_cast<int>(data.getSize());
|
||||
char* bytes = MALLOC(char, *length);
|
||||
memcpy(bytes, data.getBytes(), *length);
|
||||
return bytes;
|
||||
Data data = FileUtils::getInstance()->getDataFromFile(FileUtils::getInstance()->fullPathForFilename(path));
|
||||
if (data.isNull()) return 0;
|
||||
|
||||
// avoid buffer overflow (int is shorter than ssize_t in certain platforms)
|
||||
#if COCOS2D_VERSION >= 0x00031200
|
||||
ssize_t tmpLen;
|
||||
char *ret = (char*)data.takeBuffer(&tmpLen);
|
||||
*length = static_cast<int>(tmpLen);
|
||||
return ret;
|
||||
#else
|
||||
*length = static_cast<int>(data.getSize());
|
||||
char* bytes = MALLOC(char, *length);
|
||||
memcpy(bytes, data.getBytes(), *length);
|
||||
return bytes;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue