diff options
author | Matt Sarett <msarett@google.com> | 2017-02-07 13:56:11 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-07 19:33:37 +0000 |
commit | 77a7a1b57c16c97f056c1e50c03bdc954947778c (patch) | |
tree | 15ffacdee0ba8b0a0c8ac244302ef10ead4f915e /tests | |
parent | 4f51aa57eaa4187696f7830ee7bdac096bc47ccc (diff) |
SkColorSpace: remove named API, add gamut API
Reland from: https://skia-review.googlesource.com/c/8021/
BUG=skia:
Change-Id: I18985f130587b15fccbc86b76b2bb5c49ba5ba8a
Reviewed-on: https://skia-review.googlesource.com/8136
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ColorSpaceTest.cpp | 70 | ||||
-rw-r--r-- | tests/ColorSpaceXformTest.cpp | 4 | ||||
-rw-r--r-- | tests/ICCTest.cpp | 8 | ||||
-rw-r--r-- | tests/ImageIsOpaqueTest.cpp | 7 | ||||
-rw-r--r-- | tests/ImageTest.cpp | 4 | ||||
-rw-r--r-- | tests/SRGBMipMapTest.cpp | 2 | ||||
-rw-r--r-- | tests/SkBlend_optsTest.cpp | 2 | ||||
-rw-r--r-- | tests/SkResourceCacheTest.cpp | 2 | ||||
-rw-r--r-- | tests/SpecialImageTest.cpp | 2 | ||||
-rw-r--r-- | tests/SurfaceTest.cpp | 6 | ||||
-rw-r--r-- | tests/TestConfigParsing.cpp | 2 |
11 files changed, 71 insertions, 38 deletions
diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp index 65e0450892..2bc735aaef 100644 --- a/tests/ColorSpaceTest.cpp +++ b/tests/ColorSpaceTest.cpp @@ -74,7 +74,7 @@ static constexpr float g_sRGB_G[]{ 0.3853f, 0.7170f, 0.0971f }; static constexpr float g_sRGB_B[]{ 0.1430f, 0.0606f, 0.7139f }; DEF_TEST(ColorSpace_sRGB, r) { - test_space(r, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).get(), + test_space(r, SkColorSpace::MakeSRGB().get(), g_sRGB_R, g_sRGB_G, g_sRGB_B, kSRGB_SkGammaNamed); } @@ -103,7 +103,7 @@ DEF_TEST(ColorSpaceParseICCProfiles, r) { DEF_TEST(ColorSpaceSRGBCompare, r) { // Create an sRGB color space by name - sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::MakeSRGB(); // Create an sRGB color space by value SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor); @@ -132,10 +132,10 @@ DEF_TEST(ColorSpaceSRGBCompare, r) { DEF_TEST(ColorSpaceSRGBLinearCompare, r) { // Create the linear sRGB color space by name - sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); + sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::MakeSRGBLinear(); // Create the linear sRGB color space via the sRGB color space's makeLinearGamma() - auto srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + auto srgb = SkColorSpace::MakeSRGB(); auto srgbXYZ = static_cast<SkColorSpace_XYZ*>(srgb.get()); sk_sp<SkColorSpace> viaSrgbColorSpace = srgbXYZ->makeLinearGamma(); REPORTER_ASSERT(r, namedColorSpace == viaSrgbColorSpace); @@ -178,7 +178,8 @@ DEF_TEST(ColorSpaceSRGBLinearCompare, r) { DEF_TEST(ColorSpaceAdobeCompare, r) { // Create an sRGB color space by name - sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named); + sk_sp<SkColorSpace> namedColorSpace = + SkColorSpace_Base::MakeNamed(SkColorSpace_Base::kAdobeRGB_Named); // Create an sRGB color space by value SkMatrix44 adobeToxyzD50(SkMatrix44::kUninitialized_Constructor); @@ -198,16 +199,16 @@ DEF_TEST(ColorSpaceAdobeCompare, r) { DEF_TEST(ColorSpace_Named, r) { const struct { - SkColorSpace::Named fNamed; - SkGammaNamed fExpectedGamma; + SkColorSpace_Base::Named fNamed; + SkGammaNamed fExpectedGamma; } recs[] { - { SkColorSpace::kSRGB_Named, kSRGB_SkGammaNamed }, - { SkColorSpace::kAdobeRGB_Named, k2Dot2Curve_SkGammaNamed }, - { SkColorSpace::kSRGBLinear_Named, kLinear_SkGammaNamed }, + { SkColorSpace_Base::kSRGB_Named, kSRGB_SkGammaNamed }, + { SkColorSpace_Base::kAdobeRGB_Named, k2Dot2Curve_SkGammaNamed }, + { SkColorSpace_Base::kSRGBLinear_Named, kLinear_SkGammaNamed }, }; for (auto rec : recs) { - auto cs = SkColorSpace::MakeNamed(rec.fNamed); + auto cs = SkColorSpace_Base::MakeNamed(rec.fNamed); REPORTER_ASSERT(r, cs); if (cs) { SkASSERT(SkColorSpace_Base::Type::kXYZ == as_CSB(cs)->type()); @@ -240,9 +241,9 @@ static void test_serialize(skiatest::Reporter* r, SkColorSpace* space, bool isNa } DEF_TEST(ColorSpace_Serialize, r) { - test_serialize(r, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).get(), true); - test_serialize(r, SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named).get(), true); - test_serialize(r, SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named).get(), true); + test_serialize(r, SkColorSpace::MakeSRGB().get(), true); + test_serialize(r, SkColorSpace_Base::MakeNamed(SkColorSpace_Base::kAdobeRGB_Named).get(), true); + test_serialize(r, SkColorSpace::MakeSRGBLinear().get(), true); sk_sp<SkData> monitorData = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); @@ -267,8 +268,8 @@ DEF_TEST(ColorSpace_Serialize, r) { } DEF_TEST(ColorSpace_Equals, r) { - sk_sp<SkColorSpace> srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); - sk_sp<SkColorSpace> adobe = SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named); + sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB(); + sk_sp<SkColorSpace> adobe = SkColorSpace_Base::MakeNamed(SkColorSpace_Base::kAdobeRGB_Named); sk_sp<SkData> data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); sk_sp<SkColorSpace> z30 = SkColorSpace::MakeICC(data->data(), data->size()); @@ -356,7 +357,7 @@ DEF_TEST(ColorSpace_Primaries, r) { sk_sp<SkColorSpace> space = SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, srgbToXYZ); - REPORTER_ASSERT(r, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named) == space); + REPORTER_ASSERT(r, SkColorSpace::MakeSRGB() == space); // AdobeRGB primaries (D65) SkColorSpacePrimaries adobe; @@ -377,7 +378,7 @@ DEF_TEST(ColorSpace_Primaries, r) { fn.fB = fn.fC = fn.fD = fn.fE = fn.fF = 0.0f; fn.fG = 2.2f; space = SkColorSpace::MakeRGB(fn, adobeToXYZ); - REPORTER_ASSERT(r, SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named) == space); + REPORTER_ASSERT(r, SkColorSpace_Base::MakeNamed(SkColorSpace_Base::kAdobeRGB_Named) == space); // ProPhoto (D50) SkColorSpacePrimaries proPhoto; @@ -410,6 +411,37 @@ DEF_TEST(ColorSpace_Primaries, r) { 0.1852204f, 0.5915984f, 0.0555518f, 0.1446290f, 0.0974520f, 0.7708399f); check_primaries(r, ntsc, ntscToXYZ); + + // DCI P3 (D65) + SkColorSpacePrimaries p3; + p3.fRX = 0.680f; + p3.fRY = 0.320f; + p3.fGX = 0.265f; + p3.fGY = 0.690f; + p3.fBX = 0.150f; + p3.fBY = 0.060f; + p3.fWX = 0.3127f; + p3.fWY = 0.3290f; + space = SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, + SkColorSpace::kDCIP3_D65_Gamut); + SkMatrix44 reference(SkMatrix44::kUninitialized_Constructor); + SkAssertResult(space->toXYZD50(&reference)); + check_primaries(r, p3, reference); + + // Rec 2020 (D65) + SkColorSpacePrimaries rec2020; + rec2020.fRX = 0.708f; + rec2020.fRY = 0.292f; + rec2020.fGX = 0.170f; + rec2020.fGY = 0.797f; + rec2020.fBX = 0.131f; + rec2020.fBY = 0.046f; + rec2020.fWX = 0.3127f; + rec2020.fWY = 0.3290f; + space = SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, + SkColorSpace::kRec2020_Gamut); + SkAssertResult(space->toXYZD50(&reference)); + check_primaries(r, rec2020, reference); } DEF_TEST(ColorSpace_InvalidICC, r) { @@ -421,7 +453,7 @@ DEF_TEST(ColorSpace_InvalidICC, r) { } DEF_TEST(ColorSpace_MatrixHash, r) { - sk_sp<SkColorSpace> srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB(); SkColorSpaceTransferFn fn; fn.fA = 1.0f; diff --git a/tests/ColorSpaceXformTest.cpp b/tests/ColorSpaceXformTest.cpp index bdcdd3e1a4..f8a5c8fec4 100644 --- a/tests/ColorSpaceXformTest.cpp +++ b/tests/ColorSpaceXformTest.cpp @@ -326,8 +326,8 @@ DEF_TEST(SkColorSpaceXform_LoadTail, r) { std::unique_ptr<uint64_t[]> srcPixel(new uint64_t[1]); srcPixel[0] = 0; uint32_t dstPixel; - sk_sp<SkColorSpace> adobe = SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named); - sk_sp<SkColorSpace> srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> adobe = SkColorSpace_Base::MakeNamed(SkColorSpace_Base::kAdobeRGB_Named); + sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB(); std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(adobe.get(), srgb.get()); // ASAN will catch us if we read past the tail. diff --git a/tests/ICCTest.cpp b/tests/ICCTest.cpp index 794483c682..5d541bdc27 100644 --- a/tests/ICCTest.cpp +++ b/tests/ICCTest.cpp @@ -124,7 +124,7 @@ DEF_TEST(ICC_WriteICC, r) { SkMatrix44 adobeMatrix(SkMatrix44::kUninitialized_Constructor); adobeMatrix.set3x3RowMajorf(gAdobeRGB_toXYZD50); test_write_icc(r, adobeFn, adobeMatrix, - SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named).get(), false); + SkColorSpace_Base::MakeNamed(SkColorSpace_Base::kAdobeRGB_Named).get(), false); SkColorSpaceTransferFn srgbFn; srgbFn.fA = 1.0f / 1.055f; @@ -136,7 +136,7 @@ DEF_TEST(ICC_WriteICC, r) { srgbFn.fG = 2.4f; SkMatrix44 srgbMatrix(SkMatrix44::kUninitialized_Constructor); srgbMatrix.set3x3RowMajorf(gSRGB_toXYZD50); - test_write_icc(r, srgbFn, srgbMatrix, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).get(), + test_write_icc(r, srgbFn, srgbMatrix, SkColorSpace::MakeSRGB().get(), false); } @@ -166,11 +166,11 @@ public: }; DEF_TEST(ICC_RawTransferFns, r) { - sk_sp<SkICC> srgb = ICCTest::MakeICC(SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)); + sk_sp<SkICC> srgb = ICCTest::MakeICC(SkColorSpace::MakeSRGB()); test_raw_transfer_fn(r, srgb.get()); sk_sp<SkICC> adobe = - ICCTest::MakeICC(SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named)); + ICCTest::MakeICC(SkColorSpace_Base::MakeNamed(SkColorSpace_Base::kAdobeRGB_Named)); test_raw_transfer_fn(r, adobe.get()); // Lookup-table based gamma curves diff --git a/tests/ImageIsOpaqueTest.cpp b/tests/ImageIsOpaqueTest.cpp index cbbe331c5b..81f1d76609 100644 --- a/tests/ImageIsOpaqueTest.cpp +++ b/tests/ImageIsOpaqueTest.cpp @@ -12,6 +12,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" #endif +#include "SkColorSpace_Base.h" #include "SkImage.h" #include "SkSurface.h" #include "SkReadBuffer.h" @@ -50,8 +51,8 @@ DEF_TEST(ImageInfo_flattening, reporter) { sk_sp<SkColorSpace> spaces[] = { nullptr, - SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named), - SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named), + SkColorSpace::MakeSRGB(), + SkColorSpace_Base::MakeNamed(SkColorSpace_Base::kAdobeRGB_Named), space0, space1, space2, @@ -126,7 +127,7 @@ DEF_TEST(Image_isAlphaOnly, reporter) { GetResourceAsImage("color_wheel.jpg"), SkImage::MakeFromPicture(make_picture(), { 10, 10 }, nullptr, nullptr, SkImage::BitDepth::kU8, - SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)), + SkColorSpace::MakeSRGB()), }) { REPORTER_ASSERT(reporter, image->isAlphaOnly() == false); diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 67ddd6cdf5..c4f8abbd00 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -131,7 +131,7 @@ static sk_sp<SkImage> create_picture_image() { canvas->clear(SK_ColorCYAN); return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(), SkISize::Make(10, 10), nullptr, nullptr, SkImage::BitDepth::kU8, - SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)); + SkColorSpace::MakeSRGB()); }; #endif // Want to ensure that our Release is called when the owning image is destroyed @@ -486,7 +486,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeTextureImage, reporter, contextIn sk_sp<SkColorSpace> dstColorSpaces[] ={ nullptr, - SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named), + SkColorSpace::MakeSRGB(), }; for (auto& dstColorSpace : dstColorSpaces) { diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp index 22d68903eb..dbdcaeccab 100644 --- a/tests/SRGBMipMapTest.cpp +++ b/tests/SRGBMipMapTest.cpp @@ -121,7 +121,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) { sk_sp<GrTexture> texture(texProvider->createTexture(desc, SkBudgeted::kNo, texData, 0)); // Create two render target contexts (L32 and S32) - sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeSRGB(); sk_sp<GrRenderTargetContext> l32RenderTargetContext = context->makeRenderTargetContext( SkBackingFit::kExact, rtS, rtS, kRGBA_8888_GrPixelConfig, nullptr); sk_sp<GrRenderTargetContext> s32RenderTargetContext = context->makeRenderTargetContext( diff --git a/tests/SkBlend_optsTest.cpp b/tests/SkBlend_optsTest.cpp index 554818adec..f8cf2d83de 100644 --- a/tests/SkBlend_optsTest.cpp +++ b/tests/SkBlend_optsTest.cpp @@ -52,7 +52,7 @@ static void test_blender(std::string resourceName, skiatest::Reporter* reporter) return; } SkBitmap bm; - sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeSRGB(); if (!as_IB(image)->getROPixels(&bm, srgbColorSpace.get())) { ERRORF(reporter, "Could not read resource"); return; diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp index 922aceff25..2141885b11 100644 --- a/tests/SkResourceCacheTest.cpp +++ b/tests/SkResourceCacheTest.cpp @@ -331,7 +331,7 @@ DEF_TEST(BitmapCache_discarded_image, reporter) { return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(), SkISize::Make(10, 10), nullptr, nullptr, SkImage::BitDepth::kU8, - SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)); + SkColorSpace::MakeSRGB()); }); } } diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp index 551efff6c5..94683a0cdf 100644 --- a/tests/SpecialImageTest.cpp +++ b/tests/SpecialImageTest.cpp @@ -184,7 +184,7 @@ DEF_TEST(SpecialImage_Image_Legacy, reporter) { } DEF_TEST(SpecialImage_Image_ColorSpaceAware, reporter) { - sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeSRGB(); test_specialimage_image(reporter, srgbColorSpace.get()); } diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 2097ab3fa6..dd71943dd9 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -807,8 +807,8 @@ static void test_surface_creation_and_snapshot_with_color_space( bool f16Support, std::function<sk_sp<SkSurface>(const SkImageInfo&)> surfaceMaker) { - auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); - auto adobeColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named); + auto srgbColorSpace = SkColorSpace::MakeSRGB(); + auto adobeColorSpace = SkColorSpace_Base::MakeNamed(SkColorSpace_Base::kAdobeRGB_Named); const SkMatrix44* srgbMatrix = as_CSB(srgbColorSpace)->toXYZD50(); SkASSERT(srgbMatrix); SkColorSpaceTransferFn oddGamma; @@ -816,7 +816,7 @@ static void test_surface_creation_and_snapshot_with_color_space( oddGamma.fB = oddGamma.fC = oddGamma.fD = oddGamma.fE = oddGamma.fF = 0.0f; oddGamma.fG = 4.0f; auto oddColorSpace = SkColorSpace::MakeRGB(oddGamma, *srgbMatrix); - auto linearColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); + auto linearColorSpace = SkColorSpace::MakeSRGBLinear(); const struct { SkColorType fColorType; diff --git a/tests/TestConfigParsing.cpp b/tests/TestConfigParsing.cpp index 9675eedbc9..70fe0e2ff9 100644 --- a/tests/TestConfigParsing.cpp +++ b/tests/TestConfigParsing.cpp @@ -86,7 +86,7 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) { SkCommandLineConfigArray configs; ParseConfigs(config1, &configs); - auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + auto srgbColorSpace = SkColorSpace::MakeSRGB(); REPORTER_ASSERT(reporter, configs.count() == config1.count()); for (int i = 0; i < config1.count(); ++i) { |