mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 08:57:35 +00:00

It was fun for everyone to share a single framebuffer but it was also kinda really awful. Let's move towards having a "GraphicsBitmap" as the backing store for each Window. This is going to need a lot of refactoring so let's get started.
25 lines
501 B
C++
25 lines
501 B
C++
#include "GraphicsBitmap.h"
|
|
#include <AK/kmalloc.h>
|
|
|
|
RetainPtr<GraphicsBitmap> GraphicsBitmap::create(const Size& size)
|
|
{
|
|
return adopt(*new GraphicsBitmap(size));
|
|
}
|
|
|
|
GraphicsBitmap::GraphicsBitmap(const Size& size)
|
|
: m_size(size)
|
|
{
|
|
m_data = (byte*)kmalloc(size.width() * size.height() * 4);
|
|
}
|
|
|
|
GraphicsBitmap::~GraphicsBitmap()
|
|
{
|
|
kfree(m_data);
|
|
}
|
|
|
|
dword* GraphicsBitmap::scanline(int y)
|
|
{
|
|
unsigned pitch = m_size.width() * 4;
|
|
return (dword*)(((byte*)m_data) + (y * pitch));
|
|
}
|
|
|