25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_fb.c,v 1.121 2006/07/08 12:30:02 debug Exp $ |
* $Id: dev_fb.c,v 1.123 2006/07/24 08:08:39 debug Exp $ |
29 |
* |
* |
30 |
* Generic framebuffer device. |
* Generic framebuffer device. |
31 |
* |
* |
235 |
* block copy/fill. |
* block copy/fill. |
236 |
* |
* |
237 |
* If fillflag is non-zero, then fill_[rgb] should contain the color |
* If fillflag is non-zero, then fill_[rgb] should contain the color |
238 |
* with which to fill. |
* with which to fill. (In 8-bit mode, only fill_r is used.) |
239 |
* |
* |
240 |
* If fillflag is zero, copy mode is used, and from_[xy] should contain |
* If fillflag is zero, copy mode is used, and from_[xy] should contain |
241 |
* the offset on the framebuffer where we should copy from. |
* the offset on the framebuffer where we should copy from. |
246 |
int fill_g, int fill_b, int x1, int y1, int x2, int y2, |
int fill_g, int fill_b, int x1, int y1, int x2, int y2, |
247 |
int from_x, int from_y) |
int from_x, int from_y) |
248 |
{ |
{ |
249 |
int y; |
int x, y; |
250 |
long from_ofs, dest_ofs, linelen; |
long from_ofs, dest_ofs, linelen; |
251 |
|
|
252 |
if (fillflag) |
if (fillflag) |
269 |
if (fillflag) { |
if (fillflag) { |
270 |
for (y=y1; y<=y2; y++) { |
for (y=y1; y<=y2; y++) { |
271 |
if (y>=0 && y<d->ysize) { |
if (y>=0 && y<d->ysize) { |
272 |
int x; |
unsigned char *buf = |
273 |
char buf[8192 * 3]; |
d->framebuffer + dest_ofs; |
274 |
if (d->bit_depth == 24) |
|
275 |
|
if (d->bit_depth == 24) { |
276 |
for (x=0; x<linelen && x<sizeof(buf); |
for (x=0; x<linelen && x<sizeof(buf); |
277 |
x += 3) { |
x += 3) { |
278 |
buf[x] = fill_r; |
buf[x] = fill_r; |
279 |
buf[x+1] = fill_g; |
buf[x+1] = fill_g; |
280 |
buf[x+2] = fill_b; |
buf[x+2] = fill_b; |
281 |
} |
} |
282 |
else { |
} else if (d->bit_depth == 8) { |
283 |
fatal("[ fb: TODO: fill for non-24-bit" |
memset(buf, fill_r, linelen); |
284 |
" modes ]\n"); |
} else { |
285 |
|
fatal("Unimplemented bit-depth (%i)" |
286 |
|
" for fb fill\n", d->bit_depth); |
287 |
|
exit(1); |
288 |
} |
} |
|
|
|
|
memmove(d->framebuffer + dest_ofs, buf, |
|
|
linelen); |
|
289 |
} |
} |
290 |
|
|
291 |
dest_ofs += d->bytes_per_line; |
dest_ofs += d->bytes_per_line; |
293 |
} else { |
} else { |
294 |
from_ofs = d->bytes_per_line * from_y + |
from_ofs = d->bytes_per_line * from_y + |
295 |
(d->bit_depth/8) * from_x; |
(d->bit_depth/8) * from_x; |
|
|
|
296 |
for (y=y1; y<=y2; y++) { |
for (y=y1; y<=y2; y++) { |
297 |
if (y>=0 && y<d->ysize) |
if (y >= 0 && y < d->ysize) { |
298 |
memmove(d->framebuffer + dest_ofs, |
if (from_y >= 0 && from_y < d->ysize) |
299 |
d->framebuffer + from_ofs, linelen); |
memmove(d->framebuffer + dest_ofs, |
300 |
|
d->framebuffer + from_ofs, linelen); |
301 |
|
else |
302 |
|
memset(d->framebuffer + dest_ofs, |
303 |
|
0, linelen); |
304 |
|
} |
305 |
|
from_y ++; |
306 |
from_ofs += d->bytes_per_line; |
from_ofs += d->bytes_per_line; |
307 |
dest_ofs += d->bytes_per_line; |
dest_ofs += d->bytes_per_line; |
308 |
} |
} |