summaryrefslogtreecommitdiff
path: root/src/modules/stars
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@gnugeneration.com>2017-02-08 20:03:38 -0800
committerGitHub <noreply@github.com>2017-02-08 20:03:38 -0800
commit8563edd058bb5e564b5e6c2bafde6636b3fce6ee (patch)
treed3232ac628eee1517e258d9b512b0f9a838e9f02 /src/modules/stars
parent9d032314e9db794dc88889bc24bf50bbafc3ec8d (diff)
parentb35ba71b6de341f7b87beb3bc078600f3d191612 (diff)
Consolidate fb_fragment_t interactions
sparkler and stars both cleared fragments and drew individual pixels into fragments, add that functionality to fb.h and cleanup sparkler and stars accordingly.
Diffstat (limited to 'src/modules/stars')
-rw-r--r--src/modules/stars/draw.h16
-rw-r--r--src/modules/stars/stars.c4
2 files changed, 2 insertions, 18 deletions
diff --git a/src/modules/stars/draw.h b/src/modules/stars/draw.h
index 5010374..0b68c00 100644
--- a/src/modules/stars/draw.h
+++ b/src/modules/stars/draw.h
@@ -3,8 +3,6 @@
#include <stdint.h>
-#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)
{
@@ -15,18 +13,4 @@ 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)
-{
- 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
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c
index e009714..2ff9b99 100644
--- a/src/modules/stars/stars.c
+++ b/src/modules/stars/stars.c
@@ -37,13 +37,13 @@ static void stars(fb_fragment_t *fragment)
}
// draw space (or blank the frame, if you prefer)
- memset(fragment->buf, 0, ((fragment->width << 2) + fragment->stride) * fragment->height);
+ fb_fragment_zero(fragment);
// draw stars
for (;;) {
int ret = process_point( u, &rp );
if (ret==0) break;
- if (ret==1) draw_pixel(fragment, rp.x+(width/2), rp.y+(height/2),
+ if (ret==1) fb_fragment_put_pixel_unchecked(fragment, rp.x+(width/2), rp.y+(height/2),
makergb(0xFF, 0xFF, 0xFF, (float)rp.opacity/OPACITY_MAX)
);
}
© All Rights Reserved