mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
LibGfx: Add forward declaration header
This patch adds <LibGfx/Forward.h> with forward declarations for Gfx.
This commit is contained in:
parent
184475d45a
commit
3fe2640c8c
37 changed files with 264 additions and 172 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/MenuBar.h>
|
#include <LibGUI/MenuBar.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <LibGUI/MenuBar.h>
|
#include <LibGUI/MenuBar.h>
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/MenuBar.h>
|
#include <LibGUI/MenuBar.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "HexEditorWidget.h"
|
#include "HexEditorWidget.h"
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|
|
@ -52,9 +52,9 @@ static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::Point& start_position, Co
|
||||||
while (!queue.is_empty()) {
|
while (!queue.is_empty()) {
|
||||||
auto position = queue.dequeue();
|
auto position = queue.dequeue();
|
||||||
|
|
||||||
if (bitmap.get_pixel<Gfx::Bitmap::Format::RGB32>(position.x(), position.y()) != target_color)
|
if (bitmap.get_pixel<Gfx::BitmapFormat::RGB32>(position.x(), position.y()) != target_color)
|
||||||
continue;
|
continue;
|
||||||
bitmap.set_pixel<Gfx::Bitmap::Format::RGB32>(position.x(), position.y(), fill_color);
|
bitmap.set_pixel<Gfx::BitmapFormat::RGB32>(position.x(), position.y(), fill_color);
|
||||||
|
|
||||||
if (position.x() != 0)
|
if (position.x() != 0)
|
||||||
queue.enqueue(position.translated(-1, 0));
|
queue.enqueue(position.translated(-1, 0));
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/Menu.h>
|
#include <LibGUI/Menu.h>
|
||||||
#include <LibGUI/Painter.h>
|
#include <LibGUI/Painter.h>
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
|
|
||||||
EraseTool::EraseTool()
|
EraseTool::EraseTool()
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,7 @@ PaintableWidget::PaintableWidget(GUI::Widget* parent)
|
||||||
pal.set_color(ColorRole::Window, Color::MidGray);
|
pal.set_color(ColorRole::Window, Color::MidGray);
|
||||||
set_palette(pal);
|
set_palette(pal);
|
||||||
set_background_color(Color::MidGray);
|
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);
|
m_bitmap->fill(Color::White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ void SprayTool::paint_it()
|
||||||
continue;
|
continue;
|
||||||
if (ypos < 0 || ypos >= bitmap.height())
|
if (ypos < 0 || ypos >= bitmap.height())
|
||||||
continue;
|
continue;
|
||||||
bitmap.set_pixel<Gfx::Bitmap::Format::RGB32>(xpos, ypos, m_color);
|
bitmap.set_pixel<Gfx::BitmapFormat::RGB32>(xpos, ypos, m_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <LibGUI/Menu.h>
|
#include <LibGUI/Menu.h>
|
||||||
#include <LibGUI/MenuBar.h>
|
#include <LibGUI/MenuBar.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|
|
@ -269,7 +269,7 @@ GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, Role role) const
|
||||||
if (thread.current_state.icon_id != -1) {
|
if (thread.current_state.icon_id != -1) {
|
||||||
auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(thread.current_state.icon_id);
|
auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(thread.current_state.icon_id);
|
||||||
if (icon_buffer) {
|
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)
|
if (icon_bitmap)
|
||||||
return *icon_bitmap;
|
return *icon_bitmap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
|
||||||
if (auto* window = WindowList::the().window(identifier)) {
|
if (auto* window = WindowList::the().window(identifier)) {
|
||||||
auto buffer = SharedBuffer::create_from_shared_buffer_id(changed_event.icon_buffer_id());
|
auto buffer = SharedBuffer::create_from_shared_buffer_id(changed_event.icon_buffer_id());
|
||||||
ASSERT(buffer);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "TextEditorWidget.h"
|
#include "TextEditorWidget.h"
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|
|
@ -114,7 +114,7 @@ private:
|
||||||
Fire::Fire(GUI::Widget* parent)
|
Fire::Fire(GUI::Widget* parent)
|
||||||
: 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 */
|
/* Initialize fire palette */
|
||||||
for (int i = 0; i < 30; i++)
|
for (int i = 0; i < 30; i++)
|
||||||
|
|
|
@ -34,80 +34,80 @@ namespace GUI {
|
||||||
|
|
||||||
namespace CommonActions {
|
namespace CommonActions {
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_open_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_open_action(Function<void(Action&)> 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);
|
return Action::create("Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)> 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);
|
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<Action> make_move_to_back_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)> 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);
|
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<Action> make_undo_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_undo_action(Function<void(Action&)> 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);
|
return Action::create("Undo", { Mod_Ctrl, Key_Z }, Gfx::Bitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_redo_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_redo_action(Function<void(Action&)> 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);
|
return Action::create("Redo", { Mod_Ctrl, Key_Y }, Gfx::Bitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_delete_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_delete_action(Function<void(Action&)> 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);
|
return Action::create("Delete", { Mod_None, Key_Delete }, Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_cut_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_cut_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||||
{
|
{
|
||||||
return Action::create("Cut", { Mod_Ctrl, Key_X }, Gfx::Bitmap::load_from_file("/res/icons/cut16.png"), move(callback), parent);
|
return Action::create("Cut", { Mod_Ctrl, Key_X }, Gfx::Bitmap::load_from_file("/res/icons/cut16.png"), move(callback), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_copy_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_copy_action(Function<void(Action&)> 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);
|
return Action::create("Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_paste_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_paste_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||||
{
|
{
|
||||||
return Action::create("Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/paste16.png"), move(callback), parent);
|
return Action::create("Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/paste16.png"), move(callback), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_fullscreen_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_fullscreen_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||||
{
|
{
|
||||||
return Action::create("Fullscreen", { Mod_None, Key_F11 }, move(callback), parent);
|
return Action::create("Fullscreen", { Mod_None, Key_F11 }, move(callback), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_quit_action(Function<void(Action&)> callback)
|
NonnullRefPtr<Action> make_quit_action(Function<void(Action&)> callback)
|
||||||
{
|
{
|
||||||
return Action::create("Quit", { Mod_Alt, Key_F4 }, move(callback));
|
return Action::create("Quit", { Mod_Alt, Key_F4 }, move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)> 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);
|
return Action::create("Go back", { Mod_Alt, Key_Left }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)> 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);
|
return Action::create("Go forward", { Mod_Alt, Key_Right }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> 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);
|
return Action::create("Go home", { Mod_Alt, Key_Home }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Action> make_reload_action(Function<void(Action&)> callback, Core::Object* parent)
|
NonnullRefPtr<Action> make_reload_action(Function<void(Action&)> 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);
|
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>, ActionGroup* group)
|
||||||
m_action_group = group ? group->make_weak_ptr() : nullptr;
|
m_action_group = group ? group->make_weak_ptr() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Action::set_icon(const Gfx::Bitmap* icon)
|
||||||
|
{
|
||||||
|
m_icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/WeakPtr.h>
|
#include <AK/WeakPtr.h>
|
||||||
#include <AK/Weakable.h>
|
#include <AK/Weakable.h>
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Forward.h>
|
||||||
#include <LibGUI/Shortcut.h>
|
#include <LibGUI/Shortcut.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public:
|
||||||
String text() const { return m_text; }
|
String text() const { return m_text; }
|
||||||
Shortcut shortcut() const { return m_shortcut; }
|
Shortcut shortcut() const { return m_shortcut; }
|
||||||
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
|
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(); }
|
const Core::Object* activator() const { return m_activator.ptr(); }
|
||||||
Core::Object* activator() { return m_activator.ptr(); }
|
Core::Object* activator() { return m_activator.ptr(); }
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/Badge.h>
|
#include <AK/Badge.h>
|
||||||
|
#include <AK/SharedBuffer.h>
|
||||||
#include <LibGUI/DragOperation.h>
|
#include <LibGUI/DragOperation.h>
|
||||||
#include <LibGUI/WindowServerConnection.h>
|
#include <LibGUI/WindowServerConnection.h>
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Bitmap.h>
|
||||||
|
|
|
@ -25,10 +25,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/HashMap.h>
|
#include <AK/HashMap.h>
|
||||||
|
#include <AK/SharedBuffer.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/ActionGroup.h>
|
#include <LibGUI/ActionGroup.h>
|
||||||
#include <LibGUI/Menu.h>
|
#include <LibGUI/Menu.h>
|
||||||
#include <LibGUI/WindowServerConnection.h>
|
#include <LibGUI/WindowServerConnection.h>
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
|
|
||||||
//#define MENU_DEBUG
|
//#define MENU_DEBUG
|
||||||
|
|
||||||
|
@ -123,12 +125,12 @@ int Menu::realize_menu()
|
||||||
auto& action = *item.action();
|
auto& action = *item.action();
|
||||||
int icon_buffer_id = -1;
|
int icon_buffer_id = -1;
|
||||||
if (action.icon()) {
|
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));
|
ASSERT(action.icon()->size() == Gfx::Size(16, 16));
|
||||||
if (action.icon()->shared_buffer_id() == -1) {
|
if (action.icon()->shared_buffer_id() == -1) {
|
||||||
auto shared_buffer = SharedBuffer::create_with_size(action.icon()->size_in_bytes());
|
auto shared_buffer = SharedBuffer::create_with_size(action.icon()->size_in_bytes());
|
||||||
ASSERT(shared_buffer);
|
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());
|
memcpy(shared_buffer->data(), action.icon()->bits(0), action.icon()->size_in_bytes());
|
||||||
shared_buffer->seal();
|
shared_buffer->seal();
|
||||||
shared_buffer->share_with(WindowServerConnection::the().server_pid());
|
shared_buffer->share_with(WindowServerConnection::the().server_pid());
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <LibGUI/Painter.h>
|
#include <LibGUI/Painter.h>
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
Painter::Painter(Gfx::Bitmap& bitmap)
|
Painter::Painter(Gfx::Bitmap& bitmap)
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <LibGUI/SyntaxHighlighter.h>
|
#include <LibGUI/SyntaxHighlighter.h>
|
||||||
#include <LibGUI/TextEditor.h>
|
#include <LibGUI/TextEditor.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <LibGfx/Palette.h>
|
#include <LibGfx/Palette.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
|
@ -493,7 +493,7 @@ void Window::flip(const Vector<Gfx::Rect, 32>& dirty_rects)
|
||||||
m_back_bitmap->shared_buffer()->set_volatile();
|
m_back_bitmap->shared_buffer()->set_volatile();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Gfx::Bitmap> Window::create_shared_bitmap(Gfx::Bitmap::Format format, const Gfx::Size& size)
|
NonnullRefPtr<Gfx::Bitmap> Window::create_shared_bitmap(Gfx::BitmapFormat format, const Gfx::Size& size)
|
||||||
{
|
{
|
||||||
ASSERT(WindowServerConnection::the().server_pid());
|
ASSERT(WindowServerConnection::the().server_pid());
|
||||||
ASSERT(!size.is_empty());
|
ASSERT(!size.is_empty());
|
||||||
|
@ -507,7 +507,7 @@ NonnullRefPtr<Gfx::Bitmap> Window::create_shared_bitmap(Gfx::Bitmap::Format form
|
||||||
|
|
||||||
NonnullRefPtr<Gfx::Bitmap> Window::create_backing_bitmap(const Gfx::Size& size)
|
NonnullRefPtr<Gfx::Bitmap> 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);
|
return create_shared_bitmap(format, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ void Window::set_icon(const Gfx::Bitmap* icon)
|
||||||
if (m_icon == icon)
|
if (m_icon == icon)
|
||||||
return;
|
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 painter(*m_icon);
|
||||||
painter.blit({ 0, 0 }, *icon, icon->rect());
|
painter.blit({ 0, 0 }, *icon, icon->rect());
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
#include <AK/WeakPtr.h>
|
#include <AK/WeakPtr.h>
|
||||||
#include <LibCore/Object.h>
|
#include <LibCore/Object.h>
|
||||||
#include <LibGUI/WindowType.h>
|
#include <LibGUI/WindowType.h>
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Color.h>
|
||||||
|
#include <LibGfx/Forward.h>
|
||||||
#include <LibGfx/Rect.h>
|
#include <LibGfx/Rect.h>
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
@ -184,7 +185,7 @@ private:
|
||||||
virtual bool is_window() const override final { return true; }
|
virtual bool is_window() const override final { return true; }
|
||||||
|
|
||||||
NonnullRefPtr<Gfx::Bitmap> create_backing_bitmap(const Gfx::Size&);
|
NonnullRefPtr<Gfx::Bitmap> create_backing_bitmap(const Gfx::Size&);
|
||||||
NonnullRefPtr<Gfx::Bitmap> create_shared_bitmap(Gfx::Bitmap::Format, const Gfx::Size&);
|
NonnullRefPtr<Gfx::Bitmap> create_shared_bitmap(Gfx::BitmapFormat, const Gfx::Size&);
|
||||||
void set_current_backing_bitmap(Gfx::Bitmap&, bool flush_immediately = false);
|
void set_current_backing_bitmap(Gfx::Bitmap&, bool flush_immediately = false);
|
||||||
void flip(const Vector<Gfx::Rect, 32>& dirty_rects);
|
void flip(const Vector<Gfx::Rect, 32>& dirty_rects);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/SharedBuffer.h>
|
||||||
#include <LibCore/MimeData.h>
|
#include <LibCore/MimeData.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
|
@ -35,6 +36,7 @@
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
#include <LibGUI/WindowServerConnection.h>
|
#include <LibGUI/WindowServerConnection.h>
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <LibGfx/Palette.h>
|
#include <LibGfx/Palette.h>
|
||||||
#include <LibGfx/SystemTheme.h>
|
#include <LibGfx/SystemTheme.h>
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/MappedFile.h>
|
#include <AK/SharedBuffer.h>
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <LibGfx/PNGLoader.h>
|
#include <LibGfx/PNGLoader.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -35,24 +35,24 @@
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
NonnullRefPtr<Bitmap> Bitmap::create(Format format, const Size& size)
|
NonnullRefPtr<Bitmap> Bitmap::create(BitmapFormat format, const Size& size)
|
||||||
{
|
{
|
||||||
return adopt(*new Bitmap(format, size, Purgeable::No));
|
return adopt(*new Bitmap(format, size, Purgeable::No));
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Bitmap> Bitmap::create_purgeable(Format format, const Size& size)
|
NonnullRefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const Size& size)
|
||||||
{
|
{
|
||||||
return adopt(*new Bitmap(format, size, Purgeable::Yes));
|
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_size(size)
|
||||||
, m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16))
|
, m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16))
|
||||||
, m_format(format)
|
, m_format(format)
|
||||||
, m_purgeable(purgeable == Purgeable::Yes)
|
, m_purgeable(purgeable == Purgeable::Yes)
|
||||||
{
|
{
|
||||||
ASSERT(!m_size.is_empty());
|
ASSERT(!m_size.is_empty());
|
||||||
if (format == Format::Indexed8)
|
if (format == BitmapFormat::Indexed8)
|
||||||
m_palette = new RGBA32[256];
|
m_palette = new RGBA32[256];
|
||||||
int map_flags = purgeable == Purgeable::Yes ? (MAP_PURGEABLE | MAP_PRIVATE) : (MAP_ANONYMOUS | MAP_PRIVATE);
|
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());
|
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;
|
m_needs_munmap = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Bitmap> Bitmap::create_wrapper(Format format, const Size& size, size_t pitch, RGBA32* data)
|
NonnullRefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const Size& size, size_t pitch, RGBA32* data)
|
||||||
{
|
{
|
||||||
return adopt(*new Bitmap(format, size, pitch, data));
|
return adopt(*new Bitmap(format, size, pitch, data));
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ RefPtr<Bitmap> Bitmap::load_from_file(const StringView& path)
|
||||||
return load_png(path);
|
return load_png(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Bitmap> Bitmap::load_from_file(Format format, const StringView& path, const Size& size)
|
RefPtr<Bitmap> Bitmap::load_from_file(BitmapFormat format, const StringView& path, const Size& size)
|
||||||
{
|
{
|
||||||
MappedFile mapped_file(path);
|
MappedFile mapped_file(path);
|
||||||
if (!mapped_file.is_valid())
|
if (!mapped_file.is_valid())
|
||||||
|
@ -78,39 +78,39 @@ RefPtr<Bitmap> Bitmap::load_from_file(Format format, const StringView& path, con
|
||||||
return adopt(*new Bitmap(format, size, move(mapped_file)));
|
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_size(size)
|
||||||
, m_data(data)
|
, m_data(data)
|
||||||
, m_pitch(pitch)
|
, m_pitch(pitch)
|
||||||
, m_format(format)
|
, m_format(format)
|
||||||
{
|
{
|
||||||
if (format == Format::Indexed8)
|
if (format == BitmapFormat::Indexed8)
|
||||||
m_palette = new RGBA32[256];
|
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_size(size)
|
||||||
, m_data((RGBA32*)mapped_file.data())
|
, m_data((RGBA32*)mapped_file.data())
|
||||||
, m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16))
|
, m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16))
|
||||||
, m_format(format)
|
, m_format(format)
|
||||||
, m_mapped_file(move(mapped_file))
|
, m_mapped_file(move(mapped_file))
|
||||||
{
|
{
|
||||||
ASSERT(format != Format::Indexed8);
|
ASSERT(format != BitmapFormat::Indexed8);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Bitmap> Bitmap::create_with_shared_buffer(Format format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size)
|
NonnullRefPtr<Bitmap> Bitmap::create_with_shared_buffer(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size)
|
||||||
{
|
{
|
||||||
return adopt(*new Bitmap(format, move(shared_buffer), size));
|
return adopt(*new Bitmap(format, move(shared_buffer), size));
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap::Bitmap(Format format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size)
|
Bitmap::Bitmap(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size)
|
||||||
: m_size(size)
|
: m_size(size)
|
||||||
, m_data((RGBA32*)shared_buffer->data())
|
, m_data((RGBA32*)shared_buffer->data())
|
||||||
, m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16))
|
, m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16))
|
||||||
, m_format(format)
|
, m_format(format)
|
||||||
, m_shared_buffer(move(shared_buffer))
|
, m_shared_buffer(move(shared_buffer))
|
||||||
{
|
{
|
||||||
ASSERT(format != Format::Indexed8);
|
ASSERT(format != BitmapFormat::Indexed8);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Bitmap> Bitmap::to_shareable_bitmap() const
|
NonnullRefPtr<Bitmap> Bitmap::to_shareable_bitmap() const
|
||||||
|
@ -141,7 +141,7 @@ void Bitmap::set_mmap_name(const StringView& name)
|
||||||
|
|
||||||
void Bitmap::fill(Color color)
|
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) {
|
for (int y = 0; y < height(); ++y) {
|
||||||
auto* scanline = this->scanline(y);
|
auto* scanline = this->scanline(y);
|
||||||
fast_u32_fill(scanline, color.value(), width());
|
fast_u32_fill(scanline, color.value(), width());
|
||||||
|
@ -175,4 +175,9 @@ void Bitmap::set_volatile()
|
||||||
return rc == 0;
|
return rc == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Bitmap::shared_buffer_id() const
|
||||||
|
{
|
||||||
|
return m_shared_buffer ? m_shared_buffer->shared_buffer_id() : -1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,33 +26,32 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Color.h"
|
#include <AK/Forward.h>
|
||||||
#include "Rect.h"
|
|
||||||
#include "Size.h"
|
|
||||||
#include <AK/MappedFile.h>
|
#include <AK/MappedFile.h>
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
#include <AK/SharedBuffer.h>
|
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/StringView.h>
|
#include <LibGfx/Color.h>
|
||||||
|
#include <LibGfx/Rect.h>
|
||||||
|
#include <LibGfx/Size.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
|
enum class BitmapFormat {
|
||||||
|
Invalid,
|
||||||
|
RGB32,
|
||||||
|
RGBA32,
|
||||||
|
Indexed8
|
||||||
|
};
|
||||||
|
|
||||||
class Bitmap : public RefCounted<Bitmap> {
|
class Bitmap : public RefCounted<Bitmap> {
|
||||||
public:
|
public:
|
||||||
enum class Format {
|
static NonnullRefPtr<Bitmap> create(BitmapFormat, const Size&);
|
||||||
Invalid,
|
static NonnullRefPtr<Bitmap> create_purgeable(BitmapFormat, const Size&);
|
||||||
RGB32,
|
static NonnullRefPtr<Bitmap> create_wrapper(BitmapFormat, const Size&, size_t pitch, RGBA32*);
|
||||||
RGBA32,
|
|
||||||
Indexed8
|
|
||||||
};
|
|
||||||
|
|
||||||
static NonnullRefPtr<Bitmap> create(Format, const Size&);
|
|
||||||
static NonnullRefPtr<Bitmap> create_purgeable(Format, const Size&);
|
|
||||||
static NonnullRefPtr<Bitmap> create_wrapper(Format, const Size&, size_t pitch, RGBA32*);
|
|
||||||
static RefPtr<Bitmap> load_from_file(const StringView& path);
|
static RefPtr<Bitmap> load_from_file(const StringView& path);
|
||||||
static RefPtr<Bitmap> load_from_file(Format, const StringView& path, const Size&);
|
static RefPtr<Bitmap> load_from_file(BitmapFormat, const StringView& path, const Size&);
|
||||||
static NonnullRefPtr<Bitmap> create_with_shared_buffer(Format, NonnullRefPtr<SharedBuffer>&&, const Size&);
|
static NonnullRefPtr<Bitmap> create_with_shared_buffer(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const Size&);
|
||||||
|
|
||||||
NonnullRefPtr<Bitmap> to_shareable_bitmap() const;
|
NonnullRefPtr<Bitmap> to_shareable_bitmap() const;
|
||||||
|
|
||||||
|
@ -69,7 +68,7 @@ public:
|
||||||
int width() const { return m_size.width(); }
|
int width() const { return m_size.width(); }
|
||||||
int height() const { return m_size.height(); }
|
int height() const { return m_size.height(); }
|
||||||
size_t pitch() const { return m_pitch; }
|
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(); }
|
SharedBuffer* shared_buffer() { return m_shared_buffer.ptr(); }
|
||||||
const SharedBuffer* shared_buffer() const { return m_shared_buffer.ptr(); }
|
const SharedBuffer* shared_buffer() const { return m_shared_buffer.ptr(); }
|
||||||
|
@ -77,22 +76,22 @@ public:
|
||||||
unsigned bpp() const
|
unsigned bpp() const
|
||||||
{
|
{
|
||||||
switch (m_format) {
|
switch (m_format) {
|
||||||
case Format::Indexed8:
|
case BitmapFormat::Indexed8:
|
||||||
return 8;
|
return 8;
|
||||||
case Format::RGB32:
|
case BitmapFormat::RGB32:
|
||||||
case Format::RGBA32:
|
case BitmapFormat::RGBA32:
|
||||||
return 32;
|
return 32;
|
||||||
default:
|
default:
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
case Format::Invalid:
|
case BitmapFormat::Invalid:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill(Color);
|
void fill(Color);
|
||||||
|
|
||||||
bool has_alpha_channel() const { return m_format == Format::RGBA32; }
|
bool has_alpha_channel() const { return m_format == BitmapFormat::RGBA32; }
|
||||||
Format format() const { return m_format; }
|
BitmapFormat format() const { return m_format; }
|
||||||
|
|
||||||
void set_mmap_name(const StringView&);
|
void set_mmap_name(const StringView&);
|
||||||
|
|
||||||
|
@ -101,7 +100,7 @@ public:
|
||||||
Color palette_color(u8 index) const { return Color::from_rgba(m_palette[index]); }
|
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(); }
|
void set_palette_color(u8 index, Color color) { m_palette[index] = color.value(); }
|
||||||
|
|
||||||
template<Format>
|
template<BitmapFormat>
|
||||||
Color get_pixel(int x, int y) const
|
Color get_pixel(int x, int y) const
|
||||||
{
|
{
|
||||||
(void)x;
|
(void)x;
|
||||||
|
@ -116,7 +115,7 @@ public:
|
||||||
return get_pixel(position.x(), position.y());
|
return get_pixel(position.x(), position.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<Format>
|
template<BitmapFormat>
|
||||||
void set_pixel(int x, int y, Color)
|
void set_pixel(int x, int y, Color)
|
||||||
{
|
{
|
||||||
(void)x;
|
(void)x;
|
||||||
|
@ -139,16 +138,16 @@ public:
|
||||||
private:
|
private:
|
||||||
enum class Purgeable { No,
|
enum class Purgeable { No,
|
||||||
Yes };
|
Yes };
|
||||||
Bitmap(Format, const Size&, Purgeable);
|
Bitmap(BitmapFormat, const Size&, Purgeable);
|
||||||
Bitmap(Format, const Size&, size_t pitch, RGBA32*);
|
Bitmap(BitmapFormat, const Size&, size_t pitch, RGBA32*);
|
||||||
Bitmap(Format, const Size&, MappedFile&&);
|
Bitmap(BitmapFormat, const Size&, MappedFile&&);
|
||||||
Bitmap(Format, NonnullRefPtr<SharedBuffer>&&, const Size&);
|
Bitmap(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const Size&);
|
||||||
|
|
||||||
Size m_size;
|
Size m_size;
|
||||||
RGBA32* m_data { nullptr };
|
RGBA32* m_data { nullptr };
|
||||||
RGBA32* m_palette { nullptr };
|
RGBA32* m_palette { nullptr };
|
||||||
size_t m_pitch { 0 };
|
size_t m_pitch { 0 };
|
||||||
Format m_format { Format::Invalid };
|
BitmapFormat m_format { BitmapFormat::Invalid };
|
||||||
bool m_needs_munmap { false };
|
bool m_needs_munmap { false };
|
||||||
bool m_purgeable { false };
|
bool m_purgeable { false };
|
||||||
bool m_volatile { false };
|
bool m_volatile { false };
|
||||||
|
@ -177,19 +176,19 @@ inline u8* Bitmap::bits(int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline Color Bitmap::get_pixel<Bitmap::Format::RGB32>(int x, int y) const
|
inline Color Bitmap::get_pixel<BitmapFormat::RGB32>(int x, int y) const
|
||||||
{
|
{
|
||||||
return Color::from_rgb(scanline(y)[x]);
|
return Color::from_rgb(scanline(y)[x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline Color Bitmap::get_pixel<Bitmap::Format::RGBA32>(int x, int y) const
|
inline Color Bitmap::get_pixel<BitmapFormat::RGBA32>(int x, int y) const
|
||||||
{
|
{
|
||||||
return Color::from_rgba(scanline(y)[x]);
|
return Color::from_rgba(scanline(y)[x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline Color Bitmap::get_pixel<Bitmap::Format::Indexed8>(int x, int y) const
|
inline Color Bitmap::get_pixel<BitmapFormat::Indexed8>(int x, int y) const
|
||||||
{
|
{
|
||||||
return Color::from_rgba(m_palette[bits(y)[x]]);
|
return Color::from_rgba(m_palette[bits(y)[x]]);
|
||||||
}
|
}
|
||||||
|
@ -197,12 +196,12 @@ inline Color Bitmap::get_pixel<Bitmap::Format::Indexed8>(int x, int y) const
|
||||||
inline Color Bitmap::get_pixel(int x, int y) const
|
inline Color Bitmap::get_pixel(int x, int y) const
|
||||||
{
|
{
|
||||||
switch (m_format) {
|
switch (m_format) {
|
||||||
case Format::RGB32:
|
case BitmapFormat::RGB32:
|
||||||
return get_pixel<Format::RGB32>(x, y);
|
return get_pixel<BitmapFormat::RGB32>(x, y);
|
||||||
case Format::RGBA32:
|
case BitmapFormat::RGBA32:
|
||||||
return get_pixel<Format::RGBA32>(x, y);
|
return get_pixel<BitmapFormat::RGBA32>(x, y);
|
||||||
case Format::Indexed8:
|
case BitmapFormat::Indexed8:
|
||||||
return get_pixel<Format::Indexed8>(x, y);
|
return get_pixel<BitmapFormat::Indexed8>(x, y);
|
||||||
default:
|
default:
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
return {};
|
return {};
|
||||||
|
@ -210,13 +209,13 @@ inline Color Bitmap::get_pixel(int x, int y) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline void Bitmap::set_pixel<Bitmap::Format::RGB32>(int x, int y, Color color)
|
inline void Bitmap::set_pixel<BitmapFormat::RGB32>(int x, int y, Color color)
|
||||||
{
|
{
|
||||||
scanline(y)[x] = color.value();
|
scanline(y)[x] = color.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline void Bitmap::set_pixel<Bitmap::Format::RGBA32>(int x, int y, Color color)
|
inline void Bitmap::set_pixel<BitmapFormat::RGBA32>(int x, int y, Color color)
|
||||||
{
|
{
|
||||||
scanline(y)[x] = color.value();
|
scanline(y)[x] = color.value();
|
||||||
}
|
}
|
||||||
|
@ -224,13 +223,13 @@ inline void Bitmap::set_pixel<Bitmap::Format::RGBA32>(int x, int y, Color color)
|
||||||
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) {
|
switch (m_format) {
|
||||||
case Format::RGB32:
|
case BitmapFormat::RGB32:
|
||||||
set_pixel<Format::RGB32>(x, y, color);
|
set_pixel<BitmapFormat::RGB32>(x, y, color);
|
||||||
break;
|
break;
|
||||||
case Format::RGBA32:
|
case BitmapFormat::RGBA32:
|
||||||
set_pixel<Format::RGBA32>(x, y, color);
|
set_pixel<BitmapFormat::RGBA32>(x, y, color);
|
||||||
break;
|
break;
|
||||||
case Format::Indexed8:
|
case BitmapFormat::Indexed8:
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
default:
|
default:
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
|
|
52
Libraries/LibGfx/Forward.h
Normal file
52
Libraries/LibGfx/Forward.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||||
|
* 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;
|
|
@ -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);
|
unfilter(context);
|
||||||
|
|
||||||
|
|
|
@ -51,14 +51,14 @@
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
template<Bitmap::Format format = Bitmap::Format::Invalid>
|
template<BitmapFormat format = BitmapFormat::Invalid>
|
||||||
static ALWAYS_INLINE Color get_pixel(const Gfx::Bitmap& bitmap, int x, int y)
|
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]);
|
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]);
|
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 Color::from_rgba(bitmap.scanline(y)[x]);
|
||||||
return bitmap.get_pixel(x, y);
|
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();
|
RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x();
|
||||||
const size_t dst_skip = m_target->pitch() / sizeof(RGBA32);
|
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();
|
int x_start = first_column + a_dst_rect.left();
|
||||||
for (int row = first_row; row <= last_row; ++row) {
|
for (int row = first_row; row <= last_row; ++row) {
|
||||||
const RGBA32* sl = source.scanline((row + a_dst_rect.top())
|
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();
|
RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x();
|
||||||
const size_t dst_skip = m_target->pitch() / sizeof(RGBA32);
|
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();
|
int x_start = first_column + src_rect.left();
|
||||||
for (int row = first_row; row <= last_row; ++row) {
|
for (int row = first_row; row <= last_row; ++row) {
|
||||||
int sr = row - offset.y() + src_rect.top();
|
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();
|
RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x();
|
||||||
const size_t dst_skip = m_target->pitch() / sizeof(RGBA32);
|
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 RGBA32* src = source.scanline(src_rect.top() + first_row) + src_rect.left() + first_column;
|
||||||
const size_t src_skip = source.pitch() / sizeof(RGBA32);
|
const size_t src_skip = source.pitch() / sizeof(RGBA32);
|
||||||
for (int row = first_row; row <= last_row; ++row) {
|
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;
|
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 u8* src = source.bits(src_rect.top() + first_row) + src_rect.left() + first_column;
|
||||||
const size_t src_skip = source.pitch();
|
const size_t src_skip = source.pitch();
|
||||||
for (int row = first_row; row <= last_row; ++row) {
|
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()) {
|
if (source.has_alpha_channel()) {
|
||||||
switch (source.format()) {
|
switch (source.format()) {
|
||||||
case Bitmap::Format::RGB32:
|
case BitmapFormat::RGB32:
|
||||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::RGB32>);
|
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::RGB32>);
|
||||||
break;
|
break;
|
||||||
case Bitmap::Format::RGBA32:
|
case BitmapFormat::RGBA32:
|
||||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::RGBA32>);
|
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::RGBA32>);
|
||||||
break;
|
break;
|
||||||
case Bitmap::Format::Indexed8:
|
case BitmapFormat::Indexed8:
|
||||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::Indexed8>);
|
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::Indexed8>);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::Invalid>);
|
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::Invalid>);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (source.format()) {
|
switch (source.format()) {
|
||||||
case Bitmap::Format::RGB32:
|
case BitmapFormat::RGB32:
|
||||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::RGB32>);
|
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::RGB32>);
|
||||||
break;
|
break;
|
||||||
case Bitmap::Format::RGBA32:
|
case BitmapFormat::RGBA32:
|
||||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::RGBA32>);
|
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::RGBA32>);
|
||||||
break;
|
break;
|
||||||
case Bitmap::Format::Indexed8:
|
case BitmapFormat::Indexed8:
|
||||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::Indexed8>);
|
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::Indexed8>);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::Invalid>);
|
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::Invalid>);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/Badge.h>
|
||||||
|
#include <AK/SharedBuffer.h>
|
||||||
#include <LibGfx/Palette.h>
|
#include <LibGfx/Palette.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
@ -73,4 +75,13 @@ void Palette::set_color(ColorRole role, Color color)
|
||||||
theme.color[(int)role] = color;
|
theme.color[(int)role] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PaletteImpl::~PaletteImpl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaletteImpl::replace_internal_buffer(Badge<GUI::Application>, SharedBuffer& buffer)
|
||||||
|
{
|
||||||
|
m_theme_buffer = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Badge.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/Noncopyable.h>
|
#include <AK/Noncopyable.h>
|
||||||
#include <LibGfx/SystemTheme.h>
|
#include <LibGfx/SystemTheme.h>
|
||||||
|
|
||||||
|
@ -40,13 +40,14 @@ class PaletteImpl : public RefCounted<PaletteImpl> {
|
||||||
AK_MAKE_NONCOPYABLE(PaletteImpl)
|
AK_MAKE_NONCOPYABLE(PaletteImpl)
|
||||||
AK_MAKE_NONMOVABLE(PaletteImpl)
|
AK_MAKE_NONMOVABLE(PaletteImpl)
|
||||||
public:
|
public:
|
||||||
|
~PaletteImpl();
|
||||||
static NonnullRefPtr<PaletteImpl> create_with_shared_buffer(SharedBuffer&);
|
static NonnullRefPtr<PaletteImpl> create_with_shared_buffer(SharedBuffer&);
|
||||||
NonnullRefPtr<PaletteImpl> clone() const;
|
NonnullRefPtr<PaletteImpl> clone() const;
|
||||||
|
|
||||||
Color color(ColorRole) const;
|
Color color(ColorRole) const;
|
||||||
const SystemTheme& theme() const;
|
const SystemTheme& theme() const;
|
||||||
|
|
||||||
void replace_internal_buffer(Badge<GUI::Application>, SharedBuffer& buffer) { m_theme_buffer = buffer; }
|
void replace_internal_buffer(Badge<GUI::Application>, SharedBuffer& buffer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit PaletteImpl(SharedBuffer&);
|
explicit PaletteImpl(SharedBuffer&);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/SharedBuffer.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
#include <LibGfx/SystemTheme.h>
|
#include <LibGfx/SystemTheme.h>
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/SharedBuffer.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <LibGfx/Color.h>
|
#include <LibGfx/Color.h>
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <LibGUI/Painter.h>
|
#include <LibGUI/Painter.h>
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
#include <LibGfx/Bitmap.h>
|
||||||
|
|
||||||
class AudioWidget final : public GUI::Widget {
|
class AudioWidget final : public GUI::Widget {
|
||||||
C_OBJECT(AudioWidget)
|
C_OBJECT(AudioWidget)
|
||||||
|
|
|
@ -196,7 +196,7 @@ OwnPtr<Messages::WindowServer::AddMenuItemResponse> ClientConnection::handle(con
|
||||||
if (!icon_buffer)
|
if (!icon_buffer)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
// FIXME: Verify that the icon buffer can accomodate a 16x16 bitmap view.
|
// 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_icon(shared_icon);
|
||||||
}
|
}
|
||||||
menu_item->set_submenu_id(message.submenu_id());
|
menu_item->set_submenu_id(message.submenu_id());
|
||||||
|
@ -354,7 +354,7 @@ OwnPtr<Messages::WindowServer::SetWindowIconBitmapResponse> ClientConnection::ha
|
||||||
if (!icon_buffer) {
|
if (!icon_buffer) {
|
||||||
window.set_default_icon();
|
window.set_default_icon();
|
||||||
} else {
|
} 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();
|
window.frame().invalidate_title_bar();
|
||||||
|
@ -516,7 +516,7 @@ OwnPtr<Messages::WindowServer::SetWindowBackingStoreResponse> ClientConnection::
|
||||||
if (!shared_buffer)
|
if (!shared_buffer)
|
||||||
return make<Messages::WindowServer::SetWindowBackingStoreResponse>();
|
return make<Messages::WindowServer::SetWindowBackingStoreResponse>();
|
||||||
auto backing_store = Gfx::Bitmap::create_with_shared_buffer(
|
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,
|
*shared_buffer,
|
||||||
message.size());
|
message.size());
|
||||||
window.set_backing_store(move(backing_store));
|
window.set_backing_store(move(backing_store));
|
||||||
|
@ -675,7 +675,7 @@ OwnPtr<Messages::WindowServer::StartDragResponse> ClientConnection::handle(const
|
||||||
did_misbehave("SetAppletBackingStore: Shared buffer is too small for applet size");
|
did_misbehave("SetAppletBackingStore: Shared buffer is too small for applet size");
|
||||||
return nullptr;
|
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());
|
wm.start_dnd_drag(*this, message.text(), bitmap, message.data_type(), message.data());
|
||||||
|
|
|
@ -89,12 +89,12 @@ void Compositor::init_bitmaps()
|
||||||
auto& screen = Screen::the();
|
auto& screen = Screen::the();
|
||||||
auto size = screen.size();
|
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)
|
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
|
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<Gfx::Painter>(*m_front_bitmap);
|
m_front_painter = make<Gfx::Painter>(*m_front_bitmap);
|
||||||
m_back_painter = make<Gfx::Painter>(*m_back_bitmap);
|
m_back_painter = make<Gfx::Painter>(*m_back_bitmap);
|
||||||
|
|
|
@ -103,7 +103,7 @@ void Window::set_rect(const Gfx::Rect& rect)
|
||||||
old_rect = m_rect;
|
old_rect = m_rect;
|
||||||
m_rect = rect;
|
m_rect = rect;
|
||||||
if (!m_client && (!m_backing_store || old_rect.size() != rect.size())) {
|
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);
|
m_frame.notify_window_rect_changed(old_rect, rect);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include <AK/LogStream.h>
|
#include <AK/LogStream.h>
|
||||||
|
#include <AK/SharedBuffer.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibGfx/CharacterBitmap.h>
|
#include <LibGfx/CharacterBitmap.h>
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "EventLoop.h"
|
#include "EventLoop.h"
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
#include "WindowManager.h"
|
#include "WindowManager.h"
|
||||||
|
#include <AK/SharedBuffer.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
#include <LibGfx/Palette.h>
|
#include <LibGfx/Palette.h>
|
||||||
#include <LibGfx/SystemTheme.h>
|
#include <LibGfx/SystemTheme.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue