diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 823368e23f..4ef8ead898 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -296,16 +296,6 @@ cc.Director = Class.extend(/** @lends cc.Director# */{ this._afterVisitScene(); }, - render: function (deltaTime) { - cc.g_NumberOfDraws = 0; - cc.renderer.clear(); - - cc.renderer.rendering(cc._renderContext); - this._totalFrames++; - - this.emit(cc.Director.EVENT_AFTER_DRAW); - }, - _beforeVisitScene: null, _afterVisitScene: null, @@ -1389,7 +1379,16 @@ cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.Director# */{ } this.visit(); - this.render(); + + // Render + cc.g_NumberOfDraws = 0; + cc.renderer.clear(); + + cc.renderer.rendering(cc._renderContext); + this._totalFrames++; + + this.emit(cc.Director.EVENT_AFTER_DRAW); + } : function () { if (this._purgeDirectorInNextLoop) { this._purgeDirectorInNextLoop = false; @@ -1421,7 +1420,15 @@ cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.Director# */{ } this.visit(this._deltaTime); - this.render(this._deltaTime); + + // Render + cc.g_NumberOfDraws = 0; + cc.renderer.clear(); + + cc.renderer.rendering(cc._renderContext); + this._totalFrames++; + + this.emit(cc.Director.EVENT_AFTER_DRAW); this._calculateMPF(); } diff --git a/cocos2d/core/event/event-target.js b/cocos2d/core/event/event-target.js index 7e825896e6..dc0b3a82ac 100644 --- a/cocos2d/core/event/event-target.js +++ b/cocos2d/core/event/event-target.js @@ -56,7 +56,15 @@ var _doDispatchEvent = function (owner, event) { // Event.AT_TARGET // checks if destroyed in capturing callbacks if (owner._isTargetActive(event.type)) { - _doSendEvent(owner, event); + // Event.AT_TARGET + event.eventPhase = 2; + event.currentTarget = owner; + if (owner._capturingListeners) { + owner._capturingListeners.invoke(event); + } + if (!event._propagationImmediateStopped && owner._bubblingListeners) { + owner._bubblingListeners.invoke(event); + } } if (!event._propagationStopped && event.bubbles) { @@ -81,22 +89,6 @@ var _doDispatchEvent = function (owner, event) { cachedArray.length = 0; }; - -var _doSendEvent = function (owner, event) { - // Event.AT_TARGET - event.eventPhase = 2; - event.currentTarget = owner; - if (owner._capturingListeners) { - owner._capturingListeners.invoke(event); - if (event._propagationImmediateStopped) { - return; - } - } - if (owner._bubblingListeners) { - owner._bubblingListeners.invoke(event); - } -}; - /** * !#en * EventTarget is an object to which an event is dispatched when something has occurred. @@ -337,7 +329,16 @@ JS.mixin(EventTarget.prototype, { var event = new cc.Event.EventCustom(message); event.detail = detail; - _doSendEvent(this, event); + + // Event.AT_TARGET + event.eventPhase = 2; + event.currentTarget = this; + if (caplisteners) { + this._capturingListeners.invoke(event); + } + if (bublisteners && !event._propagationImmediateStopped) { + this._bubblingListeners.invoke(event); + } }, /* diff --git a/cocos2d/core/event/event.js b/cocos2d/core/event/event.js index 47e887084b..73c30d686f 100644 --- a/cocos2d/core/event/event.js +++ b/cocos2d/core/event/event.js @@ -53,7 +53,7 @@ cc.Event = function(type, bubbles) { * @property bubbles * @type {Boolean} */ - this.bubbles = bubbles || false; + this.bubbles = !!bubbles; /** * !#en A reference to the target to which the event was originally dispatched. diff --git a/cocos2d/core/load-pipeline/loading-items.js b/cocos2d/core/load-pipeline/loading-items.js index 915661533f..11751add22 100644 --- a/cocos2d/core/load-pipeline/loading-items.js +++ b/cocos2d/core/load-pipeline/loading-items.js @@ -100,11 +100,9 @@ JS.mixin(LoadingItems.prototype, CallbacksInvoker.prototype, { var item = items[i]; var id = item.id; // No duplicated url - if (!this.completed[id]) { - if (!this.map[id]) { - this.map[id] = item; - } - list.push(this.map[id]); + if (!this.map[id]) { + this.map[item.id] = item; + list.push(item); } } this.totalCount += list.length; diff --git a/cocos2d/core/load-pipeline/pipeline.js b/cocos2d/core/load-pipeline/pipeline.js index b4be3f11c7..27e962969d 100644 --- a/cocos2d/core/load-pipeline/pipeline.js +++ b/cocos2d/core/load-pipeline/pipeline.js @@ -351,7 +351,7 @@ JS.mixin(Pipeline.prototype, { * @param {Function} callback * @return {Array} Items accepted by the pipeline */ - flowInDeps: function (owner, urlList, callback) { + flowInDeps: function (urlList, callback) { var checker = {}; var items = this._items; @@ -375,13 +375,13 @@ JS.mixin(Pipeline.prototype, { continue; } var item = items.map[url]; - if ( item && (url === owner || item.complete) ) { - checker[url] = item; - } - else { + if ( !item ) { items.addListener(url, loadedCheck); checker[url] = null; } + else { + checker[url] = item; + } } var accepted = this.flowIn(urlList); // No new resources, complete directly diff --git a/cocos2d/core/load-pipeline/uuid-loader.js b/cocos2d/core/load-pipeline/uuid-loader.js index 91aad4f303..a074f4e931 100644 --- a/cocos2d/core/load-pipeline/uuid-loader.js +++ b/cocos2d/core/load-pipeline/uuid-loader.js @@ -97,7 +97,7 @@ function loadDepends (pipeline, item, asset, tdInfo, deferredLoadRawAssetsInRunt return callback(null, asset); } - pipeline.flowInDeps(uuid, depends, function (items) { + pipeline.flowInDeps(depends, function (items) { var item; for (var src in items) { item = items[src]; diff --git a/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js index 9346fab5f8..202e755255 100644 --- a/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js @@ -85,21 +85,6 @@ proto._uploadSliced = function (vertices, uvs, color, z, f32buffer, ui32buffer, return 36; }; -proto._uploadVertices = function (vertices, uvs, color, z, f32buffer, ui32buffer, offset) { - // src: bl, br, tl, tr - var count = this._node._vertCount; - for (var i = 0, srcOff = 0; i < count; i++, srcOff += 2) { - f32buffer[offset] = vertices[srcOff]; - f32buffer[offset + 1] = vertices[srcOff+1]; - f32buffer[offset + 2] = z; - ui32buffer[offset + 3] = color[0]; - f32buffer[offset + 4] = uvs[srcOff]; - f32buffer[offset + 5] = uvs[srcOff+1]; - offset += 6; - } - return count; -}; - proto.transform = function (parentCmd, recursive) { this.originTransform(parentCmd, recursive); this._node._rebuildQuads(); @@ -151,7 +136,17 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){ case types.SIMPLE: case types.TILED: case types.FILLED: - len = this._uploadVertices(vertices, uvs, this._color, z, f32buffer, ui32buffer, offset); + // Inline for performance + len = this._node._vertCount; + for (var i = 0, srcOff = 0; i < len; i++, srcOff += 2) { + f32buffer[offset] = vertices[srcOff]; + f32buffer[offset + 1] = vertices[srcOff+1]; + f32buffer[offset + 2] = z; + ui32buffer[offset + 3] = this._color[0]; + f32buffer[offset + 4] = uvs[srcOff]; + f32buffer[offset + 5] = uvs[srcOff+1]; + offset += 6; + } break; case types.SLICED: len = this._uploadSliced(vertices, uvs, this._color, z, f32buffer, ui32buffer, offset); diff --git a/jsb/jsb-etc.js b/jsb/jsb-etc.js index 96ee3674be..13036ea748 100644 --- a/jsb/jsb-etc.js +++ b/jsb/jsb-etc.js @@ -71,9 +71,9 @@ cc.js.mixin(cc.path, { // cc.Scheduler cc.Scheduler.prototype.schedule = function (callback, target, interval, repeat, delay, paused) { - repeat = repeat || cc.macro.REPEAT_FOREVER; + repeat = isFinite(repeat) ? repeat : cc.macro.REPEAT_FOREVER; delay = delay || 0; - paused = paused || false; + paused = !!paused; this.scheduleCallbackForTarget(target, callback, interval, repeat, delay, paused); }; cc.Scheduler.prototype.scheduleUpdate = cc.Scheduler.prototype.scheduleUpdateForTarget; diff --git a/test/qunit/unit/test-loader.js b/test/qunit/unit/test-loader.js index 92be410e25..e0631a6b89 100644 --- a/test/qunit/unit/test-loader.js +++ b/test/qunit/unit/test-loader.js @@ -83,7 +83,7 @@ asyncTest('Load with dependencies', function () { dep2, dep3 ]; - this.pipeline.flowInDeps(item.id, resources, function (deps) { + this.pipeline.flowInDeps(resources, function (deps) { callback(null, result); }); }