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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 this.contentItem_ = item; | 277 this.contentItem_ = item; |
278 this.contentRevision_ = -1; | 278 this.contentRevision_ = -1; |
279 | 279 |
280 var cached = item.contentImage; | 280 var cached = item.contentImage; |
281 if (cached) { | 281 if (cached) { |
282 displayMainImage(ImageView.LOAD_TYPE_CACHED_FULL, | 282 displayMainImage(ImageView.LOAD_TYPE_CACHED_FULL, |
283 false /* no preview */, cached); | 283 false /* no preview */, cached); |
284 } else { | 284 } else { |
285 var cachedScreen = item.screenImage; | 285 var cachedScreen = item.screenImage; |
286 var imageWidth = metadata.media && metadata.media.width || | 286 var imageWidth = metadata.media && metadata.media.width || |
287 metadata.drive && metadata.drive.imageWidth; | 287 metadata.external && metadata.external.imageWidth; |
288 var imageHeight = metadata.media && metadata.media.height || | 288 var imageHeight = metadata.media && metadata.media.height || |
289 metadata.drive && metadata.drive.imageHeight; | 289 metadata.external && metadata.external.imageHeight; |
290 if (cachedScreen) { | 290 if (cachedScreen) { |
291 // We have a cached screen-scale canvas, use it instead of a thumbnail. | 291 // We have a cached screen-scale canvas, use it instead of a thumbnail. |
292 displayThumbnail(ImageView.LOAD_TYPE_CACHED_SCREEN, cachedScreen); | 292 displayThumbnail(ImageView.LOAD_TYPE_CACHED_SCREEN, cachedScreen); |
293 // As far as the user can tell the image is loaded. We still need to load | 293 // As far as the user can tell the image is loaded. We still need to load |
294 // the full res image to make editing possible, but we can report now. | 294 // the full res image to make editing possible, but we can report now. |
295 ImageUtil.metrics.recordInterval(ImageUtil.getMetricName('DisplayTime')); | 295 ImageUtil.metrics.recordInterval(ImageUtil.getMetricName('DisplayTime')); |
296 } else if ((effect && effect.constructor.name === 'Slide') && | 296 } else if ((effect && effect.constructor.name === 'Slide') && |
297 (metadata.thumbnail && metadata.thumbnail.url)) { | 297 (metadata.thumbnail && metadata.thumbnail.url)) { |
298 // Only show thumbnails if there is no effect or the effect is Slide. | 298 // Only show thumbnails if there is no effect or the effect is Slide. |
299 // Also no thumbnail if the image is too large to be loaded. | 299 // Also no thumbnail if the image is too large to be loaded. |
(...skipping 12 matching lines...) Expand all Loading... |
312 } | 312 } |
313 | 313 |
314 function displayThumbnail(loadType, canvas) { | 314 function displayThumbnail(loadType, canvas) { |
315 if (canvas) { | 315 if (canvas) { |
316 var width = null; | 316 var width = null; |
317 var height = null; | 317 var height = null; |
318 if (metadata.media) { | 318 if (metadata.media) { |
319 width = metadata.media.width; | 319 width = metadata.media.width; |
320 height = metadata.media.height; | 320 height = metadata.media.height; |
321 } | 321 } |
322 // If metadata.drive.present is true, the image data is loaded directly | 322 // If metadata.external.present is true, the image data is loaded directly |
323 // from local cache, whose size may be out of sync with the drive | 323 // from local cache, whose size may be out of sync with the drive |
324 // metadata. | 324 // metadata. |
325 if (metadata.drive && !metadata.drive.present) { | 325 if (metadata.external && !metadata.external.present) { |
326 width = metadata.drive.imageWidth; | 326 width = metadata.external.imageWidth; |
327 height = metadata.drive.imageHeight; | 327 height = metadata.external.imageHeight; |
328 } | 328 } |
329 self.replace( | 329 self.replace( |
330 canvas, | 330 canvas, |
331 effect, | 331 effect, |
332 width, | 332 width, |
333 height, | 333 height, |
334 true /* preview */); | 334 true /* preview */); |
335 if (displayCallback) displayCallback(); | 335 if (displayCallback) displayCallback(); |
336 } | 336 } |
337 loadMainImage(loadType, entry, !!canvas, | 337 loadMainImage(loadType, entry, !!canvas, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } | 374 } |
375 | 375 |
376 if (loadType !== ImageView.LOAD_TYPE_ERROR && | 376 if (loadType !== ImageView.LOAD_TYPE_ERROR && |
377 loadType !== ImageView.LOAD_TYPE_CACHED_SCREEN) { | 377 loadType !== ImageView.LOAD_TYPE_CACHED_SCREEN) { |
378 ImageUtil.metrics.recordInterval(ImageUtil.getMetricName('DisplayTime')); | 378 ImageUtil.metrics.recordInterval(ImageUtil.getMetricName('DisplayTime')); |
379 } | 379 } |
380 ImageUtil.metrics.recordEnum(ImageUtil.getMetricName('LoadMode'), | 380 ImageUtil.metrics.recordEnum(ImageUtil.getMetricName('LoadMode'), |
381 loadType, ImageView.LOAD_TYPE_TOTAL); | 381 loadType, ImageView.LOAD_TYPE_TOTAL); |
382 | 382 |
383 if (loadType === ImageView.LOAD_TYPE_ERROR && | 383 if (loadType === ImageView.LOAD_TYPE_ERROR && |
384 !navigator.onLine && !metadata.drive.present) { | 384 !navigator.onLine && !metadata.external.present) { |
385 loadType = ImageView.LOAD_TYPE_OFFLINE; | 385 loadType = ImageView.LOAD_TYPE_OFFLINE; |
386 } | 386 } |
387 if (loadCallback) loadCallback(loadType, animationDuration, opt_error); | 387 if (loadCallback) loadCallback(loadType, animationDuration, opt_error); |
388 } | 388 } |
389 }; | 389 }; |
390 | 390 |
391 /** | 391 /** |
392 * Prefetches an image. | 392 * Prefetches an image. |
393 * @param {Gallery.Item} item The image item. | 393 * @param {Gallery.Item} item The image item. |
394 * @param {number} delay Image load delay in ms. | 394 * @param {number} delay Image load delay in ms. |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 }; | 832 }; |
833 | 833 |
834 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; | 834 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; |
835 | 835 |
836 /** | 836 /** |
837 * @override | 837 * @override |
838 */ | 838 */ |
839 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { | 839 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { |
840 return viewport.getInverseTransformForRotatedImage(this.orientation_); | 840 return viewport.getInverseTransformForRotatedImage(this.orientation_); |
841 }; | 841 }; |
OLD | NEW |