| 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" | 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 "SkLazyPixelRef.h" |
| 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" | 24 #include "SkTArray.h" |
| 23 #include "picture_utils.h" | 25 #include "picture_utils.h" |
| 24 | 26 |
| 25 | 27 |
| 26 SkBenchLogger gLogger; | 28 SkBenchLogger gLogger; |
| 27 | 29 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 result += "\n\t\t"; | 137 result += "\n\t\t"; |
| 136 len = result.size(); | 138 len = result.size(); |
| 137 } | 139 } |
| 138 if (index < kFilterFlagsCount - 1) { | 140 if (index < kFilterFlagsCount - 1) { |
| 139 result += " | "; | 141 result += " | "; |
| 140 } | 142 } |
| 141 } | 143 } |
| 142 return result; | 144 return result; |
| 143 } | 145 } |
| 144 | 146 |
| 145 #include "SkData.h" | 147 // These are defined in PictureRenderingFlags.cpp |
| 146 #include "SkLruImageCache.h" | 148 extern SkLruImageCache gLruImageCache; |
| 147 #include "SkLazyPixelRef.h" | 149 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 | 150 |
| 160 #if LAZY_CACHE_STATS | 151 #if LAZY_CACHE_STATS |
| 161 static int32_t gTotalCacheHits; | 152 static int32_t gTotalCacheHits; |
| 162 static int32_t gTotalCacheMisses; | 153 static int32_t gTotalCacheMisses; |
| 163 #endif | 154 #endif |
| 164 | 155 |
| 165 static bool run_single_benchmark(const SkString& inputPath, | 156 static bool run_single_benchmark(const SkString& inputPath, |
| 166 sk_tools::PictureBenchmark& benchmark) { | 157 sk_tools::PictureBenchmark& benchmark) { |
| 167 SkFILEStream inputStream; | 158 SkFILEStream inputStream; |
| 168 | 159 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 441 } |
| 451 #endif | 442 #endif |
| 452 return 0; | 443 return 0; |
| 453 } | 444 } |
| 454 | 445 |
| 455 #if !defined SK_BUILD_FOR_IOS | 446 #if !defined SK_BUILD_FOR_IOS |
| 456 int main(int argc, char * const argv[]) { | 447 int main(int argc, char * const argv[]) { |
| 457 return tool_main(argc, (char**) argv); | 448 return tool_main(argc, (char**) argv); |
| 458 } | 449 } |
| 459 #endif | 450 #endif |
| OLD | NEW |