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

Side by Side Diff: bench/ColorCodecBench.cpp

Issue 2078623002: Support sRGB dsts in opt code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Drop parens Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | dm/DM.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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(SK_TEST_QCMS) 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 DEFINE_bool(srgb, false, "Convert to srgb dst space");
18 19
19 ColorCodecBench::ColorCodecBench(const char* name, sk_sp<SkData> encoded) 20 ColorCodecBench::ColorCodecBench(const char* name, sk_sp<SkData> encoded)
20 : fEncoded(std::move(encoded)) 21 : fEncoded(std::move(encoded))
21 #if defined(SK_TEST_QCMS) 22 #if defined(SK_TEST_QCMS)
22 , fDstSpaceQCMS(nullptr) 23 , fDstSpaceQCMS(nullptr)
23 #endif 24 #endif
24 { 25 {
25 fName.appendf("Color%s", FLAGS_xform_only ? "Xform" : "Codec"); 26 fName.appendf("Color%s", FLAGS_xform_only ? "Xform" : "Codec");
26 #if defined(SK_TEST_QCMS) 27 #if defined(SK_TEST_QCMS)
27 fName.appendf("%s", FLAGS_qcms ? "QCMS" : ""); 28 fName.appendf("%s", FLAGS_qcms ? "QCMS" : "");
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 164 }
164 165
165 fSrcData = codec->getICCData(); 166 fSrcData = codec->getICCData();
166 sk_sp<SkData> dstData = SkData::MakeFromFileName( 167 sk_sp<SkData> dstData = SkData::MakeFromFileName(
167 GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str()); 168 GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str());
168 SkASSERT(dstData); 169 SkASSERT(dstData);
169 170
170 171
171 #if defined(SK_TEST_QCMS) 172 #if defined(SK_TEST_QCMS)
172 if (FLAGS_qcms) { 173 if (FLAGS_qcms) {
173 fDstSpaceQCMS.reset(qcms_profile_from_memory(dstData->data(), dstData->s ize())); 174 fDstSpaceQCMS.reset(FLAGS_srgb ?
175 qcms_profile_sRGB() :
176 qcms_profile_from_memory(dstData->data(), dstData->size()));
174 SkASSERT(fDstSpaceQCMS); 177 SkASSERT(fDstSpaceQCMS);
175 178
176 // This call takes a non-trivial amount of time, but I think it's the mo st fair to 179 // This call takes a non-trivial amount of time, but I think it's the mo st fair to
177 // treat it as overhead. It only needs to happen once. 180 // treat it as overhead. It only needs to happen once.
178 qcms_profile_precache_output_transform(fDstSpaceQCMS); 181 qcms_profile_precache_output_transform(fDstSpaceQCMS);
179 } else 182 } else
180 #endif 183 #endif
181 { 184 {
182 fDstSpace = SkColorSpace::NewICC(dstData->data(), dstData->size()); 185 fDstSpace = FLAGS_srgb ? SkColorSpace::NewNamed(SkColorSpace::kSRGB_Name d) :
186 SkColorSpace::NewICC(dstData->data(), dstData-> size());
183 SkASSERT(fDstSpace); 187 SkASSERT(fDstSpace);
184 } 188 }
185 } 189 }
186 190
187 void ColorCodecBench::onDraw(int n, SkCanvas*) { 191 void ColorCodecBench::onDraw(int n, SkCanvas*) {
188 for (int i = 0; i < n; i++) { 192 for (int i = 0; i < n; i++) {
189 #if defined(SK_TEST_QCMS) 193 #if defined(SK_TEST_QCMS)
190 if (FLAGS_qcms) { 194 if (FLAGS_qcms) {
191 if (FLAGS_xform_only) { 195 if (FLAGS_xform_only) {
192 this->xformOnlyQCMS(); 196 this->xformOnlyQCMS();
193 } else { 197 } else {
194 this->decodeAndXformQCMS(); 198 this->decodeAndXformQCMS();
195 } 199 }
196 } else 200 } else
197 #endif 201 #endif
198 { 202 {
199 if (FLAGS_xform_only) { 203 if (FLAGS_xform_only) {
200 this->xformOnly(); 204 this->xformOnly();
201 } else { 205 } else {
202 this->decodeAndXform(); 206 this->decodeAndXform();
203 } 207 }
204 } 208 }
205 } 209 }
206 } 210 }
OLDNEW
« no previous file with comments | « no previous file | dm/DM.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698