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