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 '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. |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 success ? thumbnailLoader.getImage() : null); | 396 success ? thumbnailLoader.getImage() : null); |
397 }); | 397 }); |
398 } else { | 398 } else { |
399 loadMainImage(ImageView.LOAD_TYPE_IMAGE_FILE, entry, | 399 loadMainImage(ImageView.LOAD_TYPE_IMAGE_FILE, entry, |
400 false /* no preview*/, 0 /* delay */); | 400 false /* no preview*/, 0 /* delay */); |
401 } | 401 } |
402 } | 402 } |
403 | 403 |
404 function displayThumbnail(loadType, canvas) { | 404 function displayThumbnail(loadType, canvas) { |
405 if (canvas) { | 405 if (canvas) { |
| 406 var width = null; |
| 407 var height = null; |
| 408 if (metadata.media) { |
| 409 width = metadata.media.width; |
| 410 height = metadata.media.height; |
| 411 } |
| 412 // If metadata.drive.present is true, the image data is loaded directly |
| 413 // from local cache, whose size may be out of sync with the drive |
| 414 // metadata. |
| 415 if (metadata.drive && !metadata.drive.present) { |
| 416 width = metadata.drive.imageWidth; |
| 417 height = metadata.drive.imageHeight; |
| 418 } |
406 self.replace( | 419 self.replace( |
407 canvas, | 420 canvas, |
408 effect, | 421 effect, |
409 (metadata.media && metadata.media.width) || | 422 width, |
410 metadata.drive.imageWidth, | 423 height, |
411 (metadata.media && metadata.media.height) || | |
412 metadata.drive.imageHeight, | |
413 true /* preview */); | 424 true /* preview */); |
414 if (displayCallback) displayCallback(); | 425 if (displayCallback) displayCallback(); |
415 } | 426 } |
416 loadMainImage(loadType, entry, !!canvas, | 427 loadMainImage(loadType, entry, !!canvas, |
417 (effect && canvas) ? effect.getSafeInterval() : 0); | 428 (effect && canvas) ? effect.getSafeInterval() : 0); |
418 } | 429 } |
419 | 430 |
420 function loadMainImage(loadType, contentEntry, previewShown, delay) { | 431 function loadMainImage(loadType, contentEntry, previewShown, delay) { |
421 if (self.prefetchLoader_.isLoading(contentEntry)) { | 432 if (self.prefetchLoader_.isLoading(contentEntry)) { |
422 // The image we need is already being prefetched. Initiating another load | 433 // The image we need is already being prefetched. Initiating another load |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 | 1069 |
1059 /** | 1070 /** |
1060 * @param {HTMLCanvasElement|HTMLVideoElement} element Element. | 1071 * @param {HTMLCanvasElement|HTMLVideoElement} element Element. |
1061 * @return {string} Transform string. | 1072 * @return {string} Transform string. |
1062 */ | 1073 */ |
1063 ImageView.Effect.Rotate.prototype.transform = function(element) { | 1074 ImageView.Effect.Rotate.prototype.transform = function(element) { |
1064 var ratio = ImageView.Effect.getPixelRatio_(element); | 1075 var ratio = ImageView.Effect.getPixelRatio_(element); |
1065 return 'rotate(' + (this.rotate90_ * 90) + 'deg) ' + | 1076 return 'rotate(' + (this.rotate90_ * 90) + 'deg) ' + |
1066 'scale(' + (this.scale_ / ratio) + ')'; | 1077 'scale(' + (this.scale_ / ratio) + ')'; |
1067 }; | 1078 }; |
OLD | NEW |