Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2015 Google Inc. | |
|
scroggo
2016/02/10 16:29:49
nit 2016
msarett
2016/02/11 14:07:15
Done.
| |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #include "AndroidCodecBench.h" | |
| 9 #include "CodecBenchPriv.h" | |
| 10 #include "SkBitmap.h" | |
| 11 #include "SkAndroidCodec.h" | |
| 12 #include "SkCommandLineFlags.h" | |
| 13 #include "SkOSFile.h" | |
| 14 | |
| 15 AndroidCodecBench::AndroidCodecBench(SkString baseName, SkData* encoded, int sam pleSize) | |
| 16 : fData(SkRef(encoded)) | |
| 17 , fSampleSize(sampleSize) | |
| 18 { | |
| 19 // Parse filename and the color type to give the benchmark a useful name | |
| 20 fName.printf("AndroidCodec_%s_SampleSize%d", baseName.c_str(), sampleSize); | |
|
scroggo
2016/02/10 16:29:49
This just occurred to me - should we print the ben
msarett
2016/02/10 20:06:45
Do you think I should change the name to match the
scroggo
2016/02/10 21:13:54
My idea was that the name did not include the type
msarett
2016/02/11 14:07:15
Ahh ok I understand. I think it's a good idea, bu
scroggo
2016/02/11 14:08:54
sgtm
| |
| 21 } | |
| 22 | |
| 23 const char* AndroidCodecBench::onGetName() { | |
| 24 return fName.c_str(); | |
| 25 } | |
| 26 | |
| 27 bool AndroidCodecBench::isSuitableFor(Backend backend) { | |
| 28 return kNonRendering_Backend == backend; | |
| 29 } | |
| 30 | |
| 31 void AndroidCodecBench::onDelayedSetup() { | |
| 32 SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(fData)); | |
| 33 SkISize scaledSize = codec->getSampledDimensions(fSampleSize); | |
| 34 | |
| 35 fInfo = codec->getInfo().makeWH(scaledSize.width(), scaledSize.height()) | |
| 36 .makeColorType(kN32_SkColorType); | |
|
scroggo
2016/02/10 16:29:49
why only n32, and only premul?
- edit: looking do
msarett
2016/02/10 20:06:45
Yep that's right
| |
| 37 if (kUnpremul_SkAlphaType == fInfo.alphaType()) { | |
| 38 fInfo = fInfo.makeAlphaType(kPremul_SkAlphaType); | |
| 39 } | |
| 40 | |
| 41 fPixelStorage.reset(fInfo.getSafeSize(fInfo.minRowBytes())); | |
| 42 } | |
| 43 | |
| 44 void AndroidCodecBench::onDraw(int n, SkCanvas* canvas) { | |
| 45 SkAutoTDelete<SkAndroidCodec> codec; | |
| 46 SkAndroidCodec::AndroidOptions options; | |
| 47 options.fSampleSize = fSampleSize; | |
| 48 for (int i = 0; i < n; i++) { | |
| 49 codec.reset(SkAndroidCodec::NewFromData(fData)); | |
| 50 #ifdef SK_DEBUG | |
| 51 const SkCodec::Result result = | |
| 52 #endif | |
| 53 codec->getAndroidPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(), &options); | |
| 54 SkASSERT(result == SkCodec::kSuccess || result == SkCodec::kIncompleteIn put); | |
| 55 } | |
| 56 } | |
| OLD | NEW |