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

Unified Diff: third_party/qcms/src/iccread.c

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/qcms/README.chromium ('k') | tools/android/asan/asan_device_setup.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/qcms/src/iccread.c
diff --git a/third_party/qcms/src/iccread.c b/third_party/qcms/src/iccread.c
index 2e86aa814b8bfcbaea6fe7b9417af4b98612b9d8..6cec34a31c0e5edd1adeffd05a6f563018e96d1f 100644
--- a/third_party/qcms/src/iccread.c
+++ b/third_party/qcms/src/iccread.c
@@ -356,6 +356,7 @@ static struct tag *find_tag(struct tag_index index, uint32_t tag_id)
#define DESC_TYPE 0x64657363 // 'desc'
#define MLUC_TYPE 0x6d6c7563 // 'mluc'
+#define MMOD_TYPE 0x6D6D6F64 // 'mmod'
static bool read_tag_descType(qcms_profile *profile, struct mem_source *src, struct tag_index index, uint32_t tag_id)
{
@@ -365,25 +366,25 @@ static bool read_tag_descType(qcms_profile *profile, struct mem_source *src, str
uint32_t offset = tag->offset;
uint32_t type = read_u32(src, offset);
uint32_t length = read_u32(src, offset+8);
- uint32_t i, description;
+ uint32_t i, description_offset;
bool mluc = false;
if (length && type == MLUC_TYPE) {
length = read_u32(src, offset+20);
if (!length || (length & 1) || (read_u32(src, offset+12) != 12))
goto invalid_desc_tag;
- description = offset + read_u32(src, offset+24);
+ description_offset = offset + read_u32(src, offset+24);
if (!src->valid)
goto invalid_desc_tag;
mluc = true;
} else if (length && type == DESC_TYPE) {
- description = offset + 12;
+ description_offset = offset + 12;
} else {
goto invalid_desc_tag;
}
if (length >= limit)
length = limit - 1;
for (i = 0; i < length; ++i) {
- uint8_t value = read_u8(src, description+i);
+ uint8_t value = read_u8(src, description_offset + i);
if (!src->valid)
goto invalid_desc_tag;
if (mluc && !value)
@@ -405,9 +406,10 @@ invalid_desc_tag:
#if defined(__APPLE__)
+// Use the dscm tag to change profile description "Display" to its more specific en-localized monitor name, if any.
+
#define TAG_dscm 0x6473636D // 'dscm'
-// Use dscm tag to change profile description "Display" to its more specific en-localized monitor name, if any.
static bool read_tag_dscmType(qcms_profile *profile, struct mem_source *src, struct tag_index index, uint32_t tag_id)
{
if (strcmp(profile->description, "Display") != 0)
@@ -462,6 +464,40 @@ invalid_dscm_tag:
return false;
}
+// Use the mmod tag to change profile description "Display" to its specific mmod maker model data, if any.
+
+#define TAG_mmod 0x6D6D6F64 // 'mmod'
+
+static bool read_tag_mmodType(qcms_profile *profile, struct mem_source *src, struct tag_index index, uint32_t tag_id)
+{
+ if (strcmp(profile->description, "Display") != 0)
+ return true;
+
+ struct tag *tag = find_tag(index, tag_id);
+ if (tag) {
+ const uint8_t length = 4 * 4; // Four 4-byte fields: 'mmod', 0, maker, model.
+
+ uint32_t offset = tag->offset;
+ if (tag->size < 40 || read_u32(src, offset) != MMOD_TYPE)
+ goto invalid_mmod_tag;
+
+ for (uint8_t i = 0; i < length; ++i) {
+ uint8_t value = read_u8(src, offset + i);
+ if (!src->valid)
+ goto invalid_mmod_tag;
+ profile->description[i] = value ? value : '.';
+ }
+ profile->description[length] = 0;
+ }
+
+ if (src->valid)
+ return true;
+
+invalid_mmod_tag:
+ invalid_source(src, "invalid mmod tag");
+ return false;
+}
+
#endif // __APPLE__
#define XYZ_TYPE 0x58595a20 // 'XYZ '
@@ -1163,6 +1199,8 @@ qcms_profile* qcms_profile_from_memory(const void *mem, size_t size)
#if defined(__APPLE__)
if (!read_tag_dscmType(profile, src, index, TAG_dscm))
goto invalid_tag_table;
+ if (!read_tag_mmodType(profile, src, index, TAG_mmod))
+ goto invalid_tag_table;
#endif // __APPLE__
if (find_tag(index, TAG_CHAD)) {
« no previous file with comments | « third_party/qcms/README.chromium ('k') | tools/android/asan/asan_device_setup.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698