| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 void* data = sk_malloc_throw(size); | 45 void* data = sk_malloc_throw(size); |
| 46 if (fileStream.read(data, size) < size) { | 46 if (fileStream.read(data, size) < size) { |
| 47 fValid = false; | 47 fValid = false; |
| 48 } else { | 48 } else { |
| 49 SkAutoTUnref<SkData> skdata(SkData::NewFromMalloc(data, size)); | 49 SkAutoTUnref<SkData> skdata(SkData::NewFromMalloc(data, size)); |
| 50 fStream.setData(skdata.get()); | 50 fStream.setData(skdata.get()); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual void onDraw(SkCanvas*) SK_OVERRIDE { | 55 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { |
| 56 #ifdef SK_DEBUG | 56 #ifdef SK_DEBUG |
| 57 if (!fValid) { | 57 if (!fValid) { |
| 58 SkDebugf("stream was invalid: %s\n", fName.c_str()); | 58 SkDebugf("stream was invalid: %s\n", fName.c_str()); |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 #endif | 61 #endif |
| 62 // Decode a bunch of times | 62 // Decode a bunch of times |
| 63 SkBitmap bm; | 63 SkBitmap bm; |
| 64 for (int i = 0; i < this->getLoops(); ++i) { | 64 for (int i = 0; i < loops; ++i) { |
| 65 SkDEBUGCODE(bool success =) SkImageDecoder::DecodeStream(&fStream, &
bm); | 65 SkDEBUGCODE(bool success =) SkImageDecoder::DecodeStream(&fStream, &
bm); |
| 66 #ifdef SK_DEBUG | 66 #ifdef SK_DEBUG |
| 67 if (!success) { | 67 if (!success) { |
| 68 SkDebugf("failed to decode %s\n", fName.c_str()); | 68 SkDebugf("failed to decode %s\n", fName.c_str()); |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 #endif | 71 #endif |
| 72 SkDEBUGCODE(success =) fStream.rewind(); | 72 SkDEBUGCODE(success =) fStream.rewind(); |
| 73 #ifdef SK_DEBUG | 73 #ifdef SK_DEBUG |
| 74 if (!success) { | 74 if (!success) { |
| 75 SkDebugf("failed to rewind %s\n", fName.c_str()); | 75 SkDebugf("failed to rewind %s\n", fName.c_str()); |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 #endif | 78 #endif |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 SkString fName; | 83 SkString fName; |
| 84 const SkString fFilename; | 84 const SkString fFilename; |
| 85 SkMemoryStream fStream; | 85 SkMemoryStream fStream; |
| 86 bool fValid; | 86 bool fValid; |
| 87 | 87 |
| 88 typedef SkBenchmark INHERITED; | 88 typedef SkBenchmark INHERITED; |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 // These are files which call decodePalette | 91 // These are files which call decodePalette |
| 92 //DEF_BENCH( return SkNEW_ARGS(ImageDecodeBench, ("/usr/local/google/home/scrogg
o/Downloads/images/hal_163x90.png")); ) | 92 //DEF_BENCH( return SkNEW_ARGS(ImageDecodeBench, ("/usr/local/google/home/scrogg
o/Downloads/images/hal_163x90.png")); ) |
| 93 //DEF_BENCH( return SkNEW_ARGS(ImageDecodeBench, ("/usr/local/google/home/scrogg
o/Downloads/images/box_19_top-left.png")); ) | 93 //DEF_BENCH( return SkNEW_ARGS(ImageDecodeBench, ("/usr/local/google/home/scrogg
o/Downloads/images/box_19_top-left.png")); ) |
| OLD | NEW |