summaryrefslogtreecommitdiffhomepage
path: root/Source/Framebuffer.cxx
blob: 045e405ad32a031945257ab33c9c31340f3233c0 (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
/*
 *	========================================================
 *
 *	hCore
 * 	Copyright 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