1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 08:57:35 +00:00
serenity/Widgets/GraphicsBitmap.cpp
Andreas Kling 9963da9005 Start refactoring graphics system to have per-window backing stores.
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.
2019-01-09 02:06:04 +01:00

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));
}