OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "LazyDecodeBitmap.h" | 8 #include "LazyDecodeBitmap.h" |
9 #include "CopyTilesRenderer.h" | 9 #include "CopyTilesRenderer.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
11 #include "SkDevice.h" | 11 #include "SkDevice.h" |
12 #include "SkCommandLineFlags.h" | 12 #include "SkCommandLineFlags.h" |
13 #include "SkGraphics.h" | 13 #include "SkGraphics.h" |
14 #include "SkImageDecoder.h" | 14 #include "SkImageDecoder.h" |
15 #include "SkImageEncoder.h" | 15 #include "SkImageEncoder.h" |
16 #include "SkMath.h" | 16 #include "SkMath.h" |
17 #include "SkOSFile.h" | 17 #include "SkOSFile.h" |
18 #include "SkPicture.h" | 18 #include "SkPicture.h" |
19 #include "SkPictureRecorder.h" | 19 #include "SkPictureRecorder.h" |
20 #include "SkStream.h" | 20 #include "SkStream.h" |
21 #include "SkString.h" | 21 #include "SkString.h" |
22 | 22 |
23 #include "image_expectations.h" | 23 #include "image_expectations.h" |
24 #include "PictureRenderer.h" | 24 #include "PictureRenderer.h" |
25 #include "PictureRenderingFlags.h" | 25 #include "PictureRenderingFlags.h" |
26 #include "picture_utils.h" | 26 #include "picture_utils.h" |
27 | 27 |
| 28 #include <stdlib.h> |
| 29 |
28 // Flags used by this file, alphabetically: | 30 // Flags used by this file, alphabetically: |
29 DEFINE_bool(bench_record, false, "If true, drop into an infinite loop of recordi
ng the picture."); | 31 DEFINE_bool(bench_record, false, "If true, drop into an infinite loop of recordi
ng the picture."); |
30 DECLARE_bool(deferImageDecoding); | 32 DECLARE_bool(deferImageDecoding); |
31 DEFINE_string(descriptions, "", "one or more key=value pairs to add to the descr
iptions section " | 33 DEFINE_string(descriptions, "", "one or more key=value pairs to add to the descr
iptions section " |
32 "of the JSON summary."); | 34 "of the JSON summary."); |
33 DEFINE_string(imageBaseGSUrl, "", "The Google Storage image base URL the images
are stored in."); | 35 DEFINE_string(imageBaseGSUrl, "", "The Google Storage image base URL the images
are stored in."); |
34 DEFINE_int32(maxComponentDiff, 256, "Maximum diff on a component, 0 - 256. Compo
nents that differ " | 36 DEFINE_int32(maxComponentDiff, 256, "Maximum diff on a component, 0 - 256. Compo
nents that differ " |
35 "by more than this amount are considered errors, though all diffs a
re reported. " | 37 "by more than this amount are considered errors, though all diffs a
re reported. " |
36 "Requires --validate."); | 38 "Requires --validate."); |
37 DEFINE_string(mismatchPath, "", "Write images for tests that failed due to " | 39 DEFINE_string(mismatchPath, "", "Write images for tests that failed due to " |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 214 |
213 return success; | 215 return success; |
214 } | 216 } |
215 | 217 |
216 static inline int getByte(uint32_t value, int index) { | 218 static inline int getByte(uint32_t value, int index) { |
217 SkASSERT(0 <= index && index < 4); | 219 SkASSERT(0 <= index && index < 4); |
218 return (value >> (index * 8)) & 0xFF; | 220 return (value >> (index * 8)) & 0xFF; |
219 } | 221 } |
220 | 222 |
221 static int MaxByteDiff(uint32_t v1, uint32_t v2) { | 223 static int MaxByteDiff(uint32_t v1, uint32_t v2) { |
222 return SkMax32(SkMax32(abs(getByte(v1, 0) - getByte(v2, 0)), abs(getByte(v1,
1) - getByte(v2, 1))), | 224 return SkMax32(SkMax32(SkTAbs(getByte(v1, 0) - getByte(v2, 0)), SkTAbs(getBy
te(v1, 1) - getByte(v2, 1))), |
223 SkMax32(abs(getByte(v1, 2) - getByte(v2, 2)), abs(getByte(v1,
3) - getByte(v2, 3)))); | 225 SkMax32(SkTAbs(getByte(v1, 2) - getByte(v2, 2)), SkTAbs(getBy
te(v1, 3) - getByte(v2, 3)))); |
224 } | 226 } |
225 | 227 |
226 class AutoRestoreBbhType { | 228 class AutoRestoreBbhType { |
227 public: | 229 public: |
228 AutoRestoreBbhType() { | 230 AutoRestoreBbhType() { |
229 fRenderer = NULL; | 231 fRenderer = NULL; |
230 fSavedBbhType = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; | 232 fSavedBbhType = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; |
231 } | 233 } |
232 | 234 |
233 void set(sk_tools::PictureRenderer* renderer, | 235 void set(sk_tools::PictureRenderer* renderer, |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); | 503 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); |
502 } | 504 } |
503 return 0; | 505 return 0; |
504 } | 506 } |
505 | 507 |
506 #if !defined SK_BUILD_FOR_IOS | 508 #if !defined SK_BUILD_FOR_IOS |
507 int main(int argc, char * const argv[]) { | 509 int main(int argc, char * const argv[]) { |
508 return tool_main(argc, (char**) argv); | 510 return tool_main(argc, (char**) argv); |
509 } | 511 } |
510 #endif | 512 #endif |
OLD | NEW |