1/*
2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors.
3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com>
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#pragma once
10#include <libg/Color.h>
11#include <libg/PixelBitmap.h>
12#include <memory>
13
14namespace WinServer {
15
16class Screen {
17public:
18 inline static Screen& the()
19 {
20 extern Screen* s_WinServer_Screen_the;
21 return *s_WinServer_Screen_the;
22 }
23
24 Screen();
25
26 void swap_buffers();
27
28 inline size_t width() { return m_bounds.width(); }
29 inline size_t height() const { return m_bounds.height(); }
30 inline LG::Rect& bounds() { return m_bounds; }
31 inline const LG::Rect& bounds() const { return m_bounds; }
32 inline uint32_t depth() const { return m_depth; }
33
34 inline LG::PixelBitmap& write_bitmap() { return *m_write_bitmap_ptr; }
35 inline const LG::PixelBitmap& write_bitmap() const { return *m_write_bitmap_ptr; }
36 inline LG::PixelBitmap& display_bitmap() { return *m_display_bitmap_ptr; }
37 inline const LG::PixelBitmap& display_bitmap() const { return *m_display_bitmap_ptr; }
38
39private:
40 int m_screen_fd;
41 LG::Rect m_bounds;
42 uint32_t m_depth;
43
44 int m_active_buffer;
45
46 LG::PixelBitmap m_write_bitmap;
47 LG::PixelBitmap m_display_bitmap;
48
49 std::unique_ptr<LG::PixelBitmap> m_write_bitmap_ptr { nullptr };
50 std::unique_ptr<LG::PixelBitmap> m_display_bitmap_ptr { nullptr };
51};
52
53} // namespace WinServer