fix mandelbrot
This commit is contained in:
parent
8f0aecb444
commit
42911b6d4a
1 changed files with 25 additions and 20 deletions
|
@ -88,26 +88,15 @@ torgb(int n)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
draw_pixel(void *closure, struct scheduler *s)
|
pixel(unsigned int *image, double scale, int x, int y, int dx, int dy,
|
||||||
|
int width)
|
||||||
{
|
{
|
||||||
struct mandelbrot_args *args = (struct mandelbrot_args *)closure;
|
unsigned rgb = torgb(mandel(toc(x, y, dx, dy, scale)));
|
||||||
unsigned int *image = args->image;
|
image[y * width + x] = rgb;
|
||||||
double scale = args->scale;
|
|
||||||
int dx = args->dx;
|
|
||||||
int dy = args->dy;
|
|
||||||
int width = args->width;
|
|
||||||
|
|
||||||
(void)s; // pas de nouvelle tâche dans le scheduler
|
|
||||||
|
|
||||||
free(closure);
|
|
||||||
|
|
||||||
unsigned rgb = torgb(mandel(toc(dx, dy, dx, dy, scale)));
|
|
||||||
|
|
||||||
image[dy * width + dx] = rgb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
draw(void *closure, struct scheduler *s)
|
draw_pixel(void *closure, struct scheduler *s)
|
||||||
{
|
{
|
||||||
struct mandelbrot_args *args = (struct mandelbrot_args *)closure;
|
struct mandelbrot_args *args = (struct mandelbrot_args *)closure;
|
||||||
unsigned int *image = args->image;
|
unsigned int *image = args->image;
|
||||||
|
@ -117,12 +106,29 @@ draw(void *closure, struct scheduler *s)
|
||||||
int dx = args->dx;
|
int dx = args->dx;
|
||||||
int dy = args->dy;
|
int dy = args->dy;
|
||||||
int width = args->width;
|
int width = args->width;
|
||||||
|
|
||||||
|
(void)s; // pas de nouvelle tâche dans le scheduler
|
||||||
|
|
||||||
|
free(closure);
|
||||||
|
|
||||||
|
pixel(image, scale, x, y, dx, dy, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
draw(void *closure, struct scheduler *s)
|
||||||
|
{
|
||||||
|
struct mandelbrot_args *args = (struct mandelbrot_args *)closure;
|
||||||
|
unsigned int *image = args->image;
|
||||||
|
double scale = args->scale;
|
||||||
|
int dx = args->dx;
|
||||||
|
int dy = args->dy;
|
||||||
|
int width = args->width;
|
||||||
int height = args->height;
|
int height = args->height;
|
||||||
|
|
||||||
free(closure);
|
free(closure);
|
||||||
|
|
||||||
for(; y < height; y++) {
|
for(int y = 0; y < height; y++) {
|
||||||
for(; x < width; x++) {
|
for(int x = 0; x < width; x++) {
|
||||||
int rc = sched_spawn(
|
int rc = sched_spawn(
|
||||||
draw_pixel,
|
draw_pixel,
|
||||||
new_mandelbrot_args(image, scale, x, y, dx, dy, width, height),
|
new_mandelbrot_args(image, scale, x, y, dx, dy, width, height),
|
||||||
|
@ -138,8 +144,7 @@ draw_serial(unsigned int *image, double scale, int dx, int dy, int width,
|
||||||
{
|
{
|
||||||
for(int y = 0; y < height; y++) {
|
for(int y = 0; y < height; y++) {
|
||||||
for(int x = 0; x < width; x++) {
|
for(int x = 0; x < width; x++) {
|
||||||
unsigned rgb = torgb(mandel(toc(x, y, dx, dy, scale)));
|
pixel(image, scale, x, y, dx, dy, width);
|
||||||
image[y * width + x] = rgb;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue