reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 1 | #include "gm.h" |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 2 | #include "SkColorPriv.h" |
reed@google.com | 8a85d0c | 2011-06-24 19:12:12 +0000 | [diff] [blame] | 3 | #include "SkData.h" |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 4 | #include "SkGraphics.h" |
| 5 | #include "SkImageDecoder.h" |
| 6 | #include "SkImageEncoder.h" |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 7 | #include "SkPicture.h" |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 8 | #include "SkStream.h" |
| 9 | #include "SkRefCnt.h" |
| 10 | |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 11 | #include "GrContext.h" |
| 12 | #include "SkGpuCanvas.h" |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 13 | #include "SkGpuDevice.h" |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 14 | #include "SkEGLContext.h" |
| 15 | #include "SkDevice.h" |
| 16 | |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 17 | #ifdef SK_SUPPORT_PDF |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 18 | #include "SkPDFDevice.h" |
| 19 | #include "SkPDFDocument.h" |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 20 | #endif |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 21 | |
| 22 | using namespace skiagm; |
| 23 | |
| 24 | // need to explicitly declare this, or we get some weird infinite loop llist |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 25 | template GMRegistry* SkTRegistry<GM*, void*>::gHead; |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 26 | |
| 27 | class Iter { |
| 28 | public: |
| 29 | Iter() { |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 30 | this->reset(); |
| 31 | } |
| 32 | |
| 33 | void reset() { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 34 | fReg = GMRegistry::Head(); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 35 | } |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 36 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 37 | GM* next() { |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 38 | if (fReg) { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 39 | GMRegistry::Factory fact = fReg->factory(); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 40 | fReg = fReg->next(); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 41 | return fact(0); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 42 | } |
| 43 | return NULL; |
| 44 | } |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 45 | |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 46 | static int Count() { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 47 | const GMRegistry* reg = GMRegistry::Head(); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 48 | int count = 0; |
| 49 | while (reg) { |
| 50 | count += 1; |
| 51 | reg = reg->next(); |
| 52 | } |
| 53 | return count; |
| 54 | } |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 55 | |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 56 | private: |
| 57 | const GMRegistry* fReg; |
| 58 | }; |
| 59 | |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 60 | static SkString make_name(const char shortName[], const char configName[]) { |
| 61 | SkString name(shortName); |
| 62 | name.appendf("_%s", configName); |
| 63 | return name; |
| 64 | } |
| 65 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 66 | static SkString make_filename(const char path[], |
| 67 | const char pathSuffix[], |
| 68 | const SkString& name, |
| 69 | const char suffix[]) { |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 70 | SkString filename(path); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 71 | if (filename.endsWith("/")) { |
| 72 | filename.remove(filename.size() - 1, 1); |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 73 | } |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 74 | filename.append(pathSuffix); |
| 75 | filename.append("/"); |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 76 | filename.appendf("%s.%s", name.c_str(), suffix); |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 77 | return filename; |
| 78 | } |
| 79 | |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 80 | /* since PNG insists on unpremultiplying our alpha, we take no precision chances |
| 81 | and force all pixels to be 100% opaque, otherwise on compare we may not get |
| 82 | a perfect match. |
| 83 | */ |
| 84 | static void force_all_opaque(const SkBitmap& bitmap) { |
| 85 | SkAutoLockPixels lock(bitmap); |
| 86 | for (int y = 0; y < bitmap.height(); y++) { |
| 87 | for (int x = 0; x < bitmap.width(); x++) { |
| 88 | *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { |
| 94 | SkBitmap copy; |
| 95 | bitmap.copyTo(©, SkBitmap::kARGB_8888_Config); |
| 96 | force_all_opaque(copy); |
| 97 | return SkImageEncoder::EncodeFile(path.c_str(), copy, |
| 98 | SkImageEncoder::kPNG_Type, 100); |
| 99 | } |
| 100 | |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 101 | static inline SkPMColor compute_diff_pmcolor(SkPMColor c0, SkPMColor c1) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 102 | int dr = SkGetPackedR32(c0) - SkGetPackedR32(c1); |
| 103 | int dg = SkGetPackedG32(c0) - SkGetPackedG32(c1); |
| 104 | int db = SkGetPackedB32(c0) - SkGetPackedB32(c1); |
| 105 | return SkPackARGB32(0xFF, SkAbs32(dr), SkAbs32(dg), SkAbs32(db)); |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | static void compute_diff(const SkBitmap& target, const SkBitmap& base, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 109 | SkBitmap* diff) { |
| 110 | SkAutoLockPixels alp(*diff); |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 111 | |
| 112 | const int w = target.width(); |
| 113 | const int h = target.height(); |
| 114 | for (int y = 0; y < h; y++) { |
| 115 | for (int x = 0; x < w; x++) { |
| 116 | SkPMColor c0 = *base.getAddr32(x, y); |
| 117 | SkPMColor c1 = *target.getAddr32(x, y); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 118 | SkPMColor d = 0; |
| 119 | if (c0 != c1) { |
| 120 | d = compute_diff_pmcolor(c0, c1); |
| 121 | } |
| 122 | *diff->getAddr32(x, y) = d; |
| 123 | } |
| 124 | } |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | static bool compare(const SkBitmap& target, const SkBitmap& base, |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 128 | const SkString& name, const char* renderModeDescriptor, |
tomhudson@google.com | 6abfa49 | 2011-04-26 14:59:32 +0000 | [diff] [blame] | 129 | SkBitmap* diff) { |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 130 | SkBitmap copy; |
| 131 | const SkBitmap* bm = ⌖ |
| 132 | if (target.config() != SkBitmap::kARGB_8888_Config) { |
| 133 | target.copyTo(©, SkBitmap::kARGB_8888_Config); |
| 134 | bm = © |
| 135 | } |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 136 | SkBitmap baseCopy; |
| 137 | const SkBitmap* bp = &base; |
| 138 | if (base.config() != SkBitmap::kARGB_8888_Config) { |
| 139 | base.copyTo(&baseCopy, SkBitmap::kARGB_8888_Config); |
| 140 | bp = &baseCopy; |
| 141 | } |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 142 | |
| 143 | force_all_opaque(*bm); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 144 | force_all_opaque(*bp); |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 145 | |
| 146 | const int w = bm->width(); |
| 147 | const int h = bm->height(); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 148 | if (w != bp->width() || h != bp->height()) { |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 149 | SkDebugf( |
| 150 | "---- %s dimensions mismatch for %s base [%d %d] current [%d %d]\n", |
| 151 | renderModeDescriptor, name.c_str(), |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 152 | bp->width(), bp->height(), w, h); |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 153 | return false; |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | SkAutoLockPixels bmLock(*bm); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 157 | SkAutoLockPixels baseLock(*bp); |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 158 | |
| 159 | for (int y = 0; y < h; y++) { |
| 160 | for (int x = 0; x < w; x++) { |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 161 | SkPMColor c0 = *bp->getAddr32(x, y); |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 162 | SkPMColor c1 = *bm->getAddr32(x, y); |
| 163 | if (c0 != c1) { |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 164 | SkDebugf( |
| 165 | "----- %s pixel mismatch for %s at [%d %d] base 0x%08X current 0x%08X\n", |
| 166 | renderModeDescriptor, name.c_str(), x, y, c0, c1); |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 167 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 168 | if (diff) { |
| 169 | diff->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 170 | diff->allocPixels(); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 171 | compute_diff(*bm, *bp, diff); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 172 | } |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 173 | return false; |
reed@android.com | b9b9a18 | 2009-07-08 02:54:47 +0000 | [diff] [blame] | 174 | } |
| 175 | } |
| 176 | } |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 177 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 178 | // they're equal |
| 179 | return true; |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 180 | } |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 181 | |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 182 | static bool write_pdf(const SkString& path, const SkDynamicMemoryWStream& pdf) { |
| 183 | SkFILEWStream stream(path.c_str()); |
reed@google.com | 8a85d0c | 2011-06-24 19:12:12 +0000 | [diff] [blame] | 184 | SkAutoDataUnref data(pdf.copyToData()); |
| 185 | return stream.writeData(data.get()); |
reed@google.com | 0770044 | 2010-12-20 19:46:07 +0000 | [diff] [blame] | 186 | } |
| 187 | |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 188 | enum Backend { |
| 189 | kRaster_Backend, |
| 190 | kGPU_Backend, |
| 191 | kPDF_Backend, |
| 192 | }; |
| 193 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 194 | struct ConfigData { |
| 195 | SkBitmap::Config fConfig; |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 196 | Backend fBackend; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 197 | const char* fName; |
| 198 | }; |
| 199 | |
| 200 | /// Returns true if processing should continue, false to skip the |
| 201 | /// remainder of this config for this GM. |
| 202 | //@todo thudson 22 April 2011 - could refactor this to take in |
| 203 | // a factory to generate the context, always call readPixels() |
| 204 | // (logically a noop for rasters, if wasted time), and thus collapse the |
| 205 | // GPU special case and also let this be used for SkPicture testing. |
| 206 | static void setup_bitmap(const ConfigData& gRec, SkISize& size, |
| 207 | SkBitmap* bitmap) { |
| 208 | bitmap->setConfig(gRec.fConfig, size.width(), size.height()); |
| 209 | bitmap->allocPixels(); |
| 210 | bitmap->eraseColor(0); |
| 211 | } |
| 212 | |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 213 | // Returns true if the test should continue, false if the test should |
| 214 | // halt. |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 215 | static bool generate_image(GM* gm, const ConfigData& gRec, |
| 216 | GrContext* context, |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 217 | SkBitmap* bitmap) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 218 | SkISize size (gm->getISize()); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 219 | setup_bitmap(gRec, size, bitmap); |
| 220 | SkCanvas canvas(*bitmap); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 221 | |
| 222 | if (gRec.fBackend == kRaster_Backend) { |
| 223 | gm->draw(&canvas); |
| 224 | } else { // GPU |
| 225 | if (NULL == context) { |
| 226 | return false; |
| 227 | } |
reed@google.com | af951c9 | 2011-06-16 19:10:39 +0000 | [diff] [blame] | 228 | // not a real object, so don't unref it |
| 229 | GrRenderTarget* rt = SkGpuDevice::Current3DApiRenderTarget(); |
| 230 | SkGpuCanvas gc(context, rt); |
| 231 | gc.setDevice(new SkGpuDevice(context, rt))->unref(); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 232 | gm->draw(&gc); |
reed@google.com | af951c9 | 2011-06-16 19:10:39 +0000 | [diff] [blame] | 233 | // the device is as large as the current rendertarget, so we explicitly |
| 234 | // only readback the amount we expect (in size) |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 235 | // overwrite our previous allocation |
| 236 | gc.readPixels(SkIRect::MakeSize(size), bitmap); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 237 | } |
| 238 | return true; |
| 239 | } |
| 240 | |
| 241 | static void generate_image_from_picture(GM* gm, const ConfigData& gRec, |
| 242 | SkPicture* pict, SkBitmap* bitmap) { |
| 243 | SkISize size = gm->getISize(); |
| 244 | setup_bitmap(gRec, size, bitmap); |
| 245 | SkCanvas canvas(*bitmap); |
| 246 | canvas.drawPicture(*pict); |
| 247 | } |
| 248 | |
| 249 | static void generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) { |
| 250 | #ifdef SK_SUPPORT_PDF |
| 251 | SkISize size = gm->getISize(); |
| 252 | SkMatrix identity; |
| 253 | identity.reset(); |
ctguil@chromium.org | 1526129 | 2011-04-29 17:54:16 +0000 | [diff] [blame] | 254 | SkPDFDevice* dev = new SkPDFDevice(size, size, identity); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 255 | SkAutoUnref aur(dev); |
| 256 | |
| 257 | SkCanvas c(dev); |
| 258 | gm->draw(&c); |
| 259 | |
| 260 | SkPDFDocument doc; |
| 261 | doc.appendPage(dev); |
| 262 | doc.emitPDF(&pdf); |
| 263 | #endif |
| 264 | } |
| 265 | |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 266 | static bool write_reference_image(const ConfigData& gRec, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 267 | const char writePath [], |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 268 | const char renderModeDescriptor [], |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 269 | const SkString& name, |
| 270 | SkBitmap& bitmap, |
| 271 | SkDynamicMemoryWStream* pdf) { |
| 272 | SkString path; |
| 273 | bool success = false; |
| 274 | if (gRec.fBackend != kPDF_Backend) { |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 275 | path = make_filename(writePath, renderModeDescriptor, name, "png"); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 276 | success = write_bitmap(path, bitmap); |
| 277 | } else if (pdf) { |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 278 | path = make_filename(writePath, renderModeDescriptor, name, "pdf"); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 279 | success = write_pdf(path, *pdf); |
| 280 | } |
| 281 | if (!success) { |
| 282 | fprintf(stderr, "FAILED to write %s\n", path.c_str()); |
| 283 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 284 | return success; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 285 | } |
| 286 | |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 287 | static bool compare_to_reference_image(const SkString& name, |
| 288 | SkBitmap &bitmap, |
| 289 | const SkBitmap& comparisonBitmap, |
| 290 | const char diffPath [], |
| 291 | const char renderModeDescriptor []) { |
| 292 | bool success; |
| 293 | SkBitmap diffBitmap; |
| 294 | success = compare(bitmap, comparisonBitmap, name, renderModeDescriptor, |
| 295 | diffPath ? &diffBitmap : NULL); |
| 296 | if (!success && diffPath) { |
| 297 | SkString diffName = make_filename(diffPath, "", name, ".diff.png"); |
| 298 | write_bitmap(diffName, diffBitmap); |
| 299 | } |
| 300 | return success; |
| 301 | } |
| 302 | |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 303 | static bool compare_to_reference_image(const char readPath [], |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 304 | const SkString& name, |
| 305 | SkBitmap &bitmap, |
tomhudson@google.com | 6abfa49 | 2011-04-26 14:59:32 +0000 | [diff] [blame] | 306 | const char diffPath [], |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 307 | const char renderModeDescriptor []) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 308 | SkString path = make_filename(readPath, "", name, "png"); |
| 309 | SkBitmap orig; |
| 310 | bool success = SkImageDecoder::DecodeFile(path.c_str(), &orig, |
| 311 | SkBitmap::kARGB_8888_Config, |
| 312 | SkImageDecoder::kDecodePixels_Mode, NULL); |
| 313 | if (success) { |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 314 | success = compare_to_reference_image(name, bitmap, |
| 315 | orig, diffPath, |
| 316 | renderModeDescriptor); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 317 | } else { |
| 318 | fprintf(stderr, "FAILED to read %s\n", path.c_str()); |
reed@google.com | ac864a9 | 2011-06-27 18:11:17 +0000 | [diff] [blame^] | 319 | // we lie here, and report succes, since we're just missing a master |
| 320 | // image. This way we can check in new tests, and not report failure. |
| 321 | // A real failure is to draw *differently* from the master image, but |
| 322 | // that's not the case here. |
| 323 | success = true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 324 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 325 | return success; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 326 | } |
| 327 | |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 328 | static bool handle_test_results(GM* gm, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 329 | const ConfigData& gRec, |
| 330 | const char writePath [], |
| 331 | const char readPath [], |
| 332 | const char diffPath [], |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 333 | const char renderModeDescriptor [], |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 334 | SkBitmap& bitmap, |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 335 | SkDynamicMemoryWStream* pdf, |
| 336 | const SkBitmap* comparisonBitmap) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 337 | SkString name = make_name(gm->shortName(), gRec.fName); |
| 338 | |
| 339 | if (writePath) { |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 340 | write_reference_image(gRec, writePath, renderModeDescriptor, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 341 | name, bitmap, pdf); |
| 342 | // TODO: Figure out a way to compare PDFs. |
| 343 | } else if (readPath && gRec.fBackend != kPDF_Backend) { |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 344 | return compare_to_reference_image(readPath, name, bitmap, |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 345 | diffPath, renderModeDescriptor); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 346 | } else if (comparisonBitmap) { |
| 347 | return compare_to_reference_image(name, bitmap, |
| 348 | *comparisonBitmap, diffPath, |
| 349 | renderModeDescriptor); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 350 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 351 | return true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | static SkPicture* generate_new_picture(GM* gm) { |
| 355 | // Pictures are refcounted so must be on heap |
| 356 | SkPicture* pict = new SkPicture; |
| 357 | SkCanvas* cv = pict->beginRecording(1000, 1000); |
| 358 | gm->draw(cv); |
| 359 | pict->endRecording(); |
| 360 | |
| 361 | return pict; |
| 362 | } |
| 363 | |
| 364 | static SkPicture* stream_to_new_picture(const SkPicture& src) { |
| 365 | |
| 366 | // To do in-memory commiunications with a stream, we need to: |
| 367 | // * create a dynamic memory stream |
| 368 | // * copy it into a buffer |
| 369 | // * create a read stream from it |
| 370 | // ?!?! |
| 371 | |
| 372 | SkDynamicMemoryWStream storage; |
| 373 | src.serialize(&storage); |
| 374 | |
| 375 | int streamSize = storage.getOffset(); |
| 376 | SkAutoMalloc dstStorage(streamSize); |
| 377 | void* dst = dstStorage.get(); |
| 378 | //char* dst = new char [streamSize]; |
| 379 | //@todo thudson 22 April 2011 when can we safely delete [] dst? |
| 380 | storage.copyTo(dst); |
| 381 | SkMemoryStream pictReadback(dst, streamSize); |
| 382 | SkPicture* retval = new SkPicture (&pictReadback); |
| 383 | return retval; |
| 384 | } |
| 385 | |
| 386 | // Test: draw into a bitmap or pdf. |
| 387 | // Depending on flags, possibly compare to an expected image |
| 388 | // and possibly output a diff image if it fails to match. |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 389 | static bool test_drawing(GM* gm, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 390 | const ConfigData& gRec, |
| 391 | const char writePath [], |
| 392 | const char readPath [], |
| 393 | const char diffPath [], |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 394 | GrContext* context, |
| 395 | SkBitmap* bitmap) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 396 | SkDynamicMemoryWStream pdf; |
| 397 | |
| 398 | if (gRec.fBackend == kRaster_Backend || |
| 399 | gRec.fBackend == kGPU_Backend) { |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 400 | // Early exit if we can't generate the image, but this is |
| 401 | // expected in some cases, so don't report a test failure. |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 402 | if (!generate_image(gm, gRec, context, bitmap)) { |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 403 | return true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 404 | } |
| 405 | } |
| 406 | // TODO: Figure out a way to compare PDFs. |
| 407 | if (gRec.fBackend == kPDF_Backend && writePath) { |
| 408 | generate_pdf(gm, pdf); |
| 409 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 410 | return handle_test_results(gm, gRec, writePath, readPath, diffPath, |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 411 | "", *bitmap, &pdf, NULL); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 412 | } |
| 413 | |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 414 | static bool test_picture_playback(GM* gm, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 415 | const ConfigData& gRec, |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 416 | const SkBitmap& comparisonBitmap, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 417 | const char readPath [], |
| 418 | const char diffPath []) { |
| 419 | SkPicture* pict = generate_new_picture(gm); |
| 420 | SkAutoUnref aur(pict); |
| 421 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 422 | if (kRaster_Backend == gRec.fBackend) { |
| 423 | SkBitmap bitmap; |
| 424 | generate_image_from_picture(gm, gRec, pict, &bitmap); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 425 | return handle_test_results(gm, gRec, NULL, NULL, diffPath, |
| 426 | "-replay", bitmap, NULL, &comparisonBitmap); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 427 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 428 | return true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 429 | } |
| 430 | |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 431 | static bool test_picture_serialization(GM* gm, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 432 | const ConfigData& gRec, |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 433 | const SkBitmap& comparisonBitmap, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 434 | const char readPath [], |
| 435 | const char diffPath []) { |
| 436 | SkPicture* pict = generate_new_picture(gm); |
| 437 | SkAutoUnref aurp(pict); |
| 438 | SkPicture* repict = stream_to_new_picture(*pict); |
| 439 | SkAutoUnref aurr(repict); |
| 440 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 441 | if (kRaster_Backend == gRec.fBackend) { |
| 442 | SkBitmap bitmap; |
| 443 | generate_image_from_picture(gm, gRec, repict, &bitmap); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 444 | return handle_test_results(gm, gRec, NULL, NULL, diffPath, |
| 445 | "-serialize", bitmap, NULL, &comparisonBitmap); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 446 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 447 | return true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | static void usage(const char * argv0) { |
| 451 | SkDebugf("%s [-w writePath] [-r readPath] [-d diffPath]\n", argv0); |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 452 | SkDebugf(" [--replay] [--serialize]\n"); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 453 | SkDebugf(" writePath: directory to write rendered images in.\n"); |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 454 | SkDebugf( |
| 455 | " readPath: directory to read reference images from;\n" |
| 456 | " reports if any pixels mismatch between reference and new images\n"); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 457 | SkDebugf(" diffPath: directory to write difference images in.\n"); |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 458 | SkDebugf(" --replay: exercise SkPicture replay.\n"); |
| 459 | SkDebugf( |
| 460 | " --serialize: exercise SkPicture serialization & deserialization.\n"); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | static const ConfigData gRec[] = { |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 464 | { SkBitmap::kARGB_8888_Config, kRaster_Backend, "8888" }, |
| 465 | { SkBitmap::kARGB_4444_Config, kRaster_Backend, "4444" }, |
| 466 | { SkBitmap::kRGB_565_Config, kRaster_Backend, "565" }, |
reed@google.com | 1a7e946 | 2011-06-20 13:21:24 +0000 | [diff] [blame] | 467 | #ifdef SK_SCALAR_IS_FLOAT |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 468 | { SkBitmap::kARGB_8888_Config, kGPU_Backend, "gpu" }, |
reed@google.com | 1a7e946 | 2011-06-20 13:21:24 +0000 | [diff] [blame] | 469 | #endif |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 470 | #ifdef SK_SUPPORT_PDF |
| 471 | { SkBitmap::kARGB_8888_Config, kPDF_Backend, "pdf" }, |
| 472 | #endif |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 473 | }; |
| 474 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 475 | int main(int argc, char * const argv[]) { |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 476 | SkAutoGraphics ag; |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 477 | |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 478 | const char* writePath = NULL; // if non-null, where we write the originals |
| 479 | const char* readPath = NULL; // if non-null, were we read from to compare |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 480 | const char* diffPath = NULL; // if non-null, where we write our diffs (from compare) |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 481 | |
reed@google.com | b8b0983 | 2011-05-26 15:57:56 +0000 | [diff] [blame] | 482 | bool doReplay = true; |
tomhudson@google.com | 6abfa49 | 2011-04-26 14:59:32 +0000 | [diff] [blame] | 483 | bool doSerialize = false; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 484 | const char* const commandName = argv[0]; |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 485 | char* const* stop = argv + argc; |
| 486 | for (++argv; argv < stop; ++argv) { |
| 487 | if (strcmp(*argv, "-w") == 0) { |
| 488 | argv++; |
| 489 | if (argv < stop && **argv) { |
| 490 | writePath = *argv; |
| 491 | } |
| 492 | } else if (strcmp(*argv, "-r") == 0) { |
| 493 | argv++; |
| 494 | if (argv < stop && **argv) { |
| 495 | readPath = *argv; |
| 496 | } |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 497 | } else if (strcmp(*argv, "-d") == 0) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 498 | argv++; |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 499 | if (argv < stop && **argv) { |
| 500 | diffPath = *argv; |
| 501 | } |
reed@google.com | b8b0983 | 2011-05-26 15:57:56 +0000 | [diff] [blame] | 502 | } else if (strcmp(*argv, "--noreplay") == 0) { |
| 503 | doReplay = false; |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 504 | } else if (strcmp(*argv, "--serialize") == 0) { |
| 505 | doSerialize = true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 506 | } else { |
| 507 | usage(commandName); |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 508 | return -1; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 509 | } |
| 510 | } |
| 511 | if (argv != stop) { |
| 512 | usage(commandName); |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 513 | return -1; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 514 | } |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 515 | |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 516 | int maxW = -1; |
| 517 | int maxH = -1; |
| 518 | Iter iter; |
| 519 | GM* gm; |
| 520 | while ((gm = iter.next()) != NULL) { |
| 521 | SkISize size = gm->getISize(); |
| 522 | maxW = SkMax32(size.width(), maxW); |
| 523 | maxH = SkMax32(size.height(), maxH); |
| 524 | } |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 525 | // setup a GL context for drawing offscreen |
reed@google.com | 37df17d | 2010-12-23 20:20:51 +0000 | [diff] [blame] | 526 | GrContext* context = NULL; |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 527 | SkEGLContext eglContext; |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 528 | if (eglContext.init(maxW, maxH)) { |
reed@google.com | 37df17d | 2010-12-23 20:20:51 +0000 | [diff] [blame] | 529 | context = GrContext::CreateGLShaderContext(); |
| 530 | } |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 531 | |
reed@android.com | 00f883e | 2010-12-14 17:46:14 +0000 | [diff] [blame] | 532 | |
| 533 | if (readPath) { |
| 534 | fprintf(stderr, "reading from %s\n", readPath); |
| 535 | } else if (writePath) { |
| 536 | fprintf(stderr, "writing to %s\n", writePath); |
| 537 | } |
| 538 | |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 539 | // Accumulate success of all tests so we can flag error in any |
| 540 | // one with the return value. |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 541 | iter.reset(); |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 542 | bool overallSuccess = true; |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 543 | while ((gm = iter.next()) != NULL) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 544 | SkISize size = gm->getISize(); |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 545 | SkDebugf("drawing... %s [%d %d]\n", gm->shortName(), |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 546 | size.width(), size.height()); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 547 | SkBitmap forwardRenderedBitmap; |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 548 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 549 | for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 550 | bool testSuccess = test_drawing(gm, gRec[i], |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 551 | writePath, readPath, diffPath, context, |
| 552 | &forwardRenderedBitmap); |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 553 | overallSuccess &= testSuccess; |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 554 | |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 555 | if (doReplay && testSuccess) { |
| 556 | testSuccess = test_picture_playback(gm, gRec[i], |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 557 | forwardRenderedBitmap, |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 558 | readPath, diffPath); |
| 559 | overallSuccess &= testSuccess; |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 560 | } |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 561 | |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 562 | if (doSerialize && testSuccess) { |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 563 | testSuccess &= test_picture_serialization(gm, gRec[i], |
| 564 | forwardRenderedBitmap, |
| 565 | readPath, diffPath); |
| 566 | overallSuccess &= testSuccess; |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 567 | } |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 568 | } |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 569 | SkDELETE(gm); |
| 570 | } |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 571 | if (false == overallSuccess) { |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 572 | return -1; |
| 573 | } |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 574 | return 0; |
| 575 | } |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 576 | |
| 577 | /////////////////////////////////////////////////////////////////////////////// |
| 578 | |
| 579 | using namespace skiagm; |
| 580 | |
| 581 | GM::GM() {} |
| 582 | GM::~GM() {} |
| 583 | |
| 584 | void GM::draw(SkCanvas* canvas) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 585 | this->onDraw(canvas); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 586 | } |