diff --git a/src/js/model/frame/AsyncCachedFrameProcessor.js b/src/js/model/frame/AsyncCachedFrameProcessor.js index f1854cec..ab4baf3e 100644 --- a/src/js/model/frame/AsyncCachedFrameProcessor.js +++ b/src/js/model/frame/AsyncCachedFrameProcessor.js @@ -32,18 +32,19 @@ processedFrame = cache[key1]; } else if (frame instanceof pskl.model.frame.RenderedFrame) { // Cannot use 2nd level cache with rendered frames - var callbackFirstLvlCacheOnly = this.onProcessorComplete_.bind(this, deferred, cache, key1, key1); + var callbackFirstLvlCacheOnly = this.onProcessorComplete_.bind(this, deferred, cache, key1/*, key1*/); this.frameProcessor(frame, callbackFirstLvlCacheOnly); } else { - var framePixels = JSON.stringify(frame.getPixels()); + // TODO: Remove? + /*var framePixels = new Float64Array(frame.pixels.buffer).toString(); var key2 = pskl.utils.hashCode(framePixels); if (cache[key2]) { processedFrame = this.outputCloner(cache[key2], frame); cache[key1] = processedFrame; - } else { - var callback = this.onProcessorComplete_.bind(this, deferred, cache, key1, key2); - this.frameProcessor(frame, callback); - } + } else {*/ + var callback = this.onProcessorComplete_.bind(this, deferred, cache, key1/*, key1*/); + this.frameProcessor(frame, callback);/* + }*/ } if (processedFrame) { @@ -53,9 +54,9 @@ return deferred.promise; }; - ns.AsyncCachedFrameProcessor.prototype.onProcessorComplete_ = function (deferred, cache, key1, key2, result) { + ns.AsyncCachedFrameProcessor.prototype.onProcessorComplete_ = function (deferred, cache, key1/*, key2*/, result) { cache[key1] = result; - cache[key2] = result; + //cache[key2] = result; deferred.resolve(result); }; })(); diff --git a/src/js/model/frame/CachedFrameProcessor.js b/src/js/model/frame/CachedFrameProcessor.js index 5a1ff57c..bc905673 100644 --- a/src/js/model/frame/CachedFrameProcessor.js +++ b/src/js/model/frame/CachedFrameProcessor.js @@ -71,16 +71,21 @@ processedFrame = this.frameProcessor(frame); cache[cacheKey] = processedFrame; } else { - var framePixels = JSON.stringify(frame.getPixels()); + // TODO: Remove? + /* + // Float64Array.toString() is about 2.4x times faster compared to Uint32Array.toString() + var framePixels = new Float64Array(frame.pixels.buffer).toString(); var frameAsString = pskl.utils.hashCode(framePixels); if (cache[frameAsString]) { + this.cacheHitLvl2_++; processedFrame = this.outputCloner(cache[frameAsString], frame); } else { - processedFrame = this.frameProcessor(frame); + */processedFrame = this.frameProcessor(frame);/* cache[frameAsString] = processedFrame; } - cache[cacheKey] = processedFrame; + cache[cacheKey] = processedFrame;*/ } + return processedFrame; }; })();