Chromium Code Reviews| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // These are defined in PictureRenderingFlags.cpp |
| 149 extern SkLruImageCache gLruImageCache; | 147 extern SkLruImageCache gLruImageCache; |
| 150 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap ); | 148 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap ); |
|
scroggo
2013/07/15 18:02:41
This is no longer needed.
sglez
2013/07/16 15:59:33
I sould have caught these.
| |
| 151 | 149 |
| 152 #if LAZY_CACHE_STATS | 150 #if LAZY_CACHE_STATS |
| 153 static int32_t gTotalCacheHits; | 151 static int32_t gTotalCacheHits; |
| 154 static int32_t gTotalCacheMisses; | 152 static int32_t gTotalCacheMisses; |
| 155 #endif | 153 #endif |
| 156 | 154 |
| 157 static bool run_single_benchmark(const SkString& inputPath, | 155 static bool run_single_benchmark(const SkString& inputPath, |
| 158 sk_tools::PictureBenchmark& benchmark) { | 156 sk_tools::PictureBenchmark& benchmark) { |
| 159 SkFILEStream inputStream; | 157 SkFILEStream inputStream; |
| 160 | 158 |
| 161 inputStream.setPath(inputPath.c_str()); | 159 inputStream.setPath(inputPath.c_str()); |
| 162 if (!inputStream.isValid()) { | 160 if (!inputStream.isValid()) { |
| 163 SkString err; | 161 SkString err; |
| 164 err.printf("Could not open file %s\n", inputPath.c_str()); | 162 err.printf("Could not open file %s\n", inputPath.c_str()); |
| 165 gLogger.logError(err); | 163 gLogger.logError(err); |
| 166 return false; | 164 return false; |
| 167 } | 165 } |
| 168 | 166 |
| 169 // Since the old picture has been deleted, all pixels should be cleared. | 167 // Since the old picture has been deleted, all pixels should be cleared. |
| 170 SkASSERT(gLruImageCache.getImageCacheUsed() == 0); | 168 SkASSERT(gLruImageCache.getImageCacheUsed() == 0); |
| 171 if (FLAGS_countRAM) { | 169 if (FLAGS_countRAM) { |
| 172 // Set the limit to zero, so all pixels will be kept | 170 // Set the limit to zero, so all pixels will be kept |
| 173 gLruImageCache.setImageCacheLimit(0); | 171 gLruImageCache.setImageCacheLimit(0); |
| 174 } | 172 } |
| 175 | 173 |
| 176 SkPicture::InstallPixelRefProc proc; | 174 SkPicture::InstallPixelRefProc proc; |
| 177 if (FLAGS_deferImageDecoding) { | 175 if (FLAGS_deferImageDecoding) { |
| 178 proc = &lazy_decode_bitmap; | 176 proc = &LazyDecodeBitmap; |
| 179 } else { | 177 } else { |
| 180 proc = &SkImageDecoder::DecodeMemory; | 178 proc = &SkImageDecoder::DecodeMemory; |
| 181 } | 179 } |
| 182 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, pr oc)); | 180 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, pr oc)); |
| 183 | 181 |
| 184 if (NULL == picture.get()) { | 182 if (NULL == picture.get()) { |
| 185 SkString err; | 183 SkString err; |
| 186 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str()); | 184 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str()); |
| 187 gLogger.logError(err); | 185 gLogger.logError(err); |
| 188 return false; | 186 return false; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 } | 439 } |
| 442 #endif | 440 #endif |
| 443 return 0; | 441 return 0; |
| 444 } | 442 } |
| 445 | 443 |
| 446 #if !defined SK_BUILD_FOR_IOS | 444 #if !defined SK_BUILD_FOR_IOS |
| 447 int main(int argc, char * const argv[]) { | 445 int main(int argc, char * const argv[]) { |
| 448 return tool_main(argc, (char**) argv); | 446 return tool_main(argc, (char**) argv); |
| 449 } | 447 } |
| 450 #endif | 448 #endif |
| OLD | NEW |