auto release cached SpriteFrame

This commit is contained in:
Jare Guo
2016-08-15 11:02:13 +08:00
parent f92c3c6127
commit 7bab9fc148
4 changed files with 9 additions and 10 deletions
+2 -1
View File
@@ -525,8 +525,9 @@ JS.mixin(CCLoader.prototype, {
// override
removeItem: function (key) {
this._baseRemoveItem(key);
var removed = this._baseRemoveItem(key);
delete this._autoReleaseSetting[key];
return removed;
},
/**
@@ -19,20 +19,17 @@ function release (loader, key, nextSceneAssets) {
if (!nextSceneAssets || nextSceneAssets.indexOf(key) === -1) {
var item = loader.getItem(key);
if (item) {
loader.removeItem(key);
var removed = loader.removeItem(key);
console.log('auto release: ' + key);
// TODO: Audio
var asset = item.content;
if (asset instanceof cc.Texture2D) {
cc.textureCache.removeTextureForKey(item.url);
}
//else if (asset instanceof cc.SpriteFrame) {
// // for the "Temporary solution" in deserialize.js
// console.log('release sprite frame: ' + key);
// if (CC_JSB) {
// asset.release();
// }
//}
else if (CC_JSB && asset instanceof cc.SpriteFrame && removed) {
// for the "Temporary solution" in deserialize.js
asset.release();
}
}
}
}
+1
View File
@@ -509,6 +509,7 @@ JS.mixin(Pipeline.prototype, {
this.flowOut(item);
}
this._items.removeItem(url);
return true;
}
else {
return false;
+1 -1
View File
@@ -32,6 +32,7 @@ require('../cocos2d/core/assets/CCAsset');
// cc.SpriteFrameAnimation = cc.Animation;
// cc.textureCache.cacheImage
cc.textureCache._textures = {};
cc.textureCache.cacheImage = function (key, texture) {
if (texture instanceof cc.Texture2D) {
@@ -75,7 +76,6 @@ prototype.textureLoaded = function () {
return this.getTexture() !== null;
};
// cc.SpriteFrame
prototype._ctor = function (filename, rect, rotated, offset, originalSize) {
this._name = '';
if (filename !== undefined) {