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

Unified Diff: ui/file_manager/image_loader/image_loader.js

Issue 1027283005: Files.app: Start to use PiexLoader in image loader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace dummy .js extension with .txt extension for avoiding licence check. Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/file_manager/image_loader/compiled_resources.gyp ('k') | ui/file_manager/image_loader/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/image_loader/image_loader.js
diff --git a/ui/file_manager/image_loader/image_loader.js b/ui/file_manager/image_loader/image_loader.js
index a723ad61353a65e9282d6db535933cab9c740928..2a995b9baab5e78097b85300c2260e4f6a548666 100644
--- a/ui/file_manager/image_loader/image_loader.js
+++ b/ui/file_manager/image_loader/image_loader.js
@@ -21,6 +21,12 @@ function ImageLoader() {
*/
this.scheduler_ = new Scheduler();
+ /**
+ * Piex loader for RAW images.
+ * @private {!PiexLoader}
+ */
+ this.piexLoader_ = new PiexLoader();
+
// Grant permissions to all volumes, initialize the cache and then start the
// scheduler.
chrome.fileManagerPrivate.getVolumeMetadataList(function(volumeMetadataList) {
@@ -99,7 +105,8 @@ ImageLoader.prototype.onMessage_ = function(senderId, request, callback) {
return false; // No callback calls.
} else {
// Create a request task and add it to the scheduler (queue).
- var requestTask = new Request(requestId, this.cache_, request, callback);
+ var requestTask = new Request(
+ requestId, this.cache_, this.piexLoader_, request, callback);
this.scheduler_.add(requestTask);
return true; // Request will call the callback.
}
@@ -203,32 +210,20 @@ ImageLoader.resize = function(source, target, options) {
var targetDimensions = ImageLoader.resizeDimensions(
source.width, source.height, options);
- target.width = targetDimensions.width;
- target.height = targetDimensions.height;
-
// Default orientation is 0deg.
- var orientation = options.orientation || 0;
-
- // For odd orientation values: 1 (90deg) and 3 (270deg) flip dimensions.
- var drawImageWidth;
- var drawImageHeight;
- if (orientation % 2) {
- drawImageWidth = target.height;
- drawImageHeight = target.width;
- } else {
- drawImageWidth = target.width;
- drawImageHeight = target.height;
- }
+ var orientation = options.orientation || new ImageOrientation(1, 0, 0, 1);
+ var size = orientation.getSizeAfterCancelling(
+ targetDimensions.width, targetDimensions.height);
+ target.width = size.width;
+ target.height = size.height;
var targetContext = target.getContext('2d');
targetContext.save();
- targetContext.translate(target.width / 2, target.height / 2);
- targetContext.rotate(orientation * Math.PI / 2);
+ orientation.cancelImageOrientation(
+ targetContext, targetDimensions.width, targetDimensions.height);
targetContext.drawImage(
source,
- 0, 0,
- source.width, source.height,
- -drawImageWidth / 2, -drawImageHeight / 2,
- drawImageWidth, drawImageHeight);
+ 0, 0, source.width, source.height,
+ 0, 0, targetDimensions.width, targetDimensions.height);
targetContext.restore();
};
« no previous file with comments | « ui/file_manager/image_loader/compiled_resources.gyp ('k') | ui/file_manager/image_loader/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698