| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * The base class for simple filters that only modify the image content | 6 * The base class for simple filters that only modify the image content |
| 7 * but do not modify the image dimensions. | 7 * but do not modify the image dimensions. |
| 8 * @param {string} name | 8 * @param {string} name |
| 9 * @param {string} title | 9 * @param {string} title |
| 10 * @constructor | 10 * @constructor |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 */ | 38 */ |
| 39 this.filter_ = null; | 39 this.filter_ = null; |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * @type {HTMLCanvasElement} | 42 * @type {HTMLCanvasElement} |
| 43 * @private | 43 * @private |
| 44 */ | 44 */ |
| 45 this.canvas_ = null; | 45 this.canvas_ = null; |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * @type {ImageData} | 48 * @private {ImageData} |
| 49 * @private | |
| 50 */ | 49 */ |
| 51 this.previewImageData_ = null; | 50 this.previewImageData_ = null; |
| 52 | 51 |
| 53 /** | 52 /** |
| 54 * @type {ImageData} | 53 * @private {ImageData} |
| 55 */ | 54 */ |
| 56 this.originalImageData = null; | 55 this.originalImageData_ = null; |
| 57 }; | 56 }; |
| 58 | 57 |
| 59 ImageEditor.Mode.Adjust.prototype = {__proto__: ImageEditor.Mode.prototype}; | 58 ImageEditor.Mode.Adjust.prototype = {__proto__: ImageEditor.Mode.prototype}; |
| 60 | 59 |
| 61 /** | 60 /** |
| 62 * Gets command to do filter. | 61 * Gets command to do filter. |
| 63 * | 62 * |
| 64 * @return {Command.Filter} Filter command. | 63 * @return {Command.Filter} Filter command. |
| 65 */ | 64 */ |
| 66 ImageEditor.Mode.Adjust.prototype.getCommand = function() { | 65 ImageEditor.Mode.Adjust.prototype.getCommand = function() { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 125 |
| 127 // Update canvas size and/or transformation. | 126 // Update canvas size and/or transformation. |
| 128 if (!this.previewImageData_ || | 127 if (!this.previewImageData_ || |
| 129 this.viewportGeneration_ !== this.getViewport().getCacheGeneration()) { | 128 this.viewportGeneration_ !== this.getViewport().getCacheGeneration()) { |
| 130 this.viewportGeneration_ = this.getViewport().getCacheGeneration(); | 129 this.viewportGeneration_ = this.getViewport().getCacheGeneration(); |
| 131 | 130 |
| 132 if (!this.canvas_) | 131 if (!this.canvas_) |
| 133 this.canvas_ = this.getImageView().createOverlayCanvas(); | 132 this.canvas_ = this.getImageView().createOverlayCanvas(); |
| 134 | 133 |
| 135 this.getImageView().setupDeviceBuffer(this.canvas_); | 134 this.getImageView().setupDeviceBuffer(this.canvas_); |
| 136 this.originalImageData = this.getImageView().copyScreenImageData(); | 135 this.originalImageData_ = this.getImageView().getScreenImageDataWith( |
| 137 this.previewImageData_ = this.getImageView().copyScreenImageData(); | 136 this.canvas_.width, this.canvas_.height); |
| 137 this.previewImageData_ = this.getImageView().getScreenImageDataWith( |
| 138 this.canvas_.width, this.canvas_.height); |
| 138 | 139 |
| 139 isPreviewImageInvalidated = true; | 140 isPreviewImageInvalidated = true; |
| 140 } else { | 141 } else { |
| 141 this.getImageView().setTransform_( | 142 this.getImageView().setTransform_( |
| 142 assert(this.canvas_), assert(this.getViewport())); | 143 assert(this.canvas_), assert(this.getViewport())); |
| 143 } | 144 } |
| 144 | 145 |
| 145 // Update preview image with applying filter. | 146 // Update preview image with applying filter. |
| 146 if (isPreviewImageInvalidated) { | 147 if (isPreviewImageInvalidated) { |
| 147 assert(this.originalImageData); | 148 assert(this.originalImageData_); |
| 148 assert(this.previewImageData_); | 149 assert(this.previewImageData_); |
| 149 | 150 |
| 150 ImageUtil.trace.resetTimer('preview'); | 151 ImageUtil.trace.resetTimer('preview'); |
| 151 this.filter_(this.previewImageData_, this.originalImageData, 0, 0); | 152 this.filter_(this.previewImageData_, this.originalImageData_, 0, 0); |
| 152 ImageUtil.trace.reportTimer('preview'); | 153 ImageUtil.trace.reportTimer('preview'); |
| 153 | 154 |
| 154 this.canvas_.getContext('2d').putImageData(this.previewImageData_, 0, 0); | 155 this.canvas_.getContext('2d').putImageData(this.previewImageData_, 0, 0); |
| 155 } | 156 } |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 /** @override */ | 159 /** @override */ |
| 159 ImageEditor.Mode.Adjust.prototype.draw = function() { | 160 ImageEditor.Mode.Adjust.prototype.draw = function() { |
| 160 this.updatePreviewImage_(null); | 161 this.updatePreviewImage_(null); |
| 161 }; | 162 }; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 }; | 300 }; |
| 300 | 301 |
| 301 ImageEditor.Mode.Sharpen.prototype = | 302 ImageEditor.Mode.Sharpen.prototype = |
| 302 {__proto__: ImageEditor.Mode.Adjust.prototype}; | 303 {__proto__: ImageEditor.Mode.Adjust.prototype}; |
| 303 | 304 |
| 304 /** @override */ | 305 /** @override */ |
| 305 ImageEditor.Mode.Sharpen.prototype.createTools = function(toolbar) { | 306 ImageEditor.Mode.Sharpen.prototype.createTools = function(toolbar) { |
| 306 toolbar.addRange('strength', 'GALLERY_STRENGTH', 0, 0, 1, 100); | 307 toolbar.addRange('strength', 'GALLERY_STRENGTH', 0, 0, 1, 100); |
| 307 toolbar.addRange('radius', 'GALLERY_RADIUS', 1, 1, 3); | 308 toolbar.addRange('radius', 'GALLERY_RADIUS', 1, 1, 3); |
| 308 }; | 309 }; |
| OLD | NEW |