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