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

Unified Diff: ui/file_manager/gallery/js/image_editor/image_view.js

Issue 402863002: Specify canvas size by using CSS width/height. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/file_manager/gallery/js/image_editor/viewport.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 61dd50ee0908394854e201c772ebfd385388cd28..518d8ddeecfbe9220760b2f45cfaddeb1523c512 100644
--- a/ui/file_manager/gallery/js/image_editor/image_view.js
+++ b/ui/file_manager/gallery/js/image_editor/image_view.js
@@ -101,16 +101,7 @@ ImageView.prototype.getZIndex = function() { return -1; };
ImageView.prototype.draw = function() {
if (!this.contentCanvas_) // Do nothing if the image content is not set.
return;
-
- var forceRepaint = false;
- var deviceBounds = this.viewport_.getDeviceBounds();
- if (deviceBounds.width != this.screenImage_.width ||
- deviceBounds.height != this.screenImage_.height) {
- this.setupDeviceBuffer(this.screenImage_);
- forceRepaint = true;
- }
-
- if (forceRepaint ||
+ if (this.setupDeviceBuffer(this.screenImage_) ||
this.displayedContentGeneration_ !== this.contentGeneration_) {
this.displayedContentGeneration_ = this.contentGeneration_;
ImageUtil.trace.resetTimer('paint');
@@ -211,22 +202,31 @@ ImageView.prototype.createOverlayCanvas = function() {
* Sets up the canvas as a buffer in the device resolution.
*
* @param {HTMLCanvasElement} canvas The buffer canvas.
+ * @return {boolean} True if the canvas needs to be rendered.
*/
ImageView.prototype.setupDeviceBuffer = function(canvas) {
// Set the canvas position and size in device pixels.
var deviceRect = this.viewport_.getDeviceBounds();
- if (canvas.width !== deviceRect.width)
+ var needRepaint = false;
+ if (canvas.width !== deviceRect.width) {
canvas.width = deviceRect.width;
- if (canvas.height !== deviceRect.height)
+ needRepaint = true;
+ }
+ if (canvas.height !== deviceRect.height) {
canvas.height = deviceRect.height;
+ needRepaint = true;
+ }
// Center the image.
- var imageBoudns = this.viewport_.getImageElementBoundsOnScreen();
- canvas.style.left = imageBoudns.left + 'px';
- canvas.style.top = imageBoudns.top + 'px';
+ var imageBounds = this.viewport_.getImageElementBoundsOnScreen();
+ canvas.style.left = imageBounds.left + 'px';
+ canvas.style.top = imageBounds.top + 'px';
+ canvas.style.width = imageBounds.width + 'px';
+ canvas.style.height = imageBounds.height + 'px';
- // Scale the canvas down to screen pixels.
this.setTransform(canvas);
+
+ return needRepaint;
};
/**
@@ -827,8 +827,7 @@ ImageView.Effect.prototype.transform = function(element, viewport) {
};
/**
- * Default effect. It is not a no-op as it needs to adjust a canvas scale
- * for devicePixelRatio.
+ * Default effect.
*
* @constructor
* @extends {ImageView.Effect}
@@ -888,8 +887,7 @@ ImageView.Effect.Slide.prototype.transform = function(element, viewport) {
/**
* Zoom effect.
*
- * Animates the original rectangle to the target rectangle. Both parameters
- * should be given in device coordinates (accounting for devicePixelRatio).
+ * Animates the original rectangle to the target rectangle.
*
* @param {number} previousImageWidth Width of the full resolution image.
* @param {number} previousImageHeight Hieght of the full resolution image.
« no previous file with comments | « no previous file | ui/file_manager/gallery/js/image_editor/viewport.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698