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

Side by Side Diff: tests/ColorSpaceTest.cpp

Issue 2085653003: Enable flattening and unflattening of SkColorSpace (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix unit tests 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 | « src/core/SkMatrix44.cpp ('k') | tests/ImageIsOpaqueTest.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 "Resources.h" 8 #include "Resources.h"
9 #include "SkCodec.h" 9 #include "SkCodec.h"
10 #include "SkColorSpace.h" 10 #include "SkColorSpace.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 REPORTER_ASSERT(r, SkColorSpace::kSRGB_GammaNamed == cs->gammaNa med()); 158 REPORTER_ASSERT(r, SkColorSpace::kSRGB_GammaNamed == cs->gammaNa med());
159 } else { 159 } else {
160 REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == cs->g ammaNamed()); 160 REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == cs->g ammaNamed());
161 } 161 }
162 } 162 }
163 } 163 }
164 164
165 SkImageInfo info = SkImageInfo::MakeS32(10, 10, kPremul_SkAlphaType); 165 SkImageInfo info = SkImageInfo::MakeS32(10, 10, kPremul_SkAlphaType);
166 REPORTER_ASSERT(r, info.gammaCloseToSRGB()); 166 REPORTER_ASSERT(r, info.gammaCloseToSRGB());
167 } 167 }
168
169 static void test_serialize(skiatest::Reporter* r, SkColorSpace* space, bool isNa med) {
170 sk_sp<SkData> data = space->serialize();
171 sk_sp<SkColorSpace> newSpace = SkColorSpace::Deserialize(data->data(), data- >size());
172
173 if (isNamed) {
174 REPORTER_ASSERT(r, space == newSpace.get());
175 } else {
176 REPORTER_ASSERT(r, space->gammaNamed() == newSpace->gammaNamed());
177
178 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(0, 0));
179 REPORTER_ASSERT(r, space->xyz().getFloat(0, 1) == newSpace->xyz().getFlo at(0, 1));
180 REPORTER_ASSERT(r, space->xyz().getFloat(0, 2) == newSpace->xyz().getFlo at(0, 2));
181 REPORTER_ASSERT(r, space->xyz().getFloat(0, 3) == newSpace->xyz().getFlo at(0, 3));
182 REPORTER_ASSERT(r, space->xyz().getFloat(1, 0) == newSpace->xyz().getFlo at(1, 0));
183 REPORTER_ASSERT(r, space->xyz().getFloat(1, 1) == newSpace->xyz().getFlo at(1, 1));
184 REPORTER_ASSERT(r, space->xyz().getFloat(1, 2) == newSpace->xyz().getFlo at(1, 2));
185 REPORTER_ASSERT(r, space->xyz().getFloat(1, 3) == newSpace->xyz().getFlo at(1, 3));
186 REPORTER_ASSERT(r, space->xyz().getFloat(2, 0) == newSpace->xyz().getFlo at(2, 0));
187 REPORTER_ASSERT(r, space->xyz().getFloat(2, 1) == newSpace->xyz().getFlo at(2, 1));
188 REPORTER_ASSERT(r, space->xyz().getFloat(2, 2) == newSpace->xyz().getFlo at(2, 2));
189 REPORTER_ASSERT(r, space->xyz().getFloat(2, 3) == newSpace->xyz().getFlo at(2, 3));
190 REPORTER_ASSERT(r, space->xyz().getFloat(3, 0) == newSpace->xyz().getFlo at(3, 0));
191 REPORTER_ASSERT(r, space->xyz().getFloat(3, 1) == newSpace->xyz().getFlo at(3, 1));
192 REPORTER_ASSERT(r, space->xyz().getFloat(3, 2) == newSpace->xyz().getFlo at(3, 2));
193 REPORTER_ASSERT(r, space->xyz().getFloat(3, 3) == newSpace->xyz().getFlo at(3, 3));
194 }
195 }
196
197 DEF_TEST(ColorSpace_Serialize, r) {
198 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(), t rue);
199 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named).get( ), true);
200
201 sk_sp<SkData> monitorData = SkData::MakeFromFileName(
202 GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str());
203 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz e()).get(), false);
204 }
205
OLDNEW
« no previous file with comments | « src/core/SkMatrix44.cpp ('k') | tests/ImageIsOpaqueTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698