diff --git a/userspace/image/Image.cpp b/userspace/image/Image.cpp index bf81cd07dc..7dcaa1387a 100644 --- a/userspace/image/Image.cpp +++ b/userspace/image/Image.cpp @@ -70,7 +70,7 @@ BAN::UniqPtr Image::load_from_file(BAN::StringView path) case 0x3350: case 0x3250: case 0x3150: - if (auto res = Netbpm::create(addr, st.st_size); res.is_error()) + if (auto res = load_netbpm(addr, st.st_size); res.is_error()) fprintf(stderr, "%s\n", strerror(res.error().get_error_code())); else image = res.release_value(); diff --git a/userspace/image/Image.h b/userspace/image/Image.h index 613ff5a4a1..87ec66c153 100644 --- a/userspace/image/Image.h +++ b/userspace/image/Image.h @@ -22,15 +22,17 @@ public: bool render_to_framebuffer(); -protected: +private: Image(uint64_t width, uint64_t height, BAN::Vector&& bitmap) : m_width(width) , m_height(height) , m_bitmap(BAN::move(bitmap)) { } -protected: +private: const uint64_t m_width; const uint64_t m_height; const BAN::Vector m_bitmap; + + friend class BAN::UniqPtr; }; diff --git a/userspace/image/Netbpm.cpp b/userspace/image/Netbpm.cpp index 6d65b0acac..5f42488217 100644 --- a/userspace/image/Netbpm.cpp +++ b/userspace/image/Netbpm.cpp @@ -29,7 +29,7 @@ BAN::Optional parse_u64(const uint8_t*& data, size_t data_size) return {}; } -BAN::ErrorOr> Netbpm::create(const void* mmap_addr, size_t size) +BAN::ErrorOr> load_netbpm(const void* mmap_addr, size_t size) { if (size < 11) { @@ -88,7 +88,7 @@ BAN::ErrorOr> Netbpm::create(const void* mmap_addr, size_t printf("Netbpm image %llux%llu\n", *width, *height); - BAN::Vector bitmap; + BAN::Vector bitmap; TRY(bitmap.resize(*width * *height)); // Fill bitmap @@ -104,5 +104,5 @@ BAN::ErrorOr> Netbpm::create(const void* mmap_addr, size_t } } - return TRY(BAN::UniqPtr::create(*width, *height, BAN::move(bitmap))); + return TRY(BAN::UniqPtr::create(*width, *height, BAN::move(bitmap))); } diff --git a/userspace/image/Netbpm.h b/userspace/image/Netbpm.h index 325d85fa71..203a7582a2 100644 --- a/userspace/image/Netbpm.h +++ b/userspace/image/Netbpm.h @@ -1,14 +1,3 @@ #include "Image.h" -class Netbpm : public Image -{ -public: - static BAN::ErrorOr> create(const void* mmap_addr, size_t size); - -private: - Netbpm(uint64_t width, uint64_t height, BAN::Vector&& bitmap) - : Image(width, height, BAN::move(bitmap)) - { } - - friend class BAN::UniqPtr; -}; +BAN::ErrorOr> load_netbpm(const void* mmap_addr, size_t size);