diff options
author | Mattias Andrée <maandree@kth.se> | 2023-01-21 19:30:25 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-01-21 19:32:34 +0100 |
commit | 4114f87af993991c7aab55ff86be3003d43244f3 (patch) | |
tree | b5841672b4a48c02a9015ddc273f7b64ad9bec3a /libglitter_update_render_context.c | |
parent | Add integer versions of libglitter_compose_* (diff) | |
download | libglitter-4114f87af993991c7aab55ff86be3003d43244f3.tar.gz libglitter-4114f87af993991c7aab55ff86be3003d43244f3.tar.bz2 libglitter-4114f87af993991c7aab55ff86be3003d43244f3.tar.xz |
Add render context
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libglitter_update_render_context.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libglitter_update_render_context.c b/libglitter_update_render_context.c new file mode 100644 index 0000000..318ec87 --- /dev/null +++ b/libglitter_update_render_context.c @@ -0,0 +1,28 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +void +libglitter_update_render_context(LIBGLITTER_RENDER_CONTEXT *this, size_t rowsize) +{ + size_t y, x; + uint8_t channel; + size_t cellsi[3] = {0, 0, 0}; + + if (this && this->render_method == RENDER_METHOD_SIMPLE && this->rowsize != rowsize) { + this->rowsize = rowsize; + for (y = 0; y < this->heightmul; y++) { + for (x = 0; x < this->widthmul; x++) { + channel = this->cellmap[y * this->widthmul + x]; + this->cells[channel][cellsi[channel]] = y * rowsize + x; + cellsi[channel] += 1; + } + } + if (cellsi[0] == 1) + this->cells[0][1] = this->cells[0][0]; + if (cellsi[1] == 1) + this->cells[1][1] = this->cells[1][0]; + if (cellsi[2] == 1) + this->cells[2][1] = this->cells[2][0]; + } +} |