Skip to content

Commit

Permalink
refine builtinBundle and deprecation (cocos#6303)
Browse files Browse the repository at this point in the history
  • Loading branch information
SantyWang committed Mar 9, 2020
1 parent 5a3b738 commit 97bb24c
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 42 deletions.
10 changes: 5 additions & 5 deletions cocos2d/core/asset-manager/CCAssetManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Bundle = require('./bundle');
const builtins = require('./builtins')
const { parse, combine } = require('./urlTransformer');
const { parseParameters, urlAppendTimestamp, asyncify } = require('./utilities');
const { assets, files, parsed, pipeline, transformPipeline, fetchPipeline, initializePipeline, LoadStrategy, RequestType, bundles, BuiltinBundle } = require('./shared');
const { assets, files, parsed, pipeline, transformPipeline, fetchPipeline, initializePipeline, LoadStrategy, RequestType, bundles, BuiltinBundleName } = require('./shared');
/**
* @module cc
*/
Expand Down Expand Up @@ -280,7 +280,7 @@ AssetManager.Config = Config;
AssetManager.LoadStrategy = LoadStrategy;
AssetManager.RequestType = RequestType;
AssetManager.Bundle = Bundle;
AssetManager.BuiltinBundle = BuiltinBundle;
AssetManager.BuiltinBundleName = BuiltinBundleName;

AssetManager.prototype = {

Expand All @@ -298,7 +298,7 @@ AssetManager.prototype = {
* @type {Bundle}
*/
get main () {
return bundles.get(BuiltinBundle.MAIN);
return bundles.get(BuiltinBundleName.MAIN);
},

/**
Expand All @@ -313,7 +313,7 @@ AssetManager.prototype = {
* @type {Bundle}
*/
get resources () {
return bundles.get(BuiltinBundle.RESOURCES);
return bundles.get(BuiltinBundleName.RESOURCES);
},

/**
Expand All @@ -328,7 +328,7 @@ AssetManager.prototype = {
* @type {Bundle}
*/
get internal () {
return bundles.get(BuiltinBundle.INTERNAL);
return bundles.get(BuiltinBundleName.INTERNAL);
},

/**
Expand Down
4 changes: 2 additions & 2 deletions cocos2d/core/asset-manager/builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
****************************************************************************/
const Cache = require('./cache');
const finalizer = require('./finalizer');
const { BuiltinBundle } = require('./shared');
const { BuiltinBundleName } = require('./shared');

/**
* @module cc.AssetManager
Expand Down Expand Up @@ -76,7 +76,7 @@ var builtins = {
*/
init (cb) {
this.clear();
if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS || !cc.assetManager.bundles.has(BuiltinBundle.INTERNAL)) {
if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS || !cc.assetManager.bundles.has(BuiltinBundleName.INTERNAL)) {
return cb && cb();
}

Expand Down
4 changes: 2 additions & 2 deletions cocos2d/core/asset-manager/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ var AssetLibrary = {
cc.assetManager.init(options);
if (options.rawAssets) {
var resources = new cc.AssetManager.Bundle();
resources.init({name: cc.AssetManager.BuiltinBundle.RESOURCES, importBase: options.importBase, nativeBase: options.nativeBase, paths: options.rawAssets.assets, uuids: Object.keys(options.rawAssets.assets)});
resources.init({name: cc.AssetManager.BuiltinBundleName.RESOURCES, importBase: options.importBase, nativeBase: options.nativeBase, paths: options.rawAssets.assets, uuids: Object.keys(options.rawAssets.assets)});
}
},

Expand Down Expand Up @@ -614,7 +614,7 @@ cc.url = {
*/
raw (url) {
if (url.startsWith('resources/')) {
return cc.assetManager.transform({'path': cc.path.changeExtname(url.substr(10)), bundle: cc.AssetManager.BuiltinBundle.RESOURCES, isNative: true, ext: cc.path.extname(url)});
return cc.assetManager.transform({'path': cc.path.changeExtname(url.substr(10)), bundle: cc.AssetManager.BuiltinBundleName.RESOURCES, isNative: true, ext: cc.path.extname(url)});
}
return '';
}
Expand Down
6 changes: 3 additions & 3 deletions cocos2d/core/asset-manager/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ var RequestType = {
* !#zh
* 内置 bundle
*
* @enum BuiltinBundle
* @enum BuiltinBundleName
*/
var BuiltinBundle = {
var BuiltinBundleName = {
/**
* !#en
* The builtin bundle corresponds to 'assets/resources'.
Expand Down Expand Up @@ -201,4 +201,4 @@ var BuiltinBundle = {
MAIN: 'main'
};

module.exports = { assets, files, parsed, pipeline, fetchPipeline, initializePipeline, transformPipeline, LoadStrategy, RequestType, bundles, BuiltinBundle };
module.exports = { assets, files, parsed, pipeline, fetchPipeline, initializePipeline, transformPipeline, LoadStrategy, RequestType, bundles, BuiltinBundleName };
6 changes: 3 additions & 3 deletions cocos2d/core/assets/CCTexture2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ var Texture2D = cc.Class({
if (!element)
return;
this._image = element;
if (element.complete || element instanceof HTMLCanvasElement || element instanceof ImageBitmap) {
if (element.complete || element instanceof HTMLCanvasElement || (cc.sys.capabilities.createImageBitmap && element instanceof ImageBitmap)) {
this.handleLoadedTexture();
}
else {
Expand Down Expand Up @@ -680,7 +680,7 @@ var Texture2D = cc.Class({
* @return {Boolean} inherit from the CCObject
*/
destroy () {
if (this._image instanceof ImageBitmap) {
if (cc.sys.capabilities.createImageBitmap && this._image instanceof ImageBitmap) {
this._image.close();
}
this._packable && cc.dynamicAtlasManager && cc.dynamicAtlasManager.deleteAtlasTexture(this);
Expand Down Expand Up @@ -759,7 +759,7 @@ var Texture2D = cc.Class({
if (this._image instanceof HTMLImageElement) {
this._clearImage();
}
else if (this._image instanceof ImageBitmap) {
else if (cc.sys.capabilities.createImageBitmap && this._image instanceof ImageBitmap) {
this._image.close();
}
}
Expand Down
10 changes: 6 additions & 4 deletions cocos2d/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,12 @@ if (CC_DEBUG) {
'minFrameSize'
], 'cc.dynamicAtlasManager')

// light component
markAsRemovedInObject(cc.Light.prototype, [
'shadowDepthScale',
], 'cc.Light.prototype');
if (cc.Light) {
// light component
markAsRemovedInObject(cc.Light.prototype, [
'shadowDepthScale',
], 'cc.Light.prototype');
}

// Value types
provideClearError(cc, {
Expand Down
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ require('./polyfill/array');
require('./polyfill/object');
require('./polyfill/array-buffer');
require('./polyfill/number');
require('./polyfill/image-bitmap');
if (!(CC_EDITOR && Editor.isMainProcess)) {
require('./polyfill/typescript');
}
Expand Down
19 changes: 0 additions & 19 deletions polyfill/image-bitmap.ts

This file was deleted.

2 changes: 1 addition & 1 deletion test/qunit/unit-es5/test-asset-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
});
var resources = new cc.AssetManager.Bundle();
resources.init({
name: cc.AssetManager.BuiltinBundle.RESOURCES,
name: cc.AssetManager.BuiltinBundleName.RESOURCES,
importBase: libPath,
nativeBase: libPath,
paths: {
Expand Down
4 changes: 2 additions & 2 deletions test/qunit/unit-es5/test-urlTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('raw', function () {
cc.assetManager.init({importBase: 'import', nativeBase: 'native'});
var bundle = new cc.AssetManager.Bundle();
bundle.init({
name: cc.AssetManager.BuiltinBundle.RESOURCES,
name: cc.AssetManager.BuiltinBundleName.RESOURCES,
base: 'test/',
importBase: 'import',
nativeBase: 'native',
Expand All @@ -50,7 +50,7 @@ test('md5', function () {
cc.assetManager.init({importBase: 'import', nativeBase: 'native'});
var bundle = new cc.AssetManager.Bundle();
bundle.init({
name: cc.AssetManager.BuiltinBundle.RESOURCES,
name: cc.AssetManager.BuiltinBundleName.RESOURCES,
base: 'test/',
importBase: 'import',
nativeBase: 'native',
Expand Down

0 comments on commit 97bb24c

Please sign in to comment.