OLD | NEW |
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 * @constructor | 11 * @constructor |
11 * @extends {ImageBuffer.Overlay} | 12 * @extends {ImageBuffer.Overlay} |
12 * @struct | 13 * @struct |
13 */ | 14 */ |
14 function ImageView(container, viewport) { | 15 function ImageView(container, viewport, metadataModel) { |
15 ImageBuffer.Overlay.call(this); | 16 ImageBuffer.Overlay.call(this); |
16 | 17 |
17 this.container_ = container; | 18 this.container_ = container; |
18 | 19 |
19 /** | 20 /** |
20 * The viewport. | 21 * The viewport. |
21 * @type {!Viewport} | 22 * @type {!Viewport} |
22 * @private | 23 * @private |
23 */ | 24 */ |
24 this.viewport_ = viewport; | 25 this.viewport_ = viewport; |
25 | 26 |
26 this.document_ = assertInstanceof(container.ownerDocument, HTMLDocument); | 27 this.document_ = assertInstanceof(container.ownerDocument, HTMLDocument); |
27 this.contentGeneration_ = 0; | 28 this.contentGeneration_ = 0; |
28 this.displayedContentGeneration_ = 0; | 29 this.displayedContentGeneration_ = 0; |
29 | 30 |
30 this.imageLoader_ = new ImageUtil.ImageLoader(this.document_); | 31 this.imageLoader_ = |
| 32 new ImageUtil.ImageLoader(this.document_, metadataModel); |
31 // We have a separate image loader for prefetch which does not get cancelled | 33 // We have a separate image loader for prefetch which does not get cancelled |
32 // when the selection changes. | 34 // when the selection changes. |
33 this.prefetchLoader_ = new ImageUtil.ImageLoader(this.document_); | 35 this.prefetchLoader_ = |
| 36 new ImageUtil.ImageLoader(this.document_, metadataModel); |
34 | 37 |
35 this.contentCallbacks_ = []; | 38 this.contentCallbacks_ = []; |
36 | 39 |
37 /** | 40 /** |
38 * The element displaying the current content. | 41 * The element displaying the current content. |
39 * @type {HTMLCanvasElement} | 42 * @type {HTMLCanvasElement} |
40 * @private | 43 * @private |
41 */ | 44 */ |
42 this.screenImage_ = null; | 45 this.screenImage_ = null; |
43 | 46 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 default: | 408 default: |
406 assertNotReached(); | 409 assertNotReached(); |
407 } | 410 } |
408 | 411 |
409 /** | 412 /** |
410 * @param {!ImageView.LoadType} loadType A load type. | 413 * @param {!ImageView.LoadType} loadType A load type. |
411 * @param {(HTMLCanvasElement|HTMLImageElement)} canvas A canvas. | 414 * @param {(HTMLCanvasElement|HTMLImageElement)} canvas A canvas. |
412 */ | 415 */ |
413 function displayThumbnail(loadType, canvas) { | 416 function displayThumbnail(loadType, canvas) { |
414 if (canvas) { | 417 if (canvas) { |
415 var width = null; | 418 var width = item.getMetadataItem().imageWidth; |
416 var height = null; | 419 var height = item.getMetadataItem().imageHeight; |
417 if (metadata.media) { | |
418 width = metadata.media.width; | |
419 height = metadata.media.height; | |
420 } | |
421 // If metadata.external.present is true, the image data is loaded directly | |
422 // from local cache, whose size may be out of sync with the drive | |
423 // metadata. | |
424 if (metadata.external && !metadata.external.present) { | |
425 width = metadata.external.imageWidth; | |
426 height = metadata.external.imageHeight; | |
427 } | |
428 self.replace( | 420 self.replace( |
429 canvas, | 421 canvas, |
430 effect, | 422 effect, |
431 width, | 423 width, |
432 height, | 424 height, |
433 true /* preview */); | 425 true /* preview */); |
434 if (displayCallback) displayCallback(); | 426 if (displayCallback) |
| 427 displayCallback(); |
435 } | 428 } |
436 loadMainImage(loadType, entry, !!canvas, | 429 loadMainImage(loadType, entry, !!canvas, |
437 (effect && canvas) ? effect.getSafeInterval() : 0); | 430 (effect && canvas) ? effect.getSafeInterval() : 0); |
438 } | 431 } |
439 | 432 |
440 /** | 433 /** |
441 * @param {!ImageView.LoadType} loadType Load type. | 434 * @param {!ImageView.LoadType} loadType Load type. |
442 * @param {Entry} contentEntry A content entry. | 435 * @param {Entry} contentEntry A content entry. |
443 * @param {boolean} previewShown A preview is shown or not. | 436 * @param {boolean} previewShown A preview is shown or not. |
444 * @param {number} delay Load delay. | 437 * @param {number} delay Load delay. |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 }; | 967 }; |
975 | 968 |
976 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; | 969 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; |
977 | 970 |
978 /** | 971 /** |
979 * @override | 972 * @override |
980 */ | 973 */ |
981 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { | 974 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { |
982 return viewport.getInverseTransformForRotatedImage(this.orientation_); | 975 return viewport.getInverseTransformForRotatedImage(this.orientation_); |
983 }; | 976 }; |
OLD | NEW |