From 6fb381247aa3f73ac1501489421a364ed79d03c4 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Wed, 28 Nov 2018 20:39:57 +0900 Subject: [PATCH] graphics: subregions --- base/usr/include/toaru/graphics.h | 1 + lib/graphics.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/base/usr/include/toaru/graphics.h b/base/usr/include/toaru/graphics.h index 6334f76a..3d73d50e 100644 --- a/base/usr/include/toaru/graphics.h +++ b/base/usr/include/toaru/graphics.h @@ -126,5 +126,6 @@ struct gradient_definition { extern uint32_t gfx_vertical_gradient_pattern(int32_t x, int32_t y, double alpha, void * extra); +extern gfx_context_t * init_graphics_subregion(gfx_context_t * base, int x, int y, int width, int height); _End_C_Header diff --git a/lib/graphics.c b/lib/graphics.c index 1b5ab46c..64a2ddae 100644 --- a/lib/graphics.c +++ b/lib/graphics.c @@ -128,6 +128,22 @@ gfx_context_t * init_graphics_fullscreen_double_buffer() { return out; } +gfx_context_t * init_graphics_subregion(gfx_context_t * base, int x, int y, int width, int height) { + gfx_context_t * out = malloc(sizeof(gfx_context_t)); + + out->clips = NULL; + out->depth = 32; + + out->width = width; + out->height = height; + out->stride = base->stride; + out->backbuffer = base->buffer + (base->stride * y) + x * 4; + out->buffer = base->buffer + (base->stride * y) + x * 4; + + out->size = 0; /* don't allow flip or clear operations */ + return out; +} + void reinit_graphics_fullscreen(gfx_context_t * out) { ioctl(framebuffer_fd, IO_VID_WIDTH, &out->width);