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