Index: gm/rebaseline_server/static/diff_viewer.js |
diff --git a/tools/skpdiff/diff_viewer.js b/gm/rebaseline_server/static/diff_viewer.js |
similarity index 63% |
copy from tools/skpdiff/diff_viewer.js |
copy to gm/rebaseline_server/static/diff_viewer.js |
index 6be434b4db17be05f0e85866b5cbd6d17e16e02c..543c8c12aff87dacf9e6a99708b9198065991bef 100644 |
--- a/tools/skpdiff/diff_viewer.js |
+++ b/gm/rebaseline_server/static/diff_viewer.js |
@@ -1,13 +1,11 @@ |
-var MAX_SWAP_IMG_SIZE = 400; |
-var MAGNIFIER_WIDTH = 200; |
-var MAGNIFIER_HEIGHT = 200; |
+var MAX_SWAP_IMG_SIZE = 200; |
epoger
2014/02/04 16:45:52
I assume the previous version of this file was cop
rmistry
2014/02/04 18:35:33
The previous version of this file is actually from
epoger
2014/02/04 18:50:14
Ah. So we currently have *3* diff_viewers:
1. her
|
+var MAGNIFIER_WIDTH = 100; |
+var MAGNIFIER_HEIGHT = 100; |
var MAGNIFIER_HALF_WIDTH = MAGNIFIER_WIDTH * 0.5; |
var MAGNIFIER_HALF_HEIGHT = MAGNIFIER_HEIGHT * 0.5; |
-// TODO add support for a magnified scale factor |
var MAGNIFIER_SCALE_FACTOR = 2.0; |
-angular.module('diff_viewer', []). |
-directive('imgCompare', function() { |
+angular.module('diff_viewer', []).directive('imgCompare', function() { |
// Custom directive for comparing (3-way) images |
return { |
restrict: 'E', // The directive can be used as an element name |
@@ -25,16 +23,16 @@ directive('imgCompare', function() { |
// When the type attribute changes, load the image and then render |
attrs.$observe('type', function(value) { |
switch(value) { |
- case "alphaMask": |
- image.src = scope.record.differencePath; |
+ case "differingPixelsInWhite": |
+ magnifyContent = true; |
+ break; |
+ case "differencePerPixel": |
maskCanvas = true; |
break; |
case "baseline": |
- image.src = scope.record.baselinePath; |
magnifyContent = true; |
break; |
case "test": |
- image.src = scope.record.testPath; |
magnifyContent = true; |
break; |
default: |
@@ -42,6 +40,7 @@ directive('imgCompare', function() { |
return; |
} |
+ image.src = attrs.src; |
image.onload = function() { |
// compute the scaled image width/height for image and canvas |
var divisor = 1; |
@@ -146,7 +145,7 @@ directive('imgCompare', function() { |
}; |
// event handler for mouse events that triggers the magnification |
- // effect across the 3 images being compared. |
+ // effect across the 4 images being compared. |
scope.MagnifyDraw = function(event, startMagnify) { |
if (startMagnify) { |
scope.setMagnifierState(true); |
@@ -177,7 +176,7 @@ directive('imgCompare', function() { |
// update scope on baseline / test that will cause them to render |
scope.setMagnifierState(false); |
scope.setMagnifyCenter(undefined); |
- }; |
+ }; |
} |
}; |
}); |
@@ -210,97 +209,3 @@ function ImageController($scope, $http, $location, $timeout, $parse) { |
} |
} |
-function DiffListController($scope, $http, $location, $timeout, $parse) { |
- // Detect if we are running the web server version of the viewer. If so, we set a flag and |
- // enable some extra functionality of the website for rebaselining. |
- $scope.isDynamic = ($location.protocol() == "http" || $location.protocol() == "https"); |
- |
- // Label each kind of differ for the sort buttons. |
- $scope.differs = [ |
- { |
- "title": "Different Pixels" |
- }, |
- { |
- "title": "Perceptual Difference" |
- } |
- ]; |
- |
- // Puts the records within AngularJS scope |
- $scope.records = SkPDiffRecords.records; |
- |
- // Keep track of the index of the last record to change so that shift clicking knows what range |
- // of records to apply the action to. |
- $scope.lastSelectedIndex = undefined; |
- |
- // Indicates which diff metric is used for sorting |
- $scope.sortIndex = 1; |
- |
- // Called by the sort buttons to adjust the metric used for sorting |
- $scope.setSortIndex = function(idx) { |
- $scope.sortIndex = idx; |
- |
- // Because the index of things has most likely changed, the ranges of shift clicking no |
- // longer make sense from the user's point of view. We reset it to avoid confusion. |
- $scope.lastSelectedIndex = undefined; |
- }; |
- |
- // A predicate for pulling out the number used for sorting |
- $scope.sortingDiffer = function(record) { |
- return record.diffs[$scope.sortIndex].result; |
- }; |
- |
- // Flash status indicator on the page, and then remove it so the style can potentially be |
- // reapplied later. |
- $scope.flashStatus = function(success) { |
- var flashStyle = success ? "success-flash" : "failure-flash"; |
- var flashDurationMillis = success ? 500 : 800; |
- |
- // Store the style in the record. The row will pick up the style this way instead of through |
- // index because index can change with sort order. |
- $scope.statusClass = flashStyle; |
- |
- // The animation cannot be repeated unless the class is removed the element. |
- $timeout(function() { |
- $scope.statusClass = ""; |
- }, flashDurationMillis); |
- }; |
- |
- $scope.selectedRebaseline = function(index, event) { |
- // Retrieve the records in the same order they are displayed. |
- var recordsInOrder = $parse("records | orderBy:sortingDiffer")($scope); |
- |
- // If the user is shift clicking, apply the last tick/untick to all elements in between this |
- // record, and the last one they ticked/unticked. |
- if (event.shiftKey && $scope.lastSelectedIndex !== undefined) { |
- var currentAction = recordsInOrder[index].isRebaselined; |
- var smallerIndex = Math.min($scope.lastSelectedIndex, index); |
- var largerIndex = Math.max($scope.lastSelectedIndex, index); |
- for (var recordIndex = smallerIndex; recordIndex <= largerIndex; recordIndex++) { |
- recordsInOrder[recordIndex].isRebaselined = currentAction; |
- } |
- $scope.lastSelectedIndex = index; |
- } |
- else |
- { |
- $scope.lastSelectedIndex = index; |
- } |
- |
- }; |
- |
- $scope.commitRebaselines = function() { |
- // Gather up all records that have the rebaseline set. |
- var rebaselines = []; |
- for (var recordIndex = 0; recordIndex < $scope.records.length; recordIndex++) { |
- if ($scope.records[recordIndex].isRebaselined) { |
- rebaselines.push($scope.records[recordIndex].testPath); |
- } |
- } |
- $http.post("/commit_rebaselines", { |
- "rebaselines": rebaselines |
- }).success(function(data) { |
- $scope.flashStatus(data.success); |
- }).error(function() { |
- $scope.flashStatus(false); |
- }); |
- }; |
-} |