mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Simplified lighten + fixed frame caching bug
This commit is contained in:
parent
56f008bda6
commit
829bcb8ad1
@ -19,11 +19,17 @@
|
||||
{key : 'shift', description : 'Apply only once per pixel'}
|
||||
];
|
||||
|
||||
this.resetUsedPixels_();
|
||||
this.usedPixels_ = {
|
||||
darken : {},
|
||||
lighten : {}
|
||||
};
|
||||
};
|
||||
|
||||
pskl.utils.inherit(ns.Lighten, ns.SimplePen);
|
||||
|
||||
/**
|
||||
* @Override
|
||||
*/
|
||||
ns.Lighten.prototype.resetUsedPixels_ = function() {
|
||||
this.usedPixels_ = {
|
||||
darken : {},
|
||||
@ -31,8 +37,9 @@
|
||||
};
|
||||
this.superclass.resetUsedPixels_.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @Override
|
||||
*/
|
||||
ns.Lighten.prototype.applyToolAt = function(col, row, color, frame, overlay, event, mouseButton) {
|
||||
var overlayColor = overlay.getPixel(col, row);
|
||||
@ -63,14 +70,4 @@
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ns.Lighten.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {
|
||||
this.setPixelsToFrame_(frame, this.pixels);
|
||||
|
||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||
type : pskl.service.HistoryService.SNAPSHOT
|
||||
});
|
||||
|
||||
this.resetUsedPixels_();
|
||||
};
|
||||
})();
|
@ -62,17 +62,17 @@
|
||||
var cache = this.cache_[namespace];
|
||||
|
||||
var cacheKey = frame.getHash();
|
||||
if (this.cache_[cacheKey]) {
|
||||
processedFrame = this.cache_[cacheKey];
|
||||
if (cache[cacheKey]) {
|
||||
processedFrame = cache[cacheKey];
|
||||
} else {
|
||||
var frameAsString = JSON.stringify(frame.getPixels());
|
||||
if (this.cache_[frameAsString]) {
|
||||
processedFrame = this.outputCloner(this.cache_[frameAsString], frame);
|
||||
if (cache[frameAsString]) {
|
||||
processedFrame = this.outputCloner(cache[frameAsString], frame);
|
||||
} else {
|
||||
processedFrame = this.frameProcessor(frame);
|
||||
this.cache_[frameAsString] = processedFrame;
|
||||
cache[frameAsString] = processedFrame;
|
||||
}
|
||||
this.cache_[cacheKey] = processedFrame;
|
||||
cache[cacheKey] = processedFrame;
|
||||
}
|
||||
return processedFrame;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user