From 272e5321e39ae89383cf17f189d0f582c5eff3a0 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 14 Feb 2023 12:59:20 -0500 Subject: [PATCH] LibGfx: Move ICC::Profile::read_tag_table() out of class --- Userland/Libraries/LibGfx/ICC/Profile.cpp | 10 ++++++---- Userland/Libraries/LibGfx/ICC/Profile.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibGfx/ICC/Profile.cpp b/Userland/Libraries/LibGfx/ICC/Profile.cpp index 0f640da3f2..ccc0335506 100644 --- a/Userland/Libraries/LibGfx/ICC/Profile.cpp +++ b/Userland/Libraries/LibGfx/ICC/Profile.cpp @@ -663,8 +663,10 @@ static ErrorOr> read_tag(ReadonlyBytes bytes, u32 offset_ } } -ErrorOr Profile::read_tag_table(ReadonlyBytes bytes) +static ErrorOr>> read_tag_table(ReadonlyBytes bytes) { + OrderedHashMap> tag_table; + // ICC v4, 7.3 Tag table // ICC v4, 7.3.1 Overview // "The tag table acts as a table of contents for the tags and an index into the tag data element in the profiles. It @@ -718,11 +720,11 @@ ErrorOr Profile::read_tag_table(ReadonlyBytes bytes) return Error::from_string_literal("ICC::Profile: two tags have same offset but different sizes"); // "Duplicate tag signatures shall not be included in the tag table." - if (TRY(m_tag_table.try_set(tag_table_entries[i].tag_signature, move(tag_data))) != AK::HashSetResult::InsertedNewEntry) + if (TRY(tag_table.try_set(tag_table_entries[i].tag_signature, move(tag_data))) != AK::HashSetResult::InsertedNewEntry) return Error::from_string_literal("ICC::Profile: duplicate tag signature"); } - return {}; + return tag_table; } static bool is_xCLR(ColorSpace color_space) @@ -1377,7 +1379,7 @@ ErrorOr> Profile::try_load_from_externally_owned_memory(R auto profile = TRY(try_make_ref_counted()); TRY(profile->read_header(bytes)); bytes = bytes.trim(profile->on_disk_size()); - TRY(profile->read_tag_table(bytes)); + profile->m_tag_table = TRY(read_tag_table(bytes)); TRY(profile->check_required_tags()); TRY(profile->check_tag_types()); diff --git a/Userland/Libraries/LibGfx/ICC/Profile.h b/Userland/Libraries/LibGfx/ICC/Profile.h index d3474d9ac0..ef0ac60901 100644 --- a/Userland/Libraries/LibGfx/ICC/Profile.h +++ b/Userland/Libraries/LibGfx/ICC/Profile.h @@ -226,7 +226,6 @@ public: private: ErrorOr read_header(ReadonlyBytes); - ErrorOr read_tag_table(ReadonlyBytes); ErrorOr check_required_tags(); ErrorOr check_tag_types();