ref: 77e0f874ec26e4662f914ea479069d091e155caf
parent: c934f9f177372c9675c98eff6d416895d1e8a4c4
author: cancel <cancel@cancel.fm>
date: Mon Dec 3 05:30:49 EST 2018
Cleanup field.h/.c, move some stuff to gbuffer.h/.c
--- a/field.c
+++ b/field.c
@@ -40,34 +40,6 @@
src->width);
}
-void field_fill_subrect(Field* f, Usz y, Usz x, Usz height, Usz width,
- Glyph fill_char) {
- Usz f_height = f->height;
- Usz f_width = f->width;
- if (y >= f_height || x >= f_width)
- return;
- Usz rows_0 = f_height - y;
- Usz rows = height;
- if (rows_0 < rows)
- rows = rows_0;
- if (rows == 0)
- return;
- Usz columns_0 = f_width - x;
- Usz columns = width;
- if (columns_0 < columns)
- columns = columns_0;
- Usz fill_bytes = columns * sizeof(Glyph);
- Glyph* p = f->buffer + y * f_width + x;
- Usz iy = 0;
- for (;;) {
- memset(p, fill_char, fill_bytes);
- ++iy;
- if (iy == rows)
- break;
- p += f_width;
- }
-}
-
static inline bool glyph_char_is_valid(char c) { return c >= '#' && c <= '~'; }
void field_fput(Field* f, FILE* stream) {
--- a/field.h
+++ b/field.h
@@ -7,8 +7,6 @@
void field_resize_raw_if_necessary(Field* field, Usz height, Usz width);
void field_deinit(Field* field);
void field_copy(Field* src, Field* dest);
-void field_fill_subrect(Field* field, Usz y, Usz x, Usz height, Usz width,
- Glyph fill_char);
void field_fput(Field* field, FILE* stream);
typedef enum {
--- a/gbuffer.c
+++ b/gbuffer.c
@@ -47,3 +47,29 @@
dest_p += dest_stride;
}
}
+
+void gbuffer_fill_subrect(Glyph* gbuffer, Usz f_height, Usz f_width, Usz y,
+ Usz x, Usz height, Usz width, Glyph fill_char) {
+ if (y >= f_height || x >= f_width)
+ return;
+ Usz rows_0 = f_height - y;
+ Usz rows = height;
+ if (rows_0 < rows)
+ rows = rows_0;
+ if (rows == 0)
+ return;
+ Usz columns_0 = f_width - x;
+ Usz columns = width;
+ if (columns_0 < columns)
+ columns = columns_0;
+ Usz fill_bytes = columns * sizeof(Glyph);
+ Glyph* p = gbuffer + y * f_width + x;
+ Usz iy = 0;
+ for (;;) {
+ memset(p, fill_char, fill_bytes);
+ ++iy;
+ if (iy == rows)
+ break;
+ p += f_width;
+ }
+}
--- a/gbuffer.h
+++ b/gbuffer.h
@@ -40,3 +40,7 @@
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* gbuffer, Usz grid_h, Usz grid_w, Usz y, Usz x,
+ Usz height, Usz width, Glyph fill_char);