| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "ColorCodecBench.h" | 8 #include "ColorCodecBench.h" |
| 9 #include "Resources.h" | 9 #include "Resources.h" |
| 10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
| 11 #include "SkCodecPriv.h" | 11 #include "SkCodecPriv.h" |
| 12 #include "SkColorSpace_Base.h" | 12 #include "SkColorSpace_Base.h" |
| 13 #include "SkColorSpaceXform.h" | 13 #include "SkColorSpaceXform.h" |
| 14 #include "SkCommandLineFlags.h" | 14 #include "SkCommandLineFlags.h" |
| 15 | 15 |
| 16 #if defined(SK_TEST_QCMS) | 16 #if defined(SK_TEST_QCMS) |
| 17 DEFINE_bool(qcms, false, "Bench qcms color conversion"); | 17 DEFINE_bool(qcms, false, "Bench qcms color conversion"); |
| 18 #endif | 18 #endif |
| 19 DEFINE_bool(xform_only, false, "Only time the color xform, do not include the de
code time"); | 19 DEFINE_bool(xform_only, false, "Only time the color xform, do not include the de
code time"); |
| 20 DEFINE_bool(srgb, false, "Convert to srgb dst space"); | 20 DEFINE_bool(srgb, false, "Convert to srgb dst space"); |
| 21 DEFINE_bool(nonstd, false, "Convert to non-standard dst space"); |
| 21 DEFINE_bool(half, false, "Convert to half floats"); | 22 DEFINE_bool(half, false, "Convert to half floats"); |
| 22 | 23 |
| 23 ColorCodecBench::ColorCodecBench(const char* name, sk_sp<SkData> encoded) | 24 ColorCodecBench::ColorCodecBench(const char* name, sk_sp<SkData> encoded) |
| 24 : fEncoded(std::move(encoded)) | 25 : fEncoded(std::move(encoded)) |
| 25 #if defined(SK_TEST_QCMS) | 26 #if defined(SK_TEST_QCMS) |
| 26 , fDstSpaceQCMS(nullptr) | 27 , fDstSpaceQCMS(nullptr) |
| 27 #endif | 28 #endif |
| 28 { | 29 { |
| 29 fName.appendf("Color%s", FLAGS_xform_only ? "Xform" : "Codec"); | 30 fName.appendf("Color%s", FLAGS_xform_only ? "Xform" : "Codec"); |
| 30 #if defined(SK_TEST_QCMS) | 31 #if defined(SK_TEST_QCMS) |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 166 } |
| 166 | 167 |
| 167 fSrcInfo = codec->getInfo().makeColorType(kRGBA_8888_SkColorType); | 168 fSrcInfo = codec->getInfo().makeColorType(kRGBA_8888_SkColorType); |
| 168 fDstInfo = fSrcInfo; | 169 fDstInfo = fSrcInfo; |
| 169 | 170 |
| 170 if (FLAGS_half) { | 171 if (FLAGS_half) { |
| 171 fDstInfo = fDstInfo.makeColorType(kRGBA_F16_SkColorType); | 172 fDstInfo = fDstInfo.makeColorType(kRGBA_F16_SkColorType); |
| 172 fDstSpace = as_CSB(fDstSpace)->makeLinearGamma(); | 173 fDstSpace = as_CSB(fDstSpace)->makeLinearGamma(); |
| 173 } | 174 } |
| 174 | 175 |
| 176 if (FLAGS_nonstd) { |
| 177 float gammas[3] = { 1.8f, 2.0f, 2.5f, }; |
| 178 SkMatrix44 matrix = SkMatrix44(SkMatrix44::kUninitialized_Constructor); |
| 179 matrix.set3x3(0.30f, 0.31f, 0.28f, 0.32f, 0.33f, 0.29f, 0.27f, 0.30f, 0.
30f); |
| 180 fDstSpace = SkColorSpace::NewRGB(gammas, matrix); |
| 181 } |
| 182 |
| 175 fDstInfo = fDstInfo.makeColorSpace(fDstSpace); | 183 fDstInfo = fDstInfo.makeColorSpace(fDstSpace); |
| 176 | 184 |
| 177 fDst.reset(fDstInfo.getSafeSize(fDstInfo.minRowBytes())); | 185 fDst.reset(fDstInfo.getSafeSize(fDstInfo.minRowBytes())); |
| 178 | 186 |
| 179 if (FLAGS_xform_only) { | 187 if (FLAGS_xform_only) { |
| 180 fSrc.reset(fSrcInfo.getSafeSize(fSrcInfo.minRowBytes())); | 188 fSrc.reset(fSrcInfo.getSafeSize(fSrcInfo.minRowBytes())); |
| 181 codec->getPixels(fSrcInfo, fSrc.get(), fSrcInfo.minRowBytes()); | 189 codec->getPixels(fSrcInfo, fSrc.get(), fSrcInfo.minRowBytes()); |
| 182 } | 190 } |
| 183 #if defined(SK_TEST_QCMS) | 191 #if defined(SK_TEST_QCMS) |
| 184 else if (FLAGS_qcms) { | 192 else if (FLAGS_qcms) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 208 #endif | 216 #endif |
| 209 { | 217 { |
| 210 if (FLAGS_xform_only) { | 218 if (FLAGS_xform_only) { |
| 211 this->xformOnly(); | 219 this->xformOnly(); |
| 212 } else { | 220 } else { |
| 213 this->decodeAndXform(); | 221 this->decodeAndXform(); |
| 214 } | 222 } |
| 215 } | 223 } |
| 216 } | 224 } |
| 217 } | 225 } |
| OLD | NEW |