From e3e6730b45e9369cab89ae5a97a428f7cdd10049 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Wed, 24 Sep 2014 07:43:04 +0200 Subject: [PATCH] improved current colors sort algorithm --- src/js/worker/ImageProcessor.js | 16 ++++------------ src/piskel-script-list.js | 1 + 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/js/worker/ImageProcessor.js b/src/js/worker/ImageProcessor.js index 0cc80209..53deb72d 100644 --- a/src/js/worker/ImageProcessor.js +++ b/src/js/worker/ImageProcessor.js @@ -1,9 +1,9 @@ (function () { var ns = $.namespace('pskl.worker'); - var worker = function () { - + var imageProcessorWorker = function () { var currentStep, currentProgress, currentTotal; + var initStepCounter_ = function (total) { currentStep = 0; currentProgress = 0; @@ -88,15 +88,6 @@ }; }; - try { - // create worker from blob - var typedArray = [(worker+"").replace(/function \(\) \{/,"").replace(/\}[^}]*$/, "")]; - var blob = new Blob(typedArray, {type: "application/javascript"}); // pass a useful mime type here - var blobUrl = window.URL.createObjectURL(blob); - } catch (e) { - console.error("Could not create worker", e.message); - } - ns.ImageProcessor = function (image, onSuccess, onStep, onError) { this.image = image; @@ -104,7 +95,8 @@ this.onSuccess = onSuccess; this.onError = onError; - this.worker = new Worker(blobUrl); + // var worker = pskl.utils.WorkerUtils.addPartialWorker(imageProcessorWorker, 'step-counter'); + this.worker = pskl.utils.WorkerUtils.createWorker(worker, 'image-colors-processor'); this.worker.onmessage = this.onWorkerMessage.bind(this); }; diff --git a/src/piskel-script-list.js b/src/piskel-script-list.js index b46e240b..6baecef6 100644 --- a/src/piskel-script-list.js +++ b/src/piskel-script-list.js @@ -26,6 +26,7 @@ "js/utils/Template.js", "js/utils/UserSettings.js", "js/utils/Uuid.js", + "js/utils/WorkerUtils.js", "js/utils/Xhr.js", "js/utils/serialization/Serializer.js", "js/utils/serialization/Deserializer.js",