epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
bsalomon@google.com | 971d0c8 | 2011-08-19 17:22:05 +0000 | [diff] [blame] | 8 | |
| 9 | |
| 10 | #include "BenchTimer.h" |
| 11 | |
| 12 | #include "GrContext.h" |
| 13 | #include "GrRenderTarget.h" |
| 14 | |
| 15 | #include "SkBenchmark.h" |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 16 | #include "SkCanvas.h" |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 17 | #include "SkColorPriv.h" |
bsalomon@google.com | 971d0c8 | 2011-08-19 17:22:05 +0000 | [diff] [blame] | 18 | #include "SkGpuDevice.h" |
reed@android.com | 3a859a0 | 2009-01-28 00:56:29 +0000 | [diff] [blame] | 19 | #include "SkGraphics.h" |
reed@android.com | b398fe8 | 2009-01-07 11:47:57 +0000 | [diff] [blame] | 20 | #include "SkImageEncoder.h" |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 21 | #if SK_ANGLE |
| 22 | #include "gl/SkANGLEGLContext.h" |
| 23 | #endif |
tomhudson@google.com | 6bf38b5 | 2012-02-14 15:11:59 +0000 | [diff] [blame] | 24 | #include "gl/SkNativeGLContext.h" |
| 25 | #include "gl/SkNullGLContext.h" |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 26 | #include "gl/SkDebugGLContext.h" |
reed@android.com | 6c924ad | 2009-03-31 03:48:49 +0000 | [diff] [blame] | 27 | #include "SkNWayCanvas.h" |
| 28 | #include "SkPicture.h" |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 29 | #include "SkString.h" |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 30 | |
djsollen@google.com | 56c6977 | 2011-11-08 19:00:26 +0000 | [diff] [blame] | 31 | #ifdef SK_BUILD_FOR_ANDROID |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 32 | static void log_error(const char msg[]) { SkDebugf("%s", msg); } |
| 33 | static void log_progress(const char msg[]) { SkDebugf("%s", msg); } |
| 34 | #else |
| 35 | static void log_error(const char msg[]) { fprintf(stderr, "%s", msg); } |
| 36 | static void log_progress(const char msg[]) { printf("%s", msg); } |
| 37 | #endif |
| 38 | |
| 39 | static void log_error(const SkString& str) { log_error(str.c_str()); } |
| 40 | static void log_progress(const SkString& str) { log_progress(str.c_str()); } |
| 41 | |
| 42 | /////////////////////////////////////////////////////////////////////////////// |
| 43 | |
reed@android.com | 6c924ad | 2009-03-31 03:48:49 +0000 | [diff] [blame] | 44 | static void erase(SkBitmap& bm) { |
| 45 | if (bm.config() == SkBitmap::kA8_Config) { |
| 46 | bm.eraseColor(0); |
| 47 | } else { |
| 48 | bm.eraseColor(SK_ColorWHITE); |
| 49 | } |
| 50 | } |
| 51 | |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 52 | #if 0 |
reed@android.com | 6c924ad | 2009-03-31 03:48:49 +0000 | [diff] [blame] | 53 | static bool equal(const SkBitmap& bm1, const SkBitmap& bm2) { |
| 54 | if (bm1.width() != bm2.width() || |
| 55 | bm1.height() != bm2.height() || |
| 56 | bm1.config() != bm2.config()) { |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | size_t pixelBytes = bm1.width() * bm1.bytesPerPixel(); |
| 61 | for (int y = 0; y < bm1.height(); y++) { |
| 62 | if (memcmp(bm1.getAddr(0, y), bm2.getAddr(0, y), pixelBytes)) { |
| 63 | return false; |
| 64 | } |
| 65 | } |
reed@android.com | 6c924ad | 2009-03-31 03:48:49 +0000 | [diff] [blame] | 66 | return true; |
| 67 | } |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 68 | #endif |
reed@android.com | 6c924ad | 2009-03-31 03:48:49 +0000 | [diff] [blame] | 69 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 70 | class Iter { |
| 71 | public: |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 72 | Iter(void* param) { |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 73 | fBench = BenchRegistry::Head(); |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 74 | fParam = param; |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | SkBenchmark* next() { |
| 78 | if (fBench) { |
| 79 | BenchRegistry::Factory f = fBench->factory(); |
| 80 | fBench = fBench->next(); |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 81 | return f(fParam); |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 82 | } |
| 83 | return NULL; |
| 84 | } |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 85 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 86 | private: |
| 87 | const BenchRegistry* fBench; |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 88 | void* fParam; |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | static void make_filename(const char name[], SkString* path) { |
| 92 | path->set(name); |
| 93 | for (int i = 0; name[i]; i++) { |
| 94 | switch (name[i]) { |
| 95 | case '/': |
| 96 | case '\\': |
| 97 | case ' ': |
| 98 | case ':': |
| 99 | path->writable_str()[i] = '-'; |
| 100 | break; |
| 101 | default: |
| 102 | break; |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 107 | static void saveFile(const char name[], const char config[], const char dir[], |
| 108 | const SkBitmap& bm) { |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 109 | SkBitmap copy; |
| 110 | if (!bm.copyTo(©, SkBitmap::kARGB_8888_Config)) { |
| 111 | return; |
| 112 | } |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 113 | |
| 114 | if (bm.config() == SkBitmap::kA8_Config) { |
| 115 | // turn alpha into gray-scale |
| 116 | size_t size = copy.getSize() >> 2; |
| 117 | SkPMColor* p = copy.getAddr32(0, 0); |
| 118 | for (size_t i = 0; i < size; i++) { |
| 119 | int c = (*p >> SK_A32_SHIFT) & 0xFF; |
| 120 | c = 255 - c; |
| 121 | c |= (c << 24) | (c << 16) | (c << 8); |
| 122 | *p++ = c | (SK_A32_MASK << SK_A32_SHIFT); |
| 123 | } |
| 124 | } |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 125 | |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 126 | SkString str; |
| 127 | make_filename(name, &str); |
| 128 | str.appendf("_%s.png", config); |
| 129 | str.prepend(dir); |
| 130 | ::remove(str.c_str()); |
| 131 | SkImageEncoder::EncodeFile(str.c_str(), copy, SkImageEncoder::kPNG_Type, |
| 132 | 100); |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | static void performClip(SkCanvas* canvas, int w, int h) { |
| 136 | SkRect r; |
| 137 | |
| 138 | r.set(SkIntToScalar(10), SkIntToScalar(10), |
| 139 | SkIntToScalar(w*2/3), SkIntToScalar(h*2/3)); |
| 140 | canvas->clipRect(r, SkRegion::kIntersect_Op); |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 141 | |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 142 | r.set(SkIntToScalar(w/3), SkIntToScalar(h/3), |
| 143 | SkIntToScalar(w-10), SkIntToScalar(h-10)); |
| 144 | canvas->clipRect(r, SkRegion::kXOR_Op); |
| 145 | } |
| 146 | |
| 147 | static void performRotate(SkCanvas* canvas, int w, int h) { |
| 148 | const SkScalar x = SkIntToScalar(w) / 2; |
| 149 | const SkScalar y = SkIntToScalar(h) / 2; |
| 150 | |
| 151 | canvas->translate(x, y); |
| 152 | canvas->rotate(SkIntToScalar(35)); |
| 153 | canvas->translate(-x, -y); |
| 154 | } |
| 155 | |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 156 | static void performScale(SkCanvas* canvas, int w, int h) { |
| 157 | const SkScalar x = SkIntToScalar(w) / 2; |
| 158 | const SkScalar y = SkIntToScalar(h) / 2; |
| 159 | |
| 160 | canvas->translate(x, y); |
| 161 | // just enough so we can't take the sprite case |
| 162 | canvas->scale(SK_Scalar1 * 99/100, SK_Scalar1 * 99/100); |
| 163 | canvas->translate(-x, -y); |
| 164 | } |
| 165 | |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 166 | static bool parse_bool_arg(char * const* argv, char* const* stop, bool* var) { |
| 167 | if (argv < stop) { |
| 168 | *var = atoi(*argv) != 0; |
| 169 | return true; |
| 170 | } |
| 171 | return false; |
| 172 | } |
| 173 | |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 174 | enum Backend { |
| 175 | kRaster_Backend, |
| 176 | kGPU_Backend, |
| 177 | kPDF_Backend, |
| 178 | }; |
| 179 | |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 180 | class GLHelper { |
| 181 | public: |
| 182 | GLHelper() { |
| 183 | } |
| 184 | |
| 185 | bool init(SkGLContext* glCtx, int width, int height) { |
| 186 | GrContext* grCtx; |
| 187 | GrRenderTarget* rt; |
| 188 | if (glCtx->init(width, height)) { |
| 189 | GrPlatform3DContext ctx = |
| 190 | reinterpret_cast<GrPlatform3DContext>(glCtx->gl()); |
| 191 | grCtx = GrContext::Create(kOpenGL_Shaders_GrEngine, ctx); |
| 192 | if (NULL != grCtx) { |
| 193 | GrPlatformRenderTargetDesc desc; |
| 194 | desc.fConfig = kSkia8888_PM_GrPixelConfig; |
| 195 | desc.fWidth = width; |
| 196 | desc.fHeight = height; |
| 197 | desc.fStencilBits = 8; |
| 198 | desc.fRenderTargetHandle = glCtx->getFBOID(); |
| 199 | rt = grCtx->createPlatformRenderTarget(desc); |
| 200 | if (NULL == rt) { |
| 201 | grCtx->unref(); |
| 202 | return false; |
| 203 | } |
| 204 | } |
| 205 | } else { |
| 206 | return false; |
| 207 | } |
| 208 | glCtx->ref(); |
| 209 | fGLContext.reset(glCtx); |
| 210 | fGrContext.reset(grCtx); |
| 211 | fRenderTarget.reset(rt); |
| 212 | return true; |
| 213 | } |
| 214 | |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 215 | void cleanup() { |
| 216 | fGLContext.reset(NULL); |
| 217 | fGrContext.reset(NULL); |
| 218 | fRenderTarget.reset(NULL); |
| 219 | } |
| 220 | |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 221 | bool isValid() { |
| 222 | return NULL != fGLContext.get(); |
| 223 | } |
| 224 | |
| 225 | SkGLContext* glContext() { |
| 226 | return fGLContext.get(); |
| 227 | } |
| 228 | |
| 229 | GrRenderTarget* renderTarget() { |
| 230 | return fRenderTarget.get(); |
| 231 | } |
| 232 | |
| 233 | GrContext* grContext() { |
| 234 | return fGrContext.get(); |
| 235 | } |
| 236 | private: |
| 237 | SkAutoTUnref<SkGLContext> fGLContext; |
| 238 | SkAutoTUnref<GrContext> fGrContext; |
| 239 | SkAutoTUnref<GrRenderTarget> fRenderTarget; |
| 240 | }; |
| 241 | |
| 242 | static GLHelper gRealGLHelper; |
| 243 | static GLHelper gNullGLHelper; |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 244 | static GLHelper gDebugGLHelper; |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 245 | #if SK_ANGLE |
| 246 | static GLHelper gANGLEGLHelper; |
| 247 | #endif |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 248 | |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 249 | static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size, |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 250 | Backend backend, GLHelper* glHelper) { |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 251 | SkDevice* device = NULL; |
| 252 | SkBitmap bitmap; |
| 253 | bitmap.setConfig(config, size.fX, size.fY); |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 254 | |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 255 | switch (backend) { |
| 256 | case kRaster_Backend: |
| 257 | bitmap.allocPixels(); |
| 258 | erase(bitmap); |
reed@google.com | af951c9 | 2011-06-16 19:10:39 +0000 | [diff] [blame] | 259 | device = new SkDevice(bitmap); |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 260 | break; |
| 261 | case kGPU_Backend: |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 262 | device = new SkGpuDevice(glHelper->grContext(), |
| 263 | glHelper->renderTarget()); |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 264 | break; |
| 265 | case kPDF_Backend: |
| 266 | default: |
| 267 | SkASSERT(!"unsupported"); |
| 268 | } |
| 269 | return device; |
| 270 | } |
| 271 | |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 272 | static const struct { |
| 273 | SkBitmap::Config fConfig; |
| 274 | const char* fName; |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 275 | Backend fBackend; |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 276 | GLHelper* fGLHelper; |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 277 | } gConfigs[] = { |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 278 | { SkBitmap::kARGB_8888_Config, "8888", kRaster_Backend, NULL }, |
| 279 | { SkBitmap::kRGB_565_Config, "565", kRaster_Backend, NULL }, |
| 280 | { SkBitmap::kARGB_8888_Config, "GPU", kGPU_Backend, &gRealGLHelper }, |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 281 | #if SK_ANGLE |
| 282 | { SkBitmap::kARGB_8888_Config, "ANGLE", kGPU_Backend, &gANGLEGLHelper }, |
| 283 | #endif |
robertphillips@google.com | a0b63b8 | 2012-03-30 12:23:56 +0000 | [diff] [blame^] | 284 | #ifdef SK_DEBUG |
| 285 | { SkBitmap::kARGB_8888_Config, "Debug", kGPU_Backend, &gDebugGLHelper }, |
| 286 | #endif |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 287 | { SkBitmap::kARGB_8888_Config, "NULLGPU", kGPU_Backend, &gNullGLHelper }, |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 288 | }; |
| 289 | |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 290 | static int findConfig(const char config[]) { |
| 291 | for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { |
| 292 | if (!strcmp(config, gConfigs[i].fName)) { |
| 293 | return i; |
| 294 | } |
| 295 | } |
| 296 | return -1; |
| 297 | } |
| 298 | |
tomhudson@google.com | 8382394 | 2011-10-28 14:59:07 +0000 | [diff] [blame] | 299 | static void determine_gpu_context_size(SkTDict<const char*>& defineDict, |
| 300 | int* contextWidth, |
| 301 | int* contextHeight) { |
| 302 | Iter iter(&defineDict); |
| 303 | SkBenchmark* bench; |
| 304 | while ((bench = iter.next()) != NULL) { |
| 305 | SkIPoint dim = bench->getSize(); |
| 306 | if (*contextWidth < dim.fX) { |
| 307 | *contextWidth = dim.fX; |
| 308 | } |
| 309 | if (*contextHeight < dim.fY) { |
| 310 | *contextHeight = dim.fY; |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | |
reed@google.com | 1a7eabc | 2011-10-31 16:33:52 +0000 | [diff] [blame] | 315 | static bool skip_name(const SkTDArray<const char*> array, const char name[]) { |
| 316 | if (0 == array.count()) { |
| 317 | // no names, so don't skip anything |
| 318 | return false; |
| 319 | } |
| 320 | for (int i = 0; i < array.count(); ++i) { |
| 321 | if (strstr(name, array[i])) { |
| 322 | // found the name, so don't skip |
| 323 | return false; |
| 324 | } |
| 325 | } |
| 326 | return true; |
| 327 | } |
| 328 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 329 | int main (int argc, char * const argv[]) { |
reed@android.com | 3a859a0 | 2009-01-28 00:56:29 +0000 | [diff] [blame] | 330 | SkAutoGraphics ag; |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 331 | |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 332 | SkTDict<const char*> defineDict(1024); |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 333 | int repeatDraw = 1; |
| 334 | int forceAlpha = 0xFF; |
| 335 | bool forceAA = true; |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 336 | bool forceFilter = false; |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 337 | SkTriState::State forceDither = SkTriState::kDefault; |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 338 | bool timerWall = false; |
| 339 | bool timerCpu = true; |
| 340 | bool timerGpu = true; |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 341 | bool doScale = false; |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 342 | bool doRotate = false; |
| 343 | bool doClip = false; |
agl@chromium.org | 652807b | 2010-04-27 15:47:34 +0000 | [diff] [blame] | 344 | bool hasStrokeWidth = false; |
| 345 | float strokeWidth; |
reed@google.com | 1a7eabc | 2011-10-31 16:33:52 +0000 | [diff] [blame] | 346 | SkTDArray<const char*> fMatches; |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 347 | |
reed@android.com | b398fe8 | 2009-01-07 11:47:57 +0000 | [diff] [blame] | 348 | SkString outDir; |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 349 | SkBitmap::Config outConfig = SkBitmap::kNo_Config; |
bsalomon@google.com | cadbcb8 | 2012-01-06 19:22:11 +0000 | [diff] [blame] | 350 | GLHelper* glHelper = NULL; |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 351 | const char* configName = ""; |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 352 | Backend backend = kRaster_Backend; // for warning |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 353 | int configCount = SK_ARRAY_COUNT(gConfigs); |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 354 | |
reed@android.com | b398fe8 | 2009-01-07 11:47:57 +0000 | [diff] [blame] | 355 | char* const* stop = argv + argc; |
| 356 | for (++argv; argv < stop; ++argv) { |
| 357 | if (strcmp(*argv, "-o") == 0) { |
| 358 | argv++; |
| 359 | if (argv < stop && **argv) { |
| 360 | outDir.set(*argv); |
| 361 | if (outDir.c_str()[outDir.size() - 1] != '/') { |
| 362 | outDir.append("/"); |
| 363 | } |
| 364 | } |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 365 | } else if (strcmp(*argv, "-repeat") == 0) { |
| 366 | argv++; |
| 367 | if (argv < stop) { |
| 368 | repeatDraw = atoi(*argv); |
| 369 | if (repeatDraw < 1) { |
| 370 | repeatDraw = 1; |
| 371 | } |
| 372 | } else { |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 373 | log_error("missing arg for -repeat\n"); |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 374 | return -1; |
| 375 | } |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 376 | } else if (strcmp(*argv, "-timers") == 0) { |
| 377 | argv++; |
| 378 | if (argv < stop) { |
| 379 | timerWall = false; |
| 380 | timerCpu = false; |
| 381 | timerGpu = false; |
| 382 | for (char* t = *argv; *t; ++t) { |
| 383 | switch (*t) { |
| 384 | case 'w': timerWall = true; break; |
| 385 | case 'c': timerCpu = true; break; |
| 386 | case 'g': timerGpu = true; break; |
| 387 | } |
| 388 | } |
| 389 | } else { |
| 390 | log_error("missing arg for -timers\n"); |
| 391 | return -1; |
| 392 | } |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 393 | } else if (!strcmp(*argv, "-rotate")) { |
| 394 | doRotate = true; |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 395 | } else if (!strcmp(*argv, "-scale")) { |
| 396 | doScale = true; |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 397 | } else if (!strcmp(*argv, "-clip")) { |
| 398 | doClip = true; |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 399 | } else if (strcmp(*argv, "-forceAA") == 0) { |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 400 | if (!parse_bool_arg(++argv, stop, &forceAA)) { |
| 401 | log_error("missing arg for -forceAA\n"); |
| 402 | return -1; |
| 403 | } |
| 404 | } else if (strcmp(*argv, "-forceFilter") == 0) { |
| 405 | if (!parse_bool_arg(++argv, stop, &forceFilter)) { |
| 406 | log_error("missing arg for -forceFilter\n"); |
| 407 | return -1; |
| 408 | } |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 409 | } else if (strcmp(*argv, "-forceDither") == 0) { |
| 410 | bool tmp; |
| 411 | if (!parse_bool_arg(++argv, stop, &tmp)) { |
| 412 | log_error("missing arg for -forceDither\n"); |
| 413 | return -1; |
| 414 | } |
| 415 | forceDither = tmp ? SkTriState::kTrue : SkTriState::kFalse; |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 416 | } else if (strcmp(*argv, "-forceBlend") == 0) { |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 417 | bool wantAlpha = false; |
| 418 | if (!parse_bool_arg(++argv, stop, &wantAlpha)) { |
| 419 | log_error("missing arg for -forceBlend\n"); |
| 420 | return -1; |
| 421 | } |
| 422 | forceAlpha = wantAlpha ? 0x80 : 0xFF; |
agl@chromium.org | 652807b | 2010-04-27 15:47:34 +0000 | [diff] [blame] | 423 | } else if (strcmp(*argv, "-strokeWidth") == 0) { |
| 424 | argv++; |
| 425 | if (argv < stop) { |
| 426 | const char *strokeWidthStr = *argv; |
| 427 | if (sscanf(strokeWidthStr, "%f", &strokeWidth) != 1) { |
| 428 | log_error("bad arg for -strokeWidth\n"); |
| 429 | return -1; |
| 430 | } |
| 431 | hasStrokeWidth = true; |
| 432 | } else { |
| 433 | log_error("missing arg for -strokeWidth\n"); |
| 434 | return -1; |
| 435 | } |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 436 | } else if (strcmp(*argv, "-match") == 0) { |
| 437 | argv++; |
| 438 | if (argv < stop) { |
reed@google.com | 1a7eabc | 2011-10-31 16:33:52 +0000 | [diff] [blame] | 439 | *fMatches.append() = *argv; |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 440 | } else { |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 441 | log_error("missing arg for -match\n"); |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 442 | return -1; |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 443 | } |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 444 | } else if (strcmp(*argv, "-config") == 0) { |
| 445 | argv++; |
| 446 | if (argv < stop) { |
| 447 | int index = findConfig(*argv); |
| 448 | if (index >= 0) { |
| 449 | outConfig = gConfigs[index].fConfig; |
| 450 | configName = gConfigs[index].fName; |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 451 | backend = gConfigs[index].fBackend; |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 452 | glHelper = gConfigs[index].fGLHelper; |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 453 | configCount = 1; |
| 454 | } else { |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 455 | SkString str; |
| 456 | str.printf("unrecognized config %s\n", *argv); |
| 457 | log_error(str); |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 458 | return -1; |
| 459 | } |
| 460 | } else { |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 461 | log_error("missing arg for -config\n"); |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 462 | return -1; |
| 463 | } |
reed@android.com | 0c9da39 | 2010-02-22 19:50:13 +0000 | [diff] [blame] | 464 | } else if (strlen(*argv) > 2 && strncmp(*argv, "-D", 2) == 0) { |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 465 | argv++; |
reed@android.com | 0c9da39 | 2010-02-22 19:50:13 +0000 | [diff] [blame] | 466 | if (argv < stop) { |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 467 | defineDict.set(argv[-1] + 2, *argv); |
| 468 | } else { |
| 469 | log_error("incomplete '-Dfoo bar' definition\n"); |
| 470 | return -1; |
| 471 | } |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 472 | } else { |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 473 | SkString str; |
| 474 | str.printf("unrecognized arg %s\n", *argv); |
| 475 | log_error(str); |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 476 | return -1; |
reed@android.com | b398fe8 | 2009-01-07 11:47:57 +0000 | [diff] [blame] | 477 | } |
| 478 | } |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 479 | |
reed@google.com | 3b14dc1 | 2011-04-04 14:31:36 +0000 | [diff] [blame] | 480 | // report our current settings |
| 481 | { |
| 482 | SkString str; |
bungeman@google.com | a5d4841 | 2011-06-15 17:25:46 +0000 | [diff] [blame] | 483 | str.printf("skia bench: alpha=0x%02X antialias=%d filter=%d", |
reed@google.com | 3b14dc1 | 2011-04-04 14:31:36 +0000 | [diff] [blame] | 484 | forceAlpha, forceAA, forceFilter); |
bungeman@google.com | a5d4841 | 2011-06-15 17:25:46 +0000 | [diff] [blame] | 485 | str.appendf(" rotate=%d scale=%d clip=%d", |
| 486 | doRotate, doScale, doClip); |
| 487 | |
| 488 | const char * ditherName; |
| 489 | switch (forceDither) { |
| 490 | case SkTriState::kDefault: ditherName = "default"; break; |
| 491 | case SkTriState::kTrue: ditherName = "true"; break; |
| 492 | case SkTriState::kFalse: ditherName = "false"; break; |
| 493 | default: ditherName = "<invalid>"; break; |
| 494 | } |
| 495 | str.appendf(" dither=%s", ditherName); |
| 496 | |
| 497 | if (hasStrokeWidth) { |
| 498 | str.appendf(" strokeWidth=%f", strokeWidth); |
| 499 | } else { |
| 500 | str.append(" strokeWidth=none"); |
| 501 | } |
| 502 | |
| 503 | #if defined(SK_SCALAR_IS_FLOAT) |
| 504 | str.append(" scalar=float"); |
| 505 | #elif defined(SK_SCALAR_IS_FIXED) |
| 506 | str.append(" scalar=fixed"); |
| 507 | #endif |
| 508 | |
| 509 | #if defined(SK_BUILD_FOR_WIN32) |
| 510 | str.append(" system=WIN32"); |
| 511 | #elif defined(SK_BUILD_FOR_MAC) |
| 512 | str.append(" system=MAC"); |
| 513 | #elif defined(SK_BUILD_FOR_ANDROID) |
| 514 | str.append(" system=ANDROID"); |
| 515 | #elif defined(SK_BUILD_FOR_UNIX) |
| 516 | str.append(" system=UNIX"); |
| 517 | #else |
| 518 | str.append(" system=other"); |
| 519 | #endif |
| 520 | |
| 521 | #if defined(SK_DEBUG) |
| 522 | str.append(" DEBUG"); |
| 523 | #endif |
| 524 | str.append("\n"); |
reed@google.com | 3b14dc1 | 2011-04-04 14:31:36 +0000 | [diff] [blame] | 525 | log_progress(str); |
| 526 | } |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 527 | |
bungeman@google.com | a5d4841 | 2011-06-15 17:25:46 +0000 | [diff] [blame] | 528 | //Don't do GL when fixed. |
| 529 | #if !defined(SK_SCALAR_IS_FIXED) |
tomhudson@google.com | 8382394 | 2011-10-28 14:59:07 +0000 | [diff] [blame] | 530 | int contextWidth = 1024; |
| 531 | int contextHeight = 1024; |
| 532 | determine_gpu_context_size(defineDict, &contextWidth, &contextHeight); |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 533 | SkAutoTUnref<SkGLContext> realGLCtx(new SkNativeGLContext); |
| 534 | SkAutoTUnref<SkGLContext> nullGLCtx(new SkNullGLContext); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 535 | SkAutoTUnref<SkGLContext> debugGLCtx(new SkDebugGLContext); |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 536 | #if SK_ANGLE |
| 537 | SkAutoTUnref<SkGLContext> angleGLCtx(new SkANGLEGLContext); |
| 538 | #endif |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 539 | gRealGLHelper.init(realGLCtx.get(), contextWidth, contextHeight); |
| 540 | gNullGLHelper.init(nullGLCtx.get(), contextWidth, contextHeight); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 541 | gDebugGLHelper.init(debugGLCtx.get(), contextWidth, contextHeight); |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 542 | #if SK_ANGLE |
| 543 | gANGLEGLHelper.init(angleGLCtx.get(), contextWidth, contextHeight); |
| 544 | #endif |
bungeman@google.com | a5d4841 | 2011-06-15 17:25:46 +0000 | [diff] [blame] | 545 | #endif |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 546 | BenchTimer timer = BenchTimer(gRealGLHelper.glContext()); |
bsalomon@google.com | 7491372 | 2011-10-27 20:44:19 +0000 | [diff] [blame] | 547 | |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 548 | Iter iter(&defineDict); |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 549 | SkBenchmark* bench; |
| 550 | while ((bench = iter.next()) != NULL) { |
reed@android.com | b398fe8 | 2009-01-07 11:47:57 +0000 | [diff] [blame] | 551 | SkIPoint dim = bench->getSize(); |
| 552 | if (dim.fX <= 0 || dim.fY <= 0) { |
| 553 | continue; |
| 554 | } |
reed@android.com | b398fe8 | 2009-01-07 11:47:57 +0000 | [diff] [blame] | 555 | |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 556 | bench->setForceAlpha(forceAlpha); |
| 557 | bench->setForceAA(forceAA); |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 558 | bench->setForceFilter(forceFilter); |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 559 | bench->setDither(forceDither); |
agl@chromium.org | 652807b | 2010-04-27 15:47:34 +0000 | [diff] [blame] | 560 | if (hasStrokeWidth) { |
| 561 | bench->setStrokeWidth(strokeWidth); |
| 562 | } |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 563 | |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 564 | // only run benchmarks if their name contains matchStr |
reed@google.com | 1a7eabc | 2011-10-31 16:33:52 +0000 | [diff] [blame] | 565 | if (skip_name(fMatches, bench->getName())) { |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 566 | continue; |
| 567 | } |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 568 | |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 569 | { |
| 570 | SkString str; |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 571 | str.printf("running bench [%d %d] %28s", dim.fX, dim.fY, |
reed@android.com | 0c9da39 | 2010-02-22 19:50:13 +0000 | [diff] [blame] | 572 | bench->getName()); |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 573 | log_progress(str); |
| 574 | } |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 575 | |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 576 | for (int configIndex = 0; configIndex < configCount; configIndex++) { |
| 577 | if (configCount > 1) { |
| 578 | outConfig = gConfigs[configIndex].fConfig; |
| 579 | configName = gConfigs[configIndex].fName; |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 580 | backend = gConfigs[configIndex].fBackend; |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 581 | glHelper = gConfigs[configIndex].fGLHelper; |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 582 | } |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 583 | |
| 584 | if (kGPU_Backend == backend && |
| 585 | (NULL == glHelper || !glHelper->isValid())) { |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 586 | continue; |
| 587 | } |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 588 | |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 589 | SkDevice* device = make_device(outConfig, dim, backend, glHelper); |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 590 | SkCanvas canvas(device); |
| 591 | device->unref(); |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 592 | |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 593 | if (doClip) { |
| 594 | performClip(&canvas, dim.fX, dim.fY); |
| 595 | } |
reed@android.com | 387359e | 2009-08-04 01:51:09 +0000 | [diff] [blame] | 596 | if (doScale) { |
| 597 | performScale(&canvas, dim.fX, dim.fY); |
| 598 | } |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 599 | if (doRotate) { |
| 600 | performRotate(&canvas, dim.fX, dim.fY); |
| 601 | } |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 602 | |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 603 | //warm up caches if needed |
reed@android.com | eca4836 | 2010-12-20 18:34:17 +0000 | [diff] [blame] | 604 | if (repeatDraw > 1) { |
| 605 | SkAutoCanvasRestore acr(&canvas, true); |
| 606 | bench->draw(&canvas); |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 607 | if (glHelper) { |
| 608 | glHelper->grContext()->flush(); |
| 609 | SK_GL(*glHelper->glContext(), Finish()); |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 610 | } |
reed@android.com | eca4836 | 2010-12-20 18:34:17 +0000 | [diff] [blame] | 611 | } |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 612 | |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 613 | timer.start(); |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 614 | for (int i = 0; i < repeatDraw; i++) { |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 615 | SkAutoCanvasRestore acr(&canvas, true); |
| 616 | bench->draw(&canvas); |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 617 | if (glHelper) { |
| 618 | glHelper->grContext()->flush(); |
reed@google.com | 25df888 | 2011-07-14 19:03:58 +0000 | [diff] [blame] | 619 | } |
| 620 | } |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 621 | if (glHelper) { |
| 622 | SK_GL(*glHelper->glContext(), Finish()); |
bsalomon@google.com | 788e247 | 2011-10-19 20:56:30 +0000 | [diff] [blame] | 623 | } |
bsalomon@google.com | 788e247 | 2011-10-19 20:56:30 +0000 | [diff] [blame] | 624 | timer.end(); |
bungeman@google.com | d1a416a | 2011-05-18 18:37:07 +0000 | [diff] [blame] | 625 | |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 626 | if (repeatDraw > 1) { |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 627 | SkString str; |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 628 | str.printf(" %4s:", configName); |
| 629 | if (timerWall) { |
| 630 | str.appendf(" msecs = %6.2f", timer.fWall / repeatDraw); |
| 631 | } |
| 632 | if (timerCpu) { |
| 633 | str.appendf(" cmsecs = %6.2f", timer.fCpu / repeatDraw); |
| 634 | } |
bsalomon@google.com | 508824b | 2011-12-13 16:49:49 +0000 | [diff] [blame] | 635 | if (timerGpu && glHelper && timer.fGpu > 0) { |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 636 | str.appendf(" gmsecs = %6.2f", timer.fGpu / repeatDraw); |
| 637 | } |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 638 | log_progress(str); |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 639 | } |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 640 | if (outDir.size() > 0) { |
mike@reedtribe.org | a9015f8 | 2011-05-17 02:25:05 +0000 | [diff] [blame] | 641 | saveFile(bench->getName(), configName, outDir.c_str(), |
| 642 | device->accessBitmap(false)); |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 643 | } |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 644 | } |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 645 | log_progress("\n"); |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 646 | } |
bsalomon@google.com | 971d0c8 | 2011-08-19 17:22:05 +0000 | [diff] [blame] | 647 | |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 648 | // need to clean up here rather than post-main to allow leak detection to work |
| 649 | gDebugGLHelper.cleanup(); |
| 650 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 651 | return 0; |
| 652 | } |