OLD | NEW |
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 "LazyDecodeBitmap.h" |
10 #include "PictureBenchmark.h" | 11 #include "PictureBenchmark.h" |
11 #include "PictureRenderingFlags.h" | 12 #include "PictureRenderingFlags.h" |
12 #include "SkBenchLogger.h" | 13 #include "SkBenchLogger.h" |
13 #include "SkCommandLineFlags.h" | 14 #include "SkCommandLineFlags.h" |
14 #include "SkForceLinking.h" | |
15 #include "SkGraphics.h" | 15 #include "SkGraphics.h" |
16 #include "SkImageDecoder.h" | 16 #include "SkImageDecoder.h" |
17 #if LAZY_CACHE_STATS | 17 #if LAZY_CACHE_STATS |
18 #include "SkLazyPixelRef.h" | 18 #include "SkLazyPixelRef.h" |
19 #endif | 19 #endif |
20 #include "SkLruImageCache.h" | 20 #include "SkLruImageCache.h" |
21 #include "SkMath.h" | 21 #include "SkMath.h" |
22 #include "SkOSFile.h" | 22 #include "SkOSFile.h" |
23 #include "SkPicture.h" | 23 #include "SkPicture.h" |
24 #include "SkStream.h" | 24 #include "SkStream.h" |
25 #include "picture_utils.h" | 25 #include "picture_utils.h" |
26 | 26 |
27 __SK_FORCE_IMAGE_DECODER_LINKING; | |
28 | |
29 SkBenchLogger gLogger; | 27 SkBenchLogger gLogger; |
30 | 28 |
31 // Flags used by this file, in alphabetical order. | 29 // Flags used by this file, in alphabetical order. |
32 DEFINE_bool(countRAM, false, "Count the RAM used for bitmap pixels in each skp f
ile"); | 30 DEFINE_bool(countRAM, false, "Count the RAM used for bitmap pixels in each skp f
ile"); |
33 DECLARE_bool(deferImageDecoding); | 31 DECLARE_bool(deferImageDecoding); |
34 DEFINE_string(filter, "", | 32 DEFINE_string(filter, "", |
35 "type:flag : Enable canvas filtering to disable a paint flag, " | 33 "type:flag : Enable canvas filtering to disable a paint flag, " |
36 "use no blur or low quality blur, or use no hinting or " | 34 "use no blur or low quality blur, or use no hinting or " |
37 "slight hinting. For all flags except AAClip, specify the " | 35 "slight hinting. For all flags except AAClip, specify the " |
38 "type of primitive to effect, or choose all. for AAClip " | 36 "type of primitive to effect, or choose all. for AAClip " |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 result += "\n\t\t"; | 136 result += "\n\t\t"; |
139 len = result.size(); | 137 len = result.size(); |
140 } | 138 } |
141 if (index < kFilterFlagsCount - 1) { | 139 if (index < kFilterFlagsCount - 1) { |
142 result += " | "; | 140 result += " | "; |
143 } | 141 } |
144 } | 142 } |
145 return result; | 143 return result; |
146 } | 144 } |
147 | 145 |
148 // These are defined in PictureRenderingFlags.cpp | 146 // Defined in LazyDecodeBitmap.cpp |
149 extern SkLruImageCache gLruImageCache; | 147 extern SkLruImageCache gLruImageCache; |
150 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap
); | |
151 | 148 |
152 #if LAZY_CACHE_STATS | 149 #if LAZY_CACHE_STATS |
153 static int32_t gTotalCacheHits; | 150 static int32_t gTotalCacheHits; |
154 static int32_t gTotalCacheMisses; | 151 static int32_t gTotalCacheMisses; |
155 #endif | 152 #endif |
156 | 153 |
157 static bool run_single_benchmark(const SkString& inputPath, | 154 static bool run_single_benchmark(const SkString& inputPath, |
158 sk_tools::PictureBenchmark& benchmark) { | 155 sk_tools::PictureBenchmark& benchmark) { |
159 SkFILEStream inputStream; | 156 SkFILEStream inputStream; |
160 | 157 |
161 inputStream.setPath(inputPath.c_str()); | 158 inputStream.setPath(inputPath.c_str()); |
162 if (!inputStream.isValid()) { | 159 if (!inputStream.isValid()) { |
163 SkString err; | 160 SkString err; |
164 err.printf("Could not open file %s\n", inputPath.c_str()); | 161 err.printf("Could not open file %s\n", inputPath.c_str()); |
165 gLogger.logError(err); | 162 gLogger.logError(err); |
166 return false; | 163 return false; |
167 } | 164 } |
168 | 165 |
169 // Since the old picture has been deleted, all pixels should be cleared. | 166 // Since the old picture has been deleted, all pixels should be cleared. |
170 SkASSERT(gLruImageCache.getImageCacheUsed() == 0); | 167 SkASSERT(gLruImageCache.getImageCacheUsed() == 0); |
171 if (FLAGS_countRAM) { | 168 if (FLAGS_countRAM) { |
172 // Set the limit to zero, so all pixels will be kept | 169 // Set the limit to zero, so all pixels will be kept |
173 gLruImageCache.setImageCacheLimit(0); | 170 gLruImageCache.setImageCacheLimit(0); |
174 } | 171 } |
175 | 172 |
176 SkPicture::InstallPixelRefProc proc; | 173 SkPicture::InstallPixelRefProc proc; |
177 if (FLAGS_deferImageDecoding) { | 174 if (FLAGS_deferImageDecoding) { |
178 proc = &lazy_decode_bitmap; | 175 proc = &sk_tools::LazyDecodeBitmap; |
179 } else { | 176 } else { |
180 proc = &SkImageDecoder::DecodeMemory; | 177 proc = &SkImageDecoder::DecodeMemory; |
181 } | 178 } |
182 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, pr
oc)); | 179 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, pr
oc)); |
183 | 180 |
184 if (NULL == picture.get()) { | 181 if (NULL == picture.get()) { |
185 SkString err; | 182 SkString err; |
186 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str()); | 183 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str()); |
187 gLogger.logError(err); | 184 gLogger.logError(err); |
188 return false; | 185 return false; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 } | 438 } |
442 #endif | 439 #endif |
443 return 0; | 440 return 0; |
444 } | 441 } |
445 | 442 |
446 #if !defined SK_BUILD_FOR_IOS | 443 #if !defined SK_BUILD_FOR_IOS |
447 int main(int argc, char * const argv[]) { | 444 int main(int argc, char * const argv[]) { |
448 return tool_main(argc, (char**) argv); | 445 return tool_main(argc, (char**) argv); |
449 } | 446 } |
450 #endif | 447 #endif |
OLD | NEW |