summaryrefslogtreecommitdiff
path: root/Widgets
diff options
context:
space:
mode:
Diffstat (limited to 'Widgets')
-rw-r--r--Widgets/GraphicsBitmap.cpp17
-rw-r--r--Widgets/GraphicsBitmap.h12
-rw-r--r--Widgets/Painter.cpp4
-rw-r--r--Widgets/Widget.cpp3
-rw-r--r--Widgets/Window.cpp10
-rw-r--r--Widgets/Window.h3
-rw-r--r--Widgets/WindowManager.cpp9
7 files changed, 32 insertions, 26 deletions
diff --git a/Widgets/GraphicsBitmap.cpp b/Widgets/GraphicsBitmap.cpp
index 98fdb85b23..75bbff0f56 100644
--- a/Widgets/GraphicsBitmap.cpp
+++ b/Widgets/GraphicsBitmap.cpp
@@ -1,19 +1,18 @@
#include "GraphicsBitmap.h"
#include "EventLoop.h"
#include <AK/kmalloc.h>
+
+#ifdef KERNEL
#include "Process.h"
#include "MemoryManager.h"
+#endif
+#ifdef KERNEL
RetainPtr<GraphicsBitmap> GraphicsBitmap::create(Process& process, const Size& size)
{
return adopt(*new GraphicsBitmap(process, size));
}
-RetainPtr<GraphicsBitmap> GraphicsBitmap::create_wrapper(const Size& size, RGBA32* data)
-{
- return adopt(*new GraphicsBitmap(size, data));
-}
-
GraphicsBitmap::GraphicsBitmap(Process& process, const Size& size)
: m_size(size)
, m_pitch(size.width() * sizeof(RGBA32))
@@ -34,6 +33,12 @@ GraphicsBitmap::GraphicsBitmap(Process& process, const Size& size)
}
m_data = (RGBA32*)m_server_region->linearAddress.asPtr();
}
+#endif
+
+RetainPtr<GraphicsBitmap> GraphicsBitmap::create_wrapper(const Size& size, RGBA32* data)
+{
+ return adopt(*new GraphicsBitmap(size, data));
+}
GraphicsBitmap::GraphicsBitmap(const Size& size, RGBA32* data)
: m_size(size)
@@ -44,10 +49,12 @@ GraphicsBitmap::GraphicsBitmap(const Size& size, RGBA32* data)
GraphicsBitmap::~GraphicsBitmap()
{
+#ifdef KERNEL
if (m_client_region)
m_client_process->deallocate_region(*m_client_region);
if (m_server_region)
EventLoop::main().server_process().deallocate_region(*m_server_region);
+#endif
m_data = nullptr;
}
diff --git a/Widgets/GraphicsBitmap.h b/Widgets/GraphicsBitmap.h
index f0f78175c3..fad84f15d4 100644
--- a/Widgets/GraphicsBitmap.h
+++ b/Widgets/GraphicsBitmap.h
@@ -4,11 +4,16 @@
#include "Size.h"
#include <AK/Retainable.h>
#include <AK/RetainPtr.h>
+
+#ifdef KERNEL
#include "Process.h"
+#endif
class GraphicsBitmap : public Retainable<GraphicsBitmap> {
public:
+#ifdef KERNEL
static RetainPtr<GraphicsBitmap> create(Process&, const Size&);
+#endif
static RetainPtr<GraphicsBitmap> create_wrapper(const Size&, RGBA32*);
~GraphicsBitmap();
@@ -20,17 +25,24 @@ public:
int height() const { return m_size.height(); }
size_t pitch() const { return m_pitch; }
+#ifdef KERNEL
Region* client_region() { return m_client_region; }
Region* server_region() { return m_server_region; }
+#endif
private:
+#ifdef KERNEL
GraphicsBitmap(Process&, const Size&);
+#endif
GraphicsBitmap(const Size&, RGBA32*);
Size m_size;
RGBA32* m_data { nullptr };
size_t m_pitch { 0 };
+
+#ifdef KERNEL
Process* m_client_process { nullptr };
Region* m_client_region { nullptr };
Region* m_server_region { nullptr };
+#endif
};
diff --git a/Widgets/Painter.cpp b/Widgets/Painter.cpp
index ac863cb8a2..12313a6bf6 100644
--- a/Widgets/Painter.cpp
+++ b/Widgets/Painter.cpp
@@ -1,7 +1,7 @@
#include "Painter.h"
#include "Widget.h"
#include "Font.h"
-#include "Window.h"
+#include "GraphicsBitmap.h"
#include <AK/Assertions.h>
#include <AK/StdLibExtras.h>
@@ -115,7 +115,7 @@ void Painter::draw_text(const Rect& rect, const String& text, TextAlignment alig
continue;
auto* bitmap = font().glyphBitmap(ch);
if (!bitmap) {
- printf("Font doesn't have 0x%02x ('%c')\n", ch, ch);
+ dbgprintf("Font doesn't have 0x%02x ('%c')\n", ch, ch);
ASSERT_NOT_REACHED();
}
int x = point.x() + i * font().glyphWidth();
diff --git a/Widgets/Widget.cpp b/Widgets/Widget.cpp
index d83877e3ff..3a2dea77e7 100644
--- a/Widgets/Widget.cpp
+++ b/Widgets/Widget.cpp
@@ -29,8 +29,7 @@ void Widget::setWindowRelativeRect(const Rect& rect, bool should_update)
void Widget::repaint(const Rect& rect)
{
- if (auto* w = window())
- w->repaint(rect);
+ // FIXME: Implement.
}
void Widget::event(Event& event)
diff --git a/Widgets/Window.cpp b/Widgets/Window.cpp
index f984e7bd45..4f4f7f2da5 100644
--- a/Widgets/Window.cpp
+++ b/Widgets/Window.cpp
@@ -37,16 +37,6 @@ void Window::setRect(const Rect& rect)
WindowManager::the().notifyRectChanged(*this, oldRect, m_rect);
}
-void Window::repaint(const Rect& rect)
-{
- event(*make<PaintEvent>(rect));
-}
-
-void Window::update(const Rect& rect)
-{
- EventLoop::main().postEvent(this, make<PaintEvent>(rect));
-}
-
// FIXME: Just use the same types.
static GUI_MouseButton to_api(MouseButton button)
{
diff --git a/Widgets/Window.h b/Widgets/Window.h
index 2d311c82c7..3376e6926a 100644
--- a/Widgets/Window.h
+++ b/Widgets/Window.h
@@ -38,9 +38,6 @@ public:
bool isBeingDragged() const { return m_isBeingDragged; }
void setIsBeingDragged(bool b) { m_isBeingDragged = b; }
- void repaint(const Rect& = Rect());
- void update(const Rect& = Rect());
-
bool isActive() const;
bool isVisible() const;
diff --git a/Widgets/WindowManager.cpp b/Widgets/WindowManager.cpp
index 9c036f01f3..febf64fe57 100644
--- a/Widgets/WindowManager.cpp
+++ b/Widgets/WindowManager.cpp
@@ -267,7 +267,8 @@ void WindowManager::processMouseEvent(MouseEvent& event)
void WindowManager::compose()
{
- printf("[WM] compose #%u (%u rects)\n", ++m_recompose_count, m_invalidated_rects.size());
+ auto invalidated_rects = move(m_invalidated_rects);
+ printf("[WM] compose #%u (%u rects)\n", ++m_recompose_count, invalidated_rects.size());
dbgprintf("kmalloc stats: alloc:%u free:%u eternal:%u\n", sum_alloc, sum_free, kmalloc_sum_eternal);
@@ -279,7 +280,7 @@ void WindowManager::compose()
return false;
};
- for (auto& r : m_invalidated_rects) {
+ for (auto& r : invalidated_rects) {
if (any_window_contains_rect(r))
continue;
//dbgprintf("Repaint root %d,%d %dx%d\n", r.x(), r.y(), r.width(), r.height());
@@ -291,10 +292,9 @@ void WindowManager::compose()
paintWindowFrame(*window);
m_back_painter->blit(window->position(), *window->backing());
}
- for (auto& r : m_invalidated_rects)
+ for (auto& r : invalidated_rects)
flush(r);
draw_cursor();
- m_invalidated_rects.clear_with_capacity();
}
void WindowManager::draw_cursor()
@@ -364,6 +364,7 @@ void WindowManager::invalidate(const Rect& a_rect)
auto rect = Rect::intersection(a_rect, m_screen_rect);
if (rect.is_empty())
return;
+
for (auto& r : m_invalidated_rects) {
if (r.contains(rect))
return;