From fc4e5f9d1e734affab9917558f19102a1331942f Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 27 Apr 2017 09:48:15 -0700 Subject: sparkler: respect fragment->frame_{width,height} should_draw_expire_if_oob() assumed the fragment represented the entire frame. Instead, return 0 if the coordinates are outside the fragment, but only reset longevity if outside of the frame. If sparkler goes threaded in the drawing, this would result in threads simply skipping particles outside the fragment. The longevity reset occurring in all threads appears suspicious but should be benign since they all write the same thing - 0. --- src/modules/sparkler/helpers.h | 5 ++--- src/modules/sparkler/particles.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/modules/sparkler') diff --git a/src/modules/sparkler/helpers.h b/src/modules/sparkler/helpers.h index e263d36..3fd1bda 100644 --- a/src/modules/sparkler/helpers.h +++ b/src/modules/sparkler/helpers.h @@ -23,9 +23,8 @@ static inline uint32_t makergb(uint32_t r, uint32_t g, uint32_t b, float intensi static inline int should_draw_expire_if_oob(particles_t *particles, particle_t *p, int x, int y, fb_fragment_t *f, int *longevity) { if (!fb_fragment_contains(f, x, y)) { - /* offscreen */ - if (longevity) - *longevity = 0; + if (longevity && (x < 0 || x > f->frame_width || y < 0 || y > f->frame_height)) + *longevity = 0; /* offscreen */ return 0; } diff --git a/src/modules/sparkler/particles.c b/src/modules/sparkler/particles.c index e504adb..5116e3a 100644 --- a/src/modules/sparkler/particles.c +++ b/src/modules/sparkler/particles.c @@ -216,7 +216,7 @@ bsp_t * particles_bsp(particles_t *particles) static inline void _particles_draw(particles_t *particles, list_head_t *list, fb_fragment_t *fragment) { - float w2 = fragment->width * .5f, h2 = fragment->height * .5f; + float w2 = fragment->frame_width * .5f, h2 = fragment->frame_height * .5f; _particle_t *p; assert(particles); -- cgit v1.2.1