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

Side by Side Diff: tests/ColorSpaceTest.cpp

Issue 2194903002: Fix various SkColorSpace bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use switch statement in nonstandard struct Created 4 years, 4 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/SkColorSpace_Base.h ('k') | no next file » | 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::k SRGB_Named); 118 sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::k SRGB_Named);
119 sk_sp<SkData> namedData = as_CSB(namedColorSpace)->writeToICC(); 119 sk_sp<SkData> namedData = as_CSB(namedColorSpace)->writeToICC();
120 sk_sp<SkColorSpace> iccColorSpace = SkColorSpace::NewICC(namedData->data(), namedData->size()); 120 sk_sp<SkColorSpace> iccColorSpace = SkColorSpace::NewICC(namedData->data(), namedData->size());
121 test_space(r, iccColorSpace.get(), g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6 ], 121 test_space(r, iccColorSpace.get(), g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6 ],
122 SkColorSpace::k2Dot2Curve_GammaNamed); 122 SkColorSpace::k2Dot2Curve_GammaNamed);
123 // FIXME (msarett): Test disabled. sRGB profiles are written approximately as 2.2f curves. 123 // FIXME (msarett): Test disabled. sRGB profiles are written approximately as 2.2f curves.
124 // REPORTER_ASSERT(r, iccColorSpace == namedColorSpace); 124 // REPORTER_ASSERT(r, iccColorSpace == namedColorSpace);
125 125
126 // Test saving the original ICC data 126 // Test saving the original ICC data
127 sk_sp<SkData> monitorData = SkData::MakeFromFileName( 127 sk_sp<SkData> monitorData = SkData::MakeFromFileName(
128 GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str()); 128 GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str());
129 REPORTER_ASSERT(r, monitorData); 129 REPORTER_ASSERT(r, monitorData);
130 if (!monitorData) { 130 if (!monitorData) {
131 return; 131 return;
132 } 132 }
133 sk_sp<SkColorSpace> monitorSpace = SkColorSpace::NewICC(monitorData->data(), 133 sk_sp<SkColorSpace> monitorSpace = SkColorSpace::NewICC(monitorData->data(),
134 monitorData->size()) ; 134 monitorData->size()) ;
135 sk_sp<SkData> newMonitorData = as_CSB(monitorSpace)->writeToICC(); 135 sk_sp<SkData> newMonitorData = as_CSB(monitorSpace)->writeToICC();
136 sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->d ata(), 136 sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->d ata(),
137 newMonitorData->s ize()); 137 newMonitorData->s ize());
138 REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz()); 138 REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 matrix_equals(r, space, newSpace1.get()); 204 matrix_equals(r, space, newSpace1.get());
205 matrix_equals(r, space, newSpace2.get()); 205 matrix_equals(r, space, newSpace2.get());
206 } 206 }
207 } 207 }
208 208
209 DEF_TEST(ColorSpace_Serialize, r) { 209 DEF_TEST(ColorSpace_Serialize, r) {
210 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(), t rue); 210 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(), t rue);
211 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named).get( ), true); 211 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named).get( ), true);
212 212
213 sk_sp<SkData> monitorData = SkData::MakeFromFileName( 213 sk_sp<SkData> monitorData = SkData::MakeFromFileName(
214 GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str()); 214 GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str());
215 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz e()).get(), false);
216 monitorData = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32 x.icc").c_str());
217 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz e()).get(), false);
218 monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLe ft.icc").c_str());
219 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz e()).get(), false);
220 monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRi ght.icc").c_str());
215 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz e()).get(), false); 221 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz e()).get(), false);
216 } 222 }
217 223
OLDNEW
« no previous file with comments | « src/core/SkColorSpace_Base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698