summaryrefslogtreecommitdiffhomepage
path: root/Private/Source/Framebuffer.cxx
blob: 1a73e4494f71ff6689a77ba7563836d1a84feaf2 (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
/*
 *	========================================================
 *
 *	hCore
 * 	Copyright 2024 Mahrouss Logic, all rights reserved.
 *
 * 	========================================================
 */

#include <KernelKit/Framebuffer.hpp>

namespace hCore {
Framebuffer::Framebuffer(hCore::Ref<FramebufferContext*>& addr)
    : m_FrameBufferAddr(addr), m_Colour(FramebufferColorKind::RGB32) {}

Framebuffer::~Framebuffer() = default;

volatile UIntPtr* Framebuffer::operator[](const UIntPtr& width_and_height) {
  if (m_FrameBufferAddr)
    return reinterpret_cast<volatile hCore::UIntPtr*>(
        m_FrameBufferAddr->m_Base + width_and_height);

  return nullptr;
}

Ref<FramebufferContext*>& Framebuffer::Leak() { return m_FrameBufferAddr; }

Framebuffer::operator bool() { return m_FrameBufferAddr; }

const FramebufferColorKind& Framebuffer::Color(
    const FramebufferColorKind& colour) {
  if (colour != FramebufferColorKind::INVALID) m_Colour = colour;

  return m_Colour;
}
}  // namespace hCore