1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:37:46 +00:00

LibGUI: Add a GPainter class that inherits from Painter.

This gets rid of the last little piece of LibGUI knowledge in Painter.
This commit is contained in:
Andreas Kling 2019-03-28 17:19:56 +01:00
parent 326c6fd607
commit 9fa21fa585
27 changed files with 75 additions and 78 deletions

View file

@ -4,16 +4,6 @@
#include <SharedGraphics/CharacterBitmap.h>
#include <AK/Assertions.h>
#include <AK/StdLibExtras.h>
#ifdef LIBGUI
#include <LibGUI/GWidget.h>
#include <LibGUI/GWindow.h>
#include <LibGUI/GEventLoop.h>
#include <LibC/stdio.h>
#include <LibC/errno.h>
#include <LibC/string.h>
#endif
#include <unistd.h>
Painter::Painter(GraphicsBitmap& bitmap)
@ -25,22 +15,6 @@ Painter::Painter(GraphicsBitmap& bitmap)
m_clip_origin = state().clip_rect;
}
#ifdef LIBGUI
Painter::Painter(GWidget& widget)
: m_window(widget.window())
, m_target(*m_window->back_bitmap())
{
m_state_stack.append(State());
state().font = &widget.font();
auto origin_rect = widget.window_relative_rect();
state().translation = origin_rect.location();
state().clip_rect = origin_rect;
m_clip_origin = origin_rect;
state().clip_rect.intersect(m_target->rect());
}
#endif
Painter::~Painter()
{
}

View file

@ -12,16 +12,8 @@ class GlyphBitmap;
class GraphicsBitmap;
class Font;
#ifdef USERLAND
class GWidget;
class GWindow;
#endif
class Painter {
public:
#ifdef USERLAND
explicit Painter(GWidget&);
#endif
explicit Painter(GraphicsBitmap&);
~Painter();
void fill_rect(const Rect&, Color);
@ -64,7 +56,7 @@ public:
void save() { m_state_stack.append(m_state_stack.last()); }
void restore() { ASSERT(m_state_stack.size() > 1); m_state_stack.take_last(); }
private:
protected:
void set_pixel_with_draw_op(dword& pixel, const Color&);
void fill_rect_with_draw_op(const Rect&, Color);
void blit_with_alpha(const Point&, const GraphicsBitmap&, const Rect& src_rect);
@ -80,7 +72,6 @@ private:
const State& state() const { return m_state_stack.last(); }
Rect m_clip_origin;
GWindow* m_window { nullptr };
Retained<GraphicsBitmap> m_target;
Vector<State> m_state_stack;
};