| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Command queue is the only way to modify images. | 6 * Command queue is the only way to modify images. |
| 7 * Supports undo/redo. | 7 * Supports undo/redo. |
| 8 * Command execution is asynchronous (callback-based). | 8 * Command execution is asynchronous (callback-based). |
| 9 * | 9 * |
| 10 * @param {Document} document Document to create canvases in. | 10 * @param {Document} document Document to create canvases in. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (this.previousImage_) { | 177 if (this.previousImage_) { |
| 178 // First undo after an execute call. | 178 // First undo after an execute call. |
| 179 this.currentImage_ = this.previousImage_; | 179 this.currentImage_ = this.previousImage_; |
| 180 this.previousImage_ = null; | 180 this.previousImage_ = null; |
| 181 complete(); | 181 complete(); |
| 182 // TODO(kaznacheev) Consider recalculating previousImage_ right here | 182 // TODO(kaznacheev) Consider recalculating previousImage_ right here |
| 183 // by replaying the commands in the background. | 183 // by replaying the commands in the background. |
| 184 } else { | 184 } else { |
| 185 this.currentImage_ = this.baselineImage_; | 185 this.currentImage_ = this.baselineImage_; |
| 186 | 186 |
| 187 function replay(index) { | 187 var replay = function(index) { |
| 188 if (index < self.undo_.length) | 188 if (index < self.undo_.length) |
| 189 self.doExecute_(self.undo_[index], {}, replay.bind(null, index + 1)); | 189 self.doExecute_(self.undo_[index], {}, replay.bind(null, index + 1)); |
| 190 else { | 190 else { |
| 191 complete(); | 191 complete(); |
| 192 } | 192 } |
| 193 } | 193 }; |
| 194 | 194 |
| 195 replay(0); | 195 replay(0); |
| 196 } | 196 } |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 /** | 199 /** |
| 200 * @return {boolean} True if Redo is applicable. | 200 * @return {boolean} True if Redo is applicable. |
| 201 */ | 201 */ |
| 202 CommandQueue.prototype.canRedo = function() { | 202 CommandQueue.prototype.canRedo = function() { |
| 203 return this.redo_.length != 0; | 203 return this.redo_.length != 0; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 398 |
| 399 function onProgressInvisible(updatedRow, rowCount) { | 399 function onProgressInvisible(updatedRow, rowCount) { |
| 400 if (updatedRow == rowCount) { | 400 if (updatedRow == rowCount) { |
| 401 callback(result); | 401 callback(result); |
| 402 } | 402 } |
| 403 } | 403 } |
| 404 | 404 |
| 405 filter.applyByStrips(result, srcCanvas, this.filter_, | 405 filter.applyByStrips(result, srcCanvas, this.filter_, |
| 406 uiContext.imageView ? onProgressVisible : onProgressInvisible); | 406 uiContext.imageView ? onProgressVisible : onProgressInvisible); |
| 407 }; | 407 }; |
| OLD | NEW |