| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "Benchmark.h" | 8 #include "Benchmark.h" |
| 9 #include "Resources.h" | 9 #include "Resources.h" |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 return fName.c_str(); | 45 return fName.c_str(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual void onPreDraw() SK_OVERRIDE { | 48 virtual void onPreDraw() SK_OVERRIDE { |
| 49 SkString resourcePath = GetResourcePath(); | 49 SkString resourcePath = GetResourcePath(); |
| 50 if (resourcePath.isEmpty()) { | 50 if (resourcePath.isEmpty()) { |
| 51 fValid = false; | 51 fValid = false; |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 | 54 |
| 55 SkString fullPath = SkOSPath::SkPathJoin(resourcePath.c_str(), | 55 SkString fullPath = SkOSPath::Join(resourcePath.c_str(), fFilename.c_str
()); |
| 56 fFilename.c_str()); | |
| 57 SkFILEStream fileStream(fullPath.c_str()); | 56 SkFILEStream fileStream(fullPath.c_str()); |
| 58 fValid = fileStream.isValid() && fileStream.getLength() > 0; | 57 fValid = fileStream.isValid() && fileStream.getLength() > 0; |
| 59 if (fValid) { | 58 if (fValid) { |
| 60 const size_t size = fileStream.getLength(); | 59 const size_t size = fileStream.getLength(); |
| 61 void* data = sk_malloc_throw(size); | 60 void* data = sk_malloc_throw(size); |
| 62 if (fileStream.read(data, size) < size) { | 61 if (fileStream.read(data, size) < size) { |
| 63 fValid = false; | 62 fValid = false; |
| 64 } else { | 63 } else { |
| 65 SkAutoTUnref<SkData> skdata(SkData::NewFromMalloc(data, size)); | 64 SkAutoTUnref<SkData> skdata(SkData::NewFromMalloc(data, size)); |
| 66 fStream.setData(skdata.get()); | 65 fStream.setData(skdata.get()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 SkMemoryStream fStream; | 108 SkMemoryStream fStream; |
| 110 bool fSkipZeroes; | 109 bool fSkipZeroes; |
| 111 bool fValid; | 110 bool fValid; |
| 112 | 111 |
| 113 typedef Benchmark INHERITED; | 112 typedef Benchmark INHERITED; |
| 114 }; | 113 }; |
| 115 | 114 |
| 116 // Enable the true version once the feature is checked in. | 115 // Enable the true version once the feature is checked in. |
| 117 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", true))); | 116 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", true))); |
| 118 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", false))); | 117 DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", false))); |
| OLD | NEW |