From 91e5956932d17de17c0c75be20c834cf7a6c6ed9 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 3 Feb 2017 13:06:26 -0800 Subject: rototiller: extricate draw_pixel() bounds checking If a z-buffer is added these checks will need to be done independent from and prior to drawing. Also it's silly to makergb() pixels which can't be drawn. --- src/modules/sparkler/draw.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/modules/sparkler/draw.h') diff --git a/src/modules/sparkler/draw.h b/src/modules/sparkler/draw.h index 5010374..b988319 100644 --- a/src/modules/sparkler/draw.h +++ b/src/modules/sparkler/draw.h @@ -15,18 +15,12 @@ static inline uint32_t makergb(uint32_t r, uint32_t g, uint32_t b, float intensi return (((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)); } -static inline int draw_pixel(fb_fragment_t *f, int x, int y, uint32_t pixel) +static inline void draw_pixel(fb_fragment_t *f, int x, int y, uint32_t pixel) { uint32_t *pixels = f->buf; - if (y < 0 || y >= f->height || x < 0 || x >= f->width) { - return 0; - } - /* FIXME this assumes stride is aligned to 4 */ pixels[(y * (f->width + (f->stride >> 2))) + x] = pixel; - - return 1; } #endif -- cgit v1.2.3 From 90fde2df2d8c59b0b885e6e02b5e89dbe966a5e9 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 3 Feb 2017 15:43:51 -0800 Subject: sparkler: use fb.h put_pixel helpers discards draw_pixel(), introduces helpers.h and a convenience function for bounds checking and oob extermination. Move makergb to helpers.h, draw.h gets removed in a later commit. --- src/modules/sparkler/draw.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/modules/sparkler/draw.h') diff --git a/src/modules/sparkler/draw.h b/src/modules/sparkler/draw.h index b988319..10701e0 100644 --- a/src/modules/sparkler/draw.h +++ b/src/modules/sparkler/draw.h @@ -5,15 +5,6 @@ #include "fb.h" -/* helper for scaling rgb colors and packing them into an pixel */ -static inline uint32_t makergb(uint32_t r, uint32_t g, uint32_t b, float intensity) -{ - r = (((float)intensity) * r); - g = (((float)intensity) * g); - b = (((float)intensity) * b); - - return (((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)); -} static inline void draw_pixel(fb_fragment_t *f, int x, int y, uint32_t pixel) { -- cgit v1.2.3 From f21492a1e8314e27ef307bc4b2629468d40e6c72 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 3 Feb 2017 15:46:08 -0800 Subject: sparkler: drop draw.h --- src/modules/sparkler/draw.h | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 src/modules/sparkler/draw.h (limited to 'src/modules/sparkler/draw.h') diff --git a/src/modules/sparkler/draw.h b/src/modules/sparkler/draw.h deleted file mode 100644 index 10701e0..0000000 --- a/src/modules/sparkler/draw.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _DRAW_H -#define _DRAW_H - -#include - -#include "fb.h" - - -static inline void draw_pixel(fb_fragment_t *f, int x, int y, uint32_t pixel) -{ - uint32_t *pixels = f->buf; - - /* FIXME this assumes stride is aligned to 4 */ - pixels[(y * (f->width + (f->stride >> 2))) + x] = pixel; -} - -#endif -- cgit v1.2.3