Xyris  0.5
framebuffer.cpp
Go to the documentation of this file.
1 /**
2  * @file framebuffer.cpp
3  * @author Keeton Feavel ([email protected])
4  * @brief
5  * @version 0.1
6  * @date 2021-06-11
7  *
8  * @copyright Copyright the Xyris Contributors (c) 2021
9  *
10  */
12 #include <stddef.h>
13 #include <stdint.h>
14 
15 namespace Graphics {
16 
17 static Framebuffer* framebuffer = NULL;
18 
20  : _addr(NULL)
21  , _width(0)
22  , _height(0)
23  , _depth(0)
24  , _pitch(0)
25  , _redMaskSize(0)
26  , _redMaskShift(0)
27  , _greenMaskSize(0)
28  , _greenMaskShift(0)
29  , _blueMaskSize(0)
30  , _blueMaskShift(0)
31  , _memoryModel(Undefined_FBMM)
32 {
33  // Default constructor.
34  if (!framebuffer)
35  framebuffer = this;
36 }
37 
38 Framebuffer::Framebuffer(uint32_t width, uint32_t height, uint16_t depth, uint32_t pitch, void* addr)
39  : _addr(addr)
40  , _width(width)
41  , _height(height)
42  , _depth(depth)
43  , _pitch(pitch)
44  , _redMaskSize(0)
45  , _redMaskShift(0)
46  , _greenMaskSize(0)
47  , _greenMaskShift(0)
48  , _blueMaskSize(0)
49  , _blueMaskShift(0)
50  , _memoryModel(Undefined_FBMM)
51 {
52  // Common parameters constructor
53  if (!framebuffer)
54  framebuffer = this;
55 }
56 
57 Framebuffer::Framebuffer(uint32_t width, uint32_t height,
58  uint16_t depth, uint32_t pitch,
59  void* addr, FramebufferMemoryModel model,
60  uint8_t redMaskSize, uint8_t redMaskShift,
61  uint8_t greenMaskSize, uint8_t greenMaskShift,
62  uint8_t blueMaskSize, uint8_t blueMaskShift)
63  : _addr(addr)
64  , _width(width)
65  , _height(height)
66  , _depth(depth)
67  , _pitch(pitch)
68  , _redMaskSize(redMaskSize)
69  , _redMaskShift(redMaskShift)
70  , _greenMaskSize(greenMaskSize)
71  , _greenMaskShift(greenMaskShift)
72  , _blueMaskSize(blueMaskSize)
73  , _blueMaskShift(blueMaskShift)
74  , _memoryModel(model)
75 {
76  // All parameters constructor
77  if (!framebuffer)
78  framebuffer = this;
79 }
80 
82 {
83  return framebuffer;
84 }
85 
86 } // !namespace FB
Graphics::FramebufferMemoryModel
FramebufferMemoryModel
Definition: framebuffer.hpp:16
Graphics::Framebuffer::Framebuffer
Framebuffer()
Definition: framebuffer.cpp:19
Graphics::Undefined_FBMM
@ Undefined_FBMM
Definition: framebuffer.hpp:17
framebuffer.hpp
Graphics
Definition: font.cpp:17
Graphics::Framebuffer
Definition: framebuffer.hpp:21
Arch::CPU::model
const char * model()
Definition: Arch.i686.cpp:134
Graphics::getFramebuffer
Framebuffer * getFramebuffer()
Get a pointer to the active framebuffer.
Definition: framebuffer.cpp:81