2023-11-15 19:20:52 -08:00
|
|
|
#include "framebuffer/framebuffer.h"
|
|
|
|
|
|
|
|
Framebuffer::Framebuffer(const FramebufferInfo& info) : fb_info_(info) {
|
|
|
|
uint64_t buff_size_bytes = fb_info_.height() * fb_info_.pitch();
|
2023-11-19 20:48:23 -08:00
|
|
|
fb_memory_ = OwnedMemoryRegion::DirectPhysical(fb_info_.address_phys(),
|
|
|
|
buff_size_bytes);
|
|
|
|
fb_ = reinterpret_cast<uint32_t*>(fb_memory_.vaddr());
|
2023-11-15 19:20:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Framebuffer::DrawPixel(uint32_t row, uint32_t col, uint32_t pixel) {
|
|
|
|
// Div by 4 because pitch is in bytes and fb_ is a 32bit array.
|
|
|
|
fb_[(row * fb_info_.pitch() / 4) + col] = pixel;
|
|
|
|
}
|