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