diff --git a/Kernel/Makefile b/Kernel/Makefile index 580a921618..b18bc828b3 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -57,7 +57,6 @@ WINDOWSERVER_OBJS = \ ../WindowServer/WSEventLoop.o \ ../WindowServer/WSWindow.o \ ../WindowServer/WSWindowManager.o \ - ../WindowServer/WSFrameBuffer.o \ ../WindowServer/WSScreen.o \ ../WindowServer/main.o diff --git a/Kernel/ProcessGUI.cpp b/Kernel/ProcessGUI.cpp index d1e53d2baa..25b520b43e 100644 --- a/Kernel/ProcessGUI.cpp +++ b/Kernel/ProcessGUI.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -11,7 +10,6 @@ void Process::initialize_gui_statics() { Font::initialize(); - WSFrameBuffer::initialize(); WSEventLoop::initialize(); WSWindowManager::initialize(); WSScreen::initialize(); diff --git a/WindowServer/WSFrameBuffer.cpp b/WindowServer/WSFrameBuffer.cpp deleted file mode 100644 index 1d39ee0d78..0000000000 --- a/WindowServer/WSFrameBuffer.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "WSFrameBuffer.h" -#include -#include - -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(((byte*)m_data) + (y * pitch)); -} diff --git a/WindowServer/WSFrameBuffer.h b/WindowServer/WSFrameBuffer.h deleted file mode 100644 index 06e90bc4d3..0000000000 --- a/WindowServer/WSFrameBuffer.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "WSScreen.h" -#include - -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 }; -}; - diff --git a/WindowServer/WSScreen.cpp b/WindowServer/WSScreen.cpp index 1fa81a3a0d..80ba9c5048 100644 --- a/WindowServer/WSScreen.cpp +++ b/WindowServer/WSScreen.cpp @@ -17,8 +17,9 @@ WSScreen& WSScreen::the() return *s_the; } -WSScreen::WSScreen(unsigned width, unsigned height) - : m_width(width) +WSScreen::WSScreen(RGBA32* framebuffer, unsigned width, unsigned height) + : m_framebuffer(framebuffer) + , m_width(width) , m_height(height) { ASSERT(!s_the); diff --git a/WindowServer/WSScreen.h b/WindowServer/WSScreen.h index 240660ac40..5fa88dcb29 100644 --- a/WindowServer/WSScreen.h +++ b/WindowServer/WSScreen.h @@ -2,14 +2,17 @@ #include #include +#include #include class WSScreen { public: + WSScreen(RGBA32*, unsigned width, unsigned height); ~WSScreen(); int width() const { return m_width; } int height() const { return m_height; } + RGBA32* scanline(int y); static WSScreen& the(); @@ -29,6 +32,8 @@ protected: WSScreen(unsigned width, unsigned height); private: + RGBA32* m_framebuffer { nullptr }; + int m_width { 0 }; int m_height { 0 }; @@ -37,3 +42,8 @@ private: bool m_right_mouse_button_pressed { false }; }; +inline RGBA32* WSScreen::scanline(int y) +{ + size_t pitch = sizeof(RGBA32) * width(); + return reinterpret_cast(((byte*)m_framebuffer) + (y * pitch)); +} diff --git a/WindowServer/WSWindowManager.cpp b/WindowServer/WSWindowManager.cpp index 735650bfdf..b5fd018610 100644 --- a/WindowServer/WSWindowManager.cpp +++ b/WindowServer/WSWindowManager.cpp @@ -2,7 +2,6 @@ #include "WSWindow.h" #include "WSScreen.h" #include "WSEventLoop.h" -#include "WSFrameBuffer.h" #include "Process.h" #include "MemoryManager.h" #include @@ -107,15 +106,15 @@ static const char* cursor_bitmap_outer_ascii = { }; WSWindowManager::WSWindowManager() - : m_framebuffer(WSFrameBuffer::the()) - , m_screen_rect(m_framebuffer.rect()) + : m_screen(WSScreen::the()) + , m_screen_rect(m_screen.rect()) { #ifndef DEBUG_COUNTERS (void)m_recompose_count; (void)m_flush_count; #endif 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); 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(); 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() }; flush(m_last_cursor_rect.united(cursor_rect)); Color inner_color = Color::White; Color outer_color = Color::Black; - if (m_framebuffer.left_mouse_button_pressed()) + if (m_screen.left_mouse_button_pressed()) 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_outer, outer_color); diff --git a/WindowServer/WSWindowManager.h b/WindowServer/WSWindowManager.h index d9a7ef18cc..75d8c217c8 100644 --- a/WindowServer/WSWindowManager.h +++ b/WindowServer/WSWindowManager.h @@ -9,7 +9,7 @@ #include #include "WSEventReceiver.h" -class WSFrameBuffer; +class WSScreen; class MouseEvent; class PaintEvent; class WSWindow; @@ -53,7 +53,7 @@ private: void compose(); void paint_window_frame(WSWindow&); - WSFrameBuffer& m_framebuffer; + WSScreen& m_screen; Rect m_screen_rect; Color m_active_window_border_color; diff --git a/WindowServer/main.cpp b/WindowServer/main.cpp index 827f8291e4..10dc450fbb 100644 --- a/WindowServer/main.cpp +++ b/WindowServer/main.cpp @@ -1,6 +1,6 @@ #include "Process.h" #include -#include +#include #include #include #include @@ -14,7 +14,7 @@ void WindowServer_main() 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();