Chromium Code Reviews| Index: ui/file_manager/gallery/js/image_editor/image_view.js |
| diff --git a/ui/file_manager/gallery/js/image_editor/image_view.js b/ui/file_manager/gallery/js/image_editor/image_view.js |
| index cd8fb1ccbc15b89f338556152d7a7ef269b48ee0..340b9eaa70d90c5739fc1882987896f66b6d5996 100644 |
| --- a/ui/file_manager/gallery/js/image_editor/image_view.js |
| +++ b/ui/file_manager/gallery/js/image_editor/image_view.js |
| @@ -307,6 +307,7 @@ ImageView.prototype.setupDeviceBuffer = function(canvas) { |
| // Set the canvas position and size in device pixels. |
| var deviceRect = this.viewport_.getDeviceBounds(); |
| var needRepaint = false; |
| + |
|
yawano
2015/09/25 11:07:59
This blank line is added for readability.
yawano
2015/09/25 11:33:03
This kind of thing should be done with separate CL
|
| if (canvas.width !== deviceRect.width) { |
| canvas.width = deviceRect.width; |
| needRepaint = true; |
| @@ -320,11 +321,29 @@ ImageView.prototype.setupDeviceBuffer = function(canvas) { |
| }; |
| /** |
| - * @return {!ImageData} A new ImageData object with a copy of the content. |
| + * Gets screen image data with specified size. |
| + * @param {number} width |
| + * @param {number} height |
| + * @return {!ImageData} A new ImageData object. |
| */ |
| -ImageView.prototype.copyScreenImageData = function() { |
| - return this.screenImage_.getContext('2d').getImageData( |
| - 0, 0, this.screenImage_.width, this.screenImage_.height); |
| +ImageView.prototype.getScreenImageDataWith = function(width, height) { |
| + // If specified size is same with current screen image size, just return it. |
| + if (width === this.screenImage_.width && |
| + height === this.screenImage_.height) { |
| + return this.screenImage_.getContext('2d').getImageData( |
| + 0, 0, this.screenImage_.width, this.screenImage_.height); |
| + } |
| + |
| + // Resize if these sizes are different. |
| + var resizeCanvas = document.createElement('canvas'); |
| + resizeCanvas.width = width; |
| + resizeCanvas.height = height; |
| + |
| + var context = resizeCanvas.getContext('2d'); |
| + context.drawImage(this.screenImage_, |
| + 0, 0, this.screenImage_.width, this.screenImage_.height, |
| + 0, 0, resizeCanvas.width, resizeCanvas.height); |
| + return context.getImageData(0, 0, resizeCanvas.width, resizeCanvas.height); |
| }; |
| /** |