mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:07:45 +00:00
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.
This commit is contained in:
parent
2735b7e50d
commit
9963da9005
21 changed files with 212 additions and 41 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "FrameBufferSDL.h"
|
||||
#include "GraphicsBitmap.h"
|
||||
#include <AK/Assertions.h>
|
||||
|
||||
FrameBufferSDL* s_the = nullptr;
|
||||
|
@ -57,3 +58,27 @@ void FrameBufferSDL::initializeSDL()
|
|||
SDL_UpdateWindowSurface(m_window);
|
||||
}
|
||||
|
||||
dword* FrameBufferSDL::scanline(int y)
|
||||
{
|
||||
return (dword*)(((byte*)m_surface->pixels) + (y * m_surface->pitch));
|
||||
}
|
||||
|
||||
void FrameBufferSDL::blit(const Point& position, GraphicsBitmap& bitmap)
|
||||
{
|
||||
Rect dst_rect(position, bitmap.size());
|
||||
|
||||
printf("blit at %d,%d %dx%d\n", dst_rect.x(), dst_rect.y(), dst_rect.width(), dst_rect.height());
|
||||
dst_rect.intersect(rect());
|
||||
printf(" -> intersection %d,%d %dx%d\n", dst_rect.x(), dst_rect.y(), dst_rect.width(), dst_rect.height());
|
||||
|
||||
for (int y = 0; y < dst_rect.height(); ++y) {
|
||||
auto* framebuffer_scanline = scanline(position.y() + y);
|
||||
auto* bitmap_scanline = bitmap.scanline(y);
|
||||
memcpy(framebuffer_scanline + position.x(), bitmap_scanline, dst_rect.width() * 4);
|
||||
}
|
||||
}
|
||||
|
||||
void FrameBufferSDL::flush()
|
||||
{
|
||||
SDL_UpdateWindowSurface(m_window);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue