20 #include "pedigree/native/graphics/Graphics.h" 21 #include "pedigree/kernel/debugger/libudis86/types.h" 23 #include "modules/subsys/pedigree-c/pedigree-syscalls.h" 25 #define PACKED __attribute__((packed)) 32 uint32_t srcx, srcy, destx, desty, width, height;
38 uintptr_t b, c, d, e, f, g, h;
44 void *pReturnProvider;
55 uintptr_t a, b, c, d, e, f;
58 Rect::Rect() : x(0), y(0), w(0), h(0)
61 Rect::Rect(
size_t x_,
size_t y_,
size_t width_,
size_t height_)
62 : x(x_), y(y_), w(width_), h(height_)
66 Rect::~Rect() =
default;
68 void Rect::update(
size_t x_,
size_t y_,
size_t w_,
size_t h_)
76 size_t Rect::getX()
const 81 size_t Rect::getY()
const 86 size_t Rect::getW()
const 91 size_t Rect::getH()
const 96 Framebuffer::Framebuffer()
97 : m_Provider(), m_bProviderValid(
false), m_bIsChild(
false)
99 int ret = pedigree_gfx_get_provider(&m_Provider);
101 m_bProviderValid =
true;
107 m_bProviderValid = m_bIsChild =
true;
114 size_t nBytes = (getWidth() * getHeight() * getBytesPerPixel());
115 uint8_t *pBuffer =
new uint8_t[nBytes];
119 args.pReturnProvider = &m_Provider;
120 args.pFramebuffer =
reinterpret_cast<void *
>(pBuffer);
124 args.h = getHeight();
125 int ok = pedigree_gfx_create_fbuffer(&gfx, &args);
130 m_bProviderValid =
false;
134 Framebuffer::~Framebuffer()
137 pedigree_gfx_delete_fbuffer(&m_Provider);
142 if (!m_bProviderValid)
145 pedigree_gfx_setpalette(&m_Provider, palette, entries);
150 if (!m_bProviderValid)
154 pedigree_gfx_fbinfo(&m_Provider, &ret, 0, 0, 0);
161 if (!m_bProviderValid)
165 pedigree_gfx_fbinfo(&m_Provider, 0, &ret, 0, 0);
172 if (!m_bProviderValid)
176 pedigree_gfx_fbinfo(&m_Provider, 0, 0, &ret, 0);
178 return static_cast<PixelFormat
>(ret);
183 if (!m_bProviderValid)
187 pedigree_gfx_fbinfo(&m_Provider, 0, 0, 0, &ret);
194 if (!m_bProviderValid)
197 return reinterpret_cast<void *
>(pedigree_gfx_get_raw_buffer(&m_Provider));
202 if (!m_bProviderValid)
207 size_t nBytes = (w * h * getBytesPerPixel());
208 uint8_t *pBuffer =
new uint8_t[nBytes];
212 args.pReturnProvider = &ret;
213 args.pFramebuffer =
reinterpret_cast<void *
>(pBuffer);
218 int ok = pedigree_gfx_create_fbuffer(&m_Provider, &args);
231 const void *srcData, PixelFormat srcFormat,
size_t width,
size_t height)
233 if (!m_bProviderValid)
238 args.a =
reinterpret_cast<uintptr_t
>(srcData);
239 args.b =
static_cast<uintptr_t
>(srcFormat);
242 int ok = pedigree_gfx_create_buffer(
243 &m_Provider, reinterpret_cast<void **>(&ret), &args);
256 if (!m_bProviderValid)
259 pedigree_gfx_destroy_buffer(&m_Provider, pBuffer);
264 if (!m_bProviderValid)
274 pedigree_gfx_redraw(&m_Provider, &args);
278 Buffer *pBuffer,
size_t srcx,
size_t srcy,
size_t destx,
size_t desty,
279 size_t width,
size_t height)
282 args.pBuffer = pBuffer;
288 args.height = height;
290 pedigree_gfx_blit(&m_Provider, &args);
294 void *pBuffer,
size_t srcx,
size_t srcy,
size_t destx,
size_t desty,
295 size_t width,
size_t height, PixelFormat format)
297 if (!m_bProviderValid)
308 args.h =
static_cast<uint32_t
>(format);
310 pedigree_gfx_draw(&m_Provider, &args);
314 size_t x,
size_t y,
size_t width,
size_t height, uint32_t colour,
317 if (!m_bProviderValid)
326 args.f =
static_cast<uint32_t
>(format);
328 pedigree_gfx_rect(&m_Provider, &args);
332 size_t srcx,
size_t srcy,
size_t destx,
size_t desty,
size_t w,
size_t h)
334 if (!m_bProviderValid)
345 pedigree_gfx_copy(&m_Provider, &args);
349 size_t x1,
size_t y1,
size_t x2,
size_t y2, uint32_t colour,
352 if (!m_bProviderValid)
361 args.f =
static_cast<uint32_t
>(format);
363 pedigree_gfx_line(&m_Provider, &args);
367 size_t x,
size_t y, uint32_t colour, PixelFormat format)
369 if (!m_bProviderValid)
372 pedigree_gfx_set_pixel(
373 &m_Provider, x, y, colour, static_cast<uint32_t>(format));
void rect(size_t x, size_t y, size_t width, size_t height, uint32_t colour, PedigreeGraphics::PixelFormat format=PedigreeGraphics::Bits32_Argb)
void draw(void *pBuffer, size_t srcx, size_t srcy, size_t destx, size_t desty, size_t width, size_t height, PedigreeGraphics::PixelFormat format=PedigreeGraphics::Bits32_Argb)
void copy(size_t srcx, size_t srcy, size_t destx, size_t desty, size_t w, size_t h)
void destroyBuffer(PedigreeGraphics::Buffer *pBuffer)
void line(size_t x1, size_t y1, size_t x2, size_t y2, uint32_t colour, PedigreeGraphics::PixelFormat format=PedigreeGraphics::Bits32_Argb)
size_t getBytesPerPixel()
PedigreeGraphics::Buffer * createBuffer(const void *srcData, PedigreeGraphics::PixelFormat srcFormat, size_t width, size_t height)
void setPalette(uint32_t *palette, size_t entries)
PedigreeGraphics::PixelFormat getFormat()
void setPixel(size_t x, size_t y, uint32_t colour, PedigreeGraphics::PixelFormat format=PedigreeGraphics::Bits32_Argb)
Framebuffer * createChild(size_t x, size_t y, size_t w, size_t h)
void blit(PedigreeGraphics::Buffer *pBuffer, size_t srcx, size_t srcy, size_t destx, size_t desty, size_t width, size_t height)
void redraw(size_t x=~0UL, size_t y=~0UL, size_t w=~0UL, size_t h=~0UL, bool bChild=false)