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 "SkColorSpaceXform.h" | 11 #include "SkColorSpaceXform.h" |
12 #include "SkCommandLineFlags.h" | 12 #include "SkCommandLineFlags.h" |
13 | 13 |
14 #if !defined(GOOGLE3) | 14 #if defined(SK_TEST_QCMS) |
15 DEFINE_bool(qcms, false, "Bench qcms color conversion"); | 15 DEFINE_bool(qcms, false, "Bench qcms color conversion"); |
16 #endif | 16 #endif |
17 DEFINE_bool(xform_only, false, "Only time the color xform, do not include the de
code time"); | 17 DEFINE_bool(xform_only, false, "Only time the color xform, do not include the de
code time"); |
18 | 18 |
19 ColorCodecBench::ColorCodecBench(const char* name, sk_sp<SkData> encoded) | 19 ColorCodecBench::ColorCodecBench(const char* name, sk_sp<SkData> encoded) |
20 : fEncoded(std::move(encoded)) | 20 : fEncoded(std::move(encoded)) |
21 #if !defined(GOOGLE3) | 21 #if defined(SK_TEST_QCMS) |
22 , fDstSpaceQCMS(nullptr) | 22 , fDstSpaceQCMS(nullptr) |
23 #endif | 23 #endif |
24 { | 24 { |
25 fName.appendf("Color%s", FLAGS_xform_only ? "Xform" : "Codec"); | 25 fName.appendf("Color%s", FLAGS_xform_only ? "Xform" : "Codec"); |
26 #if !defined(GOOGLE3) | 26 #if defined(SK_TEST_QCMS) |
27 fName.appendf("%s", FLAGS_qcms ? "QCMS" : ""); | 27 fName.appendf("%s", FLAGS_qcms ? "QCMS" : ""); |
28 #endif | 28 #endif |
29 fName.appendf("_%s", name); | 29 fName.appendf("_%s", name); |
30 } | 30 } |
31 | 31 |
32 const char* ColorCodecBench::onGetName() { | 32 const char* ColorCodecBench::onGetName() { |
33 return fName.c_str(); | 33 return fName.c_str(); |
34 } | 34 } |
35 | 35 |
36 bool ColorCodecBench::isSuitableFor(Backend backend) { | 36 bool ColorCodecBench::isSuitableFor(Backend backend) { |
(...skipping 21 matching lines...) Expand all Loading... |
58 const int rows = | 58 const int rows = |
59 #endif | 59 #endif |
60 codec->getScanlines(fSrc.get(), 1, 0); | 60 codec->getScanlines(fSrc.get(), 1, 0); |
61 SkASSERT(1 == rows); | 61 SkASSERT(1 == rows); |
62 | 62 |
63 xform->xform_RGBA_8888((uint32_t*) dst, (uint32_t*) fSrc.get(), fInfo.wi
dth()); | 63 xform->xform_RGBA_8888((uint32_t*) dst, (uint32_t*) fSrc.get(), fInfo.wi
dth()); |
64 dst = SkTAddOffset<void>(dst, fInfo.minRowBytes()); | 64 dst = SkTAddOffset<void>(dst, fInfo.minRowBytes()); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 #if !defined(GOOGLE3) | 68 #if defined(SK_TEST_QCMS) |
69 void ColorCodecBench::decodeAndXformQCMS() { | 69 void ColorCodecBench::decodeAndXformQCMS() { |
70 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fEncoded.get())); | 70 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fEncoded.get())); |
71 #ifdef SK_DEBUG | 71 #ifdef SK_DEBUG |
72 const SkCodec::Result result = | 72 const SkCodec::Result result = |
73 #endif | 73 #endif |
74 codec->startScanlineDecode(fInfo); | 74 codec->startScanlineDecode(fInfo); |
75 SkASSERT(SkCodec::kSuccess == result); | 75 SkASSERT(SkCodec::kSuccess == result); |
76 | 76 |
77 SkAutoTCallVProc<qcms_profile, qcms_profile_release> | 77 SkAutoTCallVProc<qcms_profile, qcms_profile_release> |
78 srcSpace(qcms_profile_from_memory(fSrcData->data(), fSrcData->size()
)); | 78 srcSpace(qcms_profile_from_memory(fSrcData->data(), fSrcData->size()
)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 void* dst = fDst.get(); | 114 void* dst = fDst.get(); |
115 void* src = fSrc.get(); | 115 void* src = fSrc.get(); |
116 for (int y = 0; y < fInfo.height(); y++) { | 116 for (int y = 0; y < fInfo.height(); y++) { |
117 // Transform in place | 117 // Transform in place |
118 xform->xform_RGBA_8888((uint32_t*) dst, (uint32_t*) src, fInfo.width()); | 118 xform->xform_RGBA_8888((uint32_t*) dst, (uint32_t*) src, fInfo.width()); |
119 dst = SkTAddOffset<void>(dst, fInfo.minRowBytes()); | 119 dst = SkTAddOffset<void>(dst, fInfo.minRowBytes()); |
120 src = SkTAddOffset<void>(src, fInfo.minRowBytes()); | 120 src = SkTAddOffset<void>(src, fInfo.minRowBytes()); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 #if !defined(GOOGLE3) | 124 #if defined(SK_TEST_QCMS) |
125 void ColorCodecBench::xformOnlyQCMS() { | 125 void ColorCodecBench::xformOnlyQCMS() { |
126 SkAutoTCallVProc<qcms_profile, qcms_profile_release> | 126 SkAutoTCallVProc<qcms_profile, qcms_profile_release> |
127 srcSpace(qcms_profile_from_memory(fSrcData->data(), fSrcData->size()
)); | 127 srcSpace(qcms_profile_from_memory(fSrcData->data(), fSrcData->size()
)); |
128 SkASSERT(srcSpace); | 128 SkASSERT(srcSpace); |
129 | 129 |
130 SkAutoTCallVProc<qcms_transform, qcms_transform_release> | 130 SkAutoTCallVProc<qcms_transform, qcms_transform_release> |
131 transform (qcms_transform_create(srcSpace, QCMS_DATA_RGBA_8, fDstSpa
ceQCMS.get(), | 131 transform (qcms_transform_create(srcSpace, QCMS_DATA_RGBA_8, fDstSpa
ceQCMS.get(), |
132 QCMS_DATA_RGBA_8, QCMS_INTENT_PERCE
PTUAL)); | 132 QCMS_DATA_RGBA_8, QCMS_INTENT_PERCE
PTUAL)); |
133 SkASSERT(transform); | 133 SkASSERT(transform); |
134 | 134 |
(...skipping 26 matching lines...) Expand all Loading... |
161 // Set-up a row buffer to decode into before transforming to dst. | 161 // Set-up a row buffer to decode into before transforming to dst. |
162 fSrc.reset(fInfo.minRowBytes()); | 162 fSrc.reset(fInfo.minRowBytes()); |
163 } | 163 } |
164 | 164 |
165 fSrcData = codec->getICCData(); | 165 fSrcData = codec->getICCData(); |
166 sk_sp<SkData> dstData = SkData::MakeFromFileName( | 166 sk_sp<SkData> dstData = SkData::MakeFromFileName( |
167 GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str()); | 167 GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str()); |
168 SkASSERT(dstData); | 168 SkASSERT(dstData); |
169 | 169 |
170 | 170 |
171 #if !defined(GOOGLE3) | 171 #if defined(SK_TEST_QCMS) |
172 if (FLAGS_qcms) { | 172 if (FLAGS_qcms) { |
173 fDstSpaceQCMS.reset(qcms_profile_from_memory(dstData->data(), dstData->s
ize())); | 173 fDstSpaceQCMS.reset(qcms_profile_from_memory(dstData->data(), dstData->s
ize())); |
174 SkASSERT(fDstSpaceQCMS); | 174 SkASSERT(fDstSpaceQCMS); |
175 } else | 175 } else |
176 #endif | 176 #endif |
177 { | 177 { |
178 fDstSpace = SkColorSpace::NewICC(dstData->data(), dstData->size()); | 178 fDstSpace = SkColorSpace::NewICC(dstData->data(), dstData->size()); |
179 SkASSERT(fDstSpace); | 179 SkASSERT(fDstSpace); |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 void ColorCodecBench::onDraw(int n, SkCanvas*) { | 183 void ColorCodecBench::onDraw(int n, SkCanvas*) { |
184 for (int i = 0; i < n; i++) { | 184 for (int i = 0; i < n; i++) { |
185 #if !defined(GOOGLE3) | 185 #if defined(SK_TEST_QCMS) |
186 if (FLAGS_qcms) { | 186 if (FLAGS_qcms) { |
187 if (FLAGS_xform_only) { | 187 if (FLAGS_xform_only) { |
188 this->xformOnlyQCMS(); | 188 this->xformOnlyQCMS(); |
189 } else { | 189 } else { |
190 this->decodeAndXformQCMS(); | 190 this->decodeAndXformQCMS(); |
191 } | 191 } |
192 } else | 192 } else |
193 #endif | 193 #endif |
194 { | 194 { |
195 if (FLAGS_xform_only) { | 195 if (FLAGS_xform_only) { |
196 this->xformOnly(); | 196 this->xformOnly(); |
197 } else { | 197 } else { |
198 this->decodeAndXform(); | 198 this->decodeAndXform(); |
199 } | 199 } |
200 } | 200 } |
201 } | 201 } |
202 } | 202 } |
OLD | NEW |