Index: bench/ColorCodecBench.cpp |
diff --git a/bench/ColorCodecBench.cpp b/bench/ColorCodecBench.cpp |
index ac1c2bc4c0a38197a2ee7e04d19643cf0d72a826..e17d597abb04ae2865343b607f675c73be636854 100644 |
--- a/bench/ColorCodecBench.cpp |
+++ b/bench/ColorCodecBench.cpp |
@@ -41,13 +41,32 @@ |
void ColorCodecBench::decodeAndXform() { |
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fEncoded.get())); |
- SkASSERT(codec); |
- |
-#ifdef SK_DEBUG |
- SkCodec::Result result = |
-#endif |
- codec->getPixels(fDstInfo, fDst.get(), fDstInfo.minRowBytes()); |
+#ifdef SK_DEBUG |
+ const SkCodec::Result result = |
+#endif |
+ codec->startScanlineDecode(fSrcInfo); |
SkASSERT(SkCodec::kSuccess == result); |
+ |
+ sk_sp<SkColorSpace> srcSpace = sk_ref_sp(codec->getInfo().colorSpace()); |
+ if (!srcSpace) { |
+ srcSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); |
+ } |
+ std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(srcSpace, fDstSpace); |
+ SkASSERT(xform); |
+ |
+ void* dst = fDst.get(); |
+ for (int y = 0; y < fSrcInfo.height(); y++) { |
+#ifdef SK_DEBUG |
+ const int rows = |
+#endif |
+ codec->getScanlines(fSrc.get(), 1, 0); |
+ SkASSERT(1 == rows); |
+ |
+ FLAGS_half ? |
+ xform->applyToF16((uint64_t*) dst, (uint32_t*) fSrc.get(), fSrcInfo.width()) : |
+ xform->applyTo8888((SkPMColor*) dst, (uint32_t*) fSrc.get(), fSrcInfo.width()); |
+ dst = SkTAddOffset<void>(dst, fDstInfo.minRowBytes()); |
+ } |
} |
#if defined(SK_TEST_QCMS) |
@@ -102,7 +121,7 @@ |
// Transform in place |
FLAGS_half ? |
xform->applyToF16((uint64_t*) dst, (uint32_t*) src, fSrcInfo.width()) : |
- xform->applyToRGBA((SkPMColor*) dst, (uint32_t*) src, fSrcInfo.width()); |
+ xform->applyTo8888((SkPMColor*) dst, (uint32_t*) src, fSrcInfo.width()); |
dst = SkTAddOffset<void>(dst, fDstInfo.minRowBytes()); |
src = SkTAddOffset<void>(src, fSrcInfo.minRowBytes()); |
} |
@@ -138,12 +157,28 @@ |
void ColorCodecBench::onDelayedSetup() { |
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fEncoded.get())); |
+ fSrcInfo = codec->getInfo().makeColorType(kRGBA_8888_SkColorType); |
+ |
+ fDstInfo = fSrcInfo; |
+ if (FLAGS_half) { |
+ fDstInfo = fDstInfo.makeColorType(kRGBA_F16_SkColorType); |
+ } |
+ fDst.reset(fDstInfo.getSafeSize(fDstInfo.minRowBytes())); |
+ |
+ if (FLAGS_xform_only) { |
+ fSrc.reset(fSrcInfo.getSafeSize(fSrcInfo.minRowBytes())); |
+ codec->getPixels(fSrcInfo, fSrc.get(), fSrcInfo.minRowBytes()); |
+ } else { |
+ // Set-up a row buffer to decode into before transforming to dst. |
+ fSrc.reset(fSrcInfo.minRowBytes()); |
+ } |
+ |
fSrcData = codec->getICCData(); |
sk_sp<SkData> dstData = SkData::MakeFromFileName( |
GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str()); |
SkASSERT(dstData); |
- fDstSpace = nullptr; |
+ |
#if defined(SK_TEST_QCMS) |
if (FLAGS_qcms) { |
fDstSpaceQCMS.reset(FLAGS_srgb ? |
@@ -160,22 +195,6 @@ |
fDstSpace = FLAGS_srgb ? SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : |
SkColorSpace::NewICC(dstData->data(), dstData->size()); |
SkASSERT(fDstSpace); |
- } |
- |
- fSrcInfo = codec->getInfo().makeColorType(kRGBA_8888_SkColorType); |
- |
- fDstInfo = fSrcInfo.makeColorSpace(fDstSpace); |
- if (FLAGS_half) { |
- fDstInfo = fDstInfo.makeColorType(kRGBA_F16_SkColorType); |
- } |
- fDst.reset(fDstInfo.getSafeSize(fDstInfo.minRowBytes())); |
- |
- if (FLAGS_xform_only) { |
- fSrc.reset(fSrcInfo.getSafeSize(fSrcInfo.minRowBytes())); |
- codec->getPixels(fSrcInfo, fSrc.get(), fSrcInfo.minRowBytes()); |
- } else if (FLAGS_qcms) { |
- // Set-up a row buffer to decode into before transforming to dst. |
- fSrc.reset(fSrcInfo.minRowBytes()); |
} |
} |