forked from len0rd/rockbox
Mandelbrot didn't yield() at all, leading to playback problems when heavily calculating mandelbrots
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4759 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c05b7d722a
commit
58f17cd082
1 changed files with 13 additions and 7 deletions
|
|
@ -48,14 +48,14 @@ void init_mandelbrot_set(void){
|
||||||
|
|
||||||
void calc_mandelbrot_set(void){
|
void calc_mandelbrot_set(void){
|
||||||
|
|
||||||
unsigned int start_tick;
|
unsigned int start_tick, last_yield;
|
||||||
int n_iter;
|
int n_iter;
|
||||||
int x_pixel, y_pixel;
|
int x_pixel, y_pixel;
|
||||||
int x, x2, y, y2, a, b;
|
int x, x2, y, y2, a, b;
|
||||||
int x_fact, y_fact;
|
int x_fact, y_fact;
|
||||||
int brightness;
|
int brightness;
|
||||||
|
|
||||||
start_tick = *rb->current_tick;
|
start_tick = last_yield = *rb->current_tick;
|
||||||
|
|
||||||
gray_clear_display();
|
gray_clear_display();
|
||||||
|
|
||||||
|
|
@ -63,9 +63,9 @@ void calc_mandelbrot_set(void){
|
||||||
y_fact = (y_max - y_min) / LCD_HEIGHT;
|
y_fact = (y_max - y_min) / LCD_HEIGHT;
|
||||||
|
|
||||||
for (x_pixel = 0; x_pixel<LCD_WIDTH; x_pixel++){
|
for (x_pixel = 0; x_pixel<LCD_WIDTH; x_pixel++){
|
||||||
a = (x_pixel * x_fact) + x_min;
|
a = (x_pixel * x_fact) + x_min;
|
||||||
for(y_pixel = LCD_HEIGHT-1; y_pixel>=0; y_pixel--){
|
for(y_pixel = LCD_HEIGHT-1; y_pixel>=0; y_pixel--){
|
||||||
b = (y_pixel * y_fact) + y_min;
|
b = (y_pixel * y_fact) + y_min;
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
n_iter = 0;
|
n_iter = 0;
|
||||||
|
|
@ -89,9 +89,15 @@ void calc_mandelbrot_set(void){
|
||||||
} else {
|
} else {
|
||||||
brightness = 255 - (31 * (n_iter & 7));
|
brightness = 255 - (31 * (n_iter & 7));
|
||||||
}
|
}
|
||||||
graybuffer[y_pixel]=brightness;
|
graybuffer[y_pixel]=brightness;
|
||||||
|
/* be nice to other threads:
|
||||||
|
* if at least one tick has passed, yield */
|
||||||
|
if (*rb->current_tick > last_yield){
|
||||||
|
rb->yield();
|
||||||
|
last_yield = *rb->current_tick;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gray_drawgraymap(graybuffer, x_pixel, 0, 1, LCD_HEIGHT, 1);
|
gray_drawgraymap(graybuffer, x_pixel, 0, 1, LCD_HEIGHT, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue