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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 fDecoder.reset(SkImageDecoder::Factory(&fStream)); | 65 fDecoder.reset(SkImageDecoder::Factory(&fStream)); |
66 if (fDecoder.get()) { | 66 if (fDecoder.get()) { |
67 fDecoder->setSkipWritingZeroes(fSkipZeroes); | 67 fDecoder->setSkipWritingZeroes(fSkipZeroes); |
68 } else { | 68 } else { |
69 fValid = false; | 69 fValid = false; |
70 } | 70 } |
71 } | 71 } |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 virtual void onDraw(SkCanvas*) SK_OVERRIDE { | 75 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { |
76 if (!fValid) { | 76 if (!fValid) { |
77 #ifdef SK_DEBUG | 77 #ifdef SK_DEBUG |
78 SkDebugf("stream was invalid: %s\n", fFilename.c_str()); | 78 SkDebugf("stream was invalid: %s\n", fFilename.c_str()); |
79 #endif | 79 #endif |
80 return; | 80 return; |
81 } | 81 } |
82 // Decode a bunch of times | 82 // Decode a bunch of times |
83 SkBitmap bm; | 83 SkBitmap bm; |
84 for (int i = 0; i < this->getLoops(); ++i) { | 84 for (int i = 0; i < loops; ++i) { |
85 SkDEBUGCODE(bool success =) fDecoder->decode(&fStream, &bm, | 85 SkDEBUGCODE(bool success =) fDecoder->decode(&fStream, &bm, |
86 SkImageDecoder::kDecode
Pixels_Mode); | 86 SkImageDecoder::kDecode
Pixels_Mode); |
87 #ifdef SK_DEBUG | 87 #ifdef SK_DEBUG |
88 if (!success) { | 88 if (!success) { |
89 SkDebugf("failed to decode %s\n", fFilename.c_str()); | 89 SkDebugf("failed to decode %s\n", fFilename.c_str()); |
90 return; | 90 return; |
91 } | 91 } |
92 #endif | 92 #endif |
93 SkDEBUGCODE(success =) fStream.rewind(); | 93 SkDEBUGCODE(success =) fStream.rewind(); |
94 #ifdef SK_DEBUG | 94 #ifdef SK_DEBUG |
(...skipping 12 matching lines...) Expand all Loading... |
107 SkMemoryStream fStream; | 107 SkMemoryStream fStream; |
108 bool fSkipZeroes; | 108 bool fSkipZeroes; |
109 bool fValid; | 109 bool fValid; |
110 | 110 |
111 typedef SkBenchmark INHERITED; | 111 typedef SkBenchmark INHERITED; |
112 }; | 112 }; |
113 | 113 |
114 // Enable the true version once the feature is checked in. | 114 // Enable the true version once the feature is checked in. |
115 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", true))); | 115 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", true))); |
116 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", false))); | 116 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", false))); |
OLD | NEW |