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

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

Issue 1370683003: Gallery: resize image data to overlay canvas size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « ui/file_manager/gallery/js/image_editor/image_adjust.js ('k') | no next file » | 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 overlay displaying the image. 6 * The overlay displaying the image.
7 * 7 *
8 * @param {!HTMLElement} container The container element. 8 * @param {!HTMLElement} container The container element.
9 * @param {!Viewport} viewport The viewport. 9 * @param {!Viewport} viewport The viewport.
10 * @param {!MetadataModel} metadataModel 10 * @param {!MetadataModel} metadataModel
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 /** 300 /**
301 * Sets up the canvas as a buffer in the device resolution. 301 * Sets up the canvas as a buffer in the device resolution.
302 * 302 *
303 * @param {!HTMLCanvasElement} canvas The buffer canvas. 303 * @param {!HTMLCanvasElement} canvas The buffer canvas.
304 * @return {boolean} True if the canvas needs to be rendered. 304 * @return {boolean} True if the canvas needs to be rendered.
305 */ 305 */
306 ImageView.prototype.setupDeviceBuffer = function(canvas) { 306 ImageView.prototype.setupDeviceBuffer = function(canvas) {
307 // Set the canvas position and size in device pixels. 307 // Set the canvas position and size in device pixels.
308 var deviceRect = this.viewport_.getDeviceBounds(); 308 var deviceRect = this.viewport_.getDeviceBounds();
309 var needRepaint = false; 309 var needRepaint = false;
310
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
310 if (canvas.width !== deviceRect.width) { 311 if (canvas.width !== deviceRect.width) {
311 canvas.width = deviceRect.width; 312 canvas.width = deviceRect.width;
312 needRepaint = true; 313 needRepaint = true;
313 } 314 }
314 if (canvas.height !== deviceRect.height) { 315 if (canvas.height !== deviceRect.height) {
315 canvas.height = deviceRect.height; 316 canvas.height = deviceRect.height;
316 needRepaint = true; 317 needRepaint = true;
317 } 318 }
318 this.setTransform_(canvas, this.viewport_); 319 this.setTransform_(canvas, this.viewport_);
319 return needRepaint; 320 return needRepaint;
320 }; 321 };
321 322
322 /** 323 /**
323 * @return {!ImageData} A new ImageData object with a copy of the content. 324 * Gets screen image data with specified size.
325 * @param {number} width
326 * @param {number} height
327 * @return {!ImageData} A new ImageData object.
324 */ 328 */
325 ImageView.prototype.copyScreenImageData = function() { 329 ImageView.prototype.getScreenImageDataWith = function(width, height) {
326 return this.screenImage_.getContext('2d').getImageData( 330 // If specified size is same with current screen image size, just return it.
327 0, 0, this.screenImage_.width, this.screenImage_.height); 331 if (width === this.screenImage_.width &&
332 height === this.screenImage_.height) {
333 return this.screenImage_.getContext('2d').getImageData(
334 0, 0, this.screenImage_.width, this.screenImage_.height);
335 }
336
337 // Resize if these sizes are different.
338 var resizeCanvas = document.createElement('canvas');
339 resizeCanvas.width = width;
340 resizeCanvas.height = height;
341
342 var context = resizeCanvas.getContext('2d');
343 context.drawImage(this.screenImage_,
344 0, 0, this.screenImage_.width, this.screenImage_.height,
345 0, 0, resizeCanvas.width, resizeCanvas.height);
346 return context.getImageData(0, 0, resizeCanvas.width, resizeCanvas.height);
328 }; 347 };
329 348
330 /** 349 /**
331 * @return {boolean} True if the image is currently being loaded. 350 * @return {boolean} True if the image is currently being loaded.
332 */ 351 */
333 ImageView.prototype.isLoading = function() { 352 ImageView.prototype.isLoading = function() {
334 return this.imageLoader_.isBusy(); 353 return this.imageLoader_.isBusy();
335 }; 354 };
336 355
337 /** 356 /**
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 1014
996 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; 1015 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype };
997 1016
998 /** 1017 /**
999 * @override 1018 * @override
1000 */ 1019 */
1001 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { 1020 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) {
1002 return viewport.getRotatingTransformation( 1021 return viewport.getRotatingTransformation(
1003 element.width, element.height, this.orientation_ ? -1 : 1); 1022 element.width, element.height, this.orientation_ ? -1 : 1);
1004 }; 1023 };
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/image_adjust.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698