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" |
bsalomon@google.com | 971d0c8 | 2011-08-19 17:22:05 +0000 | [diff] [blame] | 10 | #include "GrContext.h" |
| 11 | #include "GrRenderTarget.h" |
| 12 | |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 13 | #include "SkColorPriv.h" |
reed@google.com | 8a85d0c | 2011-06-24 19:12:12 +0000 | [diff] [blame] | 14 | #include "SkData.h" |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 15 | #include "SkDeferredCanvas.h" |
bsalomon@google.com | 971d0c8 | 2011-08-19 17:22:05 +0000 | [diff] [blame] | 16 | #include "SkDevice.h" |
bsalomon@google.com | 971d0c8 | 2011-08-19 17:22:05 +0000 | [diff] [blame] | 17 | #include "SkGpuCanvas.h" |
| 18 | #include "SkGpuDevice.h" |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 19 | #include "SkGraphics.h" |
| 20 | #include "SkImageDecoder.h" |
| 21 | #include "SkImageEncoder.h" |
tomhudson@google.com | 6bf38b5 | 2012-02-14 15:11:59 +0000 | [diff] [blame] | 22 | #include "gl/SkNativeGLContext.h" |
| 23 | #include "gl/SkMesaGLContext.h" |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 24 | #include "SkPicture.h" |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 25 | #include "SkStream.h" |
| 26 | #include "SkRefCnt.h" |
| 27 | |
mike@reedtribe.org | 10afbef | 2011-12-30 16:02:53 +0000 | [diff] [blame] | 28 | static bool gForceBWtext; |
| 29 | |
reed@google.com | 8923c6c | 2011-11-08 14:59:38 +0000 | [diff] [blame] | 30 | extern bool gSkSuppressFontCachePurgeSpew; |
| 31 | |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 32 | #ifdef SK_SUPPORT_PDF |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 33 | #include "SkPDFDevice.h" |
| 34 | #include "SkPDFDocument.h" |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 35 | #endif |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 36 | |
epoger@google.com | e3cc2eb | 2012-01-18 20:11:13 +0000 | [diff] [blame] | 37 | // Until we resolve http://code.google.com/p/skia/issues/detail?id=455 , |
| 38 | // stop writing out XPS-format image baselines in gm. |
| 39 | #undef SK_SUPPORT_XPS |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 40 | #ifdef SK_SUPPORT_XPS |
| 41 | #include "SkXPSDevice.h" |
| 42 | #endif |
| 43 | |
reed@google.com | 46cce91 | 2011-06-29 12:54:46 +0000 | [diff] [blame] | 44 | #ifdef SK_BUILD_FOR_MAC |
| 45 | #include "SkCGUtils.h" |
bsalomon@google.com | 0a09eef | 2011-06-29 19:42:58 +0000 | [diff] [blame] | 46 | #define CAN_IMAGE_PDF 1 |
reed@google.com | 46cce91 | 2011-06-29 12:54:46 +0000 | [diff] [blame] | 47 | #else |
bsalomon@google.com | 0a09eef | 2011-06-29 19:42:58 +0000 | [diff] [blame] | 48 | #define CAN_IMAGE_PDF 0 |
reed@google.com | 46cce91 | 2011-06-29 12:54:46 +0000 | [diff] [blame] | 49 | #endif |
| 50 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 51 | typedef int ErrorBitfield; |
| 52 | const static ErrorBitfield ERROR_NONE = 0x00; |
| 53 | const static ErrorBitfield ERROR_NO_GPU_CONTEXT = 0x01; |
| 54 | const static ErrorBitfield ERROR_PIXEL_MISMATCH = 0x02; |
| 55 | const static ErrorBitfield ERROR_DIMENSION_MISMATCH = 0x04; |
| 56 | const static ErrorBitfield ERROR_READING_REFERENCE_IMAGE = 0x08; |
| 57 | const static ErrorBitfield ERROR_WRITING_REFERENCE_IMAGE = 0x10; |
| 58 | |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 59 | using namespace skiagm; |
| 60 | |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 61 | class Iter { |
| 62 | public: |
| 63 | Iter() { |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 64 | this->reset(); |
| 65 | } |
| 66 | |
| 67 | void reset() { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 68 | fReg = GMRegistry::Head(); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 69 | } |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 70 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 71 | GM* next() { |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 72 | if (fReg) { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 73 | GMRegistry::Factory fact = fReg->factory(); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 74 | fReg = fReg->next(); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 75 | return fact(0); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 76 | } |
| 77 | return NULL; |
| 78 | } |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 79 | |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 80 | static int Count() { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 81 | const GMRegistry* reg = GMRegistry::Head(); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 82 | int count = 0; |
| 83 | while (reg) { |
| 84 | count += 1; |
| 85 | reg = reg->next(); |
| 86 | } |
| 87 | return count; |
| 88 | } |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 89 | |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 90 | private: |
| 91 | const GMRegistry* fReg; |
| 92 | }; |
| 93 | |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 94 | static SkString make_name(const char shortName[], const char configName[]) { |
| 95 | SkString name(shortName); |
| 96 | name.appendf("_%s", configName); |
| 97 | return name; |
| 98 | } |
| 99 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 100 | static SkString make_filename(const char path[], |
| 101 | const char pathSuffix[], |
| 102 | const SkString& name, |
| 103 | const char suffix[]) { |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 104 | SkString filename(path); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 105 | if (filename.endsWith("/")) { |
| 106 | filename.remove(filename.size() - 1, 1); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 107 | } |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 108 | filename.append(pathSuffix); |
| 109 | filename.append("/"); |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 110 | filename.appendf("%s.%s", name.c_str(), suffix); |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 111 | return filename; |
| 112 | } |
| 113 | |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 114 | /* since PNG insists on unpremultiplying our alpha, we take no precision chances |
| 115 | and force all pixels to be 100% opaque, otherwise on compare we may not get |
| 116 | a perfect match. |
| 117 | */ |
| 118 | static void force_all_opaque(const SkBitmap& bitmap) { |
| 119 | SkAutoLockPixels lock(bitmap); |
| 120 | for (int y = 0; y < bitmap.height(); y++) { |
| 121 | for (int x = 0; x < bitmap.width(); x++) { |
| 122 | *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { |
| 128 | SkBitmap copy; |
| 129 | bitmap.copyTo(©, SkBitmap::kARGB_8888_Config); |
| 130 | force_all_opaque(copy); |
| 131 | return SkImageEncoder::EncodeFile(path.c_str(), copy, |
| 132 | SkImageEncoder::kPNG_Type, 100); |
| 133 | } |
| 134 | |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 135 | static inline SkPMColor compute_diff_pmcolor(SkPMColor c0, SkPMColor c1) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 136 | int dr = SkGetPackedR32(c0) - SkGetPackedR32(c1); |
| 137 | int dg = SkGetPackedG32(c0) - SkGetPackedG32(c1); |
| 138 | int db = SkGetPackedB32(c0) - SkGetPackedB32(c1); |
| 139 | return SkPackARGB32(0xFF, SkAbs32(dr), SkAbs32(dg), SkAbs32(db)); |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | static void compute_diff(const SkBitmap& target, const SkBitmap& base, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 143 | SkBitmap* diff) { |
| 144 | SkAutoLockPixels alp(*diff); |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 145 | |
| 146 | const int w = target.width(); |
| 147 | const int h = target.height(); |
| 148 | for (int y = 0; y < h; y++) { |
| 149 | for (int x = 0; x < w; x++) { |
| 150 | SkPMColor c0 = *base.getAddr32(x, y); |
| 151 | SkPMColor c1 = *target.getAddr32(x, y); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 152 | SkPMColor d = 0; |
| 153 | if (c0 != c1) { |
| 154 | d = compute_diff_pmcolor(c0, c1); |
| 155 | } |
| 156 | *diff->getAddr32(x, y) = d; |
| 157 | } |
| 158 | } |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 159 | } |
| 160 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 161 | static ErrorBitfield compare(const SkBitmap& target, const SkBitmap& base, |
| 162 | const SkString& name, |
| 163 | const char* renderModeDescriptor, |
| 164 | SkBitmap* diff) { |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 165 | SkBitmap copy; |
| 166 | const SkBitmap* bm = ⌖ |
| 167 | if (target.config() != SkBitmap::kARGB_8888_Config) { |
| 168 | target.copyTo(©, SkBitmap::kARGB_8888_Config); |
| 169 | bm = © |
| 170 | } |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 171 | SkBitmap baseCopy; |
| 172 | const SkBitmap* bp = &base; |
| 173 | if (base.config() != SkBitmap::kARGB_8888_Config) { |
| 174 | base.copyTo(&baseCopy, SkBitmap::kARGB_8888_Config); |
| 175 | bp = &baseCopy; |
| 176 | } |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 177 | |
| 178 | force_all_opaque(*bm); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 179 | force_all_opaque(*bp); |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 180 | |
| 181 | const int w = bm->width(); |
| 182 | const int h = bm->height(); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 183 | if (w != bp->width() || h != bp->height()) { |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 184 | SkDebugf( |
| 185 | "---- %s dimensions mismatch for %s base [%d %d] current [%d %d]\n", |
| 186 | renderModeDescriptor, name.c_str(), |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 187 | bp->width(), bp->height(), w, h); |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 188 | return ERROR_DIMENSION_MISMATCH; |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | SkAutoLockPixels bmLock(*bm); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 192 | SkAutoLockPixels baseLock(*bp); |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 193 | |
| 194 | for (int y = 0; y < h; y++) { |
| 195 | for (int x = 0; x < w; x++) { |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 196 | SkPMColor c0 = *bp->getAddr32(x, y); |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 197 | SkPMColor c1 = *bm->getAddr32(x, y); |
| 198 | if (c0 != c1) { |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 199 | SkDebugf( |
| 200 | "----- %s pixel mismatch for %s at [%d %d] base 0x%08X current 0x%08X\n", |
| 201 | renderModeDescriptor, name.c_str(), x, y, c0, c1); |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 202 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 203 | if (diff) { |
| 204 | diff->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 205 | diff->allocPixels(); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 206 | compute_diff(*bm, *bp, diff); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 207 | } |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 208 | return ERROR_PIXEL_MISMATCH; |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | } |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 212 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 213 | // they're equal |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 214 | return ERROR_NONE; |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 215 | } |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 216 | |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 217 | static bool write_document(const SkString& path, |
| 218 | const SkDynamicMemoryWStream& document) { |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 219 | SkFILEWStream stream(path.c_str()); |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 220 | SkAutoDataUnref data(document.copyToData()); |
reed@google.com | 8a85d0c | 2011-06-24 19:12:12 +0000 | [diff] [blame] | 221 | return stream.writeData(data.get()); |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 222 | } |
| 223 | |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 224 | enum Backend { |
| 225 | kRaster_Backend, |
| 226 | kGPU_Backend, |
| 227 | kPDF_Backend, |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 228 | kXPS_Backend, |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 229 | }; |
| 230 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 231 | struct ConfigData { |
| 232 | SkBitmap::Config fConfig; |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 233 | Backend fBackend; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 234 | const char* fName; |
| 235 | }; |
| 236 | |
| 237 | /// Returns true if processing should continue, false to skip the |
| 238 | /// remainder of this config for this GM. |
| 239 | //@todo thudson 22 April 2011 - could refactor this to take in |
| 240 | // a factory to generate the context, always call readPixels() |
| 241 | // (logically a noop for rasters, if wasted time), and thus collapse the |
| 242 | // GPU special case and also let this be used for SkPicture testing. |
| 243 | static void setup_bitmap(const ConfigData& gRec, SkISize& size, |
| 244 | SkBitmap* bitmap) { |
| 245 | bitmap->setConfig(gRec.fConfig, size.width(), size.height()); |
| 246 | bitmap->allocPixels(); |
| 247 | bitmap->eraseColor(0); |
| 248 | } |
| 249 | |
mike@reedtribe.org | 10afbef | 2011-12-30 16:02:53 +0000 | [diff] [blame] | 250 | #include "SkDrawFilter.h" |
| 251 | class BWTextDrawFilter : public SkDrawFilter { |
| 252 | public: |
| 253 | virtual void filter(SkPaint*, Type) SK_OVERRIDE; |
| 254 | }; |
| 255 | void BWTextDrawFilter::filter(SkPaint* p, Type t) { |
| 256 | if (kText_Type == t) { |
| 257 | p->setAntiAlias(false); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | static void installFilter(SkCanvas* canvas) { |
| 262 | if (gForceBWtext) { |
| 263 | canvas->setDrawFilter(new BWTextDrawFilter)->unref(); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | static void invokeGM(GM* gm, SkCanvas* canvas) { |
| 268 | installFilter(canvas); |
| 269 | gm->draw(canvas); |
| 270 | canvas->setDrawFilter(NULL); |
| 271 | } |
| 272 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 273 | static ErrorBitfield generate_image(GM* gm, const ConfigData& gRec, |
| 274 | GrContext* context, |
| 275 | GrRenderTarget* rt, |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 276 | SkBitmap* bitmap, |
| 277 | bool deferred) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 278 | SkISize size (gm->getISize()); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 279 | setup_bitmap(gRec, size, bitmap); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 280 | |
| 281 | if (gRec.fBackend == kRaster_Backend) { |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 282 | SkCanvas* canvas; |
| 283 | if (deferred) { |
| 284 | canvas = new SkDeferredCanvas; |
| 285 | canvas->setDevice(new SkDevice(*bitmap))->unref(); |
| 286 | } else { |
| 287 | canvas = new SkCanvas(*bitmap); |
| 288 | } |
| 289 | SkAutoUnref canvasUnref(canvas); |
| 290 | invokeGM(gm, canvas); |
junov@chromium.org | bf6c1e4 | 2012-01-30 14:53:22 +0000 | [diff] [blame] | 291 | canvas->flush(); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 292 | } else { // GPU |
| 293 | if (NULL == context) { |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 294 | return ERROR_NO_GPU_CONTEXT; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 295 | } |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 296 | SkCanvas* gc; |
| 297 | if (deferred) { |
| 298 | gc = new SkDeferredCanvas; |
| 299 | } else { |
| 300 | gc = new SkGpuCanvas(context, rt); |
| 301 | } |
| 302 | SkAutoUnref gcUnref(gc); |
| 303 | gc->setDevice(new SkGpuDevice(context, rt))->unref(); |
| 304 | invokeGM(gm, gc); |
reed@google.com | af951c9 | 2011-06-16 19:10:39 +0000 | [diff] [blame] | 305 | // the device is as large as the current rendertarget, so we explicitly |
| 306 | // only readback the amount we expect (in size) |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 307 | // overwrite our previous allocation |
bsalomon@google.com | c698097 | 2011-11-02 19:57:21 +0000 | [diff] [blame] | 308 | bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth, |
| 309 | size.fHeight); |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 310 | gc->readPixels(bitmap, 0, 0); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 311 | } |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 312 | return ERROR_NONE; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | static void generate_image_from_picture(GM* gm, const ConfigData& gRec, |
| 316 | SkPicture* pict, SkBitmap* bitmap) { |
| 317 | SkISize size = gm->getISize(); |
| 318 | setup_bitmap(gRec, size, bitmap); |
| 319 | SkCanvas canvas(*bitmap); |
mike@reedtribe.org | 10afbef | 2011-12-30 16:02:53 +0000 | [diff] [blame] | 320 | installFilter(&canvas); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 321 | canvas.drawPicture(*pict); |
| 322 | } |
| 323 | |
| 324 | static void generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) { |
| 325 | #ifdef SK_SUPPORT_PDF |
| 326 | SkISize size = gm->getISize(); |
| 327 | SkMatrix identity; |
| 328 | identity.reset(); |
ctguil@chromium.org | 1526129 | 2011-04-29 17:54:16 +0000 | [diff] [blame] | 329 | SkPDFDevice* dev = new SkPDFDevice(size, size, identity); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 330 | SkAutoUnref aur(dev); |
| 331 | |
| 332 | SkCanvas c(dev); |
mike@reedtribe.org | 10afbef | 2011-12-30 16:02:53 +0000 | [diff] [blame] | 333 | invokeGM(gm, &c); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 334 | |
| 335 | SkPDFDocument doc; |
| 336 | doc.appendPage(dev); |
| 337 | doc.emitPDF(&pdf); |
| 338 | #endif |
| 339 | } |
| 340 | |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 341 | static void generate_xps(GM* gm, SkDynamicMemoryWStream& xps) { |
| 342 | #ifdef SK_SUPPORT_XPS |
| 343 | SkISize size = gm->getISize(); |
| 344 | |
| 345 | SkSize trimSize = SkSize::Make(SkIntToScalar(size.width()), |
| 346 | SkIntToScalar(size.height())); |
bungeman@google.com | dc9a695 | 2012-01-05 16:56:29 +0000 | [diff] [blame] | 347 | static const SkScalar inchesPerMeter = SkScalarDiv(10000, 254); |
| 348 | static const SkScalar upm = 72 * inchesPerMeter; |
| 349 | SkVector unitsPerMeter = SkPoint::Make(upm, upm); |
| 350 | static const SkScalar ppm = 200 * inchesPerMeter; |
| 351 | SkVector pixelsPerMeter = SkPoint::Make(ppm, ppm); |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 352 | |
| 353 | SkXPSDevice* dev = new SkXPSDevice(); |
| 354 | SkAutoUnref aur(dev); |
| 355 | |
| 356 | SkCanvas c(dev); |
| 357 | dev->beginPortfolio(&xps); |
| 358 | dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize); |
mike@reedtribe.org | 10afbef | 2011-12-30 16:02:53 +0000 | [diff] [blame] | 359 | invokeGM(gm, &c); |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 360 | dev->endSheet(); |
| 361 | dev->endPortfolio(); |
| 362 | |
| 363 | #endif |
| 364 | } |
| 365 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 366 | static ErrorBitfield write_reference_image(const ConfigData& gRec, |
| 367 | const char writePath [], |
| 368 | const char renderModeDescriptor [], |
| 369 | const SkString& name, |
| 370 | SkBitmap& bitmap, |
| 371 | SkDynamicMemoryWStream* document) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 372 | SkString path; |
| 373 | bool success = false; |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 374 | if (gRec.fBackend == kRaster_Backend || |
| 375 | gRec.fBackend == kGPU_Backend || |
| 376 | (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { |
| 377 | |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 378 | path = make_filename(writePath, renderModeDescriptor, name, "png"); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 379 | success = write_bitmap(path, bitmap); |
reed@google.com | 46cce91 | 2011-06-29 12:54:46 +0000 | [diff] [blame] | 380 | } |
| 381 | if (kPDF_Backend == gRec.fBackend) { |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 382 | path = make_filename(writePath, renderModeDescriptor, name, "pdf"); |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 383 | success = write_document(path, *document); |
| 384 | } |
| 385 | if (kXPS_Backend == gRec.fBackend) { |
| 386 | path = make_filename(writePath, renderModeDescriptor, name, "xps"); |
| 387 | success = write_document(path, *document); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 388 | } |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 389 | if (success) { |
| 390 | return ERROR_NONE; |
| 391 | } else { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 392 | fprintf(stderr, "FAILED to write %s\n", path.c_str()); |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 393 | return ERROR_WRITING_REFERENCE_IMAGE; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 394 | } |
| 395 | } |
| 396 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 397 | static ErrorBitfield compare_to_reference_image(const SkString& name, |
| 398 | SkBitmap &bitmap, |
| 399 | const SkBitmap& comparisonBitmap, |
| 400 | const char diffPath [], |
| 401 | const char renderModeDescriptor []) { |
| 402 | ErrorBitfield errors; |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 403 | SkBitmap diffBitmap; |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 404 | errors = compare(bitmap, comparisonBitmap, name, renderModeDescriptor, |
| 405 | diffPath ? &diffBitmap : NULL); |
| 406 | if ((ERROR_NONE == errors) && diffPath) { |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 407 | SkString diffName = make_filename(diffPath, "", name, ".diff.png"); |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 408 | if (!write_bitmap(diffName, diffBitmap)) { |
| 409 | errors |= ERROR_WRITING_REFERENCE_IMAGE; |
| 410 | } |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 411 | } |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 412 | return errors; |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 413 | } |
| 414 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 415 | static ErrorBitfield compare_to_reference_image(const char readPath [], |
| 416 | const SkString& name, |
| 417 | SkBitmap &bitmap, |
| 418 | const char diffPath [], |
| 419 | const char renderModeDescriptor []) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 420 | SkString path = make_filename(readPath, "", name, "png"); |
| 421 | SkBitmap orig; |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 422 | if (SkImageDecoder::DecodeFile(path.c_str(), &orig, |
| 423 | SkBitmap::kARGB_8888_Config, |
| 424 | SkImageDecoder::kDecodePixels_Mode, NULL)) { |
| 425 | return compare_to_reference_image(name, bitmap, |
| 426 | orig, diffPath, |
| 427 | renderModeDescriptor); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 428 | } else { |
| 429 | fprintf(stderr, "FAILED to read %s\n", path.c_str()); |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 430 | return ERROR_READING_REFERENCE_IMAGE; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 431 | } |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 432 | } |
| 433 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 434 | static ErrorBitfield handle_test_results(GM* gm, |
| 435 | const ConfigData& gRec, |
| 436 | const char writePath [], |
| 437 | const char readPath [], |
| 438 | const char diffPath [], |
| 439 | const char renderModeDescriptor [], |
| 440 | SkBitmap& bitmap, |
| 441 | SkDynamicMemoryWStream* pdf, |
| 442 | const SkBitmap* comparisonBitmap) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 443 | SkString name = make_name(gm->shortName(), gRec.fName); |
| 444 | |
| 445 | if (writePath) { |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 446 | return write_reference_image(gRec, writePath, renderModeDescriptor, |
| 447 | name, bitmap, pdf); |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 448 | } else if (readPath && ( |
| 449 | gRec.fBackend == kRaster_Backend || |
| 450 | gRec.fBackend == kGPU_Backend || |
| 451 | (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF))) { |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 452 | return compare_to_reference_image(readPath, name, bitmap, |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 453 | diffPath, renderModeDescriptor); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 454 | } else if (comparisonBitmap) { |
| 455 | return compare_to_reference_image(name, bitmap, |
| 456 | *comparisonBitmap, diffPath, |
| 457 | renderModeDescriptor); |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 458 | } else { |
| 459 | return ERROR_NONE; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 460 | } |
| 461 | } |
| 462 | |
| 463 | static SkPicture* generate_new_picture(GM* gm) { |
| 464 | // Pictures are refcounted so must be on heap |
| 465 | SkPicture* pict = new SkPicture; |
| 466 | SkCanvas* cv = pict->beginRecording(1000, 1000); |
mike@reedtribe.org | 10afbef | 2011-12-30 16:02:53 +0000 | [diff] [blame] | 467 | invokeGM(gm, cv); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 468 | pict->endRecording(); |
| 469 | |
| 470 | return pict; |
| 471 | } |
| 472 | |
| 473 | static SkPicture* stream_to_new_picture(const SkPicture& src) { |
| 474 | |
| 475 | // To do in-memory commiunications with a stream, we need to: |
| 476 | // * create a dynamic memory stream |
| 477 | // * copy it into a buffer |
| 478 | // * create a read stream from it |
| 479 | // ?!?! |
| 480 | |
| 481 | SkDynamicMemoryWStream storage; |
| 482 | src.serialize(&storage); |
| 483 | |
| 484 | int streamSize = storage.getOffset(); |
| 485 | SkAutoMalloc dstStorage(streamSize); |
| 486 | void* dst = dstStorage.get(); |
| 487 | //char* dst = new char [streamSize]; |
| 488 | //@todo thudson 22 April 2011 when can we safely delete [] dst? |
| 489 | storage.copyTo(dst); |
| 490 | SkMemoryStream pictReadback(dst, streamSize); |
| 491 | SkPicture* retval = new SkPicture (&pictReadback); |
| 492 | return retval; |
| 493 | } |
| 494 | |
| 495 | // Test: draw into a bitmap or pdf. |
| 496 | // Depending on flags, possibly compare to an expected image |
| 497 | // and possibly output a diff image if it fails to match. |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 498 | static ErrorBitfield test_drawing(GM* gm, |
| 499 | const ConfigData& gRec, |
| 500 | const char writePath [], |
| 501 | const char readPath [], |
| 502 | const char diffPath [], |
| 503 | GrContext* context, |
| 504 | GrRenderTarget* rt, |
| 505 | SkBitmap* bitmap) { |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 506 | SkDynamicMemoryWStream document; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 507 | |
| 508 | if (gRec.fBackend == kRaster_Backend || |
bsalomon@google.com | 971d0c8 | 2011-08-19 17:22:05 +0000 | [diff] [blame] | 509 | gRec.fBackend == kGPU_Backend) { |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 510 | // Early exit if we can't generate the image. |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 511 | ErrorBitfield errors = generate_image(gm, gRec, context, rt, bitmap, |
| 512 | false); |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 513 | if (ERROR_NONE != errors) { |
| 514 | return errors; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 515 | } |
reed@google.com | 46cce91 | 2011-06-29 12:54:46 +0000 | [diff] [blame] | 516 | } else if (gRec.fBackend == kPDF_Backend) { |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 517 | generate_pdf(gm, document); |
reed@google.com | 46cce91 | 2011-06-29 12:54:46 +0000 | [diff] [blame] | 518 | #if CAN_IMAGE_PDF |
bungeman@google.com | 0f1541f | 2011-10-10 13:47:06 +0000 | [diff] [blame] | 519 | SkAutoDataUnref data(document.copyToData()); |
reed@google.com | 46cce91 | 2011-06-29 12:54:46 +0000 | [diff] [blame] | 520 | SkMemoryStream stream(data.data(), data.size()); |
| 521 | SkPDFDocumentToBitmap(&stream, bitmap); |
| 522 | #endif |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 523 | } else if (gRec.fBackend == kXPS_Backend) { |
| 524 | generate_xps(gm, document); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 525 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 526 | return handle_test_results(gm, gRec, writePath, readPath, diffPath, |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 527 | "", *bitmap, &document, NULL); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 528 | } |
| 529 | |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 530 | static ErrorBitfield test_deferred_drawing(GM* gm, |
| 531 | const ConfigData& gRec, |
| 532 | const SkBitmap& comparisonBitmap, |
| 533 | const char diffPath [], |
| 534 | GrContext* context, |
| 535 | GrRenderTarget* rt) { |
| 536 | SkDynamicMemoryWStream document; |
| 537 | |
| 538 | if (gRec.fBackend == kRaster_Backend || |
| 539 | gRec.fBackend == kGPU_Backend) { |
| 540 | SkBitmap bitmap; |
| 541 | // Early exit if we can't generate the image, but this is |
| 542 | // expected in some cases, so don't report a test failure. |
| 543 | if (!generate_image(gm, gRec, context, rt, &bitmap, true)) { |
| 544 | return ERROR_NONE; |
| 545 | } |
| 546 | return handle_test_results(gm, gRec, NULL, NULL, diffPath, |
| 547 | "-deferred", bitmap, NULL, &comparisonBitmap); |
| 548 | } |
| 549 | return ERROR_NONE; |
| 550 | } |
| 551 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 552 | static ErrorBitfield test_picture_playback(GM* gm, |
| 553 | const ConfigData& gRec, |
| 554 | const SkBitmap& comparisonBitmap, |
| 555 | const char readPath [], |
| 556 | const char diffPath []) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 557 | SkPicture* pict = generate_new_picture(gm); |
| 558 | SkAutoUnref aur(pict); |
| 559 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 560 | if (kRaster_Backend == gRec.fBackend) { |
| 561 | SkBitmap bitmap; |
| 562 | generate_image_from_picture(gm, gRec, pict, &bitmap); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 563 | return handle_test_results(gm, gRec, NULL, NULL, diffPath, |
| 564 | "-replay", bitmap, NULL, &comparisonBitmap); |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 565 | } else { |
| 566 | return ERROR_NONE; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 567 | } |
| 568 | } |
| 569 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 570 | static ErrorBitfield test_picture_serialization(GM* gm, |
| 571 | const ConfigData& gRec, |
| 572 | const SkBitmap& comparisonBitmap, |
| 573 | const char readPath [], |
| 574 | const char diffPath []) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 575 | SkPicture* pict = generate_new_picture(gm); |
| 576 | SkAutoUnref aurp(pict); |
| 577 | SkPicture* repict = stream_to_new_picture(*pict); |
| 578 | SkAutoUnref aurr(repict); |
| 579 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 580 | if (kRaster_Backend == gRec.fBackend) { |
| 581 | SkBitmap bitmap; |
| 582 | generate_image_from_picture(gm, gRec, repict, &bitmap); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 583 | return handle_test_results(gm, gRec, NULL, NULL, diffPath, |
| 584 | "-serialize", bitmap, NULL, &comparisonBitmap); |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 585 | } else { |
| 586 | return ERROR_NONE; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 587 | } |
| 588 | } |
| 589 | |
| 590 | static void usage(const char * argv0) { |
junov@google.com | 77e498e | 2012-01-18 18:56:34 +0000 | [diff] [blame] | 591 | SkDebugf( |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame^] | 592 | "%s [-w writePath] [-r readPath] [-d diffPath] [-i resourcePath]\n" |
| 593 | " [--noreplay] [--serialize] [--forceBWtext] [--nopdf] \n" |
| 594 | " [--nodeferred] [--match substring] [--notexturecache]" |
junov@google.com | 77e498e | 2012-01-18 18:56:34 +0000 | [diff] [blame] | 595 | #if SK_MESA |
| 596 | " [--mesagl]" |
| 597 | #endif |
| 598 | "\n\n", argv0); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 599 | SkDebugf(" writePath: directory to write rendered images in.\n"); |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 600 | SkDebugf( |
| 601 | " readPath: directory to read reference images from;\n" |
| 602 | " reports if any pixels mismatch between reference and new images\n"); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 603 | SkDebugf(" diffPath: directory to write difference images in.\n"); |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame^] | 604 | SkDebugf(" resourcePath: directory that stores image resources.\n"); |
junov@google.com | 77e498e | 2012-01-18 18:56:34 +0000 | [diff] [blame] | 605 | SkDebugf(" --noreplay: do not exercise SkPicture replay.\n"); |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 606 | SkDebugf( |
| 607 | " --serialize: exercise SkPicture serialization & deserialization.\n"); |
junov@google.com | 77e498e | 2012-01-18 18:56:34 +0000 | [diff] [blame] | 608 | SkDebugf(" --forceBWtext: disable text anti-aliasing.\n"); |
| 609 | SkDebugf(" --nopdf: skip the pdf rendering test pass.\n"); |
| 610 | SkDebugf(" --nodeferred: skip the deferred rendering test pass.\n"); |
reed@google.com | e6a5c4d | 2011-07-25 14:30:54 +0000 | [diff] [blame] | 611 | SkDebugf(" --match foo will only run tests that substring match foo.\n"); |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 612 | #if SK_MESA |
| 613 | SkDebugf(" --mesagl will run using the osmesa sw gl rasterizer.\n"); |
| 614 | #endif |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 615 | SkDebugf(" --notexturecache: disable the gpu texture cache.\n"); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | static const ConfigData gRec[] = { |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 619 | { SkBitmap::kARGB_8888_Config, kRaster_Backend, "8888" }, |
| 620 | { SkBitmap::kARGB_4444_Config, kRaster_Backend, "4444" }, |
| 621 | { SkBitmap::kRGB_565_Config, kRaster_Backend, "565" }, |
reed@google.com | 1a7e946 | 2011-06-20 13:21:24 +0000 | [diff] [blame] | 622 | #ifdef SK_SCALAR_IS_FLOAT |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 623 | { SkBitmap::kARGB_8888_Config, kGPU_Backend, "gpu" }, |
reed@google.com | 1a7e946 | 2011-06-20 13:21:24 +0000 | [diff] [blame] | 624 | #endif |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 625 | #ifdef SK_SUPPORT_PDF |
| 626 | { SkBitmap::kARGB_8888_Config, kPDF_Backend, "pdf" }, |
| 627 | #endif |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 628 | #ifdef SK_SUPPORT_XPS |
| 629 | { SkBitmap::kARGB_8888_Config, kXPS_Backend, "xps" }, |
| 630 | #endif |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 631 | }; |
| 632 | |
reed@google.com | b2a5162 | 2011-10-31 16:30:04 +0000 | [diff] [blame] | 633 | static bool skip_name(const SkTDArray<const char*> array, const char name[]) { |
| 634 | if (0 == array.count()) { |
| 635 | // no names, so don't skip anything |
| 636 | return false; |
| 637 | } |
| 638 | for (int i = 0; i < array.count(); ++i) { |
| 639 | if (strstr(name, array[i])) { |
| 640 | // found the name, so don't skip |
| 641 | return false; |
| 642 | } |
| 643 | } |
| 644 | return true; |
| 645 | } |
| 646 | |
bsalomon@google.com | d9f826c | 2011-07-18 15:25:04 +0000 | [diff] [blame] | 647 | namespace skiagm { |
| 648 | static GrContext* gGrContext; |
| 649 | GrContext* GetGr() { |
| 650 | return gGrContext; |
| 651 | } |
| 652 | } |
| 653 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 654 | int main(int argc, char * const argv[]) { |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 655 | SkAutoGraphics ag; |
reed@google.com | 8923c6c | 2011-11-08 14:59:38 +0000 | [diff] [blame] | 656 | // we don't need to see this during a run |
| 657 | gSkSuppressFontCachePurgeSpew = true; |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 658 | |
epoger@google.com | 7bc13a6 | 2012-02-14 14:53:59 +0000 | [diff] [blame] | 659 | setSystemPreferences(); |
| 660 | |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 661 | const char* writePath = NULL; // if non-null, where we write the originals |
| 662 | 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] | 663 | 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^] | 664 | 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] | 665 | |
reed@google.com | b2a5162 | 2011-10-31 16:30:04 +0000 | [diff] [blame] | 666 | SkTDArray<const char*> fMatches; |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 667 | |
reed@google.com | ab97397 | 2011-09-19 19:01:38 +0000 | [diff] [blame] | 668 | bool doPDF = true; |
reed@google.com | b8b0983 | 2011-05-26 15:57:56 +0000 | [diff] [blame] | 669 | bool doReplay = true; |
tomhudson@google.com | 6abfa49 | 2011-04-26 14:59:32 +0000 | [diff] [blame] | 670 | bool doSerialize = false; |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 671 | bool useMesa = false; |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 672 | bool doDeferred = true; |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 673 | bool disableTextureCache = false; |
| 674 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 675 | const char* const commandName = argv[0]; |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 676 | char* const* stop = argv + argc; |
| 677 | for (++argv; argv < stop; ++argv) { |
| 678 | if (strcmp(*argv, "-w") == 0) { |
| 679 | argv++; |
| 680 | if (argv < stop && **argv) { |
| 681 | writePath = *argv; |
| 682 | } |
| 683 | } else if (strcmp(*argv, "-r") == 0) { |
| 684 | argv++; |
| 685 | if (argv < stop && **argv) { |
| 686 | readPath = *argv; |
| 687 | } |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 688 | } else if (strcmp(*argv, "-d") == 0) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 689 | argv++; |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 690 | if (argv < stop && **argv) { |
| 691 | diffPath = *argv; |
| 692 | } |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame^] | 693 | } else if (strcmp(*argv, "-i") == 0) { |
| 694 | argv++; |
| 695 | if (argv < stop && **argv) { |
| 696 | resourcePath = *argv; |
| 697 | } |
mike@reedtribe.org | 10afbef | 2011-12-30 16:02:53 +0000 | [diff] [blame] | 698 | } else if (strcmp(*argv, "--forceBWtext") == 0) { |
| 699 | gForceBWtext = true; |
reed@google.com | b8b0983 | 2011-05-26 15:57:56 +0000 | [diff] [blame] | 700 | } else if (strcmp(*argv, "--noreplay") == 0) { |
| 701 | doReplay = false; |
reed@google.com | ab97397 | 2011-09-19 19:01:38 +0000 | [diff] [blame] | 702 | } else if (strcmp(*argv, "--nopdf") == 0) { |
| 703 | doPDF = false; |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 704 | } else if (strcmp(*argv, "--nodeferred") == 0) { |
| 705 | doDeferred = false; |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 706 | } else if (strcmp(*argv, "--serialize") == 0) { |
| 707 | doSerialize = true; |
reed@google.com | ece2b02 | 2011-07-25 14:28:57 +0000 | [diff] [blame] | 708 | } else if (strcmp(*argv, "--match") == 0) { |
| 709 | ++argv; |
| 710 | if (argv < stop && **argv) { |
reed@google.com | b2a5162 | 2011-10-31 16:30:04 +0000 | [diff] [blame] | 711 | // just record the ptr, no need for a deep copy |
| 712 | *fMatches.append() = *argv; |
reed@google.com | ece2b02 | 2011-07-25 14:28:57 +0000 | [diff] [blame] | 713 | } |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 714 | #if SK_MESA |
| 715 | } else if (strcmp(*argv, "--mesagl") == 0) { |
| 716 | useMesa = true; |
| 717 | #endif |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 718 | } else if (strcmp(*argv, "--notexturecache") == 0) { |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame^] | 719 | disableTextureCache = true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 720 | } else { |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame^] | 721 | usage(commandName); |
| 722 | return -1; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 723 | } |
| 724 | } |
| 725 | if (argv != stop) { |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame^] | 726 | usage(commandName); |
| 727 | return -1; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 728 | } |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 729 | |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame^] | 730 | GM::SetResourcePath(resourcePath); |
| 731 | |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 732 | int maxW = -1; |
| 733 | int maxH = -1; |
| 734 | Iter iter; |
| 735 | GM* gm; |
| 736 | while ((gm = iter.next()) != NULL) { |
| 737 | SkISize size = gm->getISize(); |
| 738 | maxW = SkMax32(size.width(), maxW); |
| 739 | maxH = SkMax32(size.height(), maxH); |
tomhudson@google.com | 7816a4e | 2012-03-15 13:39:51 +0000 | [diff] [blame] | 740 | // This fixes a memory leak, but we are churning gms; we could |
| 741 | // instead cache them if we have constructors with side-effects. |
| 742 | SkDELETE(gm); |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 743 | } |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 744 | // setup a GL context for drawing offscreen |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 745 | SkAutoTUnref<SkGLContext> glContext; |
| 746 | #if SK_MESA |
| 747 | if (useMesa) { |
| 748 | glContext.reset(new SkMesaGLContext()); |
| 749 | } else |
| 750 | #endif |
| 751 | { |
| 752 | glContext.reset(new SkNativeGLContext()); |
| 753 | } |
| 754 | |
bsalomon@google.com | 29d3501 | 2011-11-30 16:57:21 +0000 | [diff] [blame] | 755 | GrPlatformRenderTargetDesc rtDesc; |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 756 | if (glContext.get()->init(maxW, maxH)) { |
| 757 | GrPlatform3DContext ctx = |
| 758 | reinterpret_cast<GrPlatform3DContext>(glContext.get()->gl()); |
| 759 | gGrContext = GrContext::Create(kOpenGL_Shaders_GrEngine, ctx); |
bsalomon@google.com | 971d0c8 | 2011-08-19 17:22:05 +0000 | [diff] [blame] | 760 | if (NULL != gGrContext) { |
bsalomon@google.com | 29d3501 | 2011-11-30 16:57:21 +0000 | [diff] [blame] | 761 | rtDesc.fConfig = kSkia8888_PM_GrPixelConfig; |
| 762 | rtDesc.fStencilBits = 8; |
| 763 | rtDesc.fRenderTargetHandle = glContext.get()->getFBOID(); |
bsalomon@google.com | 971d0c8 | 2011-08-19 17:22:05 +0000 | [diff] [blame] | 764 | } |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 765 | } else { |
| 766 | fprintf(stderr, "could not create GL context.\n"); |
reed@google.com | 37df17d | 2010-12-23 20:20:51 +0000 | [diff] [blame] | 767 | } |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 768 | |
reed@android.com | 00f883e | 2010-12-14 17:46:14 +0000 | [diff] [blame] | 769 | if (readPath) { |
| 770 | fprintf(stderr, "reading from %s\n", readPath); |
| 771 | } else if (writePath) { |
| 772 | fprintf(stderr, "writing to %s\n", writePath); |
| 773 | } |
| 774 | |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame^] | 775 | if (resourcePath) { |
| 776 | fprintf(stderr, "reading resources from %s\n", resourcePath); |
| 777 | } |
| 778 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 779 | // Accumulate success of all tests. |
| 780 | int testsRun = 0; |
| 781 | int testsPassed = 0; |
| 782 | int testsFailed = 0; |
| 783 | int testsMissingReferenceImages = 0; |
| 784 | |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 785 | if (disableTextureCache) { |
| 786 | skiagm::GetGr()->setTextureCacheLimits(0, 0); |
| 787 | } |
| 788 | |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 789 | iter.reset(); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 790 | while ((gm = iter.next()) != NULL) { |
reed@google.com | ece2b02 | 2011-07-25 14:28:57 +0000 | [diff] [blame] | 791 | const char* shortName = gm->shortName(); |
reed@google.com | b2a5162 | 2011-10-31 16:30:04 +0000 | [diff] [blame] | 792 | if (skip_name(fMatches, shortName)) { |
reed@google.com | ece2b02 | 2011-07-25 14:28:57 +0000 | [diff] [blame] | 793 | SkDELETE(gm); |
| 794 | continue; |
| 795 | } |
| 796 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 797 | SkISize size = gm->getISize(); |
reed@google.com | ece2b02 | 2011-07-25 14:28:57 +0000 | [diff] [blame] | 798 | SkDebugf("drawing... %s [%d %d]\n", shortName, |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 799 | size.width(), size.height()); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 800 | SkBitmap forwardRenderedBitmap; |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 801 | |
bsalomon@google.com | 29d3501 | 2011-11-30 16:57:21 +0000 | [diff] [blame] | 802 | // Above we created an fbo for the context at maxW x maxH size. |
| 803 | // Here we lie about the size of the rt. We claim it is the size |
| 804 | // desired by the test. The reason is that rasterization may change |
| 805 | // slightly when the viewport dimensions change. Previously, whenever |
| 806 | // a new test was checked in that bumped maxW or maxH several images |
| 807 | // would slightly change. |
| 808 | rtDesc.fWidth = size.width(); |
| 809 | rtDesc.fHeight = size.height(); |
| 810 | SkAutoTUnref<GrRenderTarget> rt; |
| 811 | if (gGrContext) { |
| 812 | rt.reset(gGrContext->createPlatformRenderTarget(rtDesc)); |
| 813 | } |
reed@google.com | fbc2117 | 2011-09-19 19:08:33 +0000 | [diff] [blame] | 814 | |
bsalomon@google.com | 29d3501 | 2011-11-30 16:57:21 +0000 | [diff] [blame] | 815 | for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 816 | // Skip any tests that we don't even need to try. |
bsalomon@google.com | 29d3501 | 2011-11-30 16:57:21 +0000 | [diff] [blame] | 817 | uint32_t gmFlags = gm->getFlags(); |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 818 | if ((kPDF_Backend == gRec[i].fBackend) && |
bungeman@google.com | 64e011a | 2011-09-19 19:31:04 +0000 | [diff] [blame] | 819 | (!doPDF || (gmFlags & GM::kSkipPDF_Flag))) |
| 820 | { |
reed@google.com | ab97397 | 2011-09-19 19:01:38 +0000 | [diff] [blame] | 821 | continue; |
| 822 | } |
| 823 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 824 | // Now we know that we want to run this test and record its |
| 825 | // success or failure. |
| 826 | ErrorBitfield testErrors = ERROR_NONE; |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 827 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 828 | if ((ERROR_NONE == testErrors) && |
| 829 | (kGPU_Backend == gRec[i].fBackend) && |
| 830 | (NULL == rt.get())) { |
| 831 | fprintf(stderr, "Could not create render target for gpu.\n"); |
| 832 | testErrors |= ERROR_NO_GPU_CONTEXT; |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 833 | } |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 834 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 835 | if (ERROR_NONE == testErrors) { |
| 836 | testErrors |= test_drawing(gm, gRec[i], |
| 837 | writePath, readPath, diffPath, |
| 838 | gGrContext, |
| 839 | rt.get(), &forwardRenderedBitmap); |
| 840 | } |
| 841 | |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 842 | if (doDeferred && !testErrors && |
twiz@google.com | e24a079 | 2012-01-31 18:35:30 +0000 | [diff] [blame] | 843 | (kGPU_Backend == gRec[i].fBackend || |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame^] | 844 | kRaster_Backend == gRec[i].fBackend)) { |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 845 | testErrors |= test_deferred_drawing(gm, gRec[i], |
robertphillips@google.com | 8570b5c | 2012-03-20 17:40:58 +0000 | [diff] [blame^] | 846 | forwardRenderedBitmap, |
| 847 | diffPath, gGrContext, rt.get()); |
junov@google.com | 4370aed | 2012-01-18 16:21:08 +0000 | [diff] [blame] | 848 | } |
| 849 | |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 850 | if ((ERROR_NONE == testErrors) && doReplay && |
| 851 | !(gmFlags & GM::kSkipPicture_Flag)) { |
| 852 | testErrors |= test_picture_playback(gm, gRec[i], |
| 853 | forwardRenderedBitmap, |
| 854 | readPath, diffPath); |
| 855 | } |
| 856 | |
| 857 | if ((ERROR_NONE == testErrors) && doSerialize) { |
| 858 | testErrors |= test_picture_serialization(gm, gRec[i], |
| 859 | forwardRenderedBitmap, |
| 860 | readPath, diffPath); |
| 861 | } |
| 862 | |
| 863 | // Update overall results. |
| 864 | // We only tabulate the particular error types that we currently |
| 865 | // care about (e.g., missing reference images). Later on, if we |
| 866 | // want to also tabulate pixel mismatches vs dimension mistmatches |
| 867 | // (or whatever else), we can do so. |
| 868 | testsRun++; |
| 869 | if (ERROR_NONE == testErrors) { |
| 870 | testsPassed++; |
| 871 | } else if (ERROR_READING_REFERENCE_IMAGE & testErrors) { |
| 872 | testsMissingReferenceImages++; |
| 873 | } else { |
| 874 | testsFailed++; |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 875 | } |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 876 | } |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 877 | SkDELETE(gm); |
| 878 | } |
epoger@google.com | c7cf2b3 | 2011-12-28 19:31:01 +0000 | [diff] [blame] | 879 | printf("Ran %d tests: %d passed, %d failed, %d missing reference images\n", |
| 880 | testsRun, testsPassed, testsFailed, testsMissingReferenceImages); |
| 881 | return (0 == testsFailed) ? 0 : -1; |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 882 | } |