This passes the URL of the diff image to the front-end, thus removing the need to keep frontend code for URL generation in sync with the backend.

BUG=skia:
NOTREECHECKS=true
NOTRY=true
R=epoger@google.com

Author: stephana@google.com

Review URL: https://codereview.chromium.org/471033003
This commit is contained in:
stephana 2014-08-15 06:53:23 -07:00 committed by Commit bot
parent 45f7842de7
commit a1aa5c2806
9 changed files with 52 additions and 62 deletions

View File

@ -50,6 +50,8 @@ KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL = 'maxDiffPerChannel'
KEY__DIFFERENCES__NUM_DIFF_PIXELS = 'numDifferingPixels'
KEY__DIFFERENCES__PERCENT_DIFF_PIXELS = 'percentDifferingPixels'
KEY__DIFFERENCES__PERCEPTUAL_DIFF = 'perceptualDifference'
KEY__DIFFERENCES__DIFF_URL = 'diffUrl'
KEY__DIFFERENCES__WHITE_DIFF_URL = 'whiteDiffUrl'
# Special values within ImageDiffDB._diff_dict
_DIFFRECORD_FAILED = 'failed'
@ -158,6 +160,9 @@ class DiffRecord(object):
record = data['records'][0]
self._width = record['width']
self._height = record['height']
self._diffUrl = os.path.split(record['rgbDiffPath'])[1]
self._whiteDiffUrl = os.path.split(record['whiteDiffPath'])[1]
# TODO: make max_diff_per_channel a tuple instead of a list, because the
# structure is meaningful (first element is red, second is green, etc.)
# See http://stackoverflow.com/a/626871
@ -212,9 +217,12 @@ class DiffRecord(object):
self.get_percent_pixels_differing(),
KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL: self._max_diff_per_channel,
KEY__DIFFERENCES__PERCEPTUAL_DIFF: self._perceptual_difference,
KEY__DIFFERENCES__DIFF_URL: self._diffUrl,
KEY__DIFFERENCES__WHITE_DIFF_URL: self._whiteDiffUrl,
}
class ImageDiffDB(object):
""" Calculates differences between image pairs, maintaining a database of
them for download."""

View File

@ -89,6 +89,10 @@ class ImagePairTest(unittest.TestCase):
'numDifferingPixels': 662,
'percentDifferingPixels': 0.0662,
'perceptualDifference': 0.06620300000000157,
'diffUrl': 'arcofzorro_16206093933823793653_png_png-vs-' +
'arcofzorro_13786535001616823825_png_png.png',
'whiteDiffUrl': 'arcofzorro_16206093933823793653_png_png' +
'-vs-arcofzorro_13786535001616823825_png_png.png',
},
'imageAUrl': 'arcofzorro/16206093933823793653.png',
'imageBUrl': 'arcofzorro/13786535001616823825.png',
@ -115,6 +119,13 @@ class ImagePairTest(unittest.TestCase):
'numDifferingPixels': 102400,
'percentDifferingPixels': 100.00,
'perceptualDifference': 100.00,
'diffUrl': 'gradients_degenerate_2pt_10552995703607727960' +
'_png_png-vs-gradients_degenerate_2pt_' +
'11198253335583713230_png_png.png',
'whiteDiffUrl': 'gradients_degenerate_2pt_' +
'10552995703607727960_png_png-vs-' +
'gradients_degenerate_2pt_11198253335583713230' +
'_png_png.png'
},
'expectations': {
'bugs': [1001, 1002],

View File

@ -21,6 +21,8 @@ module.constant('constants', (function() {
KEY__DIFFERENCES__NUM_DIFF_PIXELS: 'numDifferingPixels',
KEY__DIFFERENCES__PERCENT_DIFF_PIXELS: 'percentDifferingPixels',
KEY__DIFFERENCES__PERCEPTUAL_DIFF: 'perceptualDifference',
KEY__DIFFERENCES__DIFF_URL: 'diffUrl',
KEY__DIFFERENCES__WHITE_DIFF_URL: 'whiteDiffUrl',
// NOTE: Keep these in sync with ../imagepair.py
KEY__IMAGEPAIRS__DIFFERENCES: 'differenceData',

View File

@ -1040,28 +1040,5 @@ Loader.controller(
var v = parseInt(brightnessString);
return $scope.hexColorString(v, v, v);
};
/**
* Returns the last path component of image diff URL for a given ImagePair.
*
* Depending on which diff this is (whitediffs, pixeldiffs, etc.) this
* will be relative to different base URLs.
*
* We must keep this function in sync with _get_difference_locator() in
* ../imagediffdb.py
*
* @param imagePair: ImagePair to generate image diff URL for
*/
// TODO (stephana): this is a temporary fix. A fix is in the works
// to get rid of this function and include the URL in the data
// sent from the backend.
$scope.getImageDiffRelativeUrl = function(imagePair) {
var before =
imagePair[constants.KEY__IMAGEPAIRS__IMAGE_A_URL] + "_png-vs-" +
imagePair[constants.KEY__IMAGEPAIRS__IMAGE_B_URL] + "_png";
return before.replace(/[^\w\-]/g, "_") + ".png";
};
}
);

View File

@ -377,10 +377,10 @@
<div ng-if="imagePair[constants.KEY__IMAGEPAIRS__IS_DIFFERENT]"
title="{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__NUM_DIFF_PIXELS] | number:0}} of {{(100 * imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__NUM_DIFF_PIXELS] / imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__PERCENT_DIFF_PIXELS]) | number:0}} pixels ({{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__PERCENT_DIFF_PIXELS].toFixed(4)}}%) differ from expectation.">
<a href="{{imageSets[constants.KEY__IMAGESETS__SET__WHITEDIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{getImageDiffRelativeUrl(imagePair)}}" target="_blank">View Image</a><br/>
<a href="{{imageSets[constants.KEY__IMAGESETS__SET__WHITEDIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__WHITE_DIFF_URL]}}" target="_blank">View Image</a><br/>
<img ng-if="showThumbnails"
width="{{imageSize}}"
ng-src="{{imageSets[constants.KEY__IMAGESETS__SET__WHITEDIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{getImageDiffRelativeUrl(imagePair)}}" />
ng-src="{{imageSets[constants.KEY__IMAGESETS__SET__WHITEDIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__WHITE_DIFF_URL]}}" />
<br/>
{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__PERCENT_DIFF_PIXELS].toFixed(4)}}%
({{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__NUM_DIFF_PIXELS]}})
@ -396,11 +396,11 @@
<div ng-if="imagePair[constants.KEY__IMAGEPAIRS__IS_DIFFERENT]"
title="Perceptual difference measure is {{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF].toFixed(4)}}%. Maximum difference per channel: R={{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL][0]}}, G={{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL][1]}}, B={{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL][2]}}">
<a href="{{imageSets[constants.KEY__IMAGESETS__SET__DIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{getImageDiffRelativeUrl(imagePair)}}" target="_blank">View Image</a><br/>
<a href="{{imageSets[constants.KEY__IMAGESETS__SET__DIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__DIFF_URL]}}" target="_blank">View Image</a><br/>
<img ng-if="showThumbnails"
ng-style="{backgroundColor: pixelDiffBgColor}"
width="{{imageSize}}"
ng-src="{{imageSets[constants.KEY__IMAGESETS__SET__DIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{getImageDiffRelativeUrl(imagePair)}}" />
ng-src="{{imageSets[constants.KEY__IMAGESETS__SET__DIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__DIFF_URL]}}" />
<br/>
{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF].toFixed(4)}}%
{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL]}}

View File

@ -1031,27 +1031,5 @@ Loader.controller(
return $scope.hexColorString(v, v, v);
};
/**
* Returns the last path component of image diff URL for a given ImagePair.
*
* Depending on which diff this is (whitediffs, pixeldiffs, etc.) this
* will be relative to different base URLs.
*
* We must keep this function in sync with _get_difference_locator() in
* ../imagediffdb.py
*
* @param imagePair: ImagePair to generate image diff URL for
*/
// TODO (stephana): this is a temporary fix. A fix is in the works
// to get rid of this function and include the URL in the data
// sent from the backend.
$scope.getImageDiffRelativeUrl = function(imagePair) {
var before =
imagePair[constants.KEY__IMAGEPAIRS__IMAGE_A_URL] + "_png-vs-" +
imagePair[constants.KEY__IMAGEPAIRS__IMAGE_B_URL] + "_png";
return before.replace(/[^\w\-]/g, "_") + ".png";
};
}
);

View File

@ -365,10 +365,10 @@
<div ng-if="imagePair[constants.KEY__IMAGEPAIRS__IS_DIFFERENT]"
title="{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__NUM_DIFF_PIXELS] | number:0}} of {{(100 * imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__NUM_DIFF_PIXELS] / imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__PERCENT_DIFF_PIXELS]) | number:0}} pixels ({{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__PERCENT_DIFF_PIXELS].toFixed(4)}}%) differ from expectation.">
<a href="{{imageSets[constants.KEY__IMAGESETS__SET__WHITEDIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{getImageDiffRelativeUrl(imagePair)}}" target="_blank">View Image</a><br/>
<a href="{{imageSets[constants.KEY__IMAGESETS__SET__WHITEDIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__WHITE_DIFF_URL]}}" target="_blank">View Image</a><br/>
<img ng-if="showThumbnails"
width="{{imageSize}}"
ng-src="{{imageSets[constants.KEY__IMAGESETS__SET__WHITEDIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{getImageDiffRelativeUrl(imagePair)}}" />
ng-src="{{imageSets[constants.KEY__IMAGESETS__SET__WHITEDIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__WHITE_DIFF_URL]}}" />
<br/>
{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__PERCENT_DIFF_PIXELS].toFixed(4)}}%
({{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__NUM_DIFF_PIXELS]}})
@ -384,11 +384,11 @@
<div ng-if="imagePair[constants.KEY__IMAGEPAIRS__IS_DIFFERENT]"
title="Perceptual difference measure is {{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF].toFixed(4)}}%. Maximum difference per channel: R={{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL][0]}}, G={{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL][1]}}, B={{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL][2]}}">
<a href="{{imageSets[constants.KEY__IMAGESETS__SET__DIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{getImageDiffRelativeUrl(imagePair)}}" target="_blank">View Image</a><br/>
<a href="{{imageSets[constants.KEY__IMAGESETS__SET__DIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__DIFF_URL]}}" target="_blank">View Image</a><br/>
<img ng-if="showThumbnails"
ng-style="{backgroundColor: pixelDiffBgColor}"
width="{{imageSize}}"
ng-src="{{imageSets[constants.KEY__IMAGESETS__SET__DIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{getImageDiffRelativeUrl(imagePair)}}" />
ng-src="{{imageSets[constants.KEY__IMAGESETS__SET__DIFFS][constants.KEY__IMAGESETS__FIELD__BASE_URL]}}/{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__DIFF_URL]}}" />
<br/>
{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF].toFixed(4)}}%
{{imagePair[constants.KEY__IMAGEPAIRS__DIFFERENCES][constants.KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL]}}

View File

@ -104,7 +104,7 @@
"test"
],
"header": {
"dataHash": "-5829724510169924592",
"dataHash": "-8474691963189557240",
"isEditable": false,
"isExported": true,
"schemaVersion": 5,
@ -192,6 +192,7 @@
},
{
"differenceData": {
"diffUrl": "bitmap-64bitMD5_displacement_11401048196735046263_png_png-vs-bitmap-64bitMD5_displacement_5698561127291561694_png_png.png",
"maxDiffPerChannel": [
136,
68,
@ -199,7 +200,8 @@
],
"numDifferingPixels": 6081,
"percentDifferingPixels": 2.4324,
"perceptualDifference": 1.9172010000000057
"perceptualDifference": 1.9172010000000057,
"whiteDiffUrl": "bitmap-64bitMD5_displacement_11401048196735046263_png_png-vs-bitmap-64bitMD5_displacement_5698561127291561694_png_png.png"
},
"extraColumns": {
"builder": "Test-Builder-We-Have-No-Expectations-File-For",
@ -213,6 +215,7 @@
},
{
"differenceData": {
"diffUrl": "bitmap-64bitMD5_bigblurs_17309852422285247848_png_png-vs-bitmap-64bitMD5_bigblurs_1822195599289208664_png_png.png",
"maxDiffPerChannel": [
255,
221,
@ -220,7 +223,8 @@
],
"numDifferingPixels": 50097,
"percentDifferingPixels": 30.5767822265625,
"perceptualDifference": 3.391725000000008
"perceptualDifference": 3.391725000000008,
"whiteDiffUrl": "bitmap-64bitMD5_bigblurs_17309852422285247848_png_png-vs-bitmap-64bitMD5_bigblurs_1822195599289208664_png_png.png"
},
"extraColumns": {
"builder": "Test-Builder-We-Have-No-Expectations-File-For",
@ -256,6 +260,7 @@
},
{
"differenceData": {
"diffUrl": "bitmap-64bitMD5_displacement_11401048196735046263_png_png-vs-bitmap-64bitMD5_displacement_5698561127291561694_png_png.png",
"maxDiffPerChannel": [
136,
68,
@ -263,7 +268,8 @@
],
"numDifferingPixels": 6081,
"percentDifferingPixels": 2.4324,
"perceptualDifference": 1.9172010000000057
"perceptualDifference": 1.9172010000000057,
"whiteDiffUrl": "bitmap-64bitMD5_displacement_11401048196735046263_png_png-vs-bitmap-64bitMD5_displacement_5698561127291561694_png_png.png"
},
"extraColumns": {
"builder": "Test-Mac10.7-MacMini4.1-GeForce320M-x86_64-Debug",
@ -277,6 +283,7 @@
},
{
"differenceData": {
"diffUrl": "bitmap-64bitMD5_bigblurs_17309852422285247848_png_png-vs-bitmap-64bitMD5_bigblurs_1822195599289208664_png_png.png",
"maxDiffPerChannel": [
255,
221,
@ -284,7 +291,8 @@
],
"numDifferingPixels": 50097,
"percentDifferingPixels": 30.5767822265625,
"perceptualDifference": 3.391725000000008
"perceptualDifference": 3.391725000000008,
"whiteDiffUrl": "bitmap-64bitMD5_bigblurs_17309852422285247848_png_png-vs-bitmap-64bitMD5_bigblurs_1822195599289208664_png_png.png"
},
"extraColumns": {
"builder": "Test-Mac10.7-MacMini4.1-GeForce320M-x86_64-Debug",

View File

@ -120,7 +120,7 @@
"config"
],
"header": {
"dataHash": "-7804718549064096650",
"dataHash": "6366271140430198826",
"isEditable": false,
"isExported": true,
"schemaVersion": 5,
@ -131,6 +131,7 @@
"imagePairs": [
{
"differenceData": {
"diffUrl": "bitmap-64bitMD5_texdata_2736593828543197285_png_png-vs-bitmap-64bitMD5_texdata_3695033638604474475_png_png.png",
"maxDiffPerChannel": [
128,
128,
@ -138,7 +139,8 @@
],
"numDifferingPixels": 120000,
"percentDifferingPixels": 75.0,
"perceptualDifference": 50.122499
"perceptualDifference": 50.122499,
"whiteDiffUrl": "bitmap-64bitMD5_texdata_2736593828543197285_png_png-vs-bitmap-64bitMD5_texdata_3695033638604474475_png_png.png"
},
"expectations": {
"bugs": null,
@ -157,6 +159,7 @@
},
{
"differenceData": {
"diffUrl": "bitmap-64bitMD5_filterbitmap_checkerboard_192_192_9917960313903939620_png_png-vs-bitmap-64bitMD5_filterbitmap_checkerboard_192_192_4719210487426381700_png_png.png",
"maxDiffPerChannel": [
255,
255,
@ -164,7 +167,8 @@
],
"numDifferingPixels": 765891,
"percentDifferingPixels": 97.38807678222656,
"perceptualDifference": 25.256985
"perceptualDifference": 25.256985,
"whiteDiffUrl": "bitmap-64bitMD5_filterbitmap_checkerboard_192_192_9917960313903939620_png_png-vs-bitmap-64bitMD5_filterbitmap_checkerboard_192_192_4719210487426381700_png_png.png"
},
"expectations": {
"bugs": [
@ -185,6 +189,7 @@
},
{
"differenceData": {
"diffUrl": "bitmap-64bitMD5_filterbitmap_checkerboard_192_192_9917960313903939620_png_png-vs-bitmap-64bitMD5_filterbitmap_checkerboard_192_192_3154864687054945306_png_png.png",
"maxDiffPerChannel": [
255,
255,
@ -192,7 +197,8 @@
],
"numDifferingPixels": 422432,
"percentDifferingPixels": 53.715006510416664,
"perceptualDifference": 25.120543999999995
"perceptualDifference": 25.120543999999995,
"whiteDiffUrl": "bitmap-64bitMD5_filterbitmap_checkerboard_192_192_9917960313903939620_png_png-vs-bitmap-64bitMD5_filterbitmap_checkerboard_192_192_3154864687054945306_png_png.png"
},
"expectations": {
"bugs": [