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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 Command.prototype.revertView = function(canvas, imageView) { | 256 Command.prototype.revertView = function(canvas, imageView) { |
257 imageView.replace(canvas); | 257 imageView.replace(canvas); |
258 return 0; | 258 return 0; |
259 }; | 259 }; |
260 | 260 |
261 /** | 261 /** |
262 * Creates canvas to render on. | 262 * Creates canvas to render on. |
263 * | 263 * |
264 * @param {Document} document Document to create canvas in. | 264 * @param {Document} document Document to create canvas in. |
265 * @param {HTMLCanvasElement} srcCanvas to copy optional dimensions from. | 265 * @param {HTMLCanvasElement} srcCanvas to copy optional dimensions from. |
266 * @param {int} opt_width new canvas width; | 266 * @param {int} opt_width new canvas width. |
267 * @param {int} opt_height new canvas height; | 267 * @param {int} opt_height new canvas height. |
268 * @return {HTMLCanvasElement} Newly created canvas. | 268 * @return {HTMLCanvasElement} Newly created canvas. |
269 * @private | 269 * @private |
270 */ | 270 */ |
271 Command.prototype.createCanvas_ = function( | 271 Command.prototype.createCanvas_ = function( |
272 document, srcCanvas, opt_width, opt_height) { | 272 document, srcCanvas, opt_width, opt_height) { |
273 var result = document.createElement('canvas'); | 273 var result = document.createElement('canvas'); |
274 result.width = opt_width || srcCanvas.width; | 274 result.width = opt_width || srcCanvas.width; |
275 result.height = opt_height || srcCanvas.height; | 275 result.height = opt_height || srcCanvas.height; |
276 return result; | 276 return result; |
277 }; | 277 }; |
278 | 278 |
279 | 279 |
280 /** | 280 /** |
281 * Rotate command | 281 * Rotate command |
282 * @param {number} rotate90 Rotation angle in 90 degree increments (signed) | 282 * @param {number} rotate90 Rotation angle in 90 degree increments (signed). |
283 * @constructor | 283 * @constructor |
284 * @extends {Command} | 284 * @extends {Command} |
285 */ | 285 */ |
286 Command.Rotate = function(rotate90) { | 286 Command.Rotate = function(rotate90) { |
287 Command.call(this, 'rotate(' + rotate90 * 90 + 'deg)'); | 287 Command.call(this, 'rotate(' + rotate90 * 90 + 'deg)'); |
288 this.rotate90_ = rotate90; | 288 this.rotate90_ = rotate90; |
289 }; | 289 }; |
290 | 290 |
291 Command.Rotate.prototype = { __proto__: Command.prototype }; | 291 Command.Rotate.prototype = { __proto__: Command.prototype }; |
292 | 292 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 /** @override */ | 343 /** @override */ |
344 Command.Crop.prototype.revertView = function(canvas, imageView) { | 344 Command.Crop.prototype.revertView = function(canvas, imageView) { |
345 return imageView.animateAndReplace(canvas, this.imageRect_); | 345 return imageView.animateAndReplace(canvas, this.imageRect_); |
346 }; | 346 }; |
347 | 347 |
348 | 348 |
349 /** | 349 /** |
350 * Filter command. | 350 * Filter command. |
351 * | 351 * |
352 * @param {string} name Command name | 352 * @param {string} name Command name. |
353 * @param {function(ImageData,ImageData,number,number)} filter Filter function | 353 * @param {function(ImageData,ImageData,number,number)} filter Filter function. |
354 * @param {string} message Message to display when done | 354 * @param {string} message Message to display when done. |
355 * @constructor | 355 * @constructor |
356 * @extends {Command} | 356 * @extends {Command} |
357 */ | 357 */ |
358 Command.Filter = function(name, filter, message) { | 358 Command.Filter = function(name, filter, message) { |
359 Command.call(this, name); | 359 Command.call(this, name); |
360 this.filter_ = filter; | 360 this.filter_ = filter; |
361 this.message_ = message; | 361 this.message_ = message; |
362 }; | 362 }; |
363 | 363 |
364 Command.Filter.prototype = { __proto__: Command.prototype }; | 364 Command.Filter.prototype = { __proto__: Command.prototype }; |
(...skipping 33 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 |