mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibGfx: Move ICC::Profile towards "Fallible Constructors" pattern
Not quite there yet due to check_required_tags() / check_tag_types(), but getting closer :^)
This commit is contained in:
parent
db614b47dd
commit
9ba3c8e36d
2 changed files with 11 additions and 4 deletions
|
@ -1377,10 +1377,11 @@ ErrorOr<void> Profile::check_tag_types()
|
|||
|
||||
ErrorOr<NonnullRefPtr<Profile>> Profile::try_load_from_externally_owned_memory(ReadonlyBytes bytes)
|
||||
{
|
||||
auto profile = TRY(try_make_ref_counted<Profile>());
|
||||
profile->m_header = TRY(read_header(bytes));
|
||||
bytes = bytes.trim(profile->on_disk_size());
|
||||
profile->m_tag_table = TRY(read_tag_table(bytes));
|
||||
auto header = TRY(read_header(bytes));
|
||||
bytes = bytes.trim(header.on_disk_size);
|
||||
auto tag_table = TRY(read_tag_table(bytes));
|
||||
|
||||
auto profile = TRY(try_make_ref_counted<Profile>(header, move(tag_table)));
|
||||
|
||||
TRY(profile->check_required_tags());
|
||||
TRY(profile->check_tag_types());
|
||||
|
|
|
@ -210,6 +210,12 @@ class Profile : public RefCounted<Profile> {
|
|||
public:
|
||||
static ErrorOr<NonnullRefPtr<Profile>> try_load_from_externally_owned_memory(ReadonlyBytes);
|
||||
|
||||
Profile(ProfileHeader const& header, OrderedHashMap<TagSignature, NonnullRefPtr<TagData>> tag_table)
|
||||
: m_header(header)
|
||||
, m_tag_table(move(tag_table))
|
||||
{
|
||||
}
|
||||
|
||||
Optional<PreferredCMMType> preferred_cmm_type() const { return m_header.preferred_cmm_type; }
|
||||
Version version() const { return m_header.version; }
|
||||
DeviceClass device_class() const { return m_header.device_class; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue