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

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

Issue 382143004: Remove repaint callbacks from Viewport. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * The overlay displaying the image. 8 * The overlay displaying the image.
9 * 9 *
10 * @param {HTMLElement} container The container element. 10 * @param {HTMLElement} container The container element.
11 * @param {Viewport} viewport The viewport. 11 * @param {Viewport} viewport The viewport.
12 * @constructor 12 * @constructor
13 * @extends {ImageBuffer.Overlay}
13 */ 14 */
14 function ImageView(container, viewport) { 15 function ImageView(container, viewport) {
16 ImageBuffer.Overlay.call(this);
17
15 this.container_ = container; 18 this.container_ = container;
16 this.viewport_ = viewport; 19 this.viewport_ = viewport;
17 this.document_ = container.ownerDocument; 20 this.document_ = container.ownerDocument;
18 this.contentGeneration_ = 0; 21 this.contentGeneration_ = 0;
19 this.displayedContentGeneration_ = 0; 22 this.displayedContentGeneration_ = 0;
20 this.displayedViewportGeneration_ = 0; 23 this.displayedViewportGeneration_ = 0;
21 24
22 this.imageLoader_ = new ImageUtil.ImageLoader(this.document_); 25 this.imageLoader_ = new ImageUtil.ImageLoader(this.document_);
23 // We have a separate image loader for prefetch which does not get cancelled 26 // We have a separate image loader for prefetch which does not get cancelled
24 // when the selection changes. 27 // when the selection changes.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 ImageView.LOAD_TYPE_OFFLINE = 4; 85 ImageView.LOAD_TYPE_OFFLINE = 4;
83 86
84 /** 87 /**
85 * The total number of load types. 88 * The total number of load types.
86 */ 89 */
87 ImageView.LOAD_TYPE_TOTAL = 5; 90 ImageView.LOAD_TYPE_TOTAL = 5;
88 91
89 ImageView.prototype = {__proto__: ImageBuffer.Overlay.prototype}; 92 ImageView.prototype = {__proto__: ImageBuffer.Overlay.prototype};
90 93
91 /** 94 /**
92 * Draws below overlays with the default zIndex. 95 * @override
93 * @return {number} Z-index.
94 */ 96 */
95 ImageView.prototype.getZIndex = function() { return -1; }; 97 ImageView.prototype.getZIndex = function() { return -1; };
96 98
97 /** 99 /**
98 * Draws the image on screen. 100 * @override
99 */ 101 */
100 ImageView.prototype.draw = function() { 102 ImageView.prototype.draw = function() {
101 if (!this.contentCanvas_) // Do nothing if the image content is not set. 103 if (!this.contentCanvas_) // Do nothing if the image content is not set.
102 return; 104 return;
103 105
104 var forceRepaint = false; 106 var forceRepaint = false;
105 107
106 if (this.displayedViewportGeneration_ !== 108 if (this.displayedViewportGeneration_ !==
107 this.viewport_.getCacheGeneration()) { 109 this.viewport_.getCacheGeneration()) {
108 this.displayedViewportGeneration_ = this.viewport_.getCacheGeneration(); 110 this.displayedViewportGeneration_ = this.viewport_.getCacheGeneration();
109 111
110 this.setupDeviceBuffer(this.screenImage_); 112 this.setupDeviceBuffer(this.screenImage_);
111 113
112 forceRepaint = true; 114 forceRepaint = true;
113 } 115 }
114 116
115 if (forceRepaint || 117 if (forceRepaint ||
116 this.displayedContentGeneration_ !== this.contentGeneration_) { 118 this.displayedContentGeneration_ !== this.contentGeneration_) {
117 this.displayedContentGeneration_ = this.contentGeneration_; 119 this.displayedContentGeneration_ = this.contentGeneration_;
118 120
119 ImageUtil.trace.resetTimer('paint'); 121 ImageUtil.trace.resetTimer('paint');
120 this.paintDeviceRect(this.viewport_.getDeviceClipped(), 122 this.paintDeviceRect(this.viewport_.getDeviceClipped(),
121 this.contentCanvas_, this.viewport_.getImageClipped()); 123 this.contentCanvas_, this.viewport_.getImageClipped());
122 ImageUtil.trace.reportTimer('paint'); 124 ImageUtil.trace.reportTimer('paint');
123 } 125 }
124 }; 126 };
125 127
126 /** 128 /**
127 * @param {number} x X pointer position.
128 * @param {number} y Y pointer position.
129 * @param {boolean} mouseDown True if mouse is down.
130 * @return {string} CSS cursor style.
131 */
132 ImageView.prototype.getCursorStyle = function(x, y, mouseDown) {
133 // Indicate that the image is draggable.
134 if (this.viewport_.isClipped() &&
135 this.viewport_.getScreenClipped().inside(x, y))
136 return 'move';
137
138 return null;
139 };
140
141 /**
142 * @param {number} x X pointer position.
143 * @param {number} y Y pointer position.
144 * @return {function} The closure to call on drag.
145 */
146 ImageView.prototype.getDragHandler = function(x, y) {
147 var cursor = this.getCursorStyle(x, y);
148 if (cursor === 'move') {
149 // Return the handler that drags the entire image.
150 return this.viewport_.createOffsetSetter(x, y);
151 }
152
153 return null;
154 };
155
156 /**
157 * @return {number} The cache generation. 129 * @return {number} The cache generation.
158 */ 130 */
159 ImageView.prototype.getCacheGeneration = function() { 131 ImageView.prototype.getCacheGeneration = function() {
160 return this.contentGeneration_; 132 return this.contentGeneration_;
161 }; 133 };
162 134
163 /** 135 /**
164 * Invalidates the caches to force redrawing the screen canvas. 136 * Invalidates the caches to force redrawing the screen canvas.
165 */ 137 */
166 ImageView.prototype.invalidateCaches = function() { 138 ImageView.prototype.invalidateCaches = function() {
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 }; 951 };
980 952
981 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; 953 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype };
982 954
983 /** 955 /**
984 * @override 956 * @override
985 */ 957 */
986 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { 958 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) {
987 return viewport.getInverseTransformForRotatedImage(this.orientation_); 959 return viewport.getInverseTransformForRotatedImage(this.orientation_);
988 }; 960 };
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/image_editor.js ('k') | ui/file_manager/gallery/js/image_editor/viewport.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698