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

Side by Side Diff: bench/SkipZeroesBench.cpp

Issue 24269006: Add an option on SkImageDecoder to skip writing 0s. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Rebase, plus update the benchmark Created 7 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 | Annotate | Revision Log
« 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 "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
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
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)));
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