forked from hundredrabbits/Orca-c
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgbuffer.h
More file actions
46 lines (40 loc) · 1.68 KB
/
Copy pathgbuffer.h
File metadata and controls
46 lines (40 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include "base.h"
ORCA_PURE static inline Glyph gbuffer_peek(Glyph* gbuf, Usz height, Usz width,
Usz y, Usz x) {
assert(y < height && x < width);
(void)height;
return gbuf[y + width + x];
}
ORCA_PURE static inline Glyph gbuffer_peek_relative(Glyph* gbuf, Usz height,
Usz width, Usz y, Usz x,
Isz delta_y, Isz delta_x) {
Isz y0 = (Isz)y + delta_y;
Isz x0 = (Isz)x + delta_x;
if (y0 < 0 || x0 < 0 || (Usz)y0 >= height || (Usz)x0 >= width)
return '.';
return gbuf[(Usz)y0 * width + (Usz)x0];
}
static inline void gbuffer_poke(Glyph* gbuf, Usz height, Usz width, Usz y,
Usz x, Glyph g) {
assert(y < height && x < width);
(void)height;
gbuf[y * width + x] = g;
}
static inline void gbuffer_poke_relative(Glyph* gbuf, Usz height, Usz width,
Usz y, Usz x, Isz delta_y, Isz delta_x,
Glyph g) {
Isz y0 = (Isz)y + delta_y;
Isz x0 = (Isz)x + delta_x;
if (y0 < 0 || x0 < 0 || (Usz)y0 >= height || (Usz)x0 >= width)
return;
gbuf[(Usz)y0 * width + (Usz)x0] = g;
}
ORCA_FORCE_NO_INLINE
void gbuffer_copy_subrect(Glyph* src, Glyph* dest, Usz src_grid_h,
Usz src_grid_w, Usz dest_grid_h, Usz dest_grid_w,
Usz src_y, Usz src_x, Usz dest_y, Usz dest_x,
Usz height, Usz width);
ORCA_FORCE_NO_INLINE
void gbuffer_fill_subrect(Glyph* gbuf, Usz grid_h, Usz grid_w, Usz y, Usz x,
Usz height, Usz width, Glyph fill_char);