mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00
WindowServer: Merge WSFrameBuffer into WSScreen.
This commit is contained in:
parent
bb28c143fd
commit
9454c5dd52
9 changed files with 22 additions and 72 deletions
|
@ -57,7 +57,6 @@ WINDOWSERVER_OBJS = \
|
||||||
../WindowServer/WSEventLoop.o \
|
../WindowServer/WSEventLoop.o \
|
||||||
../WindowServer/WSWindow.o \
|
../WindowServer/WSWindow.o \
|
||||||
../WindowServer/WSWindowManager.o \
|
../WindowServer/WSWindowManager.o \
|
||||||
../WindowServer/WSFrameBuffer.o \
|
|
||||||
../WindowServer/WSScreen.o \
|
../WindowServer/WSScreen.o \
|
||||||
../WindowServer/main.o
|
../WindowServer/main.o
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
#include <Widgets/Font.h>
|
#include <Widgets/Font.h>
|
||||||
#include <WindowServer/WSScreen.h>
|
#include <WindowServer/WSScreen.h>
|
||||||
#include <WindowServer/WSFrameBuffer.h>
|
|
||||||
#include <WindowServer/WSEventLoop.h>
|
#include <WindowServer/WSEventLoop.h>
|
||||||
#include <WindowServer/WSWindow.h>
|
#include <WindowServer/WSWindow.h>
|
||||||
#include <WindowServer/WSWindowManager.h>
|
#include <WindowServer/WSWindowManager.h>
|
||||||
|
@ -11,7 +10,6 @@
|
||||||
void Process::initialize_gui_statics()
|
void Process::initialize_gui_statics()
|
||||||
{
|
{
|
||||||
Font::initialize();
|
Font::initialize();
|
||||||
WSFrameBuffer::initialize();
|
|
||||||
WSEventLoop::initialize();
|
WSEventLoop::initialize();
|
||||||
WSWindowManager::initialize();
|
WSWindowManager::initialize();
|
||||||
WSScreen::initialize();
|
WSScreen::initialize();
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
#include "WSFrameBuffer.h"
|
|
||||||
#include <Widgets/GraphicsBitmap.h>
|
|
||||||
#include <AK/Assertions.h>
|
|
||||||
|
|
||||||
WSFrameBuffer* s_the;
|
|
||||||
|
|
||||||
void WSFrameBuffer::initialize()
|
|
||||||
{
|
|
||||||
s_the = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
WSFrameBuffer& WSFrameBuffer::the()
|
|
||||||
{
|
|
||||||
ASSERT(s_the);
|
|
||||||
return *s_the;
|
|
||||||
}
|
|
||||||
|
|
||||||
WSFrameBuffer::WSFrameBuffer(RGBA32* data, unsigned width, unsigned height)
|
|
||||||
: WSScreen(width, height)
|
|
||||||
, m_data(data)
|
|
||||||
{
|
|
||||||
ASSERT(!s_the);
|
|
||||||
s_the = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WSFrameBuffer::~WSFrameBuffer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
RGBA32* WSFrameBuffer::scanline(int y)
|
|
||||||
{
|
|
||||||
unsigned pitch = sizeof(RGBA32) * width();
|
|
||||||
return reinterpret_cast<RGBA32*>(((byte*)m_data) + (y * pitch));
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "WSScreen.h"
|
|
||||||
#include <Widgets/Color.h>
|
|
||||||
|
|
||||||
class GraphicsBitmap;
|
|
||||||
|
|
||||||
class WSFrameBuffer final : public WSScreen {
|
|
||||||
public:
|
|
||||||
WSFrameBuffer(RGBA32*, unsigned width, unsigned height);
|
|
||||||
~WSFrameBuffer();
|
|
||||||
|
|
||||||
static WSFrameBuffer& the();
|
|
||||||
|
|
||||||
RGBA32* scanline(int y);
|
|
||||||
|
|
||||||
static void initialize();
|
|
||||||
|
|
||||||
private:
|
|
||||||
RGBA32* m_data { nullptr };
|
|
||||||
};
|
|
||||||
|
|
|
@ -17,8 +17,9 @@ WSScreen& WSScreen::the()
|
||||||
return *s_the;
|
return *s_the;
|
||||||
}
|
}
|
||||||
|
|
||||||
WSScreen::WSScreen(unsigned width, unsigned height)
|
WSScreen::WSScreen(RGBA32* framebuffer, unsigned width, unsigned height)
|
||||||
: m_width(width)
|
: m_framebuffer(framebuffer)
|
||||||
|
, m_width(width)
|
||||||
, m_height(height)
|
, m_height(height)
|
||||||
{
|
{
|
||||||
ASSERT(!s_the);
|
ASSERT(!s_the);
|
||||||
|
|
|
@ -2,14 +2,17 @@
|
||||||
|
|
||||||
#include <Widgets/Rect.h>
|
#include <Widgets/Rect.h>
|
||||||
#include <Widgets/Size.h>
|
#include <Widgets/Size.h>
|
||||||
|
#include <Widgets/Color.h>
|
||||||
#include <Kernel/Keyboard.h>
|
#include <Kernel/Keyboard.h>
|
||||||
|
|
||||||
class WSScreen {
|
class WSScreen {
|
||||||
public:
|
public:
|
||||||
|
WSScreen(RGBA32*, unsigned width, unsigned height);
|
||||||
~WSScreen();
|
~WSScreen();
|
||||||
|
|
||||||
int width() const { return m_width; }
|
int width() const { return m_width; }
|
||||||
int height() const { return m_height; }
|
int height() const { return m_height; }
|
||||||
|
RGBA32* scanline(int y);
|
||||||
|
|
||||||
static WSScreen& the();
|
static WSScreen& the();
|
||||||
|
|
||||||
|
@ -29,6 +32,8 @@ protected:
|
||||||
WSScreen(unsigned width, unsigned height);
|
WSScreen(unsigned width, unsigned height);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
RGBA32* m_framebuffer { nullptr };
|
||||||
|
|
||||||
int m_width { 0 };
|
int m_width { 0 };
|
||||||
int m_height { 0 };
|
int m_height { 0 };
|
||||||
|
|
||||||
|
@ -37,3 +42,8 @@ private:
|
||||||
bool m_right_mouse_button_pressed { false };
|
bool m_right_mouse_button_pressed { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline RGBA32* WSScreen::scanline(int y)
|
||||||
|
{
|
||||||
|
size_t pitch = sizeof(RGBA32) * width();
|
||||||
|
return reinterpret_cast<RGBA32*>(((byte*)m_framebuffer) + (y * pitch));
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include "WSWindow.h"
|
#include "WSWindow.h"
|
||||||
#include "WSScreen.h"
|
#include "WSScreen.h"
|
||||||
#include "WSEventLoop.h"
|
#include "WSEventLoop.h"
|
||||||
#include "WSFrameBuffer.h"
|
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include "MemoryManager.h"
|
#include "MemoryManager.h"
|
||||||
#include <Widgets/Painter.h>
|
#include <Widgets/Painter.h>
|
||||||
|
@ -107,15 +106,15 @@ static const char* cursor_bitmap_outer_ascii = {
|
||||||
};
|
};
|
||||||
|
|
||||||
WSWindowManager::WSWindowManager()
|
WSWindowManager::WSWindowManager()
|
||||||
: m_framebuffer(WSFrameBuffer::the())
|
: m_screen(WSScreen::the())
|
||||||
, m_screen_rect(m_framebuffer.rect())
|
, m_screen_rect(m_screen.rect())
|
||||||
{
|
{
|
||||||
#ifndef DEBUG_COUNTERS
|
#ifndef DEBUG_COUNTERS
|
||||||
(void)m_recompose_count;
|
(void)m_recompose_count;
|
||||||
(void)m_flush_count;
|
(void)m_flush_count;
|
||||||
#endif
|
#endif
|
||||||
auto size = m_screen_rect.size();
|
auto size = m_screen_rect.size();
|
||||||
m_front_bitmap = GraphicsBitmap::create_wrapper(size, m_framebuffer.scanline(0));
|
m_front_bitmap = GraphicsBitmap::create_wrapper(size, m_screen.scanline(0));
|
||||||
auto* region = current->allocate_region(LinearAddress(), size.width() * size.height() * sizeof(RGBA32), "BackBitmap", true, true, true);
|
auto* region = current->allocate_region(LinearAddress(), size.width() * size.height() * sizeof(RGBA32), "BackBitmap", true, true, true);
|
||||||
m_back_bitmap = GraphicsBitmap::create_wrapper(m_screen_rect.size(), (RGBA32*)region->linearAddress.get());
|
m_back_bitmap = GraphicsBitmap::create_wrapper(m_screen_rect.size(), (RGBA32*)region->linearAddress.get());
|
||||||
|
|
||||||
|
@ -327,12 +326,12 @@ void WSWindowManager::draw_cursor()
|
||||||
{
|
{
|
||||||
ASSERT_INTERRUPTS_ENABLED();
|
ASSERT_INTERRUPTS_ENABLED();
|
||||||
LOCKER(m_lock);
|
LOCKER(m_lock);
|
||||||
auto cursor_location = m_framebuffer.cursor_location();
|
auto cursor_location = m_screen.cursor_location();
|
||||||
Rect cursor_rect { cursor_location.x(), cursor_location.y(), (int)m_cursor_bitmap_inner->width(), (int)m_cursor_bitmap_inner->height() };
|
Rect cursor_rect { cursor_location.x(), cursor_location.y(), (int)m_cursor_bitmap_inner->width(), (int)m_cursor_bitmap_inner->height() };
|
||||||
flush(m_last_cursor_rect.united(cursor_rect));
|
flush(m_last_cursor_rect.united(cursor_rect));
|
||||||
Color inner_color = Color::White;
|
Color inner_color = Color::White;
|
||||||
Color outer_color = Color::Black;
|
Color outer_color = Color::Black;
|
||||||
if (m_framebuffer.left_mouse_button_pressed())
|
if (m_screen.left_mouse_button_pressed())
|
||||||
swap(inner_color, outer_color);
|
swap(inner_color, outer_color);
|
||||||
m_front_painter->draw_bitmap(cursor_location, *m_cursor_bitmap_inner, inner_color);
|
m_front_painter->draw_bitmap(cursor_location, *m_cursor_bitmap_inner, inner_color);
|
||||||
m_front_painter->draw_bitmap(cursor_location, *m_cursor_bitmap_outer, outer_color);
|
m_front_painter->draw_bitmap(cursor_location, *m_cursor_bitmap_outer, outer_color);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <AK/Lock.h>
|
#include <AK/Lock.h>
|
||||||
#include "WSEventReceiver.h"
|
#include "WSEventReceiver.h"
|
||||||
|
|
||||||
class WSFrameBuffer;
|
class WSScreen;
|
||||||
class MouseEvent;
|
class MouseEvent;
|
||||||
class PaintEvent;
|
class PaintEvent;
|
||||||
class WSWindow;
|
class WSWindow;
|
||||||
|
@ -53,7 +53,7 @@ private:
|
||||||
void compose();
|
void compose();
|
||||||
void paint_window_frame(WSWindow&);
|
void paint_window_frame(WSWindow&);
|
||||||
|
|
||||||
WSFrameBuffer& m_framebuffer;
|
WSScreen& m_screen;
|
||||||
Rect m_screen_rect;
|
Rect m_screen_rect;
|
||||||
|
|
||||||
Color m_active_window_border_color;
|
Color m_active_window_border_color;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include <Widgets/Font.h>
|
#include <Widgets/Font.h>
|
||||||
#include <WindowServer/WSFrameBuffer.h>
|
#include <WindowServer/WSScreen.h>
|
||||||
#include <WindowServer/WSWindowManager.h>
|
#include <WindowServer/WSWindowManager.h>
|
||||||
#include <WindowServer/WSEventLoop.h>
|
#include <WindowServer/WSEventLoop.h>
|
||||||
#include <WindowServer/WSWindow.h>
|
#include <WindowServer/WSWindow.h>
|
||||||
|
@ -14,7 +14,7 @@ void WindowServer_main()
|
||||||
|
|
||||||
dbgprintf("Screen is %ux%ux%ubpp\n", info.width, info.height, info.bpp);
|
dbgprintf("Screen is %ux%ux%ubpp\n", info.width, info.height, info.bpp);
|
||||||
|
|
||||||
WSFrameBuffer framebuffer((dword*)info.framebuffer, info.width, info.height);
|
WSScreen screen((dword*)info.framebuffer, info.width, info.height);
|
||||||
|
|
||||||
WSWindowManager::the();
|
WSWindowManager::the();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue