| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 if (fValid) { | 54 if (fValid) { |
| 55 const size_t size = fileStream.getLength(); | 55 const size_t size = fileStream.getLength(); |
| 56 void* data = sk_malloc_throw(size); | 56 void* data = sk_malloc_throw(size); |
| 57 if (fileStream.read(data, size) < size) { | 57 if (fileStream.read(data, size) < size) { |
| 58 fValid = false; | 58 fValid = false; |
| 59 } else { | 59 } else { |
| 60 SkAutoTUnref<SkData> skdata(SkData::NewFromMalloc(data, size)); | 60 SkAutoTUnref<SkData> skdata(SkData::NewFromMalloc(data, size)); |
| 61 fStream.setData(skdata.get()); | 61 fStream.setData(skdata.get()); |
| 62 fDecoder.reset(SkImageDecoder::Factory(&fStream)); | 62 fDecoder.reset(SkImageDecoder::Factory(&fStream)); |
| 63 if (fDecoder.get()) { | 63 if (fDecoder.get()) { |
| 64 // Disabling until the feature is checked in. | 64 fDecoder->setSkipWritingZeroes(fSkipZeroes); |
| 65 // See https://codereview.chromium.org/24269006/ | |
| 66 //fDecoder->setSkipWritingZeroes(fSkipZeroes); | |
| 67 if (fSkipZeroes) { | |
| 68 // This printf will never happen since this bench is | |
| 69 // only currently created with false. Remove once | |
| 70 // the above code is uncommented. | |
| 71 SkDebugf("Should be skipping zeroes...\n"); | |
| 72 } | |
| 73 } else { | 65 } else { |
| 74 fValid = false; | 66 fValid = false; |
| 75 } | 67 } |
| 76 } | 68 } |
| 77 } | 69 } |
| 78 } | 70 } |
| 79 | 71 |
| 80 virtual void onDraw(SkCanvas*) SK_OVERRIDE { | 72 virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 81 if (!fValid) { | 73 if (!fValid) { |
| 82 #ifdef SK_DEBUG | 74 #ifdef SK_DEBUG |
| (...skipping 27 matching lines...) Expand all Loading... |
| 110 SkAutoTDelete<SkImageDecoder> fDecoder; | 102 SkAutoTDelete<SkImageDecoder> fDecoder; |
| 111 const SkString fFilename; | 103 const SkString fFilename; |
| 112 SkMemoryStream fStream; | 104 SkMemoryStream fStream; |
| 113 bool fSkipZeroes; | 105 bool fSkipZeroes; |
| 114 bool fValid; | 106 bool fValid; |
| 115 | 107 |
| 116 typedef SkBenchmark INHERITED; | 108 typedef SkBenchmark INHERITED; |
| 117 }; | 109 }; |
| 118 | 110 |
| 119 // Enable the true version once the feature is checked in. | 111 // Enable the true version once the feature is checked in. |
| 120 //DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", true))); | 112 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", true))); |
| 121 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", false))); | 113 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", false))); |
| OLD | NEW |