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()); |
| 319 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 320 | return success; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 321 | } |
| 322 | |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 323 | static bool handle_test_results(GM* gm, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 324 | const ConfigData& gRec, |
| 325 | const char writePath [], |
| 326 | const char readPath [], |
| 327 | const char diffPath [], |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 328 | const char renderModeDescriptor [], |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 329 | SkBitmap& bitmap, |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 330 | SkDynamicMemoryWStream* pdf, |
| 331 | const SkBitmap* comparisonBitmap) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 332 | SkString name = make_name(gm->shortName(), gRec.fName); |
| 333 | |
| 334 | if (writePath) { |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 335 | write_reference_image(gRec, writePath, renderModeDescriptor, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 336 | name, bitmap, pdf); |
| 337 | // TODO: Figure out a way to compare PDFs. |
| 338 | } else if (readPath && gRec.fBackend != kPDF_Backend) { |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 339 | return compare_to_reference_image(readPath, name, bitmap, |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 340 | diffPath, renderModeDescriptor); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 341 | } else if (comparisonBitmap) { |
| 342 | return compare_to_reference_image(name, bitmap, |
| 343 | *comparisonBitmap, diffPath, |
| 344 | renderModeDescriptor); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 345 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 346 | return true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | static SkPicture* generate_new_picture(GM* gm) { |
| 350 | // Pictures are refcounted so must be on heap |
| 351 | SkPicture* pict = new SkPicture; |
| 352 | SkCanvas* cv = pict->beginRecording(1000, 1000); |
| 353 | gm->draw(cv); |
| 354 | pict->endRecording(); |
| 355 | |
| 356 | return pict; |
| 357 | } |
| 358 | |
| 359 | static SkPicture* stream_to_new_picture(const SkPicture& src) { |
| 360 | |
| 361 | // To do in-memory commiunications with a stream, we need to: |
| 362 | // * create a dynamic memory stream |
| 363 | // * copy it into a buffer |
| 364 | // * create a read stream from it |
| 365 | // ?!?! |
| 366 | |
| 367 | SkDynamicMemoryWStream storage; |
| 368 | src.serialize(&storage); |
| 369 | |
| 370 | int streamSize = storage.getOffset(); |
| 371 | SkAutoMalloc dstStorage(streamSize); |
| 372 | void* dst = dstStorage.get(); |
| 373 | //char* dst = new char [streamSize]; |
| 374 | //@todo thudson 22 April 2011 when can we safely delete [] dst? |
| 375 | storage.copyTo(dst); |
| 376 | SkMemoryStream pictReadback(dst, streamSize); |
| 377 | SkPicture* retval = new SkPicture (&pictReadback); |
| 378 | return retval; |
| 379 | } |
| 380 | |
| 381 | // Test: draw into a bitmap or pdf. |
| 382 | // Depending on flags, possibly compare to an expected image |
| 383 | // and possibly output a diff image if it fails to match. |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 384 | static bool test_drawing(GM* gm, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 385 | const ConfigData& gRec, |
| 386 | const char writePath [], |
| 387 | const char readPath [], |
| 388 | const char diffPath [], |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 389 | GrContext* context, |
| 390 | SkBitmap* bitmap) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 391 | SkDynamicMemoryWStream pdf; |
| 392 | |
| 393 | if (gRec.fBackend == kRaster_Backend || |
| 394 | gRec.fBackend == kGPU_Backend) { |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 395 | // Early exit if we can't generate the image, but this is |
| 396 | // expected in some cases, so don't report a test failure. |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 397 | if (!generate_image(gm, gRec, context, bitmap)) { |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 398 | return true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 399 | } |
| 400 | } |
| 401 | // TODO: Figure out a way to compare PDFs. |
| 402 | if (gRec.fBackend == kPDF_Backend && writePath) { |
| 403 | generate_pdf(gm, pdf); |
| 404 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 405 | return handle_test_results(gm, gRec, writePath, readPath, diffPath, |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 406 | "", *bitmap, &pdf, NULL); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 407 | } |
| 408 | |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 409 | static bool test_picture_playback(GM* gm, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 410 | const ConfigData& gRec, |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 411 | const SkBitmap& comparisonBitmap, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 412 | const char readPath [], |
| 413 | const char diffPath []) { |
| 414 | SkPicture* pict = generate_new_picture(gm); |
| 415 | SkAutoUnref aur(pict); |
| 416 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 417 | if (kRaster_Backend == gRec.fBackend) { |
| 418 | SkBitmap bitmap; |
| 419 | generate_image_from_picture(gm, gRec, pict, &bitmap); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 420 | return handle_test_results(gm, gRec, NULL, NULL, diffPath, |
| 421 | "-replay", bitmap, NULL, &comparisonBitmap); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 422 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 423 | return true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 424 | } |
| 425 | |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 426 | static bool test_picture_serialization(GM* gm, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 427 | const ConfigData& gRec, |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 428 | const SkBitmap& comparisonBitmap, |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 429 | const char readPath [], |
| 430 | const char diffPath []) { |
| 431 | SkPicture* pict = generate_new_picture(gm); |
| 432 | SkAutoUnref aurp(pict); |
| 433 | SkPicture* repict = stream_to_new_picture(*pict); |
| 434 | SkAutoUnref aurr(repict); |
| 435 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 436 | if (kRaster_Backend == gRec.fBackend) { |
| 437 | SkBitmap bitmap; |
| 438 | generate_image_from_picture(gm, gRec, repict, &bitmap); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 439 | return handle_test_results(gm, gRec, NULL, NULL, diffPath, |
| 440 | "-serialize", bitmap, NULL, &comparisonBitmap); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 441 | } |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 442 | return true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | static void usage(const char * argv0) { |
| 446 | SkDebugf("%s [-w writePath] [-r readPath] [-d diffPath]\n", argv0); |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 447 | SkDebugf(" [--replay] [--serialize]\n"); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 448 | SkDebugf(" writePath: directory to write rendered images in.\n"); |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 449 | SkDebugf( |
| 450 | " readPath: directory to read reference images from;\n" |
| 451 | " reports if any pixels mismatch between reference and new images\n"); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 452 | SkDebugf(" diffPath: directory to write difference images in.\n"); |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 453 | SkDebugf(" --replay: exercise SkPicture replay.\n"); |
| 454 | SkDebugf( |
| 455 | " --serialize: exercise SkPicture serialization & deserialization.\n"); |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | static const ConfigData gRec[] = { |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 459 | { SkBitmap::kARGB_8888_Config, kRaster_Backend, "8888" }, |
| 460 | { SkBitmap::kARGB_4444_Config, kRaster_Backend, "4444" }, |
| 461 | { SkBitmap::kRGB_565_Config, kRaster_Backend, "565" }, |
reed@google.com | 1a7e946 | 2011-06-20 13:21:24 +0000 | [diff] [blame] | 462 | #ifdef SK_SCALAR_IS_FLOAT |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 463 | { SkBitmap::kARGB_8888_Config, kGPU_Backend, "gpu" }, |
reed@google.com | 1a7e946 | 2011-06-20 13:21:24 +0000 | [diff] [blame] | 464 | #endif |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 465 | #ifdef SK_SUPPORT_PDF |
| 466 | { SkBitmap::kARGB_8888_Config, kPDF_Backend, "pdf" }, |
| 467 | #endif |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 468 | }; |
| 469 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 470 | int main(int argc, char * const argv[]) { |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 471 | SkAutoGraphics ag; |
reed@google.com | d4dfd10 | 2011-01-18 21:05:42 +0000 | [diff] [blame] | 472 | |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 473 | const char* writePath = NULL; // if non-null, where we write the originals |
| 474 | 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] | 475 | 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] | 476 | |
reed@google.com | b8b0983 | 2011-05-26 15:57:56 +0000 | [diff] [blame] | 477 | bool doReplay = true; |
tomhudson@google.com | 6abfa49 | 2011-04-26 14:59:32 +0000 | [diff] [blame] | 478 | bool doSerialize = false; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 479 | const char* const commandName = argv[0]; |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 480 | char* const* stop = argv + argc; |
| 481 | for (++argv; argv < stop; ++argv) { |
| 482 | if (strcmp(*argv, "-w") == 0) { |
| 483 | argv++; |
| 484 | if (argv < stop && **argv) { |
| 485 | writePath = *argv; |
| 486 | } |
| 487 | } else if (strcmp(*argv, "-r") == 0) { |
| 488 | argv++; |
| 489 | if (argv < stop && **argv) { |
| 490 | readPath = *argv; |
| 491 | } |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 492 | } else if (strcmp(*argv, "-d") == 0) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 493 | argv++; |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 494 | if (argv < stop && **argv) { |
| 495 | diffPath = *argv; |
| 496 | } |
reed@google.com | b8b0983 | 2011-05-26 15:57:56 +0000 | [diff] [blame] | 497 | } else if (strcmp(*argv, "--noreplay") == 0) { |
| 498 | doReplay = false; |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 499 | } else if (strcmp(*argv, "--serialize") == 0) { |
| 500 | doSerialize = true; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 501 | } else { |
| 502 | usage(commandName); |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 503 | return -1; |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 504 | } |
| 505 | } |
| 506 | if (argv != stop) { |
| 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 | } |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 510 | |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 511 | int maxW = -1; |
| 512 | int maxH = -1; |
| 513 | Iter iter; |
| 514 | GM* gm; |
| 515 | while ((gm = iter.next()) != NULL) { |
| 516 | SkISize size = gm->getISize(); |
| 517 | maxW = SkMax32(size.width(), maxW); |
| 518 | maxH = SkMax32(size.height(), maxH); |
| 519 | } |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 520 | // setup a GL context for drawing offscreen |
reed@google.com | 37df17d | 2010-12-23 20:20:51 +0000 | [diff] [blame] | 521 | GrContext* context = NULL; |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 522 | SkEGLContext eglContext; |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 523 | if (eglContext.init(maxW, maxH)) { |
reed@google.com | 37df17d | 2010-12-23 20:20:51 +0000 | [diff] [blame] | 524 | context = GrContext::CreateGLShaderContext(); |
| 525 | } |
reed@google.com | 873cb1e | 2010-12-23 15:00:45 +0000 | [diff] [blame] | 526 | |
reed@android.com | 00f883e | 2010-12-14 17:46:14 +0000 | [diff] [blame] | 527 | |
| 528 | if (readPath) { |
| 529 | fprintf(stderr, "reading from %s\n", readPath); |
| 530 | } else if (writePath) { |
| 531 | fprintf(stderr, "writing to %s\n", writePath); |
| 532 | } |
| 533 | |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 534 | // Accumulate success of all tests so we can flag error in any |
| 535 | // one with the return value. |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 536 | iter.reset(); |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 537 | bool overallSuccess = true; |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 538 | while ((gm = iter.next()) != NULL) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 539 | SkISize size = gm->getISize(); |
reed@google.com | 3d3f092 | 2010-12-20 21:10:29 +0000 | [diff] [blame] | 540 | SkDebugf("drawing... %s [%d %d]\n", gm->shortName(), |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 541 | size.width(), size.height()); |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 542 | SkBitmap forwardRenderedBitmap; |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 543 | |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 544 | for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 545 | bool testSuccess = test_drawing(gm, gRec[i], |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 546 | writePath, readPath, diffPath, context, |
| 547 | &forwardRenderedBitmap); |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 548 | overallSuccess &= testSuccess; |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 549 | |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 550 | if (doReplay && testSuccess) { |
| 551 | testSuccess = test_picture_playback(gm, gRec[i], |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 552 | forwardRenderedBitmap, |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 553 | readPath, diffPath); |
| 554 | overallSuccess &= testSuccess; |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 555 | } |
vandebo@chromium.org | 686abdf | 2011-02-03 23:00:40 +0000 | [diff] [blame] | 556 | |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 557 | if (doSerialize && testSuccess) { |
tomhudson@google.com | cae6b3f | 2011-06-17 13:11:45 +0000 | [diff] [blame] | 558 | testSuccess &= test_picture_serialization(gm, gRec[i], |
| 559 | forwardRenderedBitmap, |
| 560 | readPath, diffPath); |
| 561 | overallSuccess &= testSuccess; |
tomhudson@google.com | 73fb042 | 2011-04-25 19:20:54 +0000 | [diff] [blame] | 562 | } |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 563 | } |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 564 | SkDELETE(gm); |
| 565 | } |
tomhudson@google.com | ea32543 | 2011-06-09 20:30:03 +0000 | [diff] [blame] | 566 | if (false == overallSuccess) { |
tomhudson@google.com | 8e728d7 | 2011-04-26 20:22:57 +0000 | [diff] [blame] | 567 | return -1; |
| 568 | } |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 569 | return 0; |
| 570 | } |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 571 | |
| 572 | /////////////////////////////////////////////////////////////////////////////// |
| 573 | |
| 574 | using namespace skiagm; |
| 575 | |
| 576 | GM::GM() {} |
| 577 | GM::~GM() {} |
| 578 | |
| 579 | void GM::draw(SkCanvas* canvas) { |
tomhudson@google.com | 9875dd1 | 2011-04-25 15:49:53 +0000 | [diff] [blame] | 580 | this->onDraw(canvas); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 581 | } |