Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7066)

Unified Diff: bench/ColorCodecBench.cpp

Issue 2174493002: Add color space xform support to SkJpegCodec (includes F16!) (Closed) Base URL: https://skia.googlesource.com/skia.git@drop
Patch Set: Fix MSAN suppression Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/CodecBench.cpp ('k') | dm/DM.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/ColorCodecBench.cpp
diff --git a/bench/ColorCodecBench.cpp b/bench/ColorCodecBench.cpp
index e17d597abb04ae2865343b607f675c73be636854..5079b482c7976785675d265fdbd3fc0ae59409d0 100644
--- a/bench/ColorCodecBench.cpp
+++ b/bench/ColorCodecBench.cpp
@@ -41,32 +41,13 @@ bool ColorCodecBench::isSuitableFor(Backend backend) {
void ColorCodecBench::decodeAndXform() {
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fEncoded.get()));
-#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);
+ SkASSERT(codec);
- void* dst = fDst.get();
- for (int y = 0; y < fSrcInfo.height(); y++) {
#ifdef SK_DEBUG
- const int rows =
+ SkCodec::Result result =
#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());
- }
+ codec->getPixels(fDstInfo, fDst.get(), fDstInfo.minRowBytes());
+ SkASSERT(SkCodec::kSuccess == result);
}
#if defined(SK_TEST_QCMS)
@@ -121,7 +102,7 @@ void ColorCodecBench::xformOnly() {
// Transform in place
FLAGS_half ?
xform->applyToF16((uint64_t*) dst, (uint32_t*) src, fSrcInfo.width()) :
- xform->applyTo8888((SkPMColor*) dst, (uint32_t*) src, fSrcInfo.width());
+ xform->applyToRGBA((SkPMColor*) dst, (uint32_t*) src, fSrcInfo.width());
dst = SkTAddOffset<void>(dst, fDstInfo.minRowBytes());
src = SkTAddOffset<void>(src, fSrcInfo.minRowBytes());
}
@@ -157,28 +138,12 @@ void ColorCodecBench::xformOnlyQCMS() {
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 ?
@@ -196,6 +161,25 @@ void ColorCodecBench::onDelayedSetup() {
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());
+ }
+#if defined(SK_TEST_QCMS)
+ else if (FLAGS_qcms) {
+ // Set-up a row buffer to decode into before transforming to dst.
+ fSrc.reset(fSrcInfo.minRowBytes());
+ }
+#endif
}
void ColorCodecBench::onDraw(int n, SkCanvas*) {
« no previous file with comments | « bench/CodecBench.cpp ('k') | dm/DM.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698