summaryrefslogtreecommitdiff
path: root/apps/plugins/mandelbrot.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-07-25 20:50:34 +0000
committerJens Arnold <amiconn@rockbox.org>2005-07-25 20:50:34 +0000
commitc20a00ef3e35b15acf422a2e7f6716abde840c24 (patch)
tree903cf122a1203360022dad4a06cc24b7ea805463 /apps/plugins/mandelbrot.c
parent12a4ed383f21b65a5a244f47fe1bc9f13d4f63bb (diff)
downloadrockbox-c20a00ef3e35b15acf422a2e7f6716abde840c24.tar.gz
rockbox-c20a00ef3e35b15acf422a2e7f6716abde840c24.zip
Complete rework of the grayscale library: (1) Implemented the new rockbox graphics api. (2) Added buffered mode, and implemented most drawing functions for buffered mode only. Buffered mode will ease implementation of animated graphics. Some functions are additionally provided as unbuffered versions (drawing grayscale bitmaps, scrolling) since unbuffered mode is better suited for non-animated graphics (JPEG viewer, mandelbrot) and saves some RAM, which is important on Archos. (3) Put all functions in a couple of source files, no more one-function-per-files. This became possible since sectioned compilation for the plugin library and appropriate linking for the pluginswas introduced, otherwise the binaries would be bloated by unused functions.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7241 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/mandelbrot.c')
-rw-r--r--apps/plugins/mandelbrot.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c
index bb96b9b71c..1037212b15 100644
--- a/apps/plugins/mandelbrot.c
+++ b/apps/plugins/mandelbrot.c
@@ -94,7 +94,7 @@ void calc_mandelbrot_set(void){
94 94
95 start_tick = last_yield = *rb->current_tick; 95 start_tick = last_yield = *rb->current_tick;
96 96
97 gray_clear_display(); 97 gray_ub_clear_display();
98 98
99 x_fact = (x_max - x_min) / LCD_WIDTH; 99 x_fact = (x_max - x_min) / LCD_WIDTH;
100 y_fact = (y_max - y_min) / LCD_HEIGHT; 100 y_fact = (y_max - y_min) / LCD_HEIGHT;
@@ -124,7 +124,7 @@ void calc_mandelbrot_set(void){
124 if (n_iter > max_iter){ 124 if (n_iter > max_iter){
125 brightness = 0; // black 125 brightness = 0; // black
126 } else { 126 } else {
127 brightness = 255 - (31 * (n_iter & 7)); 127 brightness = 255 - (32 * (n_iter & 7));
128 } 128 }
129 graybuffer[y_pixel]=brightness; 129 graybuffer[y_pixel]=brightness;
130 /* be nice to other threads: 130 /* be nice to other threads:
@@ -134,7 +134,7 @@ void calc_mandelbrot_set(void){
134 last_yield = *rb->current_tick; 134 last_yield = *rb->current_tick;
135 } 135 }
136 } 136 }
137 gray_drawgraymap(graybuffer, x_pixel, 0, 1, LCD_HEIGHT, 1); 137 gray_ub_gray_bitmap(graybuffer, x_pixel, 0, 1, LCD_HEIGHT);
138 } 138 }
139} 139}
140 140
@@ -142,7 +142,7 @@ void cleanup(void *parameter)
142{ 142{
143 (void)parameter; 143 (void)parameter;
144 144
145 gray_release_buffer(); 145 gray_release();
146} 146}
147 147
148enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 148enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
@@ -156,17 +156,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
156 rb = api; 156 rb = api;
157 (void)parameter; 157 (void)parameter;
158 158
159 /* This plugin uses the grayscale framework, so initialize */
160 gray_init(api);
161
162 /* get the remainder of the plugin buffer */ 159 /* get the remainder of the plugin buffer */
163 gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); 160 gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
164 161
165 /* initialize the grayscale buffer: 162 /* initialize the grayscale buffer:
166 * 112 pixels wide, 8 rows (64 pixels) high, (try to) reserve 163 * 112 pixels wide, 8 rows (64 pixels) high, (try to) reserve
167 * 16 bitplanes for 17 shades of gray.*/ 164 * 16 bitplanes for 17 shades of gray.*/
168 grayscales = gray_init_buffer(gbuf, gbuf_size, 112, 8, 16, NULL) + 1; 165 grayscales = gray_init(rb, gbuf, gbuf_size, false, 112, 8, 8, NULL) + 1;
169 if (grayscales != 17){ 166 if (grayscales != 9){
170 rb->snprintf(buff, sizeof(buff), "%d", grayscales); 167 rb->snprintf(buff, sizeof(buff), "%d", grayscales);
171 rb->lcd_puts(0, 1, buff); 168 rb->lcd_puts(0, 1, buff);
172 rb->lcd_update(); 169 rb->lcd_update();
@@ -174,7 +171,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
174 return(0); 171 return(0);
175 } 172 }
176 173
177 gray_show_display(true); /* switch on grayscale overlay */ 174 gray_show(true); /* switch on greyscale overlay */
178 175
179 init_mandelbrot_set(); 176 init_mandelbrot_set();
180 lcd_aspect_ratio = ((LCD_WIDTH<<13) / LCD_HEIGHT)<<13; 177 lcd_aspect_ratio = ((LCD_WIDTH<<13) / LCD_HEIGHT)<<13;
@@ -189,7 +186,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
189 button = rb->button_get(true); 186 button = rb->button_get(true);
190 switch (button) { 187 switch (button) {
191 case MANDELBROT_QUIT: 188 case MANDELBROT_QUIT:
192 gray_release_buffer(); 189 gray_release();
193 return PLUGIN_OK; 190 return PLUGIN_OK;
194 191
195 case MANDELBROT_ZOOM_OUT: 192 case MANDELBROT_ZOOM_OUT:
@@ -270,7 +267,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
270 if (button != BUTTON_NONE) 267 if (button != BUTTON_NONE)
271 lastbutton = button; 268 lastbutton = button;
272 } 269 }
273 gray_release_buffer(); 270 gray_release();
274 return PLUGIN_OK; 271 return PLUGIN_OK;
275} 272}
276#endif 273#endif