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

Side by Side Diff: tools/skpdiff/diff_viewer.js

Issue 20654006: download and rebaseline images using server (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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 angular.module('diff_viewer', []). 1 angular.module('diff_viewer', []).
2 config(['$routeProvider', function($routeProvider) { 2 config(['$routeProvider', function($routeProvider) {
3 // Show the list of differences by default 3 // Show the list of differences by default
4 $routeProvider. 4 $routeProvider.
5 otherwise({ templateUrl: '/diff_list.html', controller: DiffListController}) ; 5 otherwise({ templateUrl: '/diff_list.html', controller: DiffListController}) ;
6 }]). 6 }]).
7 directive('swapImg', function() { 7 directive('swapImg', function() {
8 // Custom directive for showing an image that gets swapped my mouseover. 8 // Custom directive for showing an image that gets swapped my mouseover.
9 return { 9 return {
10 restrict: 'E', // The directive can be used as an element name 10 restrict: 'E', // The directive can be used as an element name
(...skipping 10 matching lines...) Expand all
21 var ctx = elm[0].getContext('2d'); 21 var ctx = elm[0].getContext('2d');
22 22
23 scope.render = function() { 23 scope.render = function() {
24 var image; 24 var image;
25 if (scope.side == "left") { 25 if (scope.side == "left") {
26 image = leftImage; 26 image = leftImage;
27 } else { 27 } else {
28 image = rightImage; 28 image = rightImage;
29 } 29 }
30 30
31 // Make it so the maximum size of an image is 500, and the image s are scaled 31 // Make it so the maximum size of an image is 400, and the image s are scaled
epoger 2013/08/02 14:33:06 Please create a constant, near the top of the file
Zach Reizner 2013/08/02 21:30:58 Done.
32 // down in halves. 32 // down in halves.
33 var divisor = 1; 33 var divisor = 1;
34 while ((image.width / divisor) > 500) { 34 while ((image.width / divisor) > 400) {
35 divisor *= 2; 35 divisor *= 2;
36 } 36 }
37 37
38 // Set canvas to correct size and draw the image into it 38 // Set canvas to correct size and draw the image into it
39 elm[0].width = image.width / divisor; 39 elm[0].width = image.width / divisor;
40 elm[0].height = image.height / divisor; 40 elm[0].height = image.height / divisor;
41 ctx.drawImage(image, 0, 0, elm[0].width, elm[0].height); 41 ctx.drawImage(image, 0, 0, elm[0].width, elm[0].height);
42 }; 42 };
43 43
44 // When the leftSrc attribute changes, load the image and then reren der 44 // When the leftSrc attribute changes, load the image and then reren der
(...skipping 22 matching lines...) Expand all
67 scope.side = "right"; 67 scope.side = "right";
68 } else { 68 } else {
69 scope.side = "left"; 69 scope.side = "left";
70 } 70 }
71 scope.render(); 71 scope.render();
72 }; 72 };
73 } 73 }
74 }; 74 };
75 }); 75 });
76 76
77 function DiffListController($scope) { 77 function DiffListController($scope, $http, $timeout) {
78 // Label each kind of differ for the sort buttons. 78 // Label each kind of differ for the sort buttons.
79 $scope.differs = [ 79 $scope.differs = [
80 { 80 {
81 "title": "Different Pixels" 81 "title": "Different Pixels"
82 }, 82 },
83 { 83 {
84 "title": "Perceptual Difference" 84 "title": "Perceptual Difference"
85 } 85 }
86 ]; 86 ];
87 87
88 // Puts the records within AngularJS scope 88 // Puts the records within AngularJS scope
89 $scope.records = SkPDiffRecords.records; 89 $scope.records = SkPDiffRecords.records;
90 90
91 // Indicates which diff metric is used for sorting 91 // Indicates which diff metric is used for sorting
92 $scope.sortIndex = 1; 92 $scope.sortIndex = 1;
93 93
94 // Called by the sort buttons to adjust the metric used for sorting 94 // Called by the sort buttons to adjust the metric used for sorting
95 $scope.setSortIndex = function(idx) { 95 $scope.setSortIndex = function(idx) {
96 $scope.sortIndex = idx; 96 $scope.sortIndex = idx;
97 }; 97 };
98 98
99 // A predicate for pulling out the number used for sorting 99 // A predicate for pulling out the number used for sorting
100 $scope.sortingDiffer = function(record) { 100 $scope.sortingDiffer = function(record) {
101 return record.diffs[$scope.sortIndex].result; 101 return record.diffs[$scope.sortIndex].result;
102 }; 102 };
103
104 // Flash status indicators on the rows, and then remove them so the style ca n potentially be
105 // reapplied later.
epoger 2013/08/02 14:33:06 Is this hosted somewhere that I can look at it, an
Zach Reizner 2013/08/02 21:30:58 Nope. Never done that before on the corp network.
epoger 2013/08/06 15:26:43 It's easy to do. See the "User directories" secti
106 $scope.flashRowStatus = function(success, record) {
107 var flashStyle = success ? "success-flash" : "failure-flash";
108 var flashDuration = success ? 500 : 800;
epoger 2013/08/02 14:33:06 I take it this is in milliseconds? If so, please
Zach Reizner 2013/08/02 21:30:58 Done.
109
110 // Store the style in the record. The row will pick up the style this wa y instead of through
111 // index because index can change with sort order.
112 record.cssClasses = flashStyle;
113
114 // The animation cannot be repeated unless the class is removed the elem ent.
115 $timeout(function() {
116 record.cssClasses = "";
117 }, flashDuration);
118 }
119
120 $scope.setHashOf = function(imagePath, record) {
121 $http.post("/set_hash", {
122 "path": imagePath
123 }).success(function(data) {
124 $scope.flashRowStatus(data.success, record);
125 }).error(function() {
126 $scope.flashRowStatus(false, record);
127 });
128
129 };
103 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698