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

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: Save 12 floats instead of 16 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
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, kSRGB_SkColorProfileType == info.profileType()); 166 REPORTER_ASSERT(r, kSRGB_SkColorProfileType == info.profileType());
167 REPORTER_ASSERT(r, SkColorSpace::kSRGB_GammaNamed == info.colorSpace()->gamm aNamed()); 167 REPORTER_ASSERT(r, SkColorSpace::kSRGB_GammaNamed == info.colorSpace()->gamm aNamed());
168 } 168 }
169
170 static void test_serialize(skiatest::Reporter* r, SkColorSpace* space, bool isNa med) {
171 sk_sp<SkData> data = space->serialize();
172 sk_sp<SkColorSpace> newSpace = SkColorSpace::Deserialize(data->data(), data- >size());
173
174 if (isNamed) {
175 REPORTER_ASSERT(r, space == newSpace.get());
176 } else {
177 REPORTER_ASSERT(r, space->gammaNamed() == newSpace->gammaNamed());
178
179 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(0, 0));
180 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(0, 1));
181 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(0, 2));
182 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(0, 3));
183 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(1, 0));
184 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(1, 1));
185 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(1, 2));
186 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(1, 3));
187 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(2, 0));
188 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(2, 1));
189 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(2, 2));
190 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(2, 3));
191 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(3, 0));
192 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(3, 1));
193 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(3, 2));
194 REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFlo at(3, 3));
195 }
196 }
197
198 DEF_TEST(ColorSpace_Serialize, r) {
199 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(), t rue);
200 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named).get( ), true);
201
202 sk_sp<SkData> monitorData = SkData::MakeFromFileName(
203 GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str());
204 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz e()).get(), false);
205 }
206
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698