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

Side by Side Diff: tests/ColorSpaceTest.cpp

Issue 2193223002: Hide (mostly) unused SkColorSpace writeToICC() function (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Continue testing 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/pdf/SkPDFDocument.cpp ('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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 srgbToxyzD50); 106 srgbToxyzD50);
107 REPORTER_ASSERT(r, rgbColorSpace == namedColorSpace); 107 REPORTER_ASSERT(r, rgbColorSpace == namedColorSpace);
108 108
109 // Change a single value from the sRGB matrix 109 // Change a single value from the sRGB matrix
110 srgbToxyzD50.set(2, 2, 0.5f); 110 srgbToxyzD50.set(2, 2, 0.5f);
111 sk_sp<SkColorSpace> strangeColorSpace = SkColorSpace::NewRGB(SkColorSpace::k SRGB_GammaNamed, 111 sk_sp<SkColorSpace> strangeColorSpace = SkColorSpace::NewRGB(SkColorSpace::k SRGB_GammaNamed,
112 srgbToxyzD50); 112 srgbToxyzD50);
113 REPORTER_ASSERT(r, strangeColorSpace != namedColorSpace); 113 REPORTER_ASSERT(r, strangeColorSpace != namedColorSpace);
114 } 114 }
115 115
116 class ColorSpaceTest {
117 public:
118 static sk_sp<SkData> WriteToICC(SkColorSpace* space) {
119 return as_CSB(space)->writeToICC();
120 }
121 };
122
116 DEF_TEST(ColorSpaceWriteICC, r) { 123 DEF_TEST(ColorSpaceWriteICC, r) {
117 // Test writing a new ICC profile 124 // Test writing a new ICC profile
118 sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::k SRGB_Named); 125 sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::k SRGB_Named);
119 sk_sp<SkData> namedData = as_CSB(namedColorSpace)->writeToICC(); 126 sk_sp<SkData> namedData = ColorSpaceTest::WriteToICC(namedColorSpace.get());
120 sk_sp<SkColorSpace> iccColorSpace = SkColorSpace::NewICC(namedData->data(), namedData->size()); 127 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 ], 128 test_space(r, iccColorSpace.get(), g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6 ],
122 SkColorSpace::k2Dot2Curve_GammaNamed); 129 SkColorSpace::k2Dot2Curve_GammaNamed);
123 // FIXME (msarett): Test disabled. sRGB profiles are written approximately as 2.2f curves. 130 // FIXME (msarett): Test disabled. sRGB profiles are written approximately as 2.2f curves.
124 // REPORTER_ASSERT(r, iccColorSpace == namedColorSpace); 131 // REPORTER_ASSERT(r, iccColorSpace == namedColorSpace);
125 132
126 // Test saving the original ICC data 133 // Test saving the original ICC data
127 sk_sp<SkData> monitorData = SkData::MakeFromFileName( 134 sk_sp<SkData> monitorData = SkData::MakeFromFileName(
128 GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); 135 GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str());
129 REPORTER_ASSERT(r, monitorData); 136 REPORTER_ASSERT(r, monitorData);
130 if (!monitorData) { 137 if (!monitorData) {
131 return; 138 return;
132 } 139 }
133 sk_sp<SkColorSpace> monitorSpace = SkColorSpace::NewICC(monitorData->data(), 140 sk_sp<SkColorSpace> monitorSpace = SkColorSpace::NewICC(monitorData->data(),
134 monitorData->size()) ; 141 monitorData->size()) ;
135 sk_sp<SkData> newMonitorData = as_CSB(monitorSpace)->writeToICC(); 142 sk_sp<SkData> newMonitorData = ColorSpaceTest::WriteToICC(monitorSpace.get() );
136 sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->d ata(), 143 sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->d ata(),
137 newMonitorData->s ize()); 144 newMonitorData->s ize());
138 REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz()); 145 REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz());
139 REPORTER_ASSERT(r, monitorSpace->gammaNamed() == newMonitorSpace->gammaNamed ()); 146 REPORTER_ASSERT(r, monitorSpace->gammaNamed() == newMonitorSpace->gammaNamed ());
140 } 147 }
141 148
142 DEF_TEST(ColorSpace_Named, r) { 149 DEF_TEST(ColorSpace_Named, r) {
143 const struct { 150 const struct {
144 SkColorSpace::Named fNamed; 151 SkColorSpace::Named fNamed;
145 bool fExpectedToSucceed; 152 bool fExpectedToSucceed;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 REPORTER_ASSERT(r, !SkColorSpace::Equals(nullptr, srgb.get())); 252 REPORTER_ASSERT(r, !SkColorSpace::Equals(nullptr, srgb.get()));
246 REPORTER_ASSERT(r, !SkColorSpace::Equals(srgb.get(), nullptr)); 253 REPORTER_ASSERT(r, !SkColorSpace::Equals(srgb.get(), nullptr));
247 REPORTER_ASSERT(r, !SkColorSpace::Equals(adobe.get(), srgb.get())); 254 REPORTER_ASSERT(r, !SkColorSpace::Equals(adobe.get(), srgb.get()));
248 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), srgb.get())); 255 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), srgb.get()));
249 REPORTER_ASSERT(r, !SkColorSpace::Equals(z32.get(), z30.get())); 256 REPORTER_ASSERT(r, !SkColorSpace::Equals(z32.get(), z30.get()));
250 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), srgb.get())); 257 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), srgb.get()));
251 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), upperRight.get())) ; 258 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), upperRight.get())) ;
252 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), upperRight.get())); 259 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), upperRight.get()));
253 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperRight.get(), adobe.get())); 260 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperRight.get(), adobe.get()));
254 } 261 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDocument.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698