From 3fe2640c8c51283cb8c89a948d7221fd79699f3d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 14 Feb 2020 23:02:47 +0100 Subject: [PATCH] LibGfx: Add forward declaration header This patch adds with forward declarations for Gfx. --- Applications/Calculator/main.cpp | 1 + Applications/DisplayProperties/main.cpp | 1 + Applications/FontEditor/main.cpp | 1 + Applications/HexEditor/main.cpp | 1 + Applications/PaintBrush/BucketTool.cpp | 4 +- Applications/PaintBrush/EraseTool.cpp | 1 + Applications/PaintBrush/PaintableWidget.cpp | 2 +- Applications/PaintBrush/SprayTool.cpp | 2 +- Applications/QuickShow/main.cpp | 1 + Applications/SystemMonitor/ProcessModel.cpp | 2 +- Applications/Taskbar/TaskbarWindow.cpp | 2 +- Applications/TextEditor/main.cpp | 1 + Demos/Fire/Fire.cpp | 2 +- Libraries/LibGUI/Action.cpp | 125 ++++++++++---------- Libraries/LibGUI/Action.h | 4 +- Libraries/LibGUI/DragOperation.cpp | 1 + Libraries/LibGUI/Menu.cpp | 6 +- Libraries/LibGUI/Painter.cpp | 1 + Libraries/LibGUI/TextEditor.cpp | 1 + Libraries/LibGUI/Window.cpp | 6 +- Libraries/LibGUI/Window.h | 5 +- Libraries/LibGUI/WindowServerConnection.cpp | 2 + Libraries/LibGfx/Bitmap.cpp | 35 +++--- Libraries/LibGfx/Bitmap.h | 93 +++++++-------- Libraries/LibGfx/Forward.h | 52 ++++++++ Libraries/LibGfx/PNGLoader.cpp | 2 +- Libraries/LibGfx/Painter.cpp | 44 +++---- Libraries/LibGfx/Palette.cpp | 11 ++ Libraries/LibGfx/Palette.h | 5 +- Libraries/LibGfx/SystemTheme.cpp | 1 + Libraries/LibGfx/SystemTheme.h | 2 +- MenuApplets/Audio/main.cpp | 1 + Servers/WindowServer/ClientConnection.cpp | 8 +- Servers/WindowServer/Compositor.cpp | 6 +- Servers/WindowServer/Window.cpp | 2 +- Servers/WindowServer/WindowManager.cpp | 1 + Servers/WindowServer/main.cpp | 1 + 37 files changed, 264 insertions(+), 172 deletions(-) create mode 100644 Libraries/LibGfx/Forward.h diff --git a/Applications/Calculator/main.cpp b/Applications/Calculator/main.cpp index 298c424ec2..968d26f4fc 100644 --- a/Applications/Calculator/main.cpp +++ b/Applications/Calculator/main.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include int main(int argc, char** argv) diff --git a/Applications/DisplayProperties/main.cpp b/Applications/DisplayProperties/main.cpp index 7008858e00..b38cd64c18 100644 --- a/Applications/DisplayProperties/main.cpp +++ b/Applications/DisplayProperties/main.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include int main(int argc, char** argv) diff --git a/Applications/FontEditor/main.cpp b/Applications/FontEditor/main.cpp index 7252a22a80..fded4827ea 100644 --- a/Applications/FontEditor/main.cpp +++ b/Applications/FontEditor/main.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include int main(int argc, char** argv) diff --git a/Applications/HexEditor/main.cpp b/Applications/HexEditor/main.cpp index d1fb95b6ba..ad5d44cef6 100644 --- a/Applications/HexEditor/main.cpp +++ b/Applications/HexEditor/main.cpp @@ -25,6 +25,7 @@ */ #include "HexEditorWidget.h" +#include #include int main(int argc, char** argv) diff --git a/Applications/PaintBrush/BucketTool.cpp b/Applications/PaintBrush/BucketTool.cpp index fa6c95dc8f..b8144b8818 100644 --- a/Applications/PaintBrush/BucketTool.cpp +++ b/Applications/PaintBrush/BucketTool.cpp @@ -52,9 +52,9 @@ static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::Point& start_position, Co while (!queue.is_empty()) { auto position = queue.dequeue(); - if (bitmap.get_pixel(position.x(), position.y()) != target_color) + if (bitmap.get_pixel(position.x(), position.y()) != target_color) continue; - bitmap.set_pixel(position.x(), position.y(), fill_color); + bitmap.set_pixel(position.x(), position.y(), fill_color); if (position.x() != 0) queue.enqueue(position.translated(-1, 0)); diff --git a/Applications/PaintBrush/EraseTool.cpp b/Applications/PaintBrush/EraseTool.cpp index aa02fbaf20..7bd2a2eb20 100644 --- a/Applications/PaintBrush/EraseTool.cpp +++ b/Applications/PaintBrush/EraseTool.cpp @@ -29,6 +29,7 @@ #include #include #include +#include EraseTool::EraseTool() { diff --git a/Applications/PaintBrush/PaintableWidget.cpp b/Applications/PaintBrush/PaintableWidget.cpp index 5ea6f89884..2fe9b26f8f 100644 --- a/Applications/PaintBrush/PaintableWidget.cpp +++ b/Applications/PaintBrush/PaintableWidget.cpp @@ -47,7 +47,7 @@ PaintableWidget::PaintableWidget(GUI::Widget* parent) pal.set_color(ColorRole::Window, Color::MidGray); set_palette(pal); set_background_color(Color::MidGray); - m_bitmap = Gfx::Bitmap::create(Gfx::Bitmap::Format::RGB32, { 600, 400 }); + m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, { 600, 400 }); m_bitmap->fill(Color::White); } diff --git a/Applications/PaintBrush/SprayTool.cpp b/Applications/PaintBrush/SprayTool.cpp index 9f29c056bf..2d56bd8d1d 100644 --- a/Applications/PaintBrush/SprayTool.cpp +++ b/Applications/PaintBrush/SprayTool.cpp @@ -70,7 +70,7 @@ void SprayTool::paint_it() continue; if (ypos < 0 || ypos >= bitmap.height()) continue; - bitmap.set_pixel(xpos, ypos, m_color); + bitmap.set_pixel(xpos, ypos, m_color); } } diff --git a/Applications/QuickShow/main.cpp b/Applications/QuickShow/main.cpp index ce8bbf7771..df90187b08 100644 --- a/Applications/QuickShow/main.cpp +++ b/Applications/QuickShow/main.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include int main(int argc, char** argv) diff --git a/Applications/SystemMonitor/ProcessModel.cpp b/Applications/SystemMonitor/ProcessModel.cpp index 280042622f..f614705e06 100644 --- a/Applications/SystemMonitor/ProcessModel.cpp +++ b/Applications/SystemMonitor/ProcessModel.cpp @@ -269,7 +269,7 @@ GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, Role role) const if (thread.current_state.icon_id != -1) { auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(thread.current_state.icon_id); if (icon_buffer) { - auto icon_bitmap = Gfx::Bitmap::create_with_shared_buffer(Gfx::Bitmap::Format::RGBA32, *icon_buffer, { 16, 16 }); + auto icon_bitmap = Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *icon_buffer, { 16, 16 }); if (icon_bitmap) return *icon_bitmap; } diff --git a/Applications/Taskbar/TaskbarWindow.cpp b/Applications/Taskbar/TaskbarWindow.cpp index 04037f7760..3bfd500e88 100644 --- a/Applications/Taskbar/TaskbarWindow.cpp +++ b/Applications/Taskbar/TaskbarWindow.cpp @@ -179,7 +179,7 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event) if (auto* window = WindowList::the().window(identifier)) { auto buffer = SharedBuffer::create_from_shared_buffer_id(changed_event.icon_buffer_id()); ASSERT(buffer); - window->button()->set_icon(Gfx::Bitmap::create_with_shared_buffer(Gfx::Bitmap::Format::RGBA32, *buffer, changed_event.icon_size())); + window->button()->set_icon(Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *buffer, changed_event.icon_size())); } break; } diff --git a/Applications/TextEditor/main.cpp b/Applications/TextEditor/main.cpp index dd94f70d43..4d33acfefe 100644 --- a/Applications/TextEditor/main.cpp +++ b/Applications/TextEditor/main.cpp @@ -25,6 +25,7 @@ */ #include "TextEditorWidget.h" +#include #include int main(int argc, char** argv) diff --git a/Demos/Fire/Fire.cpp b/Demos/Fire/Fire.cpp index 65f3400a98..9b590c32e3 100644 --- a/Demos/Fire/Fire.cpp +++ b/Demos/Fire/Fire.cpp @@ -114,7 +114,7 @@ private: Fire::Fire(GUI::Widget* parent) : GUI::Widget(parent) { - bitmap = Gfx::Bitmap::create(Gfx::Bitmap::Format::Indexed8, { 320, 200 }); + bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::Indexed8, { 320, 200 }); /* Initialize fire palette */ for (int i = 0; i < 30; i++) diff --git a/Libraries/LibGUI/Action.cpp b/Libraries/LibGUI/Action.cpp index f0a34fef54..03f136642f 100644 --- a/Libraries/LibGUI/Action.cpp +++ b/Libraries/LibGUI/Action.cpp @@ -34,80 +34,80 @@ namespace GUI { namespace CommonActions { -NonnullRefPtr make_open_action(Function callback, Core::Object* parent) -{ - return Action::create("Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent); -} + NonnullRefPtr make_open_action(Function callback, Core::Object* parent) + { + return Action::create("Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent); + } -NonnullRefPtr make_move_to_front_action(Function callback, Core::Object* parent) -{ - return Action::create("Move to front", { Mod_Ctrl | Mod_Shift, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent); -} + NonnullRefPtr make_move_to_front_action(Function callback, Core::Object* parent) + { + return Action::create("Move to front", { Mod_Ctrl | Mod_Shift, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent); + } -NonnullRefPtr make_move_to_back_action(Function callback, Core::Object* parent) -{ - return Action::create("Move to back", { Mod_Ctrl | Mod_Shift, Key_Down }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent); -} + NonnullRefPtr make_move_to_back_action(Function callback, Core::Object* parent) + { + return Action::create("Move to back", { Mod_Ctrl | Mod_Shift, Key_Down }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent); + } -NonnullRefPtr make_undo_action(Function callback, Core::Object* parent) -{ - return Action::create("Undo", { Mod_Ctrl, Key_Z }, Gfx::Bitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), parent); -} + NonnullRefPtr make_undo_action(Function callback, Core::Object* parent) + { + return Action::create("Undo", { Mod_Ctrl, Key_Z }, Gfx::Bitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), parent); + } -NonnullRefPtr make_redo_action(Function callback, Core::Object* parent) -{ - return Action::create("Redo", { Mod_Ctrl, Key_Y }, Gfx::Bitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), parent); -} + NonnullRefPtr make_redo_action(Function callback, Core::Object* parent) + { + return Action::create("Redo", { Mod_Ctrl, Key_Y }, Gfx::Bitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), parent); + } -NonnullRefPtr make_delete_action(Function callback, Core::Object* parent) -{ - return Action::create("Delete", { Mod_None, Key_Delete }, Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), parent); -} + NonnullRefPtr make_delete_action(Function callback, Core::Object* parent) + { + return Action::create("Delete", { Mod_None, Key_Delete }, Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), parent); + } -NonnullRefPtr make_cut_action(Function callback, Core::Object* parent) -{ - return Action::create("Cut", { Mod_Ctrl, Key_X }, Gfx::Bitmap::load_from_file("/res/icons/cut16.png"), move(callback), parent); -} + NonnullRefPtr make_cut_action(Function callback, Core::Object* parent) + { + return Action::create("Cut", { Mod_Ctrl, Key_X }, Gfx::Bitmap::load_from_file("/res/icons/cut16.png"), move(callback), parent); + } -NonnullRefPtr make_copy_action(Function callback, Core::Object* parent) -{ - return Action::create("Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent); -} + NonnullRefPtr make_copy_action(Function callback, Core::Object* parent) + { + return Action::create("Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent); + } -NonnullRefPtr make_paste_action(Function callback, Core::Object* parent) -{ - return Action::create("Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/paste16.png"), move(callback), parent); -} + NonnullRefPtr make_paste_action(Function callback, Core::Object* parent) + { + return Action::create("Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/paste16.png"), move(callback), parent); + } -NonnullRefPtr make_fullscreen_action(Function callback, Core::Object* parent) -{ - return Action::create("Fullscreen", { Mod_None, Key_F11 }, move(callback), parent); -} + NonnullRefPtr make_fullscreen_action(Function callback, Core::Object* parent) + { + return Action::create("Fullscreen", { Mod_None, Key_F11 }, move(callback), parent); + } -NonnullRefPtr make_quit_action(Function callback) -{ - return Action::create("Quit", { Mod_Alt, Key_F4 }, move(callback)); -} + NonnullRefPtr make_quit_action(Function callback) + { + return Action::create("Quit", { Mod_Alt, Key_F4 }, move(callback)); + } -NonnullRefPtr make_go_back_action(Function callback, Core::Object* parent) -{ - return Action::create("Go back", { Mod_Alt, Key_Left }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent); -} + NonnullRefPtr make_go_back_action(Function callback, Core::Object* parent) + { + return Action::create("Go back", { Mod_Alt, Key_Left }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent); + } -NonnullRefPtr make_go_forward_action(Function callback, Core::Object* parent) -{ - return Action::create("Go forward", { Mod_Alt, Key_Right }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent); -} + NonnullRefPtr make_go_forward_action(Function callback, Core::Object* parent) + { + return Action::create("Go forward", { Mod_Alt, Key_Right }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent); + } -NonnullRefPtr make_go_home_action(Function callback, Core::Object* parent) -{ - return Action::create("Go home", { Mod_Alt, Key_Home }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent); -} + NonnullRefPtr make_go_home_action(Function callback, Core::Object* parent) + { + return Action::create("Go home", { Mod_Alt, Key_Home }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent); + } -NonnullRefPtr make_reload_action(Function callback, Core::Object* parent) -{ - return Action::create("Reload", { Mod_Ctrl, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"), move(callback), parent); -} + NonnullRefPtr make_reload_action(Function callback, Core::Object* parent) + { + return Action::create("Reload", { Mod_Ctrl, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"), move(callback), parent); + } } @@ -239,4 +239,9 @@ void Action::set_group(Badge, ActionGroup* group) m_action_group = group ? group->make_weak_ptr() : nullptr; } +void Action::set_icon(const Gfx::Bitmap* icon) +{ + m_icon = icon; +} + } diff --git a/Libraries/LibGUI/Action.h b/Libraries/LibGUI/Action.h index d3b7a52ceb..ba1688c0e9 100644 --- a/Libraries/LibGUI/Action.h +++ b/Libraries/LibGUI/Action.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -93,7 +93,7 @@ public: String text() const { return m_text; } Shortcut shortcut() const { return m_shortcut; } const Gfx::Bitmap* icon() const { return m_icon.ptr(); } - void set_icon(const Gfx::Bitmap* icon) { m_icon = icon; } + void set_icon(const Gfx::Bitmap*); const Core::Object* activator() const { return m_activator.ptr(); } Core::Object* activator() { return m_activator.ptr(); } diff --git a/Libraries/LibGUI/DragOperation.cpp b/Libraries/LibGUI/DragOperation.cpp index 81a1a8729d..bd85629126 100644 --- a/Libraries/LibGUI/DragOperation.cpp +++ b/Libraries/LibGUI/DragOperation.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include diff --git a/Libraries/LibGUI/Menu.cpp b/Libraries/LibGUI/Menu.cpp index eefce0c871..cc5455a6b0 100644 --- a/Libraries/LibGUI/Menu.cpp +++ b/Libraries/LibGUI/Menu.cpp @@ -25,10 +25,12 @@ */ #include +#include #include #include #include #include +#include //#define MENU_DEBUG @@ -123,12 +125,12 @@ int Menu::realize_menu() auto& action = *item.action(); int icon_buffer_id = -1; if (action.icon()) { - ASSERT(action.icon()->format() == Gfx::Bitmap::Format::RGBA32); + ASSERT(action.icon()->format() == Gfx::BitmapFormat::RGBA32); ASSERT(action.icon()->size() == Gfx::Size(16, 16)); if (action.icon()->shared_buffer_id() == -1) { auto shared_buffer = SharedBuffer::create_with_size(action.icon()->size_in_bytes()); ASSERT(shared_buffer); - auto shared_icon = Gfx::Bitmap::create_with_shared_buffer(Gfx::Bitmap::Format::RGBA32, *shared_buffer, action.icon()->size()); + auto shared_icon = Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *shared_buffer, action.icon()->size()); memcpy(shared_buffer->data(), action.icon()->bits(0), action.icon()->size_in_bytes()); shared_buffer->seal(); shared_buffer->share_with(WindowServerConnection::the().server_pid()); diff --git a/Libraries/LibGUI/Painter.cpp b/Libraries/LibGUI/Painter.cpp index 0dd3e3fbcb..c0c2720c40 100644 --- a/Libraries/LibGUI/Painter.cpp +++ b/Libraries/LibGUI/Painter.cpp @@ -27,6 +27,7 @@ #include #include #include +#include namespace GUI { Painter::Painter(Gfx::Bitmap& bitmap) diff --git a/Libraries/LibGUI/TextEditor.cpp b/Libraries/LibGUI/TextEditor.cpp index 6353357869..ea106cd502 100644 --- a/Libraries/LibGUI/TextEditor.cpp +++ b/Libraries/LibGUI/TextEditor.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibGUI/Window.cpp b/Libraries/LibGUI/Window.cpp index ca05ff9f17..4222de9ea1 100644 --- a/Libraries/LibGUI/Window.cpp +++ b/Libraries/LibGUI/Window.cpp @@ -493,7 +493,7 @@ void Window::flip(const Vector& dirty_rects) m_back_bitmap->shared_buffer()->set_volatile(); } -NonnullRefPtr Window::create_shared_bitmap(Gfx::Bitmap::Format format, const Gfx::Size& size) +NonnullRefPtr Window::create_shared_bitmap(Gfx::BitmapFormat format, const Gfx::Size& size) { ASSERT(WindowServerConnection::the().server_pid()); ASSERT(!size.is_empty()); @@ -507,7 +507,7 @@ NonnullRefPtr Window::create_shared_bitmap(Gfx::Bitmap::Format form NonnullRefPtr Window::create_backing_bitmap(const Gfx::Size& size) { - auto format = m_has_alpha_channel ? Gfx::Bitmap::Format::RGBA32 : Gfx::Bitmap::Format::RGB32; + auto format = m_has_alpha_channel ? Gfx::BitmapFormat::RGBA32 : Gfx::BitmapFormat::RGB32; return create_shared_bitmap(format, size); } @@ -526,7 +526,7 @@ void Window::set_icon(const Gfx::Bitmap* icon) if (m_icon == icon) return; - m_icon = create_shared_bitmap(Gfx::Bitmap::Format::RGBA32, icon->size()); + m_icon = create_shared_bitmap(Gfx::BitmapFormat::RGBA32, icon->size()); { Painter painter(*m_icon); painter.blit({ 0, 0 }, *icon, icon->rect()); diff --git a/Libraries/LibGUI/Window.h b/Libraries/LibGUI/Window.h index 625a02d960..55b2856762 100644 --- a/Libraries/LibGUI/Window.h +++ b/Libraries/LibGUI/Window.h @@ -32,7 +32,8 @@ #include #include #include -#include +#include +#include #include namespace GUI { @@ -184,7 +185,7 @@ private: virtual bool is_window() const override final { return true; } NonnullRefPtr create_backing_bitmap(const Gfx::Size&); - NonnullRefPtr create_shared_bitmap(Gfx::Bitmap::Format, const Gfx::Size&); + NonnullRefPtr create_shared_bitmap(Gfx::BitmapFormat, const Gfx::Size&); void set_current_backing_bitmap(Gfx::Bitmap&, bool flush_immediately = false); void flip(const Vector& dirty_rects); diff --git a/Libraries/LibGUI/WindowServerConnection.cpp b/Libraries/LibGUI/WindowServerConnection.cpp index d1a17570e2..df0dab8df9 100644 --- a/Libraries/LibGUI/WindowServerConnection.cpp +++ b/Libraries/LibGUI/WindowServerConnection.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -35,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/Libraries/LibGfx/Bitmap.cpp b/Libraries/LibGfx/Bitmap.cpp index 6b3a54caa4..e64913ddbf 100644 --- a/Libraries/LibGfx/Bitmap.cpp +++ b/Libraries/LibGfx/Bitmap.cpp @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include #include @@ -35,24 +35,24 @@ namespace Gfx { -NonnullRefPtr Bitmap::create(Format format, const Size& size) +NonnullRefPtr Bitmap::create(BitmapFormat format, const Size& size) { return adopt(*new Bitmap(format, size, Purgeable::No)); } -NonnullRefPtr Bitmap::create_purgeable(Format format, const Size& size) +NonnullRefPtr Bitmap::create_purgeable(BitmapFormat format, const Size& size) { return adopt(*new Bitmap(format, size, Purgeable::Yes)); } -Bitmap::Bitmap(Format format, const Size& size, Purgeable purgeable) +Bitmap::Bitmap(BitmapFormat format, const Size& size, Purgeable purgeable) : m_size(size) , m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16)) , m_format(format) , m_purgeable(purgeable == Purgeable::Yes) { ASSERT(!m_size.is_empty()); - if (format == Format::Indexed8) + if (format == BitmapFormat::Indexed8) m_palette = new RGBA32[256]; int map_flags = purgeable == Purgeable::Yes ? (MAP_PURGEABLE | MAP_PRIVATE) : (MAP_ANONYMOUS | MAP_PRIVATE); m_data = (RGBA32*)mmap_with_name(nullptr, size_in_bytes(), PROT_READ | PROT_WRITE, map_flags, 0, 0, String::format("GraphicsBitmap [%dx%d]", width(), height()).characters()); @@ -60,7 +60,7 @@ Bitmap::Bitmap(Format format, const Size& size, Purgeable purgeable) m_needs_munmap = true; } -NonnullRefPtr Bitmap::create_wrapper(Format format, const Size& size, size_t pitch, RGBA32* data) +NonnullRefPtr Bitmap::create_wrapper(BitmapFormat format, const Size& size, size_t pitch, RGBA32* data) { return adopt(*new Bitmap(format, size, pitch, data)); } @@ -70,7 +70,7 @@ RefPtr Bitmap::load_from_file(const StringView& path) return load_png(path); } -RefPtr Bitmap::load_from_file(Format format, const StringView& path, const Size& size) +RefPtr Bitmap::load_from_file(BitmapFormat format, const StringView& path, const Size& size) { MappedFile mapped_file(path); if (!mapped_file.is_valid()) @@ -78,39 +78,39 @@ RefPtr Bitmap::load_from_file(Format format, const StringView& path, con return adopt(*new Bitmap(format, size, move(mapped_file))); } -Bitmap::Bitmap(Format format, const Size& size, size_t pitch, RGBA32* data) +Bitmap::Bitmap(BitmapFormat format, const Size& size, size_t pitch, RGBA32* data) : m_size(size) , m_data(data) , m_pitch(pitch) , m_format(format) { - if (format == Format::Indexed8) + if (format == BitmapFormat::Indexed8) m_palette = new RGBA32[256]; } -Bitmap::Bitmap(Format format, const Size& size, MappedFile&& mapped_file) +Bitmap::Bitmap(BitmapFormat format, const Size& size, MappedFile&& mapped_file) : m_size(size) , m_data((RGBA32*)mapped_file.data()) , m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16)) , m_format(format) , m_mapped_file(move(mapped_file)) { - ASSERT(format != Format::Indexed8); + ASSERT(format != BitmapFormat::Indexed8); } -NonnullRefPtr Bitmap::create_with_shared_buffer(Format format, NonnullRefPtr&& shared_buffer, const Size& size) +NonnullRefPtr Bitmap::create_with_shared_buffer(BitmapFormat format, NonnullRefPtr&& shared_buffer, const Size& size) { return adopt(*new Bitmap(format, move(shared_buffer), size)); } -Bitmap::Bitmap(Format format, NonnullRefPtr&& shared_buffer, const Size& size) +Bitmap::Bitmap(BitmapFormat format, NonnullRefPtr&& shared_buffer, const Size& size) : m_size(size) , m_data((RGBA32*)shared_buffer->data()) , m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16)) , m_format(format) , m_shared_buffer(move(shared_buffer)) { - ASSERT(format != Format::Indexed8); + ASSERT(format != BitmapFormat::Indexed8); } NonnullRefPtr Bitmap::to_shareable_bitmap() const @@ -141,7 +141,7 @@ void Bitmap::set_mmap_name(const StringView& name) void Bitmap::fill(Color color) { - ASSERT(m_format == Bitmap::Format::RGB32 || m_format == Bitmap::Format::RGBA32); + ASSERT(m_format == BitmapFormat::RGB32 || m_format == BitmapFormat::RGBA32); for (int y = 0; y < height(); ++y) { auto* scanline = this->scanline(y); fast_u32_fill(scanline, color.value(), width()); @@ -175,4 +175,9 @@ void Bitmap::set_volatile() return rc == 0; } +int Bitmap::shared_buffer_id() const +{ + return m_shared_buffer ? m_shared_buffer->shared_buffer_id() : -1; +} + } diff --git a/Libraries/LibGfx/Bitmap.h b/Libraries/LibGfx/Bitmap.h index 7c64eafd1b..5dec6a2f78 100644 --- a/Libraries/LibGfx/Bitmap.h +++ b/Libraries/LibGfx/Bitmap.h @@ -26,33 +26,32 @@ #pragma once -#include "Color.h" -#include "Rect.h" -#include "Size.h" +#include #include #include #include -#include #include -#include +#include +#include +#include namespace Gfx { +enum class BitmapFormat { + Invalid, + RGB32, + RGBA32, + Indexed8 +}; + class Bitmap : public RefCounted { public: - enum class Format { - Invalid, - RGB32, - RGBA32, - Indexed8 - }; - - static NonnullRefPtr create(Format, const Size&); - static NonnullRefPtr create_purgeable(Format, const Size&); - static NonnullRefPtr create_wrapper(Format, const Size&, size_t pitch, RGBA32*); + static NonnullRefPtr create(BitmapFormat, const Size&); + static NonnullRefPtr create_purgeable(BitmapFormat, const Size&); + static NonnullRefPtr create_wrapper(BitmapFormat, const Size&, size_t pitch, RGBA32*); static RefPtr load_from_file(const StringView& path); - static RefPtr load_from_file(Format, const StringView& path, const Size&); - static NonnullRefPtr create_with_shared_buffer(Format, NonnullRefPtr&&, const Size&); + static RefPtr load_from_file(BitmapFormat, const StringView& path, const Size&); + static NonnullRefPtr create_with_shared_buffer(BitmapFormat, NonnullRefPtr&&, const Size&); NonnullRefPtr to_shareable_bitmap() const; @@ -69,7 +68,7 @@ public: int width() const { return m_size.width(); } int height() const { return m_size.height(); } size_t pitch() const { return m_pitch; } - int shared_buffer_id() const { return m_shared_buffer ? m_shared_buffer->shared_buffer_id() : -1; } + int shared_buffer_id() const; SharedBuffer* shared_buffer() { return m_shared_buffer.ptr(); } const SharedBuffer* shared_buffer() const { return m_shared_buffer.ptr(); } @@ -77,22 +76,22 @@ public: unsigned bpp() const { switch (m_format) { - case Format::Indexed8: + case BitmapFormat::Indexed8: return 8; - case Format::RGB32: - case Format::RGBA32: + case BitmapFormat::RGB32: + case BitmapFormat::RGBA32: return 32; default: ASSERT_NOT_REACHED(); - case Format::Invalid: + case BitmapFormat::Invalid: return 0; } } void fill(Color); - bool has_alpha_channel() const { return m_format == Format::RGBA32; } - Format format() const { return m_format; } + bool has_alpha_channel() const { return m_format == BitmapFormat::RGBA32; } + BitmapFormat format() const { return m_format; } void set_mmap_name(const StringView&); @@ -101,7 +100,7 @@ public: Color palette_color(u8 index) const { return Color::from_rgba(m_palette[index]); } void set_palette_color(u8 index, Color color) { m_palette[index] = color.value(); } - template + template Color get_pixel(int x, int y) const { (void)x; @@ -116,7 +115,7 @@ public: return get_pixel(position.x(), position.y()); } - template + template void set_pixel(int x, int y, Color) { (void)x; @@ -139,16 +138,16 @@ public: private: enum class Purgeable { No, Yes }; - Bitmap(Format, const Size&, Purgeable); - Bitmap(Format, const Size&, size_t pitch, RGBA32*); - Bitmap(Format, const Size&, MappedFile&&); - Bitmap(Format, NonnullRefPtr&&, const Size&); + Bitmap(BitmapFormat, const Size&, Purgeable); + Bitmap(BitmapFormat, const Size&, size_t pitch, RGBA32*); + Bitmap(BitmapFormat, const Size&, MappedFile&&); + Bitmap(BitmapFormat, NonnullRefPtr&&, const Size&); Size m_size; RGBA32* m_data { nullptr }; RGBA32* m_palette { nullptr }; size_t m_pitch { 0 }; - Format m_format { Format::Invalid }; + BitmapFormat m_format { BitmapFormat::Invalid }; bool m_needs_munmap { false }; bool m_purgeable { false }; bool m_volatile { false }; @@ -177,19 +176,19 @@ inline u8* Bitmap::bits(int y) } template<> -inline Color Bitmap::get_pixel(int x, int y) const +inline Color Bitmap::get_pixel(int x, int y) const { return Color::from_rgb(scanline(y)[x]); } template<> -inline Color Bitmap::get_pixel(int x, int y) const +inline Color Bitmap::get_pixel(int x, int y) const { return Color::from_rgba(scanline(y)[x]); } template<> -inline Color Bitmap::get_pixel(int x, int y) const +inline Color Bitmap::get_pixel(int x, int y) const { return Color::from_rgba(m_palette[bits(y)[x]]); } @@ -197,12 +196,12 @@ inline Color Bitmap::get_pixel(int x, int y) const inline Color Bitmap::get_pixel(int x, int y) const { switch (m_format) { - case Format::RGB32: - return get_pixel(x, y); - case Format::RGBA32: - return get_pixel(x, y); - case Format::Indexed8: - return get_pixel(x, y); + case BitmapFormat::RGB32: + return get_pixel(x, y); + case BitmapFormat::RGBA32: + return get_pixel(x, y); + case BitmapFormat::Indexed8: + return get_pixel(x, y); default: ASSERT_NOT_REACHED(); return {}; @@ -210,13 +209,13 @@ inline Color Bitmap::get_pixel(int x, int y) const } template<> -inline void Bitmap::set_pixel(int x, int y, Color color) +inline void Bitmap::set_pixel(int x, int y, Color color) { scanline(y)[x] = color.value(); } template<> -inline void Bitmap::set_pixel(int x, int y, Color color) +inline void Bitmap::set_pixel(int x, int y, Color color) { scanline(y)[x] = color.value(); } @@ -224,13 +223,13 @@ inline void Bitmap::set_pixel(int x, int y, Color color) inline void Bitmap::set_pixel(int x, int y, Color color) { switch (m_format) { - case Format::RGB32: - set_pixel(x, y, color); + case BitmapFormat::RGB32: + set_pixel(x, y, color); break; - case Format::RGBA32: - set_pixel(x, y, color); + case BitmapFormat::RGBA32: + set_pixel(x, y, color); break; - case Format::Indexed8: + case BitmapFormat::Indexed8: ASSERT_NOT_REACHED(); default: ASSERT_NOT_REACHED(); diff --git a/Libraries/LibGfx/Forward.h b/Libraries/LibGfx/Forward.h new file mode 100644 index 0000000000..cef4ce84c7 --- /dev/null +++ b/Libraries/LibGfx/Forward.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2020, Andreas Kling + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +namespace Gfx { + +class Bitmap; +class CharacterBitmap; +class Color; +class DisjointRectSet; +class FloatPoint; +class FloatRect; +class FloatSize; +class Font; +class Painter; +class Palette; +class Point; +class Rect; +class Size; +class StylePainter; +class SystemTheme; +class Triangle; + +enum class BitmapFormat; + +} + +using Gfx::Color; diff --git a/Libraries/LibGfx/PNGLoader.cpp b/Libraries/LibGfx/PNGLoader.cpp index 863c63d806..d425f24a49 100644 --- a/Libraries/LibGfx/PNGLoader.cpp +++ b/Libraries/LibGfx/PNGLoader.cpp @@ -520,7 +520,7 @@ static bool decode_png_bitmap(PNGLoadingContext& context) } } - context.bitmap = Bitmap::create_purgeable(context.has_alpha() ? Bitmap::Format::RGBA32 : Bitmap::Format::RGB32, { context.width, context.height }); + context.bitmap = Bitmap::create_purgeable(context.has_alpha() ? BitmapFormat::RGBA32 : BitmapFormat::RGB32, { context.width, context.height }); unfilter(context); diff --git a/Libraries/LibGfx/Painter.cpp b/Libraries/LibGfx/Painter.cpp index c6b0091bc5..2e85a5184f 100644 --- a/Libraries/LibGfx/Painter.cpp +++ b/Libraries/LibGfx/Painter.cpp @@ -51,14 +51,14 @@ namespace Gfx { -template +template static ALWAYS_INLINE Color get_pixel(const Gfx::Bitmap& bitmap, int x, int y) { - if constexpr (format == Bitmap::Format::Indexed8) + if constexpr (format == BitmapFormat::Indexed8) return bitmap.palette_color(bitmap.bits(y)[x]); - if constexpr (format == Bitmap::Format::RGB32) + if constexpr (format == BitmapFormat::RGB32) return Color::from_rgb(bitmap.scanline(y)[x]); - if constexpr (format == Bitmap::Format::RGBA32) + if constexpr (format == BitmapFormat::RGBA32) return Color::from_rgba(bitmap.scanline(y)[x]); return bitmap.get_pixel(x, y); } @@ -399,7 +399,7 @@ void Painter::draw_tiled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& sourc RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x(); const size_t dst_skip = m_target->pitch() / sizeof(RGBA32); - if (source.format() == Bitmap::Format::RGB32 || source.format() == Bitmap::Format::RGBA32) { + if (source.format() == BitmapFormat::RGB32 || source.format() == BitmapFormat::RGBA32) { int x_start = first_column + a_dst_rect.left(); for (int row = first_row; row <= last_row; ++row) { const RGBA32* sl = source.scanline((row + a_dst_rect.top()) @@ -430,7 +430,7 @@ void Painter::blit_offset(const Point& position, RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x(); const size_t dst_skip = m_target->pitch() / sizeof(RGBA32); - if (source.format() == Bitmap::Format::RGB32 || source.format() == Bitmap::Format::RGBA32) { + if (source.format() == BitmapFormat::RGB32 || source.format() == BitmapFormat::RGBA32) { int x_start = first_column + src_rect.left(); for (int row = first_row; row <= last_row; ++row) { int sr = row - offset.y() + src_rect.top(); @@ -502,7 +502,7 @@ void Painter::blit(const Point& position, const Gfx::Bitmap& source, const Rect& RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x(); const size_t dst_skip = m_target->pitch() / sizeof(RGBA32); - if (source.format() == Bitmap::Format::RGB32 || source.format() == Bitmap::Format::RGBA32) { + if (source.format() == BitmapFormat::RGB32 || source.format() == BitmapFormat::RGBA32) { const RGBA32* src = source.scanline(src_rect.top() + first_row) + src_rect.left() + first_column; const size_t src_skip = source.pitch() / sizeof(RGBA32); for (int row = first_row; row <= last_row; ++row) { @@ -513,7 +513,7 @@ void Painter::blit(const Point& position, const Gfx::Bitmap& source, const Rect& return; } - if (source.format() == Bitmap::Format::Indexed8) { + if (source.format() == BitmapFormat::Indexed8) { const u8* src = source.bits(src_rect.top() + first_row) + src_rect.left() + first_column; const size_t src_skip = source.pitch(); for (int row = first_row; row <= last_row; ++row) { @@ -597,32 +597,32 @@ void Painter::draw_scaled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& sour if (source.has_alpha_channel()) { switch (source.format()) { - case Bitmap::Format::RGB32: - do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); + case BitmapFormat::RGB32: + do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); break; - case Bitmap::Format::RGBA32: - do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); + case BitmapFormat::RGBA32: + do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); break; - case Bitmap::Format::Indexed8: - do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); + case BitmapFormat::Indexed8: + do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); break; default: - do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); + do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); break; } } else { switch (source.format()) { - case Bitmap::Format::RGB32: - do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); + case BitmapFormat::RGB32: + do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); break; - case Bitmap::Format::RGBA32: - do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); + case BitmapFormat::RGBA32: + do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); break; - case Bitmap::Format::Indexed8: - do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); + case BitmapFormat::Indexed8: + do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); break; default: - do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); + do_draw_scaled_bitmap(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel); break; } } diff --git a/Libraries/LibGfx/Palette.cpp b/Libraries/LibGfx/Palette.cpp index 928387cb97..904b7722ab 100644 --- a/Libraries/LibGfx/Palette.cpp +++ b/Libraries/LibGfx/Palette.cpp @@ -24,6 +24,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#include #include namespace Gfx { @@ -73,4 +75,13 @@ void Palette::set_color(ColorRole role, Color color) theme.color[(int)role] = color; } +PaletteImpl::~PaletteImpl() +{ +} + +void PaletteImpl::replace_internal_buffer(Badge, SharedBuffer& buffer) +{ + m_theme_buffer = buffer; +} + } diff --git a/Libraries/LibGfx/Palette.h b/Libraries/LibGfx/Palette.h index 76c7db2826..c0c5ae9abe 100644 --- a/Libraries/LibGfx/Palette.h +++ b/Libraries/LibGfx/Palette.h @@ -26,7 +26,7 @@ #pragma once -#include +#include #include #include @@ -40,13 +40,14 @@ class PaletteImpl : public RefCounted { AK_MAKE_NONCOPYABLE(PaletteImpl) AK_MAKE_NONMOVABLE(PaletteImpl) public: + ~PaletteImpl(); static NonnullRefPtr create_with_shared_buffer(SharedBuffer&); NonnullRefPtr clone() const; Color color(ColorRole) const; const SystemTheme& theme() const; - void replace_internal_buffer(Badge, SharedBuffer& buffer) { m_theme_buffer = buffer; } + void replace_internal_buffer(Badge, SharedBuffer& buffer); private: explicit PaletteImpl(SharedBuffer&); diff --git a/Libraries/LibGfx/SystemTheme.cpp b/Libraries/LibGfx/SystemTheme.cpp index 49e84ea136..8ae4be8df7 100644 --- a/Libraries/LibGfx/SystemTheme.cpp +++ b/Libraries/LibGfx/SystemTheme.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include diff --git a/Libraries/LibGfx/SystemTheme.h b/Libraries/LibGfx/SystemTheme.h index ae27b84113..4747209e52 100644 --- a/Libraries/LibGfx/SystemTheme.h +++ b/Libraries/LibGfx/SystemTheme.h @@ -26,7 +26,7 @@ #pragma once -#include +#include #include #include diff --git a/MenuApplets/Audio/main.cpp b/MenuApplets/Audio/main.cpp index 130ac832f0..a2d310914e 100644 --- a/MenuApplets/Audio/main.cpp +++ b/MenuApplets/Audio/main.cpp @@ -29,6 +29,7 @@ #include #include #include +#include class AudioWidget final : public GUI::Widget { C_OBJECT(AudioWidget) diff --git a/Servers/WindowServer/ClientConnection.cpp b/Servers/WindowServer/ClientConnection.cpp index a29ea584e9..db0db313ba 100644 --- a/Servers/WindowServer/ClientConnection.cpp +++ b/Servers/WindowServer/ClientConnection.cpp @@ -196,7 +196,7 @@ OwnPtr ClientConnection::handle(con if (!icon_buffer) return nullptr; // FIXME: Verify that the icon buffer can accomodate a 16x16 bitmap view. - auto shared_icon = Gfx::Bitmap::create_with_shared_buffer(Gfx::Bitmap::Format::RGBA32, icon_buffer.release_nonnull(), { 16, 16 }); + auto shared_icon = Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, icon_buffer.release_nonnull(), { 16, 16 }); menu_item->set_icon(shared_icon); } menu_item->set_submenu_id(message.submenu_id()); @@ -354,7 +354,7 @@ OwnPtr ClientConnection::ha if (!icon_buffer) { window.set_default_icon(); } else { - window.set_icon(Gfx::Bitmap::create_with_shared_buffer(Gfx::Bitmap::Format::RGBA32, *icon_buffer, message.icon_size())); + window.set_icon(Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *icon_buffer, message.icon_size())); } window.frame().invalidate_title_bar(); @@ -516,7 +516,7 @@ OwnPtr ClientConnection:: if (!shared_buffer) return make(); auto backing_store = Gfx::Bitmap::create_with_shared_buffer( - message.has_alpha_channel() ? Gfx::Bitmap::Format::RGBA32 : Gfx::Bitmap::Format::RGB32, + message.has_alpha_channel() ? Gfx::BitmapFormat::RGBA32 : Gfx::BitmapFormat::RGB32, *shared_buffer, message.size()); window.set_backing_store(move(backing_store)); @@ -675,7 +675,7 @@ OwnPtr ClientConnection::handle(const did_misbehave("SetAppletBackingStore: Shared buffer is too small for applet size"); return nullptr; } - bitmap = Gfx::Bitmap::create_with_shared_buffer(Gfx::Bitmap::Format::RGBA32, *shared_buffer, message.bitmap_size()); + bitmap = Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *shared_buffer, message.bitmap_size()); } wm.start_dnd_drag(*this, message.text(), bitmap, message.data_type(), message.data()); diff --git a/Servers/WindowServer/Compositor.cpp b/Servers/WindowServer/Compositor.cpp index b8c05174b3..1ac6ae01e4 100644 --- a/Servers/WindowServer/Compositor.cpp +++ b/Servers/WindowServer/Compositor.cpp @@ -89,12 +89,12 @@ void Compositor::init_bitmaps() auto& screen = Screen::the(); auto size = screen.size(); - m_front_bitmap = Gfx::Bitmap::create_wrapper(Gfx::Bitmap::Format::RGB32, size, screen.pitch(), screen.scanline(0)); + m_front_bitmap = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGB32, size, screen.pitch(), screen.scanline(0)); if (m_screen_can_set_buffer) - m_back_bitmap = Gfx::Bitmap::create_wrapper(Gfx::Bitmap::Format::RGB32, size, screen.pitch(), screen.scanline(size.height())); + m_back_bitmap = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGB32, size, screen.pitch(), screen.scanline(size.height())); else - m_back_bitmap = Gfx::Bitmap::create(Gfx::Bitmap::Format::RGB32, size); + m_back_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, size); m_front_painter = make(*m_front_bitmap); m_back_painter = make(*m_back_bitmap); diff --git a/Servers/WindowServer/Window.cpp b/Servers/WindowServer/Window.cpp index a322d72cdd..849773f747 100644 --- a/Servers/WindowServer/Window.cpp +++ b/Servers/WindowServer/Window.cpp @@ -103,7 +103,7 @@ void Window::set_rect(const Gfx::Rect& rect) old_rect = m_rect; m_rect = rect; if (!m_client && (!m_backing_store || old_rect.size() != rect.size())) { - m_backing_store = Gfx::Bitmap::create(Gfx::Bitmap::Format::RGB32, m_rect.size()); + m_backing_store = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, m_rect.size()); } m_frame.notify_window_rect_changed(old_rect, rect); } diff --git a/Servers/WindowServer/WindowManager.cpp b/Servers/WindowServer/WindowManager.cpp index 689cb5734c..d392c6afb9 100644 --- a/Servers/WindowServer/WindowManager.cpp +++ b/Servers/WindowServer/WindowManager.cpp @@ -33,6 +33,7 @@ #include "Screen.h" #include "Window.h" #include +#include #include #include #include diff --git a/Servers/WindowServer/main.cpp b/Servers/WindowServer/main.cpp index 935cc0d7e9..fa973c3b61 100644 --- a/Servers/WindowServer/main.cpp +++ b/Servers/WindowServer/main.cpp @@ -29,6 +29,7 @@ #include "EventLoop.h" #include "Screen.h" #include "WindowManager.h" +#include #include #include #include