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

Side by Side Diff: tools/bench_pictures_main.cpp

Issue 12378075: Provide an option in bench_pictures to count pixel ram. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 9 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
« include/lazy/SkLruImageCache.h ('K') | « src/lazy/SkLruImageCache.cpp ('k') | no next file » | 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 2012 Google Inc. 2 * Copyright 2012 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 "BenchTimer.h" 8 #include "BenchTimer.h"
9 #include "CopyTilesRenderer.h" 9 #include "CopyTilesRenderer.h"
10 #include "PictureBenchmark.h" 10 #include "PictureBenchmark.h"
11 #include "PictureRenderingFlags.h" 11 #include "PictureRenderingFlags.h"
12 #include "SkBenchLogger.h" 12 #include "SkBenchLogger.h"
13 #include "SkBitmapFactory.h" 13 #include "SkBitmapFactory.h"
14 #include "SkCanvas.h" 14 #include "SkCanvas.h"
15 #include "SkFlags.h" 15 #include "SkFlags.h"
16 #include "SkGraphics.h" 16 #include "SkGraphics.h"
17 #include "SkImageDecoder.h" 17 #include "SkImageDecoder.h"
18 #include "SkMath.h" 18 #include "SkMath.h"
19 #include "SkOSFile.h" 19 #include "SkOSFile.h"
20 #include "SkPicture.h" 20 #include "SkPicture.h"
21 #include "SkStream.h" 21 #include "SkStream.h"
22 #include "SkTArray.h" 22 #include "SkTArray.h"
23 #include "picture_utils.h" 23 #include "picture_utils.h"
24 24
25 25
26 SkBenchLogger gLogger; 26 SkBenchLogger gLogger;
27 27
28 // Flags used by this file, in alphabetical order. 28 // Flags used by this file, in alphabetical order.
29 DEFINE_bool(countRAM, false, "Count the RAM used for bitmap pixels in each skp f ile");
29 DECLARE_bool(deferImageDecoding); 30 DECLARE_bool(deferImageDecoding);
30 DEFINE_string(filter, "", 31 DEFINE_string(filter, "",
31 "type:flag : Enable canvas filtering to disable a paint flag, " 32 "type:flag : Enable canvas filtering to disable a paint flag, "
32 "use no blur or low quality blur, or use no hinting or " 33 "use no blur or low quality blur, or use no hinting or "
33 "slight hinting. For all flags except AAClip, specify the " 34 "slight hinting. For all flags except AAClip, specify the "
34 "type of primitive to effect, or choose all. for AAClip " 35 "type of primitive to effect, or choose all. for AAClip "
35 "alone, the filter affects all clips independent of type. " 36 "alone, the filter affects all clips independent of type. "
36 "Specific flags are listed above."); 37 "Specific flags are listed above.");
37 DEFINE_string(logFile, "", "Destination for writing log output, in addition to s tdout."); 38 DEFINE_string(logFile, "", "Destination for writing log output, in addition to s tdout.");
38 DEFINE_bool(logPerIter, false, "Log each repeat timer instead of mean."); 39 DEFINE_bool(logPerIter, false, "Log each repeat timer instead of mean.");
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 SkFILEStream inputStream; 158 SkFILEStream inputStream;
158 159
159 inputStream.setPath(inputPath.c_str()); 160 inputStream.setPath(inputPath.c_str());
160 if (!inputStream.isValid()) { 161 if (!inputStream.isValid()) {
161 SkString err; 162 SkString err;
162 err.printf("Could not open file %s\n", inputPath.c_str()); 163 err.printf("Could not open file %s\n", inputPath.c_str());
163 gLogger.logError(err); 164 gLogger.logError(err);
164 return false; 165 return false;
165 } 166 }
166 167
168 // Since the old picture has been deleted, all pixels should be cleared.
169 SkASSERT(gLruImageCache.getRamUsed() == 0);
170 if (FLAGS_countRAM) {
171 // Set the budget to zero, so all pixels will be kept
172 gLruImageCache.setBudget(0);
173 }
174
167 bool success = false; 175 bool success = false;
168 SkPicture* picture; 176 SkPicture* picture;
169 if (FLAGS_deferImageDecoding) { 177 if (FLAGS_deferImageDecoding) {
170 picture = SkNEW_ARGS(SkPicture, (&inputStream, &success, &lazy_decode_bi tmap)); 178 picture = SkNEW_ARGS(SkPicture, (&inputStream, &success, &lazy_decode_bi tmap));
171 } else { 179 } else {
172 picture = SkNEW_ARGS(SkPicture, (&inputStream, &success, &SkImageDecoder ::DecodeMemory)); 180 picture = SkNEW_ARGS(SkPicture, (&inputStream, &success, &SkImageDecoder ::DecodeMemory));
173 } 181 }
174 SkAutoTDelete<SkPicture> ad(picture); 182 SkAutoTDelete<SkPicture> ad(picture);
175 183
176 if (!success) { 184 if (!success) {
177 SkString err; 185 SkString err;
178 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str()); 186 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
179 gLogger.logError(err); 187 gLogger.logError(err);
180 return false; 188 return false;
181 } 189 }
182 190
183 SkString filename; 191 SkString filename;
184 sk_tools::get_basename(&filename, inputPath); 192 sk_tools::get_basename(&filename, inputPath);
185 193
186 SkString result; 194 SkString result;
187 result.printf("running bench [%i %i] %s ", picture->width(), picture->height (), 195 result.printf("running bench [%i %i] %s ", picture->width(), picture->height (),
188 filename.c_str()); 196 filename.c_str());
189 gLogger.logProgress(result); 197 gLogger.logProgress(result);
190 198
191 benchmark.run(picture); 199 benchmark.run(picture);
200
201 if (FLAGS_countRAM) {
202 SkDebugf("RAM used for bitmaps: ");
203 size_t bytes = gLruImageCache.getRamUsed();
204 if (bytes > 1024) {
205 size_t kb = bytes / 1024;
206 if (kb > 1024) {
207 size_t mb = kb / 1024;
208 SkDebugf("%i MB\n", mb);
209 } else {
210 SkDebugf("%i KB\n", kb);
211 }
212 } else {
213 SkDebugf("%i bytes\n", bytes);
214 }
215 }
216
192 return true; 217 return true;
193 } 218 }
194 219
195 static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) { 220 static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) {
196 sk_tools::PictureRenderer::DrawFilterFlags drawFilters[SkDrawFilter::kTypeCo unt]; 221 sk_tools::PictureRenderer::DrawFilterFlags drawFilters[SkDrawFilter::kTypeCo unt];
197 sk_bzero(drawFilters, sizeof(drawFilters)); 222 sk_bzero(drawFilters, sizeof(drawFilters));
198 223
199 if (FLAGS_filter.count() > 0) { 224 if (FLAGS_filter.count() > 0) {
200 const char* filters = FLAGS_filter[0]; 225 const char* filters = FLAGS_filter[0];
201 const char* colon = strchr(filters, ':'); 226 const char* colon = strchr(filters, ':');
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 return 1; 422 return 1;
398 } 423 }
399 return 0; 424 return 0;
400 } 425 }
401 426
402 #if !defined SK_BUILD_FOR_IOS 427 #if !defined SK_BUILD_FOR_IOS
403 int main(int argc, char * const argv[]) { 428 int main(int argc, char * const argv[]) {
404 return tool_main(argc, (char**) argv); 429 return tool_main(argc, (char**) argv);
405 } 430 }
406 #endif 431 #endif
OLDNEW
« include/lazy/SkLruImageCache.h ('K') | « src/lazy/SkLruImageCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698