summaryrefslogtreecommitdiffhomepage
path: root/Private/Source/Framebuffer.cxx
blob: 6ea2fa5b4d67a3f9051c55cd1ce8c9d56081f38e (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
/* -------------------------------------------

    Copyright Mahrouss Logic

    File: Framebuffer.cxx
    Purpose: Framebuffer object

    Revision History:

    01/02/24: Added file (amlel)
    02/02/24: Add documentation (amlel)

------------------------------------------- */

#include <KernelKit/Framebuffer.hpp>

/**
 * @brief Framebuffer object implementation.
 *
 */

using namespace HCore;

/**
 * @brief Get Pixel at
 *
 * @param pos position of pixel.
 * @return volatile*
 */
volatile UIntPtr *Framebuffer::operator[](const UIntPtr &pos) {
  return (UIntPtr *)(m_FrameBufferAddr->m_Base * pos);
}

/// @brief Boolean operator.
Framebuffer::operator bool() {
  return m_FrameBufferAddr.Leak()->m_Base != 0 && m_Colour != FramebufferColorKind::INVALID &&
        m_FrameBufferAddr.Leak()->m_Base != kBadPtr;
}

/// @brief Set color kind of framebuffer.
/// @param colour 
/// @return 
const FramebufferColorKind &Framebuffer::Color(
    const FramebufferColorKind &colour) {
  if (m_Colour != FramebufferColorKind::INVALID &&
      colour != FramebufferColorKind::INVALID) {
    m_Colour = colour;
  }

  return m_Colour;
}

/// @brief Leak fraembuffer context.
/// @return The reference of the framebuffer context.
Ref<FramebufferContext *> &Framebuffer::Leak() {
  return this->m_FrameBufferAddr;
}