epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
bsalomon@google.com | 971d0c8 | 2011-08-19 17:22:05 +0000 | [diff] [blame] | 7 | |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 8 | #include "gm.h" |
epoger@google.com | 7bc13a6 | 2012-02-14 14:53:59 +0000 | [diff] [blame] | 9 | #include "system_preferences.h" |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 10 | #include "SkColorPriv.h" |
reed@google.com | 8a85d0c | 2011-06-24 19:12:12 +0000 | [diff] [blame] | 11 | #include "SkData.h" |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 12 | #include "SkDeferredCanvas.h" |
bsalomon@google.com | 971d0c8 | 2011-08-19 17:22:05 +0000 | [diff] [blame] | 13 | #include "SkDevice.h" |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 14 | #include "SkDrawFilter.h" |
scroggo@google.com | 5af9b20 | 2012-06-04 17:17:36 +0000 | [diff] [blame] | 15 | #include "SkGPipe.h" |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 16 | #include "SkGraphics.h" |
| 17 | #include "SkImageDecoder.h" |
| 18 | #include "SkImageEncoder.h" |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 19 | #include "SkOSFile.h" |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 20 | #include "SkPicture.h" |
robertphillips@google.com | 977b9c8 | 2012-06-05 19:35:09 +0000 | [diff] [blame] | 21 | #include "SkRefCnt.h" |
scroggo@google.com | 72c9672 | 2012-06-06 21:07:10 +0000 | [diff] [blame] | 22 | #include "SkStream.h" |
bsalomon@google.com | 2a48c3a | 2012-08-03 14:54:45 +0000 | [diff] [blame] | 23 | #include "SkTArray.h" |
scroggo@google.com | 72c9672 | 2012-06-06 21:07:10 +0000 | [diff] [blame] | 24 | #include "SamplePipeControllers.h" |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 25 | |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 26 | #if SK_SUPPORT_GPU |
| 27 | #include "GrContextFactory.h" |
| 28 | #include "GrRenderTarget.h" |
| 29 | #include "SkGpuDevice.h" |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 30 | typedef GrContextFactory::GLContextType GLContextType; |
| 31 | #else |
| 32 | class GrContext; |
| 33 | class GrRenderTarget; |
| 34 | typedef int GLContextType; |
| 35 | #endif |
| 36 | |
mike@reedtribe.org | 10afbef | 2011-12-30 16:02:53 +0000 | [diff] [blame] | 37 | static bool gForceBWtext; |
| 38 | |
reed@google.com | 8923c6c | 2011-11-08 14:59:38 +0000 | [diff] [blame] | 39 | extern bool gSkSuppressFontCachePurgeSpew; |
| 40 | |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 41 | #ifdef SK_SUPPORT_PDF |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 42 | #include "SkPDFDevice.h" |
| 43 | #include "SkPDFDocument.h" |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 44 | #endif |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 45 | |
epoger@google.com | e3cc2eb | 2012-01-18 20:11:13 +0000 | [diff] [blame] | 46 | // Until we resolve http://code.google.com/p/skia/issues/detail?id=455 , |
| 47 | // stop writing out XPS-format image baselines in gm. |
| 48 | #undef SK_SUPPORT_XPS |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 49 | #ifdef SK_SUPPORT_XPS |
| 50 | #include "SkXPSDevice.h" |
| 51 | #endif |
| 52 | |
reed@google.com | 46cce91 | 2011-06-29 12:54:46 +0000 | [diff] [blame] | 53 | #ifdef SK_BUILD_FOR_MAC |
| 54 | #include "SkCGUtils.h" |
bsalomon@google.com | 0a09eef | 2011-06-29 19:42:58 +0000 | [diff] [blame] | 55 | #define CAN_IMAGE_PDF 1 |
reed@google.com | 46cce91 | 2011-06-29 12:54:46 +0000 | [diff] [blame] | 56 | #else |
bsalomon@google.com | 0a09eef | 2011-06-29 19:42:58 +0000 | [diff] [blame] | 57 | #define CAN_IMAGE_PDF 0 |
reed@google.com | 46cce91 | 2011-06-29 12:54:46 +0000 | [diff] [blame] | 58 | #endif |
| 59 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 60 | typedef int ErrorBitfield; |
| 61 | const static ErrorBitfield ERROR_NONE = 0x00; |
| 62 | const static ErrorBitfield ERROR_NO_GPU_CONTEXT = 0x01; |
| 63 | const static ErrorBitfield ERROR_PIXEL_MISMATCH = 0x02; |
| 64 | const static ErrorBitfield ERROR_DIMENSION_MISMATCH = 0x04; |
| 65 | const static ErrorBitfield ERROR_READING_REFERENCE_IMAGE = 0x08; |
| 66 | const static ErrorBitfield ERROR_WRITING_REFERENCE_IMAGE = 0x10; |
| 67 | |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 68 | using namespace skiagm; |
| 69 | |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 70 | /* |
| 71 | * Return the max of the difference (in absolute value) for any component. |
| 72 | * Returns 0 if they are equal. |
| 73 | */ |
| 74 | static int compute_PMColor_maxDiff(SkPMColor c0, SkPMColor c1) { |
| 75 | int da = SkAbs32(SkGetPackedA32(c0) - SkGetPackedA32(c1)); |
| 76 | int dr = SkAbs32(SkGetPackedR32(c0) - SkGetPackedR32(c1)); |
| 77 | int dg = SkAbs32(SkGetPackedG32(c0) - SkGetPackedG32(c1)); |
| 78 | int db = SkAbs32(SkGetPackedB32(c0) - SkGetPackedB32(c1)); |
| 79 | return SkMax32(da, SkMax32(dr, SkMax32(dg, db))); |
| 80 | } |
| 81 | |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 82 | class Iter { |
| 83 | public: |
| 84 | Iter() { |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 85 | this->reset(); |
| 86 | } |
| 87 | |
| 88 | void reset() { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 89 | fReg = GMRegistry::Head(); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 90 | } |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 91 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 92 | GM* next() { |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 93 | if (fReg) { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 94 | GMRegistry::Factory fact = fReg->factory(); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 95 | fReg = fReg->next(); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 96 | return fact(0); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 97 | } |
| 98 | return NULL; |
| 99 | } |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 100 | |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 101 | static int Count() { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 102 | const GMRegistry* reg = GMRegistry::Head(); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 103 | int count = 0; |
| 104 | while (reg) { |
| 105 | count += 1; |
| 106 | reg = reg->next(); |
| 107 | } |
| 108 | return count; |
| 109 | } |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 110 | |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 111 | private: |
| 112 | const GMRegistry* fReg; |
| 113 | }; |
| 114 | |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 115 | enum Backend { |
| 116 | kRaster_Backend, |
| 117 | kGPU_Backend, |
| 118 | kPDF_Backend, |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 119 | kXPS_Backend, |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 120 | }; |
| 121 | |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 122 | enum ConfigFlags { |
| 123 | kNone_ConfigFlag = 0x0, |
| 124 | /* Write GM images if a write path is provided. */ |
| 125 | kWrite_ConfigFlag = 0x1, |
epoger@google.com | f28dd8a | 2012-10-25 16:27:34 +0000 | [diff] [blame] | 126 | /* Read reference GM images if a read path is provided. */ |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 127 | kRead_ConfigFlag = 0x2, |
| 128 | kRW_ConfigFlag = (kWrite_ConfigFlag | kRead_ConfigFlag), |
| 129 | }; |
| 130 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 131 | struct ConfigData { |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 132 | SkBitmap::Config fConfig; |
| 133 | Backend fBackend; |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 134 | GLContextType fGLContextType; // GPU backend only |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 135 | int fSampleCnt; // GPU backend only |
| 136 | ConfigFlags fFlags; |
| 137 | const char* fName; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
mike@reedtribe.org | 10afbef | 2011-12-30 16:02:53 +0000 | [diff] [blame] | 140 | class BWTextDrawFilter : public SkDrawFilter { |
| 141 | public: |
| 142 | virtual void filter(SkPaint*, Type) SK_OVERRIDE; |
| 143 | }; |
| 144 | void BWTextDrawFilter::filter(SkPaint* p, Type t) { |
| 145 | if (kText_Type == t) { |
| 146 | p->setAntiAlias(false); |
| 147 | } |
| 148 | } |
| 149 | |
scroggo@google.com | 565254b | 2012-06-28 15:41:32 +0000 | [diff] [blame] | 150 | struct PipeFlagComboData { |
| 151 | const char* name; |
| 152 | uint32_t flags; |
| 153 | }; |
| 154 | |
| 155 | static PipeFlagComboData gPipeWritingFlagCombos[] = { |
| 156 | { "", 0 }, |
| 157 | { " cross-process", SkGPipeWriter::kCrossProcess_Flag }, |
scroggo | b3c0f48 | 2012-07-02 19:07:57 +0000 | [diff] [blame] | 158 | { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag |
scroggo@google.com | 15011ee | 2012-07-26 20:03:32 +0000 | [diff] [blame] | 159 | | SkGPipeWriter::kSharedAddressSpace_Flag } |
scroggo@google.com | 565254b | 2012-06-28 15:41:32 +0000 | [diff] [blame] | 160 | }; |
| 161 | |
scroggo@google.com | 5af9b20 | 2012-06-04 17:17:36 +0000 | [diff] [blame] | 162 | |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 163 | class GMMain { |
| 164 | public: |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 165 | GMMain() { |
| 166 | // Set default values of member variables, which tool_main() |
| 167 | // may override. |
| 168 | fNotifyMissingReadReference = true; |
| 169 | fUseFileHierarchy = false; |
| 170 | } |
| 171 | |
| 172 | SkString make_name(const char shortName[], const char configName[]) { |
| 173 | SkString name; |
| 174 | if (fUseFileHierarchy) { |
| 175 | name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); |
| 176 | } else { |
| 177 | name.appendf("%s_%s", shortName, configName); |
| 178 | } |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 179 | return name; |
| 180 | } |
| 181 | |
| 182 | static SkString make_filename(const char path[], |
| 183 | const char pathSuffix[], |
| 184 | const SkString& name, |
| 185 | const char suffix[]) { |
| 186 | SkString filename(path); |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 187 | if (filename.endsWith(SkPATH_SEPARATOR)) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 188 | filename.remove(filename.size() - 1, 1); |
| 189 | } |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 190 | filename.appendf("%s%c%s.%s", pathSuffix, SkPATH_SEPARATOR, |
| 191 | name.c_str(), suffix); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 192 | return filename; |
| 193 | } |
| 194 | |
| 195 | /* since PNG insists on unpremultiplying our alpha, we take no |
| 196 | precision chances and force all pixels to be 100% opaque, |
| 197 | otherwise on compare we may not get a perfect match. |
| 198 | */ |
| 199 | static void force_all_opaque(const SkBitmap& bitmap) { |
| 200 | SkAutoLockPixels lock(bitmap); |
| 201 | for (int y = 0; y < bitmap.height(); y++) { |
| 202 | for (int x = 0; x < bitmap.width(); x++) { |
| 203 | *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
| 204 | } |
scroggo@google.com | 565254b | 2012-06-28 15:41:32 +0000 | [diff] [blame] | 205 | } |
| 206 | } |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 207 | |
| 208 | static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { |
| 209 | SkBitmap copy; |
| 210 | bitmap.copyTo(©, SkBitmap::kARGB_8888_Config); |
| 211 | force_all_opaque(copy); |
| 212 | return SkImageEncoder::EncodeFile(path.c_str(), copy, |
| 213 | SkImageEncoder::kPNG_Type, 100); |
| 214 | } |
| 215 | |
| 216 | static inline SkPMColor compute_diff_pmcolor(SkPMColor c0, SkPMColor c1) { |
| 217 | int dr = SkGetPackedR32(c0) - SkGetPackedR32(c1); |
| 218 | int dg = SkGetPackedG32(c0) - SkGetPackedG32(c1); |
| 219 | int db = SkGetPackedB32(c0) - SkGetPackedB32(c1); |
| 220 | return SkPackARGB32(0xFF, SkAbs32(dr), SkAbs32(dg), SkAbs32(db)); |
| 221 | } |
| 222 | |
| 223 | static void compute_diff(const SkBitmap& target, const SkBitmap& base, |
| 224 | SkBitmap* diff) { |
| 225 | SkAutoLockPixels alp(*diff); |
| 226 | |
| 227 | const int w = target.width(); |
| 228 | const int h = target.height(); |
| 229 | for (int y = 0; y < h; y++) { |
| 230 | for (int x = 0; x < w; x++) { |
| 231 | SkPMColor c0 = *base.getAddr32(x, y); |
| 232 | SkPMColor c1 = *target.getAddr32(x, y); |
| 233 | SkPMColor d = 0; |
| 234 | if (c0 != c1) { |
| 235 | d = compute_diff_pmcolor(c0, c1); |
| 236 | } |
| 237 | *diff->getAddr32(x, y) = d; |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | // Compares "target" and "base" bitmaps, returning the result |
| 243 | // (ERROR_NONE if the two bitmaps are identical). |
| 244 | // |
| 245 | // If a "diff" bitmap is passed in, pixel diffs (if any) will be written |
| 246 | // into it. |
| 247 | // |
| 248 | // The "name" and "renderModeDescriptor" arguments are only used |
| 249 | // in the debug output. |
| 250 | static ErrorBitfield compare(const SkBitmap& target, const SkBitmap& base, |
| 251 | const SkString& name, |
| 252 | const char* renderModeDescriptor, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 253 | SkBitmap* diff, int* maxPixelError) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 254 | SkBitmap copy; |
| 255 | const SkBitmap* bm = ⌖ |
| 256 | if (target.config() != SkBitmap::kARGB_8888_Config) { |
| 257 | target.copyTo(©, SkBitmap::kARGB_8888_Config); |
| 258 | bm = © |
| 259 | } |
| 260 | SkBitmap baseCopy; |
| 261 | const SkBitmap* bp = &base; |
| 262 | if (base.config() != SkBitmap::kARGB_8888_Config) { |
| 263 | base.copyTo(&baseCopy, SkBitmap::kARGB_8888_Config); |
| 264 | bp = &baseCopy; |
| 265 | } |
| 266 | |
| 267 | force_all_opaque(*bm); |
| 268 | force_all_opaque(*bp); |
| 269 | |
| 270 | const int w = bm->width(); |
| 271 | const int h = bm->height(); |
| 272 | if (w != bp->width() || h != bp->height()) { |
| 273 | SkDebugf( |
| 274 | "---- %s dimensions mismatch for %s base [%d %d] current [%d %d]\n", |
| 275 | renderModeDescriptor, name.c_str(), |
| 276 | bp->width(), bp->height(), w, h); |
| 277 | return ERROR_DIMENSION_MISMATCH; |
| 278 | } |
| 279 | |
| 280 | SkAutoLockPixels bmLock(*bm); |
| 281 | SkAutoLockPixels baseLock(*bp); |
| 282 | |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 283 | int maxErr = 0; |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 284 | for (int y = 0; y < h; y++) { |
| 285 | for (int x = 0; x < w; x++) { |
| 286 | SkPMColor c0 = *bp->getAddr32(x, y); |
| 287 | SkPMColor c1 = *bm->getAddr32(x, y); |
| 288 | if (c0 != c1) { |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 289 | maxErr = SkMax32(maxErr, compute_PMColor_maxDiff(c0, c1)); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 290 | } |
| 291 | } |
| 292 | } |
| 293 | |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 294 | if (maxPixelError) { |
| 295 | *maxPixelError = maxErr; |
| 296 | } |
| 297 | if (maxErr > 0) { |
| 298 | SkDebugf( |
| 299 | "----- %s max pixel mismatch for %s is %d\n", |
| 300 | renderModeDescriptor, name.c_str(), maxErr); |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 301 | |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 302 | if (diff) { |
| 303 | diff->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 304 | diff->allocPixels(); |
| 305 | compute_diff(*bm, *bp, diff); |
| 306 | } |
| 307 | return ERROR_PIXEL_MISMATCH; |
| 308 | } |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 309 | return ERROR_NONE; |
| 310 | } |
| 311 | |
| 312 | static bool write_document(const SkString& path, |
| 313 | const SkDynamicMemoryWStream& document) { |
| 314 | SkFILEWStream stream(path.c_str()); |
| 315 | SkAutoDataUnref data(document.copyToData()); |
| 316 | return stream.writeData(data.get()); |
| 317 | } |
| 318 | |
| 319 | /// Returns true if processing should continue, false to skip the |
| 320 | /// remainder of this config for this GM. |
| 321 | //@todo thudson 22 April 2011 - could refactor this to take in |
| 322 | // a factory to generate the context, always call readPixels() |
| 323 | // (logically a noop for rasters, if wasted time), and thus collapse the |
| 324 | // GPU special case and also let this be used for SkPicture testing. |
| 325 | static void setup_bitmap(const ConfigData& gRec, SkISize& size, |
| 326 | SkBitmap* bitmap) { |
| 327 | bitmap->setConfig(gRec.fConfig, size.width(), size.height()); |
| 328 | bitmap->allocPixels(); |
| 329 | bitmap->eraseColor(0); |
| 330 | } |
| 331 | |
| 332 | static void installFilter(SkCanvas* canvas) { |
| 333 | if (gForceBWtext) { |
| 334 | canvas->setDrawFilter(new BWTextDrawFilter)->unref(); |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | static void invokeGM(GM* gm, SkCanvas* canvas, bool isPDF = false) { |
| 339 | SkAutoCanvasRestore acr(canvas, true); |
| 340 | |
| 341 | if (!isPDF) { |
| 342 | canvas->concat(gm->getInitialTransform()); |
| 343 | } |
| 344 | installFilter(canvas); |
| 345 | gm->draw(canvas); |
| 346 | canvas->setDrawFilter(NULL); |
| 347 | } |
| 348 | |
| 349 | static ErrorBitfield generate_image(GM* gm, const ConfigData& gRec, |
| 350 | GrContext* context, |
| 351 | GrRenderTarget* rt, |
| 352 | SkBitmap* bitmap, |
| 353 | bool deferred) { |
| 354 | SkISize size (gm->getISize()); |
| 355 | setup_bitmap(gRec, size, bitmap); |
| 356 | |
| 357 | SkAutoTUnref<SkCanvas> canvas; |
| 358 | |
| 359 | if (gRec.fBackend == kRaster_Backend) { |
| 360 | SkAutoTUnref<SkDevice> device(new SkDevice(*bitmap)); |
| 361 | if (deferred) { |
| 362 | canvas.reset(new SkDeferredCanvas(device)); |
| 363 | } else { |
| 364 | canvas.reset(new SkCanvas(device)); |
| 365 | } |
| 366 | invokeGM(gm, canvas); |
| 367 | canvas->flush(); |
| 368 | } |
| 369 | #if SK_SUPPORT_GPU |
| 370 | else { // GPU |
| 371 | if (NULL == context) { |
| 372 | return ERROR_NO_GPU_CONTEXT; |
| 373 | } |
| 374 | SkAutoTUnref<SkDevice> device(new SkGpuDevice(context, rt)); |
| 375 | if (deferred) { |
| 376 | canvas.reset(new SkDeferredCanvas(device)); |
| 377 | } else { |
| 378 | canvas.reset(new SkCanvas(device)); |
| 379 | } |
| 380 | invokeGM(gm, canvas); |
| 381 | // the device is as large as the current rendertarget, so |
| 382 | // we explicitly only readback the amount we expect (in |
| 383 | // size) overwrite our previous allocation |
| 384 | bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth, |
| 385 | size.fHeight); |
| 386 | canvas->readPixels(bitmap, 0, 0); |
| 387 | } |
| 388 | #endif |
| 389 | return ERROR_NONE; |
| 390 | } |
| 391 | |
| 392 | static void generate_image_from_picture(GM* gm, const ConfigData& gRec, |
| 393 | SkPicture* pict, SkBitmap* bitmap) { |
| 394 | SkISize size = gm->getISize(); |
| 395 | setup_bitmap(gRec, size, bitmap); |
| 396 | SkCanvas canvas(*bitmap); |
| 397 | installFilter(&canvas); |
| 398 | canvas.drawPicture(*pict); |
| 399 | } |
| 400 | |
| 401 | static void generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) { |
| 402 | #ifdef SK_SUPPORT_PDF |
| 403 | SkMatrix initialTransform = gm->getInitialTransform(); |
| 404 | SkISize pageSize = gm->getISize(); |
| 405 | SkPDFDevice* dev = NULL; |
| 406 | if (initialTransform.isIdentity()) { |
| 407 | dev = new SkPDFDevice(pageSize, pageSize, initialTransform); |
| 408 | } else { |
| 409 | SkRect content = SkRect::MakeWH(SkIntToScalar(pageSize.width()), |
| 410 | SkIntToScalar(pageSize.height())); |
| 411 | initialTransform.mapRect(&content); |
| 412 | content.intersect(0, 0, SkIntToScalar(pageSize.width()), |
| 413 | SkIntToScalar(pageSize.height())); |
| 414 | SkISize contentSize = |
| 415 | SkISize::Make(SkScalarRoundToInt(content.width()), |
| 416 | SkScalarRoundToInt(content.height())); |
| 417 | dev = new SkPDFDevice(pageSize, contentSize, initialTransform); |
| 418 | } |
| 419 | SkAutoUnref aur(dev); |
| 420 | |
| 421 | SkCanvas c(dev); |
| 422 | invokeGM(gm, &c, true); |
| 423 | |
| 424 | SkPDFDocument doc; |
| 425 | doc.appendPage(dev); |
| 426 | doc.emitPDF(&pdf); |
| 427 | #endif |
| 428 | } |
| 429 | |
| 430 | static void generate_xps(GM* gm, SkDynamicMemoryWStream& xps) { |
| 431 | #ifdef SK_SUPPORT_XPS |
| 432 | SkISize size = gm->getISize(); |
| 433 | |
| 434 | SkSize trimSize = SkSize::Make(SkIntToScalar(size.width()), |
| 435 | SkIntToScalar(size.height())); |
| 436 | static const SkScalar inchesPerMeter = SkScalarDiv(10000, 254); |
| 437 | static const SkScalar upm = 72 * inchesPerMeter; |
| 438 | SkVector unitsPerMeter = SkPoint::Make(upm, upm); |
| 439 | static const SkScalar ppm = 200 * inchesPerMeter; |
| 440 | SkVector pixelsPerMeter = SkPoint::Make(ppm, ppm); |
| 441 | |
| 442 | SkXPSDevice* dev = new SkXPSDevice(); |
| 443 | SkAutoUnref aur(dev); |
| 444 | |
| 445 | SkCanvas c(dev); |
| 446 | dev->beginPortfolio(&xps); |
| 447 | dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize); |
| 448 | invokeGM(gm, &c); |
| 449 | dev->endSheet(); |
| 450 | dev->endPortfolio(); |
| 451 | |
| 452 | #endif |
| 453 | } |
| 454 | |
| 455 | static ErrorBitfield write_reference_image( |
| 456 | const ConfigData& gRec, const char writePath [], |
| 457 | const char renderModeDescriptor [], const SkString& name, |
| 458 | SkBitmap& bitmap, SkDynamicMemoryWStream* document) { |
| 459 | SkString path; |
| 460 | bool success = false; |
| 461 | if (gRec.fBackend == kRaster_Backend || |
| 462 | gRec.fBackend == kGPU_Backend || |
| 463 | (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { |
| 464 | |
| 465 | path = make_filename(writePath, renderModeDescriptor, name, "png"); |
| 466 | success = write_bitmap(path, bitmap); |
| 467 | } |
| 468 | if (kPDF_Backend == gRec.fBackend) { |
| 469 | path = make_filename(writePath, renderModeDescriptor, name, "pdf"); |
| 470 | success = write_document(path, *document); |
| 471 | } |
| 472 | if (kXPS_Backend == gRec.fBackend) { |
| 473 | path = make_filename(writePath, renderModeDescriptor, name, "xps"); |
| 474 | success = write_document(path, *document); |
| 475 | } |
| 476 | if (success) { |
| 477 | return ERROR_NONE; |
| 478 | } else { |
| 479 | fprintf(stderr, "FAILED to write %s\n", path.c_str()); |
| 480 | return ERROR_WRITING_REFERENCE_IMAGE; |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | // Compares bitmap "bitmap" to "referenceBitmap"; if they are |
| 485 | // different, writes out "bitmap" (in PNG format) within the |
| 486 | // diffPath subdir. |
| 487 | // |
| 488 | // Returns the ErrorBitfield from compare(), describing any differences |
| 489 | // between "bitmap" and "referenceBitmap" (or ERROR_NONE if there are none). |
| 490 | static ErrorBitfield compare_to_reference_image_in_memory( |
| 491 | const SkString& name, SkBitmap &bitmap, const SkBitmap& referenceBitmap, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 492 | const char diffPath [], const char renderModeDescriptor [], |
| 493 | int* maxPixelError) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 494 | ErrorBitfield errors; |
| 495 | SkBitmap diffBitmap; |
| 496 | errors = compare(bitmap, referenceBitmap, name, renderModeDescriptor, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 497 | diffPath ? &diffBitmap : NULL, maxPixelError); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 498 | if ((ERROR_NONE != errors) && diffPath) { |
| 499 | // write out the generated image |
| 500 | SkString genName = make_filename(diffPath, "", name, "png"); |
| 501 | if (!write_bitmap(genName, bitmap)) { |
| 502 | errors |= ERROR_WRITING_REFERENCE_IMAGE; |
| 503 | } |
| 504 | } |
| 505 | return errors; |
| 506 | } |
| 507 | |
| 508 | // Compares bitmap "bitmap" to a reference bitmap read from disk; |
| 509 | // if they are different, writes out "bitmap" (in PNG format) |
| 510 | // within the diffPath subdir. |
| 511 | // |
| 512 | // Returns a description of the difference between "bitmap" and |
| 513 | // the reference bitmap, or ERROR_READING_REFERENCE_IMAGE if |
| 514 | // unable to read the reference bitmap from disk. |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 515 | ErrorBitfield compare_to_reference_image_on_disk( |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 516 | const char readPath [], const SkString& name, SkBitmap &bitmap, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 517 | const char diffPath [], const char renderModeDescriptor [], |
| 518 | int* maxPixelError) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 519 | SkString path = make_filename(readPath, "", name, "png"); |
| 520 | SkBitmap referenceBitmap; |
| 521 | if (SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, |
| 522 | SkBitmap::kARGB_8888_Config, |
| 523 | SkImageDecoder::kDecodePixels_Mode, |
| 524 | NULL)) { |
| 525 | return compare_to_reference_image_in_memory(name, bitmap, |
| 526 | referenceBitmap, |
| 527 | diffPath, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 528 | renderModeDescriptor, |
| 529 | maxPixelError); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 530 | } else { |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 531 | if (fNotifyMissingReadReference) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 532 | fprintf(stderr, "FAILED to read %s\n", path.c_str()); |
| 533 | } |
| 534 | return ERROR_READING_REFERENCE_IMAGE; |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | // NOTE: As far as I can tell, this function is NEVER called with a |
| 539 | // non-blank renderModeDescriptor, EXCEPT when readPath and writePath are |
| 540 | // both NULL (and thus no images are read from or written to disk). |
| 541 | // So I don't trust that the renderModeDescriptor is being used for |
| 542 | // anything other than debug output these days. |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 543 | ErrorBitfield handle_test_results(GM* gm, |
| 544 | const ConfigData& gRec, |
| 545 | const char writePath [], |
| 546 | const char readPath [], |
| 547 | const char diffPath [], |
| 548 | const char renderModeDescriptor [], |
| 549 | SkBitmap& bitmap, |
| 550 | SkDynamicMemoryWStream* pdf, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 551 | const SkBitmap* referenceBitmap, |
| 552 | int* maxPixelError) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 553 | SkString name = make_name(gm->shortName(), gRec.fName); |
| 554 | ErrorBitfield retval = ERROR_NONE; |
| 555 | |
| 556 | if (readPath && (gRec.fFlags & kRead_ConfigFlag)) { |
| 557 | retval |= compare_to_reference_image_on_disk(readPath, name, bitmap, |
| 558 | diffPath, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 559 | renderModeDescriptor, |
| 560 | maxPixelError); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 561 | } |
| 562 | if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
| 563 | retval |= write_reference_image(gRec, writePath, |
| 564 | renderModeDescriptor, |
| 565 | name, bitmap, pdf); |
| 566 | } |
| 567 | if (referenceBitmap) { |
| 568 | retval |= compare_to_reference_image_in_memory( |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 569 | name, bitmap, *referenceBitmap, diffPath, renderModeDescriptor, |
| 570 | maxPixelError); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 571 | } |
| 572 | return retval; |
| 573 | } |
| 574 | |
| 575 | static SkPicture* generate_new_picture(GM* gm) { |
| 576 | // Pictures are refcounted so must be on heap |
| 577 | SkPicture* pict = new SkPicture; |
| 578 | SkISize size = gm->getISize(); |
| 579 | SkCanvas* cv = pict->beginRecording(size.width(), size.height()); |
| 580 | invokeGM(gm, cv); |
| 581 | pict->endRecording(); |
| 582 | |
| 583 | return pict; |
| 584 | } |
| 585 | |
| 586 | static SkPicture* stream_to_new_picture(const SkPicture& src) { |
| 587 | |
| 588 | // To do in-memory commiunications with a stream, we need to: |
| 589 | // * create a dynamic memory stream |
| 590 | // * copy it into a buffer |
| 591 | // * create a read stream from it |
| 592 | // ?!?! |
| 593 | |
| 594 | SkDynamicMemoryWStream storage; |
| 595 | src.serialize(&storage); |
| 596 | |
| 597 | int streamSize = storage.getOffset(); |
| 598 | SkAutoMalloc dstStorage(streamSize); |
| 599 | void* dst = dstStorage.get(); |
| 600 | //char* dst = new char [streamSize]; |
| 601 | //@todo thudson 22 April 2011 when can we safely delete [] dst? |
| 602 | storage.copyTo(dst); |
| 603 | SkMemoryStream pictReadback(dst, streamSize); |
| 604 | SkPicture* retval = new SkPicture (&pictReadback); |
| 605 | return retval; |
| 606 | } |
| 607 | |
| 608 | // Test: draw into a bitmap or pdf. |
| 609 | // Depending on flags, possibly compare to an expected image |
| 610 | // and possibly output a diff image if it fails to match. |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 611 | ErrorBitfield test_drawing(GM* gm, |
| 612 | const ConfigData& gRec, |
| 613 | const char writePath [], |
| 614 | const char readPath [], |
| 615 | const char diffPath [], |
| 616 | GrContext* context, |
| 617 | GrRenderTarget* rt, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 618 | SkBitmap* bitmap, |
| 619 | int* maxPixelError) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 620 | SkDynamicMemoryWStream document; |
| 621 | |
| 622 | if (gRec.fBackend == kRaster_Backend || |
| 623 | gRec.fBackend == kGPU_Backend) { |
| 624 | // Early exit if we can't generate the image. |
| 625 | ErrorBitfield errors = generate_image(gm, gRec, context, rt, bitmap, |
| 626 | false); |
| 627 | if (ERROR_NONE != errors) { |
| 628 | return errors; |
| 629 | } |
| 630 | } else if (gRec.fBackend == kPDF_Backend) { |
| 631 | generate_pdf(gm, document); |
| 632 | #if CAN_IMAGE_PDF |
| 633 | SkAutoDataUnref data(document.copyToData()); |
| 634 | SkMemoryStream stream(data->data(), data->size()); |
| 635 | SkPDFDocumentToBitmap(&stream, bitmap); |
| 636 | #endif |
| 637 | } else if (gRec.fBackend == kXPS_Backend) { |
| 638 | generate_xps(gm, document); |
| 639 | } |
| 640 | return handle_test_results(gm, gRec, writePath, readPath, diffPath, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 641 | "", *bitmap, &document, NULL, maxPixelError); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 642 | } |
| 643 | |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 644 | ErrorBitfield test_deferred_drawing(GM* gm, |
| 645 | const ConfigData& gRec, |
| 646 | const SkBitmap& referenceBitmap, |
| 647 | const char diffPath [], |
| 648 | GrContext* context, |
| 649 | GrRenderTarget* rt) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 650 | SkDynamicMemoryWStream document; |
| 651 | |
| 652 | if (gRec.fBackend == kRaster_Backend || |
| 653 | gRec.fBackend == kGPU_Backend) { |
| 654 | SkBitmap bitmap; |
| 655 | // Early exit if we can't generate the image, but this is |
| 656 | // expected in some cases, so don't report a test failure. |
| 657 | if (!generate_image(gm, gRec, context, rt, &bitmap, true)) { |
| 658 | return ERROR_NONE; |
| 659 | } |
| 660 | return handle_test_results(gm, gRec, NULL, NULL, diffPath, |
| 661 | "-deferred", bitmap, NULL, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 662 | &referenceBitmap, NULL); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 663 | } |
| 664 | return ERROR_NONE; |
| 665 | } |
| 666 | |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 667 | ErrorBitfield test_pipe_playback(GM* gm, |
| 668 | const ConfigData& gRec, |
| 669 | const SkBitmap& referenceBitmap, |
| 670 | const char readPath [], |
| 671 | const char diffPath []) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 672 | ErrorBitfield errors = ERROR_NONE; |
| 673 | for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
| 674 | SkBitmap bitmap; |
| 675 | SkISize size = gm->getISize(); |
| 676 | setup_bitmap(gRec, size, &bitmap); |
| 677 | SkCanvas canvas(bitmap); |
| 678 | PipeController pipeController(&canvas); |
| 679 | SkGPipeWriter writer; |
| 680 | SkCanvas* pipeCanvas = writer.startRecording( |
| 681 | &pipeController, gPipeWritingFlagCombos[i].flags); |
| 682 | invokeGM(gm, pipeCanvas); |
| 683 | writer.endRecording(); |
| 684 | SkString string("-pipe"); |
| 685 | string.append(gPipeWritingFlagCombos[i].name); |
| 686 | errors |= handle_test_results(gm, gRec, NULL, NULL, diffPath, |
| 687 | string.c_str(), bitmap, NULL, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 688 | &referenceBitmap, NULL); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 689 | if (errors != ERROR_NONE) { |
| 690 | break; |
| 691 | } |
| 692 | } |
| 693 | return errors; |
| 694 | } |
| 695 | |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 696 | ErrorBitfield test_tiled_pipe_playback( |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 697 | GM* gm, const ConfigData& gRec, const SkBitmap& referenceBitmap, |
| 698 | const char readPath [], const char diffPath []) { |
| 699 | ErrorBitfield errors = ERROR_NONE; |
| 700 | for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
| 701 | SkBitmap bitmap; |
| 702 | SkISize size = gm->getISize(); |
| 703 | setup_bitmap(gRec, size, &bitmap); |
| 704 | SkCanvas canvas(bitmap); |
| 705 | TiledPipeController pipeController(bitmap); |
| 706 | SkGPipeWriter writer; |
| 707 | SkCanvas* pipeCanvas = writer.startRecording( |
| 708 | &pipeController, gPipeWritingFlagCombos[i].flags); |
| 709 | invokeGM(gm, pipeCanvas); |
| 710 | writer.endRecording(); |
| 711 | SkString string("-tiled pipe"); |
| 712 | string.append(gPipeWritingFlagCombos[i].name); |
| 713 | errors |= handle_test_results(gm, gRec, NULL, NULL, diffPath, |
| 714 | string.c_str(), bitmap, NULL, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 715 | &referenceBitmap, NULL); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 716 | if (errors != ERROR_NONE) { |
| 717 | break; |
| 718 | } |
| 719 | } |
| 720 | return errors; |
| 721 | } |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 722 | |
| 723 | // |
| 724 | // member variables. |
| 725 | // They are public for now, to allow easier setting by tool_main(). |
| 726 | // |
| 727 | |
| 728 | // if true, emit a message when we can't find a reference image to compare |
| 729 | bool fNotifyMissingReadReference; |
| 730 | |
| 731 | bool fUseFileHierarchy; |
| 732 | |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 733 | }; // end of GMMain class definition |
scroggo@google.com | 72c9672 | 2012-06-06 21:07:10 +0000 | [diff] [blame] | 734 | |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 735 | #if SK_SUPPORT_GPU |
| 736 | static const GLContextType kDontCare_GLContextType = GrContextFactory::kNative_GLContextType; |
| 737 | #else |
| 738 | static const GLContextType kDontCare_GLContextType = 0; |
| 739 | #endif |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 740 | |
| 741 | // If the platform does not support writing PNGs of PDFs then there will be no |
epoger@google.com | f28dd8a | 2012-10-25 16:27:34 +0000 | [diff] [blame] | 742 | // reference images to read. However, we can always write the .pdf files |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 743 | static const ConfigFlags kPDFConfigFlags = CAN_IMAGE_PDF ? kRW_ConfigFlag : |
| 744 | kWrite_ConfigFlag; |
| 745 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 746 | static const ConfigData gRec[] = { |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 747 | { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "8888" }, |
| 748 | { SkBitmap::kARGB_4444_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "4444" }, |
| 749 | { SkBitmap::kRGB_565_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "565" }, |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 750 | #if defined(SK_SCALAR_IS_FLOAT) && SK_SUPPORT_GPU |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 751 | { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GLContextType, 0, kRW_ConfigFlag, "gpu" }, |
robertphillips@google.com | a73e860 | 2012-08-02 17:56:02 +0000 | [diff] [blame] | 752 | #ifndef SK_BUILD_FOR_ANDROID |
| 753 | // currently we don't want to run MSAA tests on Android |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 754 | { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GLContextType, 16, kRW_ConfigFlag, "msaa16" }, |
robertphillips@google.com | a73e860 | 2012-08-02 17:56:02 +0000 | [diff] [blame] | 755 | #endif |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 756 | /* The debug context does not generate images */ |
| 757 | { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kDebug_GLContextType, 0, kNone_ConfigFlag, "debug" }, |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 758 | #if SK_ANGLE |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 759 | { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLContextType, 0, kRW_ConfigFlag, "angle" }, |
| 760 | { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLContextType, 16, kRW_ConfigFlag, "anglemsaa16" }, |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 761 | #endif // SK_ANGLE |
| 762 | #ifdef SK_MESA |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 763 | { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kMESA_GLContextType, 0, kRW_ConfigFlag, "mesa" }, |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 764 | #endif // SK_MESA |
robertphillips@google.com | a73e860 | 2012-08-02 17:56:02 +0000 | [diff] [blame] | 765 | #endif // defined(SK_SCALAR_IS_FLOAT) && SK_SUPPORT_GPU |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 766 | #ifdef SK_SUPPORT_XPS |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 767 | /* At present we have no way of comparing XPS files (either natively or by converting to PNG). */ |
| 768 | { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType, 0, kWrite_ConfigFlag, "xps" }, |
robertphillips@google.com | a73e860 | 2012-08-02 17:56:02 +0000 | [diff] [blame] | 769 | #endif // SK_SUPPORT_XPS |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 770 | #ifdef SK_SUPPORT_PDF |
| 771 | { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType, 0, kPDFConfigFlags, "pdf" }, |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 772 | #endif // SK_SUPPORT_PDF |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 773 | }; |
| 774 | |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 775 | static void usage(const char * argv0) { |
| 776 | SkDebugf("%s\n", argv0); |
reed@google.com | e5f48b9 | 2012-06-22 15:27:39 +0000 | [diff] [blame] | 777 | SkDebugf(" [--config "); |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 778 | for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 779 | if (i > 0) { |
| 780 | SkDebugf("|"); |
| 781 | } |
| 782 | SkDebugf(gRec[i].fName); |
| 783 | } |
epoger@google.com | 82cb65b | 2012-10-29 18:59:17 +0000 | [diff] [blame] | 784 | SkDebugf("]:\n run these configurations\n"); |
| 785 | SkDebugf( |
| 786 | // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). |
| 787 | // It would probably be better if we allowed both yes-and-no settings for each |
| 788 | // one, e.g.: |
| 789 | // [--replay|--noreplay]: whether to exercise SkPicture replay; default is yes |
| 790 | " [--nodeferred]: skip the deferred rendering test pass\n" |
| 791 | " [--diffPath|-d <path>]: write difference images into this directory\n" |
| 792 | " [--disable-missing-warning]: don't print a message to stderr if\n" |
| 793 | " unable to read a reference image for any tests (NOT default behavior)\n" |
| 794 | " [--enable-missing-warning]: print message to stderr (but don't fail) if\n" |
| 795 | " unable to read a reference image for any tests (default behavior)\n" |
| 796 | " [--forceBWtext]: disable text anti-aliasing\n" |
| 797 | " [--help|-h]: show this help message\n" |
| 798 | " [--hierarchy|--nohierarchy]: whether to use multilevel directory structure\n" |
| 799 | " when reading/writing files; default is no\n" |
| 800 | " [--match <substring>]: only run tests whose name includes this substring\n" |
| 801 | " [--modulo <remainder> <divisor>]: only run tests for which \n" |
| 802 | " testIndex %% divisor == remainder\n" |
| 803 | " [--nopdf]: skip the pdf rendering test pass\n" |
| 804 | " [--nopipe]: Skip SkGPipe replay\n" |
| 805 | " [--readPath|-r <path>]: read reference images from this dir, and report\n" |
| 806 | " any differences between those and the newly generated ones\n" |
| 807 | " [--noreplay]: do not exercise SkPicture replay\n" |
| 808 | " [--resourcePath|-i <path>]: directory that stores image resources\n" |
| 809 | " [--noserialize]: do not exercise SkPicture serialization & deserialization\n" |
| 810 | " [--notexturecache]: disable the gpu texture cache\n" |
| 811 | " [--tiledPipe]: Exercise tiled SkGPipe replay\n" |
| 812 | " [--writePath|-w <path>]: write rendered images into this directory\n" |
| 813 | " [--writePicturePath|-wp <path>]: write .skp files into this directory\n" |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 814 | ); |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 815 | } |
| 816 | |
| 817 | static int findConfig(const char config[]) { |
| 818 | for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { |
| 819 | if (!strcmp(config, gRec[i].fName)) { |
| 820 | return i; |
| 821 | } |
| 822 | } |
| 823 | return -1; |
| 824 | } |
| 825 | |
reed@google.com | b2a5162 | 2011-10-31 16:30:04 +0000 | [diff] [blame] | 826 | static bool skip_name(const SkTDArray<const char*> array, const char name[]) { |
| 827 | if (0 == array.count()) { |
| 828 | // no names, so don't skip anything |
| 829 | return false; |
| 830 | } |
| 831 | for (int i = 0; i < array.count(); ++i) { |
| 832 | if (strstr(name, array[i])) { |
| 833 | // found the name, so don't skip |
| 834 | return false; |
| 835 | } |
| 836 | } |
| 837 | return true; |
| 838 | } |
| 839 | |
bsalomon@google.com | d9f826c | 2011-07-18 15:25:04 +0000 | [diff] [blame] | 840 | namespace skiagm { |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 841 | #if SK_SUPPORT_GPU |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 842 | SkAutoTUnref<GrContext> gGrContext; |
| 843 | /** |
bsalomon@google.com | c7a24d2 | 2012-11-01 18:03:48 +0000 | [diff] [blame] | 844 | * Sets the global GrContext, accessible by individual GMs |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 845 | */ |
caryclark@google.com | 1313086 | 2012-06-06 12:10:45 +0000 | [diff] [blame] | 846 | static void SetGr(GrContext* grContext) { |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 847 | SkSafeRef(grContext); |
| 848 | gGrContext.reset(grContext); |
bsalomon@google.com | d9f826c | 2011-07-18 15:25:04 +0000 | [diff] [blame] | 849 | } |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 850 | |
| 851 | /** |
| 852 | * Gets the global GrContext, can be called by GM tests. |
| 853 | */ |
caryclark@google.com | 1313086 | 2012-06-06 12:10:45 +0000 | [diff] [blame] | 854 | GrContext* GetGr(); |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 855 | GrContext* GetGr() { |
| 856 | return gGrContext.get(); |
| 857 | } |
| 858 | |
| 859 | /** |
| 860 | * Sets the global GrContext and then resets it to its previous value at |
| 861 | * destruction. |
| 862 | */ |
| 863 | class AutoResetGr : SkNoncopyable { |
| 864 | public: |
| 865 | AutoResetGr() : fOld(NULL) {} |
| 866 | void set(GrContext* context) { |
| 867 | SkASSERT(NULL == fOld); |
| 868 | fOld = GetGr(); |
| 869 | SkSafeRef(fOld); |
| 870 | SetGr(context); |
| 871 | } |
| 872 | ~AutoResetGr() { SetGr(fOld); SkSafeUnref(fOld); } |
| 873 | private: |
| 874 | GrContext* fOld; |
| 875 | }; |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 876 | #else |
| 877 | GrContext* GetGr() { return NULL; } |
| 878 | #endif |
bsalomon@google.com | d9f826c | 2011-07-18 15:25:04 +0000 | [diff] [blame] | 879 | } |
| 880 | |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 881 | static bool is_recordable_failure(ErrorBitfield errorCode) { |
| 882 | return ERROR_NONE != errorCode && !(ERROR_READING_REFERENCE_IMAGE & errorCode); |
| 883 | } |
| 884 | |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 885 | struct FailRec { |
| 886 | SkString fName; |
| 887 | int fMaxPixelError; |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 888 | |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 889 | FailRec() : fMaxPixelError(0) {} |
| 890 | FailRec(const SkString& name) : fName(name), fMaxPixelError(0) {} |
| 891 | }; |
| 892 | |
caryclark@google.com | 5987f58 | 2012-10-02 18:33:14 +0000 | [diff] [blame] | 893 | int tool_main(int argc, char** argv); |
| 894 | int tool_main(int argc, char** argv) { |
robertphillips@google.com | b74af87 | 2012-06-27 19:41:42 +0000 | [diff] [blame] | 895 | |
| 896 | #ifdef SK_ENABLE_INST_COUNT |
| 897 | gPrintInstCount = true; |
| 898 | #endif |
| 899 | |
robertphillips@google.com | 977b9c8 | 2012-06-05 19:35:09 +0000 | [diff] [blame] | 900 | SkGraphics::Init(); |
reed@google.com | 8923c6c | 2011-11-08 14:59:38 +0000 | [diff] [blame] | 901 | // we don't need to see this during a run |
| 902 | gSkSuppressFontCachePurgeSpew = true; |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 903 | |
epoger@google.com | 7bc13a6 | 2012-02-14 14:53:59 +0000 | [diff] [blame] | 904 | setSystemPreferences(); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 905 | GMMain gmmain; |
epoger@google.com | 7bc13a6 | 2012-02-14 14:53:59 +0000 | [diff] [blame] | 906 | |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 907 | const char* writePath = NULL; // if non-null, where we write the originals |
mike@reedtribe.org | 5d0c62f | 2012-06-02 14:50:13 +0000 | [diff] [blame] | 908 | const char* writePicturePath = NULL; // if non-null, where we write serialized pictures |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 909 | const char* readPath = NULL; // if non-null, were we read from to compare |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 910 | const char* diffPath = NULL; // if non-null, where we write our diffs (from compare) |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame] | 911 | const char* resourcePath = NULL;// if non-null, where we read from for image resources |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 912 | |
reed@google.com | b2a5162 | 2011-10-31 16:30:04 +0000 | [diff] [blame] | 913 | SkTDArray<const char*> fMatches; |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 914 | |
reed@google.com | ab97397 | 2011-09-19 19:01:38 +0000 | [diff] [blame] | 915 | bool doPDF = true; |
reed@google.com | b8b0983 | 2011-05-26 15:57:56 +0000 | [diff] [blame] | 916 | bool doReplay = true; |
scroggo@google.com | 565254b | 2012-06-28 15:41:32 +0000 | [diff] [blame] | 917 | bool doPipe = true; |
scroggo@google.com | 72c9672 | 2012-06-06 21:07:10 +0000 | [diff] [blame] | 918 | bool doTiledPipe = false; |
scroggo@google.com | 3936252 | 2012-09-14 17:37:46 +0000 | [diff] [blame] | 919 | bool doSerialize = true; |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 920 | bool doDeferred = true; |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 921 | bool disableTextureCache = false; |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 922 | SkTDArray<size_t> configs; |
| 923 | bool userConfig = false; |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 924 | |
epoger@google.com | 82cb65b | 2012-10-29 18:59:17 +0000 | [diff] [blame] | 925 | int moduloRemainder = -1; |
| 926 | int moduloDivisor = -1; |
reed@google.com | ae7b8f3 | 2012-10-18 21:30:57 +0000 | [diff] [blame] | 927 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 928 | const char* const commandName = argv[0]; |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 929 | char* const* stop = argv + argc; |
| 930 | for (++argv; argv < stop; ++argv) { |
epoger@google.com | 82cb65b | 2012-10-29 18:59:17 +0000 | [diff] [blame] | 931 | if (strcmp(*argv, "--config") == 0) { |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 932 | argv++; |
| 933 | if (argv < stop) { |
| 934 | int index = findConfig(*argv); |
| 935 | if (index >= 0) { |
| 936 | *configs.append() = index; |
| 937 | userConfig = true; |
| 938 | } else { |
| 939 | SkString str; |
| 940 | str.printf("unrecognized config %s\n", *argv); |
| 941 | SkDebugf(str.c_str()); |
| 942 | usage(commandName); |
| 943 | return -1; |
| 944 | } |
| 945 | } else { |
reed@google.com | e5f48b9 | 2012-06-22 15:27:39 +0000 | [diff] [blame] | 946 | SkDebugf("missing arg for --config\n"); |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 947 | usage(commandName); |
| 948 | return -1; |
| 949 | } |
epoger@google.com | 82cb65b | 2012-10-29 18:59:17 +0000 | [diff] [blame] | 950 | } else if (strcmp(*argv, "--nodeferred") == 0) { |
| 951 | doDeferred = false; |
| 952 | } else if ((0 == strcmp(*argv, "--diffPath")) || |
| 953 | (0 == strcmp(*argv, "-d"))) { |
| 954 | argv++; |
| 955 | if (argv < stop && **argv) { |
| 956 | diffPath = *argv; |
| 957 | } |
| 958 | } else if (strcmp(*argv, "--disable-missing-warning") == 0) { |
| 959 | gmmain.fNotifyMissingReadReference = false; |
| 960 | } else if (strcmp(*argv, "--enable-missing-warning") == 0) { |
| 961 | gmmain.fNotifyMissingReadReference = true; |
| 962 | } else if (strcmp(*argv, "--forceBWtext") == 0) { |
| 963 | gForceBWtext = true; |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 964 | } else if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) { |
| 965 | usage(commandName); |
| 966 | return -1; |
epoger@google.com | 82cb65b | 2012-10-29 18:59:17 +0000 | [diff] [blame] | 967 | } else if (strcmp(*argv, "--hierarchy") == 0) { |
| 968 | gmmain.fUseFileHierarchy = true; |
| 969 | } else if (strcmp(*argv, "--nohierarchy") == 0) { |
| 970 | gmmain.fUseFileHierarchy = false; |
| 971 | } else if (strcmp(*argv, "--match") == 0) { |
| 972 | ++argv; |
| 973 | if (argv < stop && **argv) { |
| 974 | // just record the ptr, no need for a deep copy |
| 975 | *fMatches.append() = *argv; |
| 976 | } |
| 977 | } else if (strcmp(*argv, "--modulo") == 0) { |
| 978 | ++argv; |
| 979 | if (argv >= stop) { |
| 980 | continue; |
| 981 | } |
| 982 | moduloRemainder = atoi(*argv); |
| 983 | |
| 984 | ++argv; |
| 985 | if (argv >= stop) { |
| 986 | continue; |
| 987 | } |
| 988 | moduloDivisor = atoi(*argv); |
bsalomon@google.com | c7a24d2 | 2012-11-01 18:03:48 +0000 | [diff] [blame] | 989 | if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= moduloDivisor) { |
| 990 | SkDebugf("invalid modulo values."); |
| 991 | return -1; |
| 992 | } |
epoger@google.com | 82cb65b | 2012-10-29 18:59:17 +0000 | [diff] [blame] | 993 | } else if (strcmp(*argv, "--nopdf") == 0) { |
| 994 | doPDF = false; |
| 995 | } else if (strcmp(*argv, "--nopipe") == 0) { |
| 996 | doPipe = false; |
| 997 | } else if ((0 == strcmp(*argv, "--readPath")) || |
| 998 | (0 == strcmp(*argv, "-r"))) { |
| 999 | argv++; |
| 1000 | if (argv < stop && **argv) { |
| 1001 | readPath = *argv; |
| 1002 | } |
| 1003 | } else if (strcmp(*argv, "--noreplay") == 0) { |
| 1004 | doReplay = false; |
| 1005 | } else if ((0 == strcmp(*argv, "--resourcePath")) || |
| 1006 | (0 == strcmp(*argv, "-i"))) { |
| 1007 | argv++; |
| 1008 | if (argv < stop && **argv) { |
| 1009 | resourcePath = *argv; |
| 1010 | } |
| 1011 | } else if (strcmp(*argv, "--serialize") == 0) { |
| 1012 | doSerialize = true; |
| 1013 | } else if (strcmp(*argv, "--noserialize") == 0) { |
| 1014 | doSerialize = false; |
| 1015 | } else if (strcmp(*argv, "--notexturecache") == 0) { |
| 1016 | disableTextureCache = true; |
| 1017 | } else if (strcmp(*argv, "--tiledPipe") == 0) { |
| 1018 | doTiledPipe = true; |
| 1019 | } else if ((0 == strcmp(*argv, "--writePath")) || |
| 1020 | (0 == strcmp(*argv, "-w"))) { |
| 1021 | argv++; |
| 1022 | if (argv < stop && **argv) { |
| 1023 | writePath = *argv; |
| 1024 | } |
| 1025 | } else if ((0 == strcmp(*argv, "--writePicturePath")) || |
| 1026 | (0 == strcmp(*argv, "-wp"))) { |
| 1027 | argv++; |
| 1028 | if (argv < stop && **argv) { |
| 1029 | writePicturePath = *argv; |
| 1030 | } |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 1031 | } else { |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame] | 1032 | usage(commandName); |
| 1033 | return -1; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 1034 | } |
| 1035 | } |
| 1036 | if (argv != stop) { |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame] | 1037 | usage(commandName); |
| 1038 | return -1; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 1039 | } |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 1040 | |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 1041 | if (!userConfig) { |
| 1042 | // if no config is specified by user, we add them all. |
| 1043 | for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 1044 | *configs.append() = i; |
| 1045 | } |
| 1046 | } |
| 1047 | |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame] | 1048 | GM::SetResourcePath(resourcePath); |
| 1049 | |
reed@android.com | 00f883e | 2010-12-14 17:46:14 +0000 | [diff] [blame] | 1050 | if (readPath) { |
| 1051 | fprintf(stderr, "reading from %s\n", readPath); |
chudy@google.com | f32f6e8 | 2012-07-12 15:42:37 +0000 | [diff] [blame] | 1052 | } |
epoger@google.com | 9284ccd | 2012-04-18 13:36:54 +0000 | [diff] [blame] | 1053 | if (writePath) { |
reed@android.com | 00f883e | 2010-12-14 17:46:14 +0000 | [diff] [blame] | 1054 | fprintf(stderr, "writing to %s\n", writePath); |
| 1055 | } |
mike@reedtribe.org | 5d0c62f | 2012-06-02 14:50:13 +0000 | [diff] [blame] | 1056 | if (writePicturePath) { |
| 1057 | fprintf(stderr, "writing pictures to %s\n", writePicturePath); |
| 1058 | } |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame] | 1059 | if (resourcePath) { |
| 1060 | fprintf(stderr, "reading resources from %s\n", resourcePath); |
| 1061 | } |
| 1062 | |
epoger@google.com | 82cb65b | 2012-10-29 18:59:17 +0000 | [diff] [blame] | 1063 | if (moduloDivisor <= 0) { |
| 1064 | moduloRemainder = -1; |
reed@google.com | ae7b8f3 | 2012-10-18 21:30:57 +0000 | [diff] [blame] | 1065 | } |
epoger@google.com | 82cb65b | 2012-10-29 18:59:17 +0000 | [diff] [blame] | 1066 | if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { |
| 1067 | moduloRemainder = -1; |
reed@google.com | ae7b8f3 | 2012-10-18 21:30:57 +0000 | [diff] [blame] | 1068 | } |
| 1069 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 1070 | // Accumulate success of all tests. |
| 1071 | int testsRun = 0; |
| 1072 | int testsPassed = 0; |
| 1073 | int testsFailed = 0; |
| 1074 | int testsMissingReferenceImages = 0; |
| 1075 | |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 1076 | #if SK_SUPPORT_GPU |
| 1077 | GrContextFactory* grFactory = new GrContextFactory; |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 1078 | if (disableTextureCache) { |
| 1079 | skiagm::GetGr()->setTextureCacheLimits(0, 0); |
| 1080 | } |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 1081 | #endif |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 1082 | |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 1083 | SkTArray<FailRec> failedTests; |
robertphillips@google.com | a2f8008 | 2012-08-02 16:22:47 +0000 | [diff] [blame] | 1084 | |
reed@google.com | ae7b8f3 | 2012-10-18 21:30:57 +0000 | [diff] [blame] | 1085 | int gmIndex = -1; |
| 1086 | SkString moduloStr; |
| 1087 | |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 1088 | // If we will be writing out files, prepare subdirectories. |
| 1089 | if (writePath) { |
| 1090 | if (!sk_mkdir(writePath)) { |
| 1091 | return -1; |
| 1092 | } |
| 1093 | if (gmmain.fUseFileHierarchy) { |
| 1094 | for (int i = 0; i < configs.count(); i++) { |
| 1095 | ConfigData config = gRec[configs[i]]; |
| 1096 | SkString subdir; |
| 1097 | subdir.appendf("%s%c%s", writePath, SkPATH_SEPARATOR, |
| 1098 | config.fName); |
| 1099 | if (!sk_mkdir(subdir.c_str())) { |
| 1100 | return -1; |
| 1101 | } |
| 1102 | } |
| 1103 | } |
| 1104 | } |
| 1105 | |
bsalomon@google.com | 7361f54 | 2012-04-19 19:15:35 +0000 | [diff] [blame] | 1106 | Iter iter; |
| 1107 | GM* gm; |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 1108 | while ((gm = iter.next()) != NULL) { |
skia.committer@gmail.com | 6a748ad | 2012-10-19 02:01:19 +0000 | [diff] [blame] | 1109 | |
reed@google.com | ae7b8f3 | 2012-10-18 21:30:57 +0000 | [diff] [blame] | 1110 | ++gmIndex; |
epoger@google.com | 82cb65b | 2012-10-29 18:59:17 +0000 | [diff] [blame] | 1111 | if (moduloRemainder >= 0) { |
| 1112 | if ((gmIndex % moduloDivisor) != moduloRemainder) { |
reed@google.com | ae7b8f3 | 2012-10-18 21:30:57 +0000 | [diff] [blame] | 1113 | continue; |
| 1114 | } |
epoger@google.com | 82cb65b | 2012-10-29 18:59:17 +0000 | [diff] [blame] | 1115 | moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); |
reed@google.com | ae7b8f3 | 2012-10-18 21:30:57 +0000 | [diff] [blame] | 1116 | } |
| 1117 | |
reed@google.com | ece2b02 | 2011-07-25 14:28:57 +0000 | [diff] [blame] | 1118 | const char* shortName = gm->shortName(); |
reed@google.com | b2a5162 | 2011-10-31 16:30:04 +0000 | [diff] [blame] | 1119 | if (skip_name(fMatches, shortName)) { |
reed@google.com | ece2b02 | 2011-07-25 14:28:57 +0000 | [diff] [blame] | 1120 | SkDELETE(gm); |
| 1121 | continue; |
| 1122 | } |
| 1123 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 1124 | SkISize size = gm->getISize(); |
reed@google.com | ae7b8f3 | 2012-10-18 21:30:57 +0000 | [diff] [blame] | 1125 | SkDebugf("%sdrawing... %s [%d %d]\n", moduloStr.c_str(), shortName, |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 1126 | size.width(), size.height()); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1127 | |
| 1128 | ErrorBitfield testErrors = ERROR_NONE; |
| 1129 | uint32_t gmFlags = gm->getFlags(); |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 1130 | |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 1131 | for (int i = 0; i < configs.count(); i++) { |
| 1132 | ConfigData config = gRec[configs[i]]; |
epoger@google.com | e8ebeb1 | 2012-10-29 16:42:11 +0000 | [diff] [blame] | 1133 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 1134 | // Skip any tests that we don't even need to try. |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 1135 | if ((kPDF_Backend == config.fBackend) && |
bungeman@google.com | 64e011a | 2011-09-19 19:31:04 +0000 | [diff] [blame] | 1136 | (!doPDF || (gmFlags & GM::kSkipPDF_Flag))) |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1137 | { |
| 1138 | continue; |
| 1139 | } |
reed@google.com | 1b6c73d | 2012-10-10 15:17:24 +0000 | [diff] [blame] | 1140 | if ((gmFlags & GM::kSkip565_Flag) && |
| 1141 | (kRaster_Backend == config.fBackend) && |
| 1142 | (SkBitmap::kRGB_565_Config == config.fConfig)) { |
| 1143 | continue; |
| 1144 | } |
reed@google.com | ab97397 | 2011-09-19 19:01:38 +0000 | [diff] [blame] | 1145 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 1146 | // Now we know that we want to run this test and record its |
| 1147 | // success or failure. |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1148 | ErrorBitfield renderErrors = ERROR_NONE; |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 1149 | GrRenderTarget* renderTarget = NULL; |
| 1150 | #if SK_SUPPORT_GPU |
| 1151 | SkAutoTUnref<GrRenderTarget> rt; |
| 1152 | AutoResetGr autogr; |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1153 | if ((ERROR_NONE == renderErrors) && |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 1154 | kGPU_Backend == config.fBackend) { |
| 1155 | GrContext* gr = grFactory->get(config.fGLContextType); |
| 1156 | bool grSuccess = false; |
| 1157 | if (gr) { |
| 1158 | // create a render target to back the device |
| 1159 | GrTextureDesc desc; |
| 1160 | desc.fConfig = kSkia8888_PM_GrPixelConfig; |
| 1161 | desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 1162 | desc.fWidth = gm->getISize().width(); |
| 1163 | desc.fHeight = gm->getISize().height(); |
| 1164 | desc.fSampleCnt = config.fSampleCnt; |
| 1165 | GrTexture* tex = gr->createUncachedTexture(desc, NULL, 0); |
| 1166 | if (tex) { |
| 1167 | rt.reset(tex->asRenderTarget()); |
| 1168 | rt.get()->ref(); |
| 1169 | tex->unref(); |
| 1170 | autogr.set(gr); |
| 1171 | renderTarget = rt.get(); |
| 1172 | grSuccess = NULL != renderTarget; |
| 1173 | } |
| 1174 | } |
| 1175 | if (!grSuccess) { |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1176 | renderErrors |= ERROR_NO_GPU_CONTEXT; |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 1177 | } |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 1178 | } |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 1179 | #endif |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 1180 | |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1181 | SkBitmap comparisonBitmap; |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 1182 | int maxPixelError = 0; |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1183 | |
| 1184 | if (ERROR_NONE == renderErrors) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1185 | renderErrors |= gmmain.test_drawing(gm, config, writePath, |
| 1186 | readPath, diffPath, GetGr(), |
| 1187 | renderTarget, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 1188 | &comparisonBitmap, |
| 1189 | &maxPixelError); |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 1190 | } |
| 1191 | |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1192 | if (doDeferred && !renderErrors && |
scroggo@google.com | 5867c0f | 2012-06-07 17:39:48 +0000 | [diff] [blame] | 1193 | (kGPU_Backend == config.fBackend || |
| 1194 | kRaster_Backend == config.fBackend)) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1195 | renderErrors |= gmmain.test_deferred_drawing(gm, config, |
| 1196 | comparisonBitmap, |
| 1197 | diffPath, GetGr(), |
| 1198 | renderTarget); |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 1199 | } |
| 1200 | |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1201 | testErrors |= renderErrors; |
| 1202 | if (is_recordable_failure(renderErrors)) { |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 1203 | FailRec& rec = failedTests.push_back(); |
| 1204 | rec.fName = gmmain.make_name(shortName, config.fName); |
| 1205 | rec.fMaxPixelError = maxPixelError; |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 1206 | } |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 1207 | } |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1208 | |
| 1209 | SkBitmap comparisonBitmap; |
| 1210 | const ConfigData compareConfig = |
| 1211 | { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "comparison" }; |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1212 | testErrors |= gmmain.generate_image(gm, compareConfig, NULL, NULL, &comparisonBitmap, false); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1213 | |
| 1214 | // run the picture centric GM steps |
| 1215 | if (!(gmFlags & GM::kSkipPicture_Flag)) { |
| 1216 | |
| 1217 | ErrorBitfield pictErrors = ERROR_NONE; |
| 1218 | |
| 1219 | //SkAutoTUnref<SkPicture> pict(generate_new_picture(gm)); |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1220 | SkPicture* pict = gmmain.generate_new_picture(gm); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1221 | SkAutoUnref aur(pict); |
| 1222 | |
| 1223 | if ((ERROR_NONE == testErrors) && doReplay) { |
| 1224 | SkBitmap bitmap; |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1225 | gmmain.generate_image_from_picture(gm, compareConfig, pict, |
| 1226 | &bitmap); |
| 1227 | pictErrors |= gmmain.handle_test_results(gm, compareConfig, |
| 1228 | NULL, NULL, diffPath, |
| 1229 | "-replay", bitmap, |
| 1230 | NULL, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 1231 | &comparisonBitmap, NULL); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1232 | if (is_recordable_failure(pictErrors)) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1233 | failedTests.push_back(gmmain.make_name(shortName, |
| 1234 | "pict-replay")); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1235 | } |
| 1236 | } |
| 1237 | |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1238 | if ((ERROR_NONE == testErrors) && |
| 1239 | (ERROR_NONE == pictErrors) && |
| 1240 | doSerialize) { |
| 1241 | SkPicture* repict = gmmain.stream_to_new_picture(*pict); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1242 | SkAutoUnref aurr(repict); |
| 1243 | |
| 1244 | SkBitmap bitmap; |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1245 | gmmain.generate_image_from_picture(gm, compareConfig, repict, |
| 1246 | &bitmap); |
| 1247 | pictErrors |= gmmain.handle_test_results(gm, compareConfig, |
| 1248 | NULL, NULL, diffPath, |
| 1249 | "-serialize", bitmap, |
| 1250 | NULL, |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 1251 | &comparisonBitmap, NULL); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1252 | if (is_recordable_failure(pictErrors)) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1253 | failedTests.push_back(gmmain.make_name(shortName, |
| 1254 | "pict-serialize")); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1255 | } |
| 1256 | } |
| 1257 | |
| 1258 | if (writePicturePath) { |
| 1259 | const char* pictureSuffix = "skp"; |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1260 | SkString path = gmmain.make_filename(writePicturePath, "", |
| 1261 | SkString(gm->shortName()), |
| 1262 | pictureSuffix); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1263 | SkFILEWStream stream(path.c_str()); |
| 1264 | pict->serialize(&stream); |
| 1265 | } |
| 1266 | |
| 1267 | testErrors |= pictErrors; |
| 1268 | } |
| 1269 | |
| 1270 | // run the pipe centric GM steps |
| 1271 | if (!(gmFlags & GM::kSkipPipe_Flag)) { |
| 1272 | |
| 1273 | ErrorBitfield pipeErrors = ERROR_NONE; |
| 1274 | |
| 1275 | if ((ERROR_NONE == testErrors) && doPipe) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1276 | pipeErrors |= gmmain.test_pipe_playback(gm, compareConfig, |
| 1277 | comparisonBitmap, |
| 1278 | readPath, diffPath); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1279 | if (is_recordable_failure(pipeErrors)) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1280 | failedTests.push_back(gmmain.make_name(shortName, "pipe")); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1281 | } |
| 1282 | } |
| 1283 | |
| 1284 | if ((ERROR_NONE == testErrors) && |
| 1285 | (ERROR_NONE == pipeErrors) && |
| 1286 | doTiledPipe && !(gmFlags & GM::kSkipTiled_Flag)) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1287 | pipeErrors |= gmmain.test_tiled_pipe_playback(gm, compareConfig, |
| 1288 | comparisonBitmap, |
| 1289 | readPath, |
| 1290 | diffPath); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1291 | if (is_recordable_failure(pipeErrors)) { |
epoger@google.com | de96163 | 2012-10-26 18:56:36 +0000 | [diff] [blame] | 1292 | failedTests.push_back(gmmain.make_name(shortName, |
| 1293 | "pipe-tiled")); |
djsollen@google.com | ebce16d | 2012-10-26 14:07:13 +0000 | [diff] [blame] | 1294 | } |
| 1295 | } |
| 1296 | |
| 1297 | testErrors |= pipeErrors; |
| 1298 | } |
| 1299 | |
| 1300 | // Update overall results. |
| 1301 | // We only tabulate the particular error types that we currently |
| 1302 | // care about (e.g., missing reference images). Later on, if we |
| 1303 | // want to also tabulate pixel mismatches vs dimension mistmatches |
| 1304 | // (or whatever else), we can do so. |
| 1305 | testsRun++; |
| 1306 | if (ERROR_NONE == testErrors) { |
| 1307 | testsPassed++; |
| 1308 | } else if (ERROR_READING_REFERENCE_IMAGE & testErrors) { |
| 1309 | testsMissingReferenceImages++; |
| 1310 | } else { |
| 1311 | testsFailed++; |
| 1312 | } |
| 1313 | |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 1314 | SkDELETE(gm); |
| 1315 | } |
robertphillips@google.com | a2f8008 | 2012-08-02 16:22:47 +0000 | [diff] [blame] | 1316 | SkDebugf("Ran %d tests: %d passed, %d failed, %d missing reference images\n", |
| 1317 | testsRun, testsPassed, testsFailed, testsMissingReferenceImages); |
| 1318 | for (int i = 0; i < failedTests.count(); ++i) { |
reed@google.com | ce7ffac | 2012-11-09 14:51:18 +0000 | [diff] [blame] | 1319 | int pixErr = failedTests[i].fMaxPixelError; |
| 1320 | SkString pixStr; |
| 1321 | if (pixErr > 0) { |
| 1322 | pixStr.printf(" pixel_error %d", pixErr); |
| 1323 | } |
| 1324 | SkDebugf("\t\t%s%s\n", failedTests[i].fName.c_str(), pixStr.c_str()); |
robertphillips@google.com | a2f8008 | 2012-08-02 16:22:47 +0000 | [diff] [blame] | 1325 | } |
robertphillips@google.com | 5f9f2f5 | 2012-08-22 10:57:05 +0000 | [diff] [blame] | 1326 | |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 1327 | #if SK_SUPPORT_GPU |
robertphillips@google.com | 5f9f2f5 | 2012-08-22 10:57:05 +0000 | [diff] [blame] | 1328 | |
robertphillips@google.com | 5955202 | 2012-08-31 13:07:37 +0000 | [diff] [blame] | 1329 | #if GR_CACHE_STATS |
robertphillips@google.com | 5f9f2f5 | 2012-08-22 10:57:05 +0000 | [diff] [blame] | 1330 | for (int i = 0; i < configs.count(); i++) { |
| 1331 | ConfigData config = gRec[configs[i]]; |
| 1332 | |
| 1333 | if (kGPU_Backend == config.fBackend) { |
| 1334 | GrContext* gr = grFactory->get(config.fGLContextType); |
| 1335 | |
| 1336 | SkDebugf("config: %s %x\n", config.fName, gr); |
| 1337 | gr->printCacheStats(); |
| 1338 | } |
| 1339 | } |
| 1340 | #endif |
| 1341 | |
robertphillips@google.com | 977b9c8 | 2012-06-05 19:35:09 +0000 | [diff] [blame] | 1342 | delete grFactory; |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 1343 | #endif |
robertphillips@google.com | 977b9c8 | 2012-06-05 19:35:09 +0000 | [diff] [blame] | 1344 | SkGraphics::Term(); |
| 1345 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 1346 | return (0 == testsFailed) ? 0 : -1; |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 1347 | } |
caryclark@google.com | 5987f58 | 2012-10-02 18:33:14 +0000 | [diff] [blame] | 1348 | |
borenet@google.com | 7158e6a | 2012-11-01 17:43:44 +0000 | [diff] [blame] | 1349 | #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
caryclark@google.com | 5987f58 | 2012-10-02 18:33:14 +0000 | [diff] [blame] | 1350 | int main(int argc, char * const argv[]) { |
| 1351 | return tool_main(argc, (char**) argv); |
| 1352 | } |
| 1353 | #endif |