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

Side by Side Diff: tools/pdf-comparison.sh

Issue 1924513002: pdf comparison tool (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-04-26 (Tuesday) 15:17:41 EDT Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/sh
2
3 # Copyright 2016 Google Inc.
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8 # This tool compares the PDF output of Skia's DM tool of two commits.
9
10 CONTROL_COMMIT="$1"
11 EXPERIMENT_COMMIT="$2"
12
13 SOURCE="${3:-gm}" # could be 'skp'
14
15 if ! [ "$1" ] || ! [ "$2" ]; then
16 echo "usage:" >&2
17 echo " $0 CONTROL_COMMIT EXPERIMENT_COMMIT [SOURCE]" >&2
18 exit 1
19 fi
20
21 BAD=''
22 for CMD in 'python' 'ninja' 'pdfium_test' 'timeout' 'skdiff'; do
23 if ! command -v "$CMD" > /dev/null ; then
24 echo "could not find $CMD command in PATH." >&2
25 BAD=1
26 fi
27 done
28 if [ "$BAD" ]; then exit 1; fi
29
30 cd "$(dirname "$0")/.."
31 if [ "$(git diff --shortstat)" ]; then
32 echo "please stash your changes" >&2
33 exit 1
34 fi
35
36 DIR=$(mktemp -d "${TMPDIR:-/tmp}/skpdf.XXXXXXXXXX")
37 EXP="${DIR}/exp"
38 CON="${DIR}/con"
39
40 set -e
41
42 git checkout "$EXPERIMENT_COMMIT"
43 python bin/sync-and-gyp && ninja -C out/Release dm
44 out/Release/dm --src "$SOURCE" --config pdf -w "$EXP"
45
46 git checkout "$CONTROL_COMMIT"
47 python bin/sync-and-gyp && ninja -C out/Release dm
48 out/Release/dm --src "$SOURCE" --config pdf -w "$CON"
49
50 set +e
51
52 EXP_DIR="${EXP}/pdf/${SOURCE}"
53 CON_DIR="${CON}/pdf/${SOURCE}"
54
55 DIFFS=''
56 # remove byte-identical PDFs
57 for con in "$CON_DIR"/*pdf; do
58 exp="$EXP_DIR/$(basename "$con")"
59 if diff "$con" "$exp" > /dev/null; then
60 rm "$con" "$exp" # no difference
61 else
62 echo "PDF differs: $(basename "$con")"
63 DIFFS=1
64 fi
65 done
66 if [ -z "$DIFFS" ]; then
67 echo 'All PDFs are byte-identical!'
68 rm -r "$DIR"
69 exit 0;
70 fi
71
72 # rasterize the remaining PDFs
73 for pdf in "$CON_DIR"/*pdf "$EXP_DIR"/*pdf ; do
74 # timeout is from GNU coreutils
75 if timeout 10 pdfium_test --png "$pdf"; then
76 rm "$pdf"
77 else
78 echo "pdfium_test '$pdf' failed."
79 fi
80 done
81
82 DIFFS=''
83 # remove byte-identical PNGs:
84 for con in "$CON_DIR"/*.png; do
85 exp="$EXP_DIR/$(basename "$con")"
86 if diff "$con" "$exp"; then
87 rm "$exp" "$con"
88 else
89 echo "PNG differs: $(basename "$con")"
90 DIFFS=1
91 fi
92 done
93 if [ -z "$DIFFS" ]; then
94 echo 'All PNGs are byte-identical!'
95 rm -r "$DIR"
96 exit 0;
97 fi
98
99 # run remaining PNG files through skdiff:
100 DIFF_DIR="${DIR}/skdiffout"
101 skdiff "$CON_DIR" "$EXP_DIR" "$DIFF_DIR"
102 echo "'$DIFF_DIR/index.html'"
103
104 if [ $(uname) = 'Darwin' ] ; then
105 open "$DIFF_DIR/index.html" # look at diffs
106 elif [ $(uname) = 'Linux' ] ; then
107 xdg-open "$DIFF_DIR/index.html" # look at diffs
108 fi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698