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

Side by Side Diff: chrome/browser/resources/file_manager/js/photo/mosaic_mode.js

Issue 14623021: Introduce a priority queue to the image loader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 7 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * @param {Element} container Content container. 8 * @param {Element} container Content container.
9 * @param {cr.ui.ArrayDataModel} dataModel Data model. 9 * @param {cr.ui.ArrayDataModel} dataModel Data model.
10 * @param {cr.ui.ListSelectionModel} selectionModel Selection model. 10 * @param {cr.ui.ListSelectionModel} selectionModel Selection model.
(...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 * Initializes the thumbnail in the tile. Does not load an image, but sets 1708 * Initializes the thumbnail in the tile. Does not load an image, but sets
1709 * target dimensions using metadata. 1709 * target dimensions using metadata.
1710 * 1710 *
1711 * @param {Object} metadata Metadata object. 1711 * @param {Object} metadata Metadata object.
1712 * @param {function()} onImageMeasured Image measured callback. 1712 * @param {function()} onImageMeasured Image measured callback.
1713 */ 1713 */
1714 Mosaic.Tile.prototype.init = function(metadata, onImageMeasured) { 1714 Mosaic.Tile.prototype.init = function(metadata, onImageMeasured) {
1715 this.markUnloaded(); 1715 this.markUnloaded();
1716 this.left_ = null; // Mark as not laid out. 1716 this.left_ = null; // Mark as not laid out.
1717 1717
1718 // Set higher priority for the selected elements to load them first.
1719 var priority = this.getAttribute('selected') ? 1 : 2;
1720
1718 // Use embedded thumbnails on Drive, since they have higher resolution. 1721 // Use embedded thumbnails on Drive, since they have higher resolution.
1719 this.thumbnailLoader_ = new ThumbnailLoader( 1722 this.thumbnailLoader_ = new ThumbnailLoader(
1720 this.getItem().getUrl(), 1723 this.getItem().getUrl(),
1721 ThumbnailLoader.LoaderType.CANVAS, 1724 ThumbnailLoader.LoaderType.CANVAS,
1722 metadata, 1725 metadata,
1723 undefined, // Media type. 1726 undefined, // Media type.
1724 FileType.isOnDrive(this.getItem().getUrl()) ? 1727 FileType.isOnDrive(this.getItem().getUrl()) ?
1725 ThumbnailLoader.UseEmbedded.USE_EMBEDDED : 1728 ThumbnailLoader.UseEmbedded.USE_EMBEDDED :
1726 ThumbnailLoader.UseEmbedded.NO_EMBEDDED); 1729 ThumbnailLoader.UseEmbedded.NO_EMBEDDED,
1730 priority);
1727 1731
1728 var setDimensions = function(width, height) { 1732 var setDimensions = function(width, height) {
1729 if (width > height) { 1733 if (width > height) {
1730 if (width > Mosaic.Tile.MAX_CONTENT_SIZE) { 1734 if (width > Mosaic.Tile.MAX_CONTENT_SIZE) {
1731 height = Math.round(height * Mosaic.Tile.MAX_CONTENT_SIZE / width); 1735 height = Math.round(height * Mosaic.Tile.MAX_CONTENT_SIZE / width);
1732 width = Mosaic.Tile.MAX_CONTENT_SIZE; 1736 width = Mosaic.Tile.MAX_CONTENT_SIZE;
1733 } 1737 }
1734 } else { 1738 } else {
1735 if (height > Mosaic.Tile.MAX_CONTENT_SIZE) { 1739 if (height > Mosaic.Tile.MAX_CONTENT_SIZE) {
1736 width = Math.round(width * Mosaic.Tile.MAX_CONTENT_SIZE / height); 1740 width = Math.round(width * Mosaic.Tile.MAX_CONTENT_SIZE / height);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 return new Rect(this.left_ - this.container_.scrollLeft, this.top_, 1877 return new Rect(this.left_ - this.container_.scrollLeft, this.top_,
1874 this.width_, this.height_).inflate(-margin, -margin); 1878 this.width_, this.height_).inflate(-margin, -margin);
1875 }; 1879 };
1876 1880
1877 /** 1881 /**
1878 * @return {number} X coordinate of the tile center. 1882 * @return {number} X coordinate of the tile center.
1879 */ 1883 */
1880 Mosaic.Tile.prototype.getCenterX = function() { 1884 Mosaic.Tile.prototype.getCenterX = function() {
1881 return this.left_ + Math.round(this.width_ / 2); 1885 return this.left_ + Math.round(this.width_ / 2);
1882 }; 1886 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698