| 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 "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" | |
| 14 #include "SkCanvas.h" | |
| 15 #include "SkFlags.h" | 13 #include "SkFlags.h" |
| 16 #include "SkGraphics.h" | 14 #include "SkGraphics.h" |
| 17 #include "SkImageDecoder.h" | 15 #include "SkImageDecoder.h" |
| 16 #if LAZY_CACHE_STATS |
| 17 #include "SkLazyPixelRef.h" |
| 18 #endif |
| 19 #include "SkLruImageCache.h" |
| 18 #include "SkMath.h" | 20 #include "SkMath.h" |
| 19 #include "SkOSFile.h" | 21 #include "SkOSFile.h" |
| 20 #include "SkPicture.h" | 22 #include "SkPicture.h" |
| 21 #include "SkStream.h" | 23 #include "SkStream.h" |
| 22 #include "SkTArray.h" | |
| 23 #include "picture_utils.h" | 24 #include "picture_utils.h" |
| 24 | 25 |
| 25 | 26 |
| 26 SkBenchLogger gLogger; | 27 SkBenchLogger gLogger; |
| 27 | 28 |
| 28 // Flags used by this file, in alphabetical order. | 29 // 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"); | 30 DEFINE_bool(countRAM, false, "Count the RAM used for bitmap pixels in each skp f
ile"); |
| 30 DECLARE_bool(deferImageDecoding); | 31 DECLARE_bool(deferImageDecoding); |
| 31 DEFINE_string(filter, "", | 32 DEFINE_string(filter, "", |
| 32 "type:flag : Enable canvas filtering to disable a paint flag, " | 33 "type:flag : Enable canvas filtering to disable a paint flag, " |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 result += "\n\t\t"; | 136 result += "\n\t\t"; |
| 136 len = result.size(); | 137 len = result.size(); |
| 137 } | 138 } |
| 138 if (index < kFilterFlagsCount - 1) { | 139 if (index < kFilterFlagsCount - 1) { |
| 139 result += " | "; | 140 result += " | "; |
| 140 } | 141 } |
| 141 } | 142 } |
| 142 return result; | 143 return result; |
| 143 } | 144 } |
| 144 | 145 |
| 145 #include "SkData.h" | 146 // These are defined in PictureRenderingFlags.cpp |
| 146 #include "SkLruImageCache.h" | 147 extern SkLruImageCache gLruImageCache; |
| 147 #include "SkLazyPixelRef.h" | 148 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap
); |
| 148 | |
| 149 static SkLruImageCache gLruImageCache(1024*1024); | |
| 150 | |
| 151 static bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap
) { | |
| 152 void* copiedBuffer = sk_malloc_throw(size); | |
| 153 memcpy(copiedBuffer, buffer, size); | |
| 154 SkAutoDataUnref data(SkData::NewFromMalloc(copiedBuffer, size)); | |
| 155 SkBitmapFactory factory(&SkImageDecoder::DecodeMemoryToTarget); | |
| 156 factory.setImageCache(&gLruImageCache); | |
| 157 return factory.installPixelRef(data, bitmap); | |
| 158 } | |
| 159 | 149 |
| 160 #if LAZY_CACHE_STATS | 150 #if LAZY_CACHE_STATS |
| 161 static int32_t gTotalCacheHits; | 151 static int32_t gTotalCacheHits; |
| 162 static int32_t gTotalCacheMisses; | 152 static int32_t gTotalCacheMisses; |
| 163 #endif | 153 #endif |
| 164 | 154 |
| 165 static bool run_single_benchmark(const SkString& inputPath, | 155 static bool run_single_benchmark(const SkString& inputPath, |
| 166 sk_tools::PictureBenchmark& benchmark) { | 156 sk_tools::PictureBenchmark& benchmark) { |
| 167 SkFILEStream inputStream; | 157 SkFILEStream inputStream; |
| 168 | 158 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 440 } |
| 451 #endif | 441 #endif |
| 452 return 0; | 442 return 0; |
| 453 } | 443 } |
| 454 | 444 |
| 455 #if !defined SK_BUILD_FOR_IOS | 445 #if !defined SK_BUILD_FOR_IOS |
| 456 int main(int argc, char * const argv[]) { | 446 int main(int argc, char * const argv[]) { |
| 457 return tool_main(argc, (char**) argv); | 447 return tool_main(argc, (char**) argv); |
| 458 } | 448 } |
| 459 #endif | 449 #endif |
| OLD | NEW |