Skip to content

Commit

Permalink
DCI-P3 -> Display P3 in Skia
Browse files Browse the repository at this point in the history
This keeps an alias so code keeps building.

Bug: skia:9792
Change-Id: If8575468d929d2ca28bc2f9e82de27291fb19aa1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/264691
Reviewed-by: Brian Osman <[email protected]>
Commit-Queue: Mike Klein <[email protected]>
  • Loading branch information
Mike Klein authored and Skia Commit-Bot committed Jan 16, 2020
1 parent 7b18610 commit b147ace
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bench/VertexColorSpaceBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class VertexColorSpaceBench : public Benchmark {
GrOpMemoryPool* pool = context->priv().opMemoryPool();

auto p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
SkNamedGamut::kDCIP3);
SkNamedGamut::kDisplayP3);
auto xform = GrColorSpaceXform::Make(sk_srgb_singleton(), kUnpremul_SkAlphaType,
p3.get(), kUnpremul_SkAlphaType);

Expand Down
14 changes: 7 additions & 7 deletions dm/DM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ static Sink* create_sink(const GrContextOptions& grCtxOptions, const SkCommandLi
auto narrow = SkColorSpace::MakeRGB(SkNamedTransferFn::k2Dot2, gNarrow_toXYZD50),
srgb = SkColorSpace::MakeSRGB(),
srgbLinear = SkColorSpace::MakeSRGBLinear(),
p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);

SINK( "f16", RasterSink, kRGBA_F16_SkColorType, srgbLinear);
SINK( "srgb", RasterSink, kRGBA_8888_SkColorType, srgb );
Expand Down Expand Up @@ -1207,12 +1207,12 @@ struct Task {
return true;
};

if (eq(gamut, SkNamedGamut::kSRGB )) { return SkString("sRGB"); }
if (eq(gamut, SkNamedGamut::kAdobeRGB)) { return SkString("Adobe"); }
if (eq(gamut, SkNamedGamut::kDCIP3 )) { return SkString("P3"); }
if (eq(gamut, SkNamedGamut::kRec2020 )) { return SkString("2020"); }
if (eq(gamut, SkNamedGamut::kXYZ )) { return SkString("XYZ"); }
if (eq(gamut, gNarrow_toXYZD50 )) { return SkString("narrow"); }
if (eq(gamut, SkNamedGamut::kSRGB )) { return SkString("sRGB"); }
if (eq(gamut, SkNamedGamut::kAdobeRGB )) { return SkString("Adobe"); }
if (eq(gamut, SkNamedGamut::kDisplayP3)) { return SkString("P3"); }
if (eq(gamut, SkNamedGamut::kRec2020 )) { return SkString("2020"); }
if (eq(gamut, SkNamedGamut::kXYZ )) { return SkString("XYZ"); }
if (eq(gamut, gNarrow_toXYZD50 )) { return SkString("narrow"); }
return SkString("other");
}
return SkString("non-XYZ");
Expand Down
4 changes: 2 additions & 2 deletions gm/p3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static void compare_pixel(const char* label,
}

DEF_SIMPLE_GM(p3, canvas, 450, 1300) {
auto p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
auto p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);
auto srgb = SkColorSpace::MakeSRGB();

auto p3_to_srgb = [&](SkColor4f c) {
Expand Down Expand Up @@ -402,7 +402,7 @@ DEF_SIMPLE_GM(p3, canvas, 450, 1300) {
}

DEF_SIMPLE_GM(p3_ovals, canvas, 450, 320) {
auto p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
auto p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);

// Test cases that exercise each Op in GrOvalOpFactory.cpp

Expand Down
5 changes: 3 additions & 2 deletions include/core/SkColorSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ static constexpr skcms_Matrix3x3 kAdobeRGB = {{
{ SkFixedToFloat(0x04fc), SkFixedToFloat(0x0f95), SkFixedToFloat(0xbe9c) },
}};

// TODO: this is the D65 P3 used for Display P3. Rename, add the real ~D63 DCI P3?
static constexpr skcms_Matrix3x3 kDCIP3 = {{
static constexpr skcms_Matrix3x3 kDisplayP3 = {{
{ 0.515102f, 0.291965f, 0.157153f },
{ 0.241182f, 0.692236f, 0.0665819f },
{ -0.00104941f, 0.0418818f, 0.784378f },
}};
// TODO: skia:9792 We originally misnamed this matrix... delete this incorrect alias?
static constexpr skcms_Matrix3x3 kDCIP3 = kDisplayP3;

static constexpr skcms_Matrix3x3 kRec2020 = {{
{ 0.673459f, 0.165661f, 0.125100f },
Expand Down
2 changes: 1 addition & 1 deletion src/codec/SkAndroidCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ sk_sp<SkColorSpace> SkAndroidCodec::computeOutputColorSpace(SkColorType outputCo
}

if (is_wide_gamut(*encodedProfile)) {
return SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
return SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/core/SkICC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ const char* get_color_profile_description(const skcms_TransferFunction& fn,
if (twoDotTwo && nearly_equal(toXYZD50, SkNamedGamut::kAdobeRGB)) {
return "AdobeRGB";
}
bool dcip3_gamut = nearly_equal(toXYZD50, SkNamedGamut::kDCIP3);
bool display_p3 = nearly_equal(toXYZD50, SkNamedGamut::kDisplayP3);
if (srgb_xfer || line_xfer) {
if (srgb_xfer && dcip3_gamut) {
return "sRGB Transfer with DCI-P3 Gamut";
if (srgb_xfer && display_p3) {
return "sRGB Transfer with Display P3 Gamut";
}
if (line_xfer && dcip3_gamut) {
return "Linear Transfer with DCI-P3 Gamut";
if (line_xfer && display_p3) {
return "Linear Transfer with Display P3 Gamut";
}
bool rec2020 = nearly_equal(toXYZD50, SkNamedGamut::kRec2020);
if (srgb_xfer && rec2020) {
Expand Down
2 changes: 1 addition & 1 deletion tests/AndroidCodecTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ DEF_TEST(AndroidCodec_wide, r) {
return;
}

auto expected = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
auto expected = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);
REPORTER_ASSERT(r, SkColorSpace::Equals(cs.get(), expected.get()));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/CodecTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ static void test_encode_icc(skiatest::Reporter* r, SkEncodedImageFormat format)

// Test with P3 color space.
SkDynamicMemoryWStream p3Buf;
sk_sp<SkColorSpace> p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
sk_sp<SkColorSpace> p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);
pixmap.setColorSpace(p3);
encode_format(&p3Buf, pixmap, format);
sk_sp<SkData> p3Data = p3Buf.detachAsData();
Expand Down
2 changes: 1 addition & 1 deletion tests/ColorSpaceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ DEF_TEST(ColorSpace_Primaries, r) {
p3.fBY = 0.060f;
p3.fWX = 0.3127f;
p3.fWY = 0.3290f;
space = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
space = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);
skcms_Matrix3x3 reference;
SkAssertResult(space->toXYZD50(&reference));
check_primaries(r, p3, reference);
Expand Down
2 changes: 1 addition & 1 deletion tests/ImageTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ DEF_TEST(Image_ColorSpace, r) {
}

DEF_TEST(Image_makeColorSpace, r) {
sk_sp<SkColorSpace> p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
sk_sp<SkColorSpace> p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);
skcms_TransferFunction fn;
fn.a = 1.f; fn.b = 0.f; fn.c = 0.f; fn.d = 0.f; fn.e = 0.f; fn.f = 0.f; fn.g = 1.8f;
sk_sp<SkColorSpace> adobeGamut = SkColorSpace::MakeRGB(fn, SkNamedGamut::kAdobeRGB);
Expand Down
2 changes: 1 addition & 1 deletion tests/NonlinearBlendingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

DEF_TEST(SkColorSpaceXformSteps_vs_skcms, r) {
auto srgb = SkColorSpace::MakeSRGB();
auto dp3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
auto dp3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);

skcms_ICCProfile srgb_profile;
srgb->toProfile(&srgb_profile);
Expand Down
2 changes: 1 addition & 1 deletion tools/flags/CommonFlagsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ static bool parse_option_gpu_color(const SkString& value,
*outColorSpace = SkColorSpace::MakeSRGB();
} else if (value.equals("p3")) {
*outColorType = kRGBA_8888_SkColorType;
*outColorSpace = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
*outColorSpace = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);
} else if (value.equals("esrgb")) {
*outColorType = kRGBA_F16_SkColorType;
*outColorSpace = SkColorSpace::MakeSRGB();
Expand Down
2 changes: 1 addition & 1 deletion tools/fm/fm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ int main(int argc, char** argv) {
};
const FlagOption<skcms_Matrix3x3> kGamuts[] = {
{ "srgb", SkNamedGamut::kSRGB },
{ "p3", SkNamedGamut::kDCIP3 },
{ "p3", SkNamedGamut::kDisplayP3 },
{ "rec2020", SkNamedGamut::kRec2020 },
{ "adobe", SkNamedGamut::kAdobeRGB },
{ "narrow", gNarrow_toXYZD50},
Expand Down

0 comments on commit b147ace

Please sign in to comment.