aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2018-05-01 13:09:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-01 17:42:35 +0000
commit0ab0f1c120050920140da7fe15fc2ccd81a8e01d (patch)
treede6e47839b9c025193ac7a421d547c2bc3e57956 /third_party
parente467d4e65639a719e953f6b62f91770a6411c0b9 (diff)
Convert skcms to only export functions (not data)
This simplifies shared library builds on Windows (no need to conditionally change declspec to dllimport). Once this lands, we can make the same change (plus update internal references): https://skia-review.googlesource.com/c/skcms/+/124982 Change-Id: I0d4fa9031258f77d370e6e6e018afaf543c29d85 Reviewed-on: https://skia-review.googlesource.com/124983 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'third_party')
-rw-r--r--third_party/skcms/skcms.h4
-rw-r--r--third_party/skcms/src/ICCProfile.c124
2 files changed, 68 insertions, 60 deletions
diff --git a/third_party/skcms/skcms.h b/third_party/skcms/skcms.h
index 94dfe03892..2053fe6828 100644
--- a/third_party/skcms/skcms.h
+++ b/third_party/skcms/skcms.h
@@ -113,9 +113,9 @@ typedef struct skcms_ICCProfile {
} skcms_ICCProfile;
// The sRGB color profile is so commonly used that we offer a canonical skcms_ICCProfile for it.
-SKCMS_API extern const skcms_ICCProfile skcms_sRGB_profile;
+SKCMS_API const skcms_ICCProfile* skcms_sRGB_profile(void);
// Ditto for XYZD50, the most common profile connection space.
-SKCMS_API extern const skcms_ICCProfile skcms_XYZD50_profile;
+SKCMS_API const skcms_ICCProfile* skcms_XYZD50_profile(void);
// Practical equality test for two skcms_ICCProfiles.
// The implementation is subject to change, but it will always try to answer
diff --git a/third_party/skcms/src/ICCProfile.c b/third_party/skcms/src/ICCProfile.c
index 90ce6fcaf2..322e0975f1 100644
--- a/third_party/skcms/src/ICCProfile.c
+++ b/third_party/skcms/src/ICCProfile.c
@@ -781,63 +781,71 @@ bool skcms_Parse(const void* buf, size_t len, skcms_ICCProfile* profile) {
return usable_as_src(profile);
}
-const skcms_ICCProfile skcms_sRGB_profile = {
- // These fields are moot when not a skcms_Parse()'d profile.
- .buffer = NULL,
- .size = 0,
- .tag_count = 0,
-
- // We choose to represent sRGB with its canonical transfer function,
- // and with its canonical XYZD50 gamut matrix.
- .data_color_space = make_signature('R', 'G', 'B', ' '),
- .pcs = make_signature('X', 'Y', 'Z', ' '),
- .has_trc = true,
- .has_toXYZD50 = true,
- .has_A2B = false,
-
- .trc = {
- {{0, {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0 }}},
- {{0, {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0 }}},
- {{0, {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0 }}},
- },
-
- .toXYZD50 = {{
- { 0.436065674f, 0.385147095f, 0.143066406f },
- { 0.222488403f, 0.716873169f, 0.060607910f },
- { 0.013916016f, 0.097076416f, 0.714096069f },
- }},
-
- .has_poly_tf = { true, true, true },
- .poly_tf = {
- {0.293833881617f, 0.704207003117f, (float)(1/12.92), 0.04045f},
- {0.293833881617f, 0.704207003117f, (float)(1/12.92), 0.04045f},
- {0.293833881617f, 0.704207003117f, (float)(1/12.92), 0.04045f},
- },
-};
-const skcms_ICCProfile skcms_XYZD50_profile = {
- .buffer = NULL,
- .size = 0,
- .tag_count = 0,
-
- .data_color_space = make_signature('R', 'G', 'B', ' '),
- .pcs = make_signature('X', 'Y', 'Z', ' '),
- .has_trc = true,
- .has_toXYZD50 = true,
- .has_A2B = false,
-
- .trc = {
- {{0, {1,1,0,0,0,0,0}}},
- {{0, {1,1,0,0,0,0,0}}},
- {{0, {1,1,0,0,0,0,0}}},
- },
-
- .toXYZD50 = {{
- {1,0,0},
- {0,1,0},
- {0,0,1},
- }},
-};
+const skcms_ICCProfile* skcms_sRGB_profile() {
+ static const skcms_ICCProfile sRGB_profile = {
+ // These fields are moot when not a skcms_Parse()'d profile.
+ .buffer = NULL,
+ .size = 0,
+ .tag_count = 0,
+
+ // We choose to represent sRGB with its canonical transfer function,
+ // and with its canonical XYZD50 gamut matrix.
+ .data_color_space = make_signature('R', 'G', 'B', ' '),
+ .pcs = make_signature('X', 'Y', 'Z', ' '),
+ .has_trc = true,
+ .has_toXYZD50 = true,
+ .has_A2B = false,
+
+ .trc = {
+ {{0, {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0 }}},
+ {{0, {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0 }}},
+ {{0, {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0 }}},
+ },
+
+ .toXYZD50 = {{
+ { 0.436065674f, 0.385147095f, 0.143066406f },
+ { 0.222488403f, 0.716873169f, 0.060607910f },
+ { 0.013916016f, 0.097076416f, 0.714096069f },
+ }},
+
+ .has_poly_tf = { true, true, true },
+ .poly_tf = {
+ {0.293833881617f, 0.704207003117f, (float)(1/12.92), 0.04045f},
+ {0.293833881617f, 0.704207003117f, (float)(1/12.92), 0.04045f},
+ {0.293833881617f, 0.704207003117f, (float)(1/12.92), 0.04045f},
+ },
+ };
+ return &sRGB_profile;
+}
+
+const skcms_ICCProfile* skcms_XYZD50_profile() {
+ static const skcms_ICCProfile XYZD50_profile = {
+ .buffer = NULL,
+ .size = 0,
+ .tag_count = 0,
+
+ .data_color_space = make_signature('R', 'G', 'B', ' '),
+ .pcs = make_signature('X', 'Y', 'Z', ' '),
+ .has_trc = true,
+ .has_toXYZD50 = true,
+ .has_A2B = false,
+
+ .trc = {
+ {{0, {1,1,0,0,0,0,0}}},
+ {{0, {1,1,0,0,0,0,0}}},
+ {{0, {1,1,0,0,0,0,0}}},
+ },
+
+ .toXYZD50 = {{
+ {1,0,0},
+ {0,1,0},
+ {0,0,1},
+ }},
+ };
+
+ return &XYZD50_profile;
+}
const uint8_t skcms_252_random_bytes[] = {
8, 179, 128, 204, 253, 38, 134, 184, 68, 102, 32, 138, 99, 39, 169, 215,
@@ -885,13 +893,13 @@ bool skcms_ApproximatelyEqualProfiles(const skcms_ICCProfile* A, const skcms_ICC
dstB[252];
if (!skcms_Transform(
skcms_252_random_bytes, fmt, skcms_AlphaFormat_Unpremul, A,
- dstA, skcms_PixelFormat_RGB_888, skcms_AlphaFormat_Unpremul, &skcms_XYZD50_profile,
+ dstA, skcms_PixelFormat_RGB_888, skcms_AlphaFormat_Unpremul, skcms_XYZD50_profile(),
npixels)) {
return false;
}
if (!skcms_Transform(
skcms_252_random_bytes, fmt, skcms_AlphaFormat_Unpremul, B,
- dstB, skcms_PixelFormat_RGB_888, skcms_AlphaFormat_Unpremul, &skcms_XYZD50_profile,
+ dstB, skcms_PixelFormat_RGB_888, skcms_AlphaFormat_Unpremul, skcms_XYZD50_profile(),
npixels)) {
return false;
}