blob: 86e77afc8c4da69fe26af78b7715ffa45aa479a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/* -------------------------------------------
Copyright Zeta Electronics Corporation
File: Framebuffer.hpp
Purpose: Framebuffer object.
------------------------------------------- */
#ifndef __INC_FB_HPP__
#define __INC_FB_HPP__
#include <NewKit/Defines.hpp>
#include <NewKit/Ref.hpp>
namespace Kernel
{
enum class FramebufferColorKind : UChar
{
RGB32,
RGB16,
RGB8,
INVALID,
};
class FramebufferContext final
{
public:
UIntPtr fBase;
UIntPtr fBpp;
UInt fWidth;
UInt fHeight;
};
class Framebuffer final
{
public:
explicit Framebuffer(Ref<FramebufferContext*>& addr);
~Framebuffer() = default;
Framebuffer& operator=(const Framebuffer&) = delete;
Framebuffer(const Framebuffer&) = default;
volatile UIntPtr* operator[](const UIntPtr& pos);
operator bool();
const FramebufferColorKind& Color(
const FramebufferColorKind& colour = FramebufferColorKind::INVALID);
Ref<FramebufferContext*>& Leak();
/// @brief Draws a rectangle inside the fb.
/// @param width the width of it
/// @param height the height of it
/// @param x its x coord.
/// @param y its y coord.
/// @param color the color of it.
/// @return the framebuffer object.
Framebuffer& DrawRect(SizeT width, SizeT height, SizeT x, SizeT y, UInt32 color);
/// @brief Puts a pixel on the screen.
/// @param x where in X
/// @param y where in Y
/// @param color the color of it.
/// @return the framebuffer object.
Framebuffer& PutPixel(SizeT x, SizeT y, UInt32 color);
private:
Ref<FramebufferContext*> fFrameBufferAddr;
FramebufferColorKind fColour;
};
/***********************************************************************************/
/// Some common colors.
/***********************************************************************************/
extern const UInt32 kRgbRed;
extern const UInt32 kRgbGreen;
extern const UInt32 kRgbBlue;
extern const UInt32 kRgbBlack;
extern const UInt32 kRgbWhite;
} // namespace Kernel
#endif /* ifndef __INC_FB_HPP__ */
|