Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: ui/file_manager/gallery/js/image_editor/image_adjust.js

Issue 1370683003: Gallery: resize image data to overlay canvas size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove blank line. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/file_manager/gallery/js/image_editor/image_view.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 };
OLDNEW
« no previous file with comments | « no previous file | ui/file_manager/gallery/js/image_editor/image_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698