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