mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Remove 2nd level cache
This commit is contained in:
parent
6ee23e22df
commit
0bbb4ff2d5
@ -32,18 +32,19 @@
|
|||||||
processedFrame = cache[key1];
|
processedFrame = cache[key1];
|
||||||
} else if (frame instanceof pskl.model.frame.RenderedFrame) {
|
} else if (frame instanceof pskl.model.frame.RenderedFrame) {
|
||||||
// Cannot use 2nd level cache with rendered frames
|
// 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);
|
this.frameProcessor(frame, callbackFirstLvlCacheOnly);
|
||||||
} else {
|
} else {
|
||||||
var framePixels = JSON.stringify(frame.getPixels());
|
// TODO: Remove?
|
||||||
|
/*var framePixels = new Float64Array(frame.pixels.buffer).toString();
|
||||||
var key2 = pskl.utils.hashCode(framePixels);
|
var key2 = pskl.utils.hashCode(framePixels);
|
||||||
if (cache[key2]) {
|
if (cache[key2]) {
|
||||||
processedFrame = this.outputCloner(cache[key2], frame);
|
processedFrame = this.outputCloner(cache[key2], frame);
|
||||||
cache[key1] = processedFrame;
|
cache[key1] = processedFrame;
|
||||||
} else {
|
} else {*/
|
||||||
var callback = this.onProcessorComplete_.bind(this, deferred, cache, key1, key2);
|
var callback = this.onProcessorComplete_.bind(this, deferred, cache, key1/*, key1*/);
|
||||||
this.frameProcessor(frame, callback);
|
this.frameProcessor(frame, callback);/*
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processedFrame) {
|
if (processedFrame) {
|
||||||
@ -53,9 +54,9 @@
|
|||||||
return deferred.promise;
|
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[key1] = result;
|
||||||
cache[key2] = result;
|
//cache[key2] = result;
|
||||||
deferred.resolve(result);
|
deferred.resolve(result);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
@ -71,16 +71,21 @@
|
|||||||
processedFrame = this.frameProcessor(frame);
|
processedFrame = this.frameProcessor(frame);
|
||||||
cache[cacheKey] = processedFrame;
|
cache[cacheKey] = processedFrame;
|
||||||
} else {
|
} 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);
|
var frameAsString = pskl.utils.hashCode(framePixels);
|
||||||
if (cache[frameAsString]) {
|
if (cache[frameAsString]) {
|
||||||
|
this.cacheHitLvl2_++;
|
||||||
processedFrame = this.outputCloner(cache[frameAsString], frame);
|
processedFrame = this.outputCloner(cache[frameAsString], frame);
|
||||||
} else {
|
} else {
|
||||||
processedFrame = this.frameProcessor(frame);
|
*/processedFrame = this.frameProcessor(frame);/*
|
||||||
cache[frameAsString] = processedFrame;
|
cache[frameAsString] = processedFrame;
|
||||||
}
|
}
|
||||||
cache[cacheKey] = processedFrame;
|
cache[cacheKey] = processedFrame;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return processedFrame;
|
return processedFrame;
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user