Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: bench/SkipZeroesBench.cpp

Issue 647023006: Qualify the return value of SkImageDecoder::decode (Closed) Base URL: https://skia.googlesource.com/skia.git/+/master
Patch Set: fix a sample Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | include/core/SkImageDecoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "Benchmark.h" 8 #include "Benchmark.h"
9 #include "Resources.h" 9 #include "Resources.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { 76 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
77 if (!fValid) { 77 if (!fValid) {
78 #ifdef SK_DEBUG 78 #ifdef SK_DEBUG
79 SkDebugf("stream was invalid: %s\n", fFilename.c_str()); 79 SkDebugf("stream was invalid: %s\n", fFilename.c_str());
80 #endif 80 #endif
81 return; 81 return;
82 } 82 }
83 // Decode a bunch of times 83 // Decode a bunch of times
84 SkBitmap bm; 84 SkBitmap bm;
85 for (int i = 0; i < loops; ++i) { 85 for (int i = 0; i < loops; ++i) {
86 SkDEBUGCODE(bool success =) fDecoder->decode(&fStream, &bm, 86 SkDEBUGCODE(SkImageDecoder::Result result =) fDecoder->decode(&fStre am, &bm,
87 SkImageDecoder::kDecode Pixels_Mode); 87 SkImageDecoder::kDecodePixels_Mode);
88 #ifdef SK_DEBUG 88 #ifdef SK_DEBUG
89 if (!success) { 89 if (SkImageDecoder::kFailure == result) {
90 SkDebugf("failed to decode %s\n", fFilename.c_str()); 90 SkDebugf("failed to decode %s\n", fFilename.c_str());
91 return; 91 return;
92 } 92 }
93 #endif 93 #endif
94 SkDEBUGCODE(success =) fStream.rewind(); 94 SkDEBUGCODE(bool success =) fStream.rewind();
95 #ifdef SK_DEBUG 95 #ifdef SK_DEBUG
96 if (!success) { 96 if (!success) {
97 SkDebugf("failed to rewind %s\n", fFilename.c_str()); 97 SkDebugf("failed to rewind %s\n", fFilename.c_str());
98 return; 98 return;
99 } 99 }
100 #endif 100 #endif
101 } 101 }
102 } 102 }
103 103
104 private: 104 private:
105 SkString fName; 105 SkString fName;
106 SkAutoTDelete<SkImageDecoder> fDecoder; 106 SkAutoTDelete<SkImageDecoder> fDecoder;
107 const SkString fFilename; 107 const SkString fFilename;
108 SkMemoryStream fStream; 108 SkMemoryStream fStream;
109 bool fSkipZeroes; 109 bool fSkipZeroes;
110 bool fValid; 110 bool fValid;
111 111
112 typedef Benchmark INHERITED; 112 typedef Benchmark INHERITED;
113 }; 113 };
114 114
115 // Enable the true version once the feature is checked in. 115 // Enable the true version once the feature is checked in.
116 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", true))); 116 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", true)));
117 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", false))); 117 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", false)));
OLDNEW
« no previous file with comments | « no previous file | include/core/SkImageDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698