Rev 2479 | Rev 2677 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2479 | Rev 2619 | ||
---|---|---|---|
Line 163... | Line 163... | ||
163 | 163 | ||
164 | static void |
164 | static void |
165 | bgr_byte0888(void *dst, int rgb) |
165 | bgr_byte0888(void *dst, int rgb) |
166 | { |
166 | { |
167 | *((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 | |
167 | *((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 | |
168 | RED(rgb, 8); |
168 | RED(rgb, 8); |
169 | } |
169 | } |
170 | 170 | ||
171 | static int |
171 | static int |
172 | byte0888_bgr(void *src) |
172 | byte0888_bgr(void *src) |
173 | { |
173 | { |
174 | int color = *(uint32_t *)(src); |
174 | int color = *(uint32_t *)(src); |
175 | return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | |
175 | return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | |
176 | ((color >> 16) & 0xff); |
176 | ((color >> 16) & 0xff); |
177 | } |
177 | } |
178 | 178 | ||
179 | static void |
179 | static void |
180 | rgb_byte888(void *dst, int rgb) |
180 | rgb_byte888(void *dst, int rgb) |
181 | { |
181 | { |
Line 206... | Line 206... | ||
206 | static void |
206 | static void |
207 | rgb_byte555(void *dst, int rgb) |
207 | rgb_byte555(void *dst, int rgb) |
208 | { |
208 | { |
209 | /* 5-bit, 5-bits, 5-bits */ |
209 | /* 5-bit, 5-bits, 5-bits */ |
210 | *((uint16_t *)(dst)) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | |
210 | *((uint16_t *)(dst)) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | |
211 | BLUE(rgb, 5); |
211 | BLUE(rgb, 5); |
212 | } |
212 | } |
213 | 213 | ||
214 | /** 16-bit depth (5:5:5) */ |
214 | /** 16-bit depth (5:5:5) */ |
215 | static int |
215 | static int |
216 | byte555_rgb(void *src) |
216 | byte555_rgb(void *src) |
217 | { |
217 | { |
218 | int color = *(uint16_t *)(src); |
218 | int color = *(uint16_t *)(src); |
219 | return (((color >> 10) & 0x1f) << (16 + 3)) | |
219 | return (((color >> 10) & 0x1f) << (16 + 3)) | |
220 | (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3); |
220 | (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3); |
221 | } |
221 | } |
222 | 222 | ||
223 | /** 16-bit depth (5:6:5) */ |
223 | /** 16-bit depth (5:6:5) */ |
224 | static void |
224 | static void |
225 | rgb_byte565(void *dst, int rgb) |
225 | rgb_byte565(void *dst, int rgb) |
226 | { |
226 | { |
227 | /* 5-bit, 6-bits, 5-bits */ |
227 | /* 5-bit, 6-bits, 5-bits */ |
228 | *((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | |
228 | *((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | |
229 | BLUE(rgb, 5); |
229 | BLUE(rgb, 5); |
230 | } |
230 | } |
231 | 231 | ||
232 | /** 16-bit depth (5:6:5) */ |
232 | /** 16-bit depth (5:6:5) */ |
233 | static int |
233 | static int |
234 | byte565_rgb(void *src) |
234 | byte565_rgb(void *src) |
235 | { |
235 | { |
236 | int color = *(uint16_t *)(src); |
236 | int color = *(uint16_t *)(src); |
237 | return (((color >> 11) & 0x1f) << (16 + 3)) | |
237 | return (((color >> 11) & 0x1f) << (16 + 3)) | |
238 | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
238 | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
239 | } |
239 | } |
240 | 240 | ||
241 | /** Put pixel - 8-bit depth (3:2:3) */ |
241 | /** Put pixel - 8-bit depth (3:2:3) */ |
242 | static void |
242 | static void |
243 | rgb_byte8(void *dst, int rgb) |
243 | rgb_byte8(void *dst, int rgb) |
Line 249... | Line 249... | ||
249 | static int |
249 | static int |
250 | byte8_rgb(void *src) |
250 | byte8_rgb(void *src) |
251 | { |
251 | { |
252 | int color = *(uint8_t *)src; |
252 | int color = *(uint8_t *)src; |
253 | return (((color >> 5) & 0x7) << (16 + 5)) | |
253 | return (((color >> 5) & 0x7) << (16 + 5)) | |
254 | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
254 | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
255 | } |
255 | } |
256 | 256 | ||
257 | /** Put pixel into viewport |
257 | /** Put pixel into viewport |
258 | * |
258 | * |
259 | * @param vport Viewport identification |
259 | * @param vport Viewport identification |
Line 267... | Line 267... | ||
267 | int dx = vport->x + x; |
267 | int dx = vport->x + x; |
268 | int dy = vport->y + y; |
268 | int dy = vport->y + y; |
269 | 269 | ||
270 | if (! (vport->paused && vport->dbdata)) |
270 | if (! (vport->paused && vport->dbdata)) |
271 | (*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)], |
271 | (*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)], |
272 | COLOR(color)); |
272 | COLOR(color)); |
273 | 273 | ||
274 | if (vport->dbdata) { |
274 | if (vport->dbdata) { |
275 | int dline = (y + vport->dboffset) % vport->height; |
275 | int dline = (y + vport->dboffset) % vport->height; |
276 | int doffset = screen.pixelbytes * (dline * vport->width + x); |
276 | int doffset = screen.pixelbytes * (dline * vport->width + x); |
277 | (*screen.rgb2scr)(&vport->dbdata[doffset], COLOR(color)); |
277 | (*screen.rgb2scr)(&vport->dbdata[doffset], COLOR(color)); |
Line 289... | Line 289... | ||
289 | } |
289 | } |
290 | 290 | ||
291 | static inline void |
291 | static inline void |
292 | putpixel_mem(char *mem, unsigned int x, unsigned int y, int color) |
292 | putpixel_mem(char *mem, unsigned int x, unsigned int y, int color) |
293 | { |
293 | { |
294 | (*screen.rgb2scr)(&mem[POINTPOS(x,y)], COLOR(color)); |
294 | (*screen.rgb2scr)(&mem[POINTPOS(x, y)], COLOR(color)); |
295 | } |
295 | } |
296 | 296 | ||
297 | static void |
297 | static void |
298 | draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy, |
298 | draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy, |
299 | unsigned int width, unsigned int height, int color) |
299 | unsigned int width, unsigned int height, int color) |
300 | { |
300 | { |
301 | unsigned int x, y; |
301 | unsigned int x, y; |
302 | static void *tmpline; |
302 | static void *tmpline; |
303 | 303 | ||
304 | if (!tmpline) |
304 | if (!tmpline) |
305 | tmpline = malloc(screen.scanline*screen.pixelbytes); |
305 | tmpline = malloc(screen.scanline * screen.pixelbytes); |
306 | 306 | ||
307 | /* Clear first line */ |
307 | /* Clear first line */ |
308 | for (x = 0; x < width; x++) |
308 | for (x = 0; x < width; x++) |
309 | putpixel_mem(tmpline, x, 0, color); |
309 | putpixel_mem(tmpline, x, 0, color); |
310 | 310 | ||
Line 313... | Line 313... | ||
313 | sx += vport->x; |
313 | sx += vport->x; |
314 | sy += vport->y; |
314 | sy += vport->y; |
315 | /* Copy the rest */ |
315 | /* Copy the rest */ |
316 | for (y = sy;y < sy+height; y++) |
316 | for (y = sy;y < sy+height; y++) |
317 | memcpy(&screen.fbaddress[POINTPOS(sx,y)], tmpline, |
317 | memcpy(&screen.fbaddress[POINTPOS(sx,y)], tmpline, |
318 | screen.pixelbytes * width); |
318 | screen.pixelbytes * width); |
319 | } |
319 | } |
320 | if (vport->dbdata) { |
320 | if (vport->dbdata) { |
321 | for (y = sy; y < sy + height; y++) { |
321 | for (y = sy; y < sy + height; y++) { |
322 | int rline = (y + vport->dboffset) % vport->height; |
322 | int rline = (y + vport->dboffset) % vport->height; |
323 | int rpos = (rline * vport->width + sx) * |
323 | int rpos = (rline * vport->width + sx) * |
324 | screen.pixelbytes; |
324 | screen.pixelbytes; |
325 | memcpy(&vport->dbdata[rpos], tmpline, |
325 | memcpy(&vport->dbdata[rpos], tmpline, |
326 | screen.pixelbytes * width); |
326 | screen.pixelbytes * width); |
327 | } |
327 | } |
328 | } |
328 | } |
329 | 329 | ||
330 | } |
330 | } |
331 | 331 | ||
332 | /** Fill viewport with background color */ |
332 | /** Fill viewport with background color */ |
333 | static void |
333 | static void |
334 | clear_port(viewport_t *vport) |
334 | clear_port(viewport_t *vport) |
335 | { |
335 | { |
336 | draw_rectangle(vport, 0, 0, vport->width, vport->height, |
336 | draw_rectangle(vport, 0, 0, vport->width, vport->height, |
337 | vport->style.bg_color); |
337 | vport->style.bg_color); |
338 | } |
338 | } |
339 | 339 | ||
340 | /** Scroll unbuffered viewport up/down |
340 | /** Scroll unbuffered viewport up/down |
341 | * |
341 | * |
342 | * @param vport Viewport to scroll |
342 | * @param vport Viewport to scroll |
Line 348... | Line 348... | ||
348 | int y; |
348 | int y; |
349 | 349 | ||
350 | if (lines > 0) { |
350 | if (lines > 0) { |
351 | for (y = vport->y; y < vport->y+vport->height - lines; y++) |
351 | for (y = vport->y; y < vport->y+vport->height - lines; y++) |
352 | memcpy(&screen.fbaddress[POINTPOS(vport->x,y)], |
352 | memcpy(&screen.fbaddress[POINTPOS(vport->x,y)], |
353 | &screen.fbaddress[POINTPOS(vport->x,y + lines)], |
353 | &screen.fbaddress[POINTPOS(vport->x,y + lines)], |
354 | screen.pixelbytes * vport->width); |
354 | screen.pixelbytes * vport->width); |
355 | draw_rectangle(vport, 0, vport->height - lines, vport->width, |
355 | draw_rectangle(vport, 0, vport->height - lines, vport->width, |
356 | lines, vport->style.bg_color); |
356 | lines, vport->style.bg_color); |
357 | } else if (lines < 0) { |
357 | } else if (lines < 0) { |
358 | lines = -lines; |
358 | lines = -lines; |
359 | for (y = vport->y + vport->height-1; y >= vport->y + lines; |
359 | for (y = vport->y + vport->height-1; y >= vport->y + lines; y--) |
360 | y--) |
- | |
361 | memcpy(&screen.fbaddress[POINTPOS(vport->x,y)], |
360 | memcpy(&screen.fbaddress[POINTPOS(vport->x,y)], |
362 | &screen.fbaddress[POINTPOS(vport->x,y - lines)], |
361 | &screen.fbaddress[POINTPOS(vport->x,y - lines)], |
363 | screen.pixelbytes * vport->width); |
362 | screen.pixelbytes * vport->width); |
364 | draw_rectangle(vport, 0, 0, vport->width, lines, |
363 | draw_rectangle(vport, 0, 0, vport->width, lines, |
365 | vport->style.bg_color); |
364 | vport->style.bg_color); |
366 | } |
365 | } |
367 | } |
366 | } |
368 | 367 | ||
369 | /** Refresh given viewport from double buffer */ |
368 | /** Refresh given viewport from double buffer */ |
370 | static void |
369 | static void |
Line 378... | Line 377... | ||
378 | 377 | ||
379 | dstx = vport->x; |
378 | dstx = vport->x; |
380 | dsty = vport->y + y; |
379 | dsty = vport->y + y; |
381 | 380 | ||
382 | memcpy(&screen.fbaddress[POINTPOS(dstx,dsty)], |
381 | memcpy(&screen.fbaddress[POINTPOS(dstx,dsty)], |
383 | &vport->dbdata[srcoff], |
- | |
384 | vport->width*screen.pixelbytes); |
382 | &vport->dbdata[srcoff], vport->width * screen.pixelbytes); |
385 | } |
383 | } |
386 | } |
384 | } |
387 | 385 | ||
388 | /** Scroll viewport that has double buffering enabled */ |
386 | /** Scroll viewport that has double buffering enabled */ |
389 | static void |
387 | static void |
390 | scroll_port_db(viewport_t *vport, int lines) |
388 | scroll_port_db(viewport_t *vport, int lines) |
391 | { |
389 | { |
392 | ++vport->paused; |
390 | ++vport->paused; |
393 | if (lines > 0) { |
391 | if (lines > 0) { |
394 | draw_rectangle(vport, 0, 0, vport->width, lines, |
392 | draw_rectangle(vport, 0, 0, vport->width, lines, |
395 | vport->style.bg_color); |
393 | vport->style.bg_color); |
396 | vport->dboffset += lines; |
394 | vport->dboffset += lines; |
397 | vport->dboffset %= vport->height; |
395 | vport->dboffset %= vport->height; |
398 | } else if (lines < 0) { |
396 | } else if (lines < 0) { |
399 | lines = -lines; |
397 | lines = -lines; |
400 | draw_rectangle(vport, 0, vport->height-lines, |
398 | draw_rectangle(vport, 0, vport->height-lines, vport->width, |
401 | vport->width, lines, |
- | |
402 | vport->style.bg_color); |
399 | lines, vport->style.bg_color); |
403 | 400 | ||
404 | if (vport->dboffset < lines) |
401 | if (vport->dboffset < lines) |
405 | vport->dboffset += vport->height; |
402 | vport->dboffset += vport->height; |
406 | vport->dboffset -= lines; |
403 | vport->dboffset -= lines; |
407 | } |
404 | } |
Line 439... | Line 436... | ||
439 | * @param sy Coordinates of top-left of the character |
436 | * @param sy Coordinates of top-left of the character |
440 | * @param style Color of the character |
437 | * @param style Color of the character |
441 | * @param transparent If false, print background color |
438 | * @param transparent If false, print background color |
442 | */ |
439 | */ |
443 | static void |
440 | static void |
444 | draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx, |
441 | draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx, unsigned int sy, |
445 | unsigned int sy, style_t style, int transparent) |
442 | style_t style, int transparent) |
446 | { |
443 | { |
447 | int i; |
444 | int i; |
448 | unsigned int y; |
445 | unsigned int y; |
449 | unsigned int glline; |
446 | unsigned int glline; |
450 | 447 | ||
451 | for (y = 0; y < FONT_SCANLINES; y++) { |
448 | for (y = 0; y < FONT_SCANLINES; y++) { |
452 | glline = fb_font[glyph * FONT_SCANLINES + y]; |
449 | glline = fb_font[glyph * FONT_SCANLINES + y]; |
453 | for (i = 0; i < 8; i++) { |
450 | for (i = 0; i < 8; i++) { |
454 | if (glline & (1 << (7 - i))) |
451 | if (glline & (1 << (7 - i))) |
455 | putpixel(vport, sx + i, sy + y, |
452 | putpixel(vport, sx + i, sy + y, style.fg_color); |
456 | style.fg_color); |
- | |
457 | else if (!transparent) |
453 | else if (!transparent) |
458 | putpixel(vport, sx + i, sy + y, |
454 | putpixel(vport, sx + i, sy + y, style.bg_color); |
459 | style.bg_color); |
- | |
460 | } |
455 | } |
461 | } |
456 | } |
462 | } |
457 | } |
463 | 458 | ||
464 | /** Invert character at given position */ |
459 | /** Invert character at given position */ |
Line 469... | Line 464... | ||
469 | unsigned int y; |
464 | unsigned int y; |
470 | 465 | ||
471 | for (x = 0; x < COL_WIDTH; x++) |
466 | for (x = 0; x < COL_WIDTH; x++) |
472 | for (y = 0; y < FONT_SCANLINES; y++) |
467 | for (y = 0; y < FONT_SCANLINES; y++) |
473 | invert_pixel(vport, col * COL_WIDTH + x, row * |
468 | invert_pixel(vport, col * COL_WIDTH + x, row * |
474 | FONT_SCANLINES + y); |
469 | FONT_SCANLINES + y); |
475 | } |
470 | } |
476 | 471 | ||
477 | /***************************************************************/ |
472 | /***************************************************************/ |
478 | /* Stdout specific functions */ |
473 | /* Stdout specific functions */ |
479 | 474 | ||
Line 628... | Line 623... | ||
628 | if (vport->cursor_active && vport->cursor_shown && |
623 | if (vport->cursor_active && vport->cursor_shown && |
629 | (vport->cur_col != col || vport->cur_row != row)) |
624 | (vport->cur_col != col || vport->cur_row != row)) |
630 | invert_char(vport, vport->cur_row, vport->cur_col); |
625 | invert_char(vport, vport->cur_row, vport->cur_col); |
631 | 626 | ||
632 | draw_glyph(vport, c, col * COL_WIDTH, row * FONT_SCANLINES, style, |
627 | draw_glyph(vport, c, col * COL_WIDTH, row * FONT_SCANLINES, style, |
633 | transparent); |
628 | transparent); |
634 | 629 | ||
635 | vport->cur_col = col; |
630 | vport->cur_col = col; |
636 | vport->cur_row = row; |
631 | vport->cur_row = row; |
637 | 632 | ||
638 | vport->cur_col++; |
633 | vport->cur_col++; |
Line 657... | Line 652... | ||
657 | int col,row; |
652 | int col,row; |
658 | 653 | ||
659 | clear_port(vport); |
654 | clear_port(vport); |
660 | for (i = 0; i < vport->cols * vport->rows; i++) { |
655 | for (i = 0; i < vport->cols * vport->rows; i++) { |
661 | if (data[i].character == ' ' && style_same(data[i].style, |
656 | if (data[i].character == ' ' && style_same(data[i].style, |
662 | vport->style)) |
657 | vport->style)) |
663 | continue; |
658 | continue; |
664 | col = i % vport->cols; |
659 | col = i % vport->cols; |
665 | row = i / vport->cols; |
660 | row = i / vport->cols; |
666 | draw_glyph(vport, data[i].character, col * COL_WIDTH, row * |
661 | draw_glyph(vport, data[i].character, col * COL_WIDTH, row * |
667 | FONT_SCANLINES, data[i].style, |
662 | FONT_SCANLINES, data[i].style, style_same(data[i].style, |
668 | style_same(data[i].style,vport->style)); |
663 | vport->style)); |
669 | } |
664 | } |
670 | cursor_print(vport); |
665 | cursor_print(vport); |
671 | } |
666 | } |
672 | 667 | ||
673 | /** Return first free pixmap */ |
668 | /** Return first free pixmap */ |
Line 709... | Line 704... | ||
709 | pmap->data = malloc(pmap->width * pmap->height * screen.pixelbytes); |
704 | pmap->data = malloc(pmap->width * pmap->height * screen.pixelbytes); |
710 | if (!pmap->data) |
705 | if (!pmap->data) |
711 | return ENOMEM; |
706 | return ENOMEM; |
712 | 707 | ||
713 | ppm_draw(shm, size, 0, 0, pmap->width, pmap->height, |
708 | ppm_draw(shm, size, 0, 0, pmap->width, pmap->height, |
714 | (putpixel_cb_t)putpixel_pixmap, (void *)pm); |
709 | (putpixel_cb_t)putpixel_pixmap, (void *)pm); |
715 | 710 | ||
716 | return pm; |
711 | return pm; |
717 | } |
712 | } |
718 | 713 | ||
719 | /** Handle shared memory communication calls |
714 | /** Handle shared memory communication calls |
Line 755... | Line 750... | ||
755 | case IPC_M_AS_AREA_SEND: |
750 | case IPC_M_AS_AREA_SEND: |
756 | /* We accept one area for data interchange */ |
751 | /* We accept one area for data interchange */ |
757 | if (IPC_GET_ARG1(*call) == shm_id) { |
752 | if (IPC_GET_ARG1(*call) == shm_id) { |
758 | void *dest = as_get_mappable_page(IPC_GET_ARG2(*call)); |
753 | void *dest = as_get_mappable_page(IPC_GET_ARG2(*call)); |
759 | shm_size = IPC_GET_ARG2(*call); |
754 | shm_size = IPC_GET_ARG2(*call); |
760 | if (!ipc_answer_fast(callid, 0, (sysarg_t) dest, 0)) |
755 | if (!ipc_answer_1(callid, EOK, (sysarg_t) dest)) |
761 | shm = dest; |
756 | shm = dest; |
762 | else |
757 | else |
763 | shm_id = 0; |
758 | shm_id = 0; |
764 | if (shm[0] != 'P') |
759 | if (shm[0] != 'P') |
765 | while (1) |
760 | while (1) |
Line 803... | Line 798... | ||
803 | retval = EINVAL; |
798 | retval = EINVAL; |
804 | break; |
799 | break; |
805 | } |
800 | } |
806 | 801 | ||
807 | ppm_draw(shm, shm_size, IPC_GET_ARG1(*call), |
802 | ppm_draw(shm, shm_size, IPC_GET_ARG1(*call), |
808 | IPC_GET_ARG2(*call), vport->width - x, |
803 | IPC_GET_ARG2(*call), vport->width - x, vport->height - y, |
809 | vport->height - y, (putpixel_cb_t)putpixel, vport); |
804 | (putpixel_cb_t)putpixel, vport); |
810 | break; |
805 | break; |
811 | case FB_DRAW_TEXT_DATA: |
806 | case FB_DRAW_TEXT_DATA: |
812 | if (!interbuffer) { |
807 | if (!interbuffer) { |
813 | retval = EINVAL; |
808 | retval = EINVAL; |
814 | break; |
809 | break; |
815 | } |
810 | } |
816 | if (intersize < vport->cols * vport->rows * |
811 | if (intersize < vport->cols * vport->rows * |
817 | sizeof(*interbuffer)) { |
812 | sizeof(*interbuffer)) { |
818 | retval = EINVAL; |
813 | retval = EINVAL; |
819 | break; |
814 | break; |
820 | } |
815 | } |
821 | draw_text_data(vport, interbuffer); |
816 | draw_text_data(vport, interbuffer); |
822 | break; |
817 | break; |
823 | default: |
818 | default: |
824 | handled = 0; |
819 | handled = 0; |
825 | } |
820 | } |
826 | 821 | ||
827 | if (handled) |
822 | if (handled) |
828 | ipc_answer_fast(callid, retval, 0, 0); |
823 | ipc_answer_0(callid, retval); |
829 | return handled; |
824 | return handled; |
830 | } |
825 | } |
831 | 826 | ||
832 | static void |
827 | static void |
833 | copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap) |
828 | copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap) |
Line 849... | Line 844... | ||
849 | srcrowsize = vport->width * screen.pixelbytes; |
844 | srcrowsize = vport->width * screen.pixelbytes; |
850 | realrowsize = realwidth * screen.pixelbytes; |
845 | realrowsize = realwidth * screen.pixelbytes; |
851 | 846 | ||
852 | for (y = 0; y < realheight; y++) { |
847 | for (y = 0; y < realheight; y++) { |
853 | tmp = (vport->y + y) * screen.scanline + |
848 | tmp = (vport->y + y) * screen.scanline + |
854 | vport->x * screen.pixelbytes; |
849 | vport->x * screen.pixelbytes; |
855 | memcpy(pmap->data + srcrowsize * y, screen.fbaddress + tmp, |
850 | memcpy(pmap->data + srcrowsize * y, screen.fbaddress + tmp, |
856 | realrowsize); |
851 | realrowsize); |
857 | } |
852 | } |
858 | } |
853 | } |
859 | 854 | ||
860 | /** Save viewport to pixmap */ |
855 | /** Save viewport to pixmap */ |
861 | static int |
856 | static int |
Line 910... | Line 905... | ||
910 | srcrowsize = vport->width * screen.pixelbytes; |
905 | srcrowsize = vport->width * screen.pixelbytes; |
911 | realrowsize = realwidth * screen.pixelbytes; |
906 | realrowsize = realwidth * screen.pixelbytes; |
912 | 907 | ||
913 | for (y = 0; y < realheight; y++) { |
908 | for (y = 0; y < realheight; y++) { |
914 | tmp = (vport->y + y) * screen.scanline + |
909 | tmp = (vport->y + y) * screen.scanline + |
915 | vport->x * screen.pixelbytes; |
910 | vport->x * screen.pixelbytes; |
916 | memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize, |
911 | memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize, |
917 | realrowsize); |
912 | realrowsize); |
918 | } |
913 | } |
919 | return 0; |
914 | return 0; |
920 | } |
915 | } |
921 | 916 | ||
922 | /** Tick animation one step forward */ |
917 | /** Tick animation one step forward */ |
Line 931... | Line 926... | ||
931 | if (counts) |
926 | if (counts) |
932 | return; |
927 | return; |
933 | 928 | ||
934 | for (i = 0; i < MAX_ANIMATIONS; i++) { |
929 | for (i = 0; i < MAX_ANIMATIONS; i++) { |
935 | if (!animations[i].animlen || !animations[i].initialized || |
930 | if (!animations[i].animlen || !animations[i].initialized || |
936 | !animations[i].enabled) |
931 | !animations[i].enabled) |
937 | continue; |
932 | continue; |
938 | draw_pixmap(animations[i].vp, |
933 | draw_pixmap(animations[i].vp, |
939 | animations[i].pixmaps[animations[i].pos]); |
934 | animations[i].pixmaps[animations[i].pos]); |
940 | animations[i].pos = (animations[i].pos + 1) % |
935 | animations[i].pos = (animations[i].pos + 1) % |
941 | animations[i].animlen; |
936 | animations[i].animlen; |
942 | } |
937 | } |
943 | } |
938 | } |
944 | 939 | ||
945 | 940 | ||
946 | static int pointer_x, pointer_y; |
941 | static int pointer_x, pointer_y; |
Line 960... | Line 955... | ||
960 | return; |
955 | return; |
961 | 956 | ||
962 | /* Save image under the cursor */ |
957 | /* Save image under the cursor */ |
963 | if (pointer_vport == -1) { |
958 | if (pointer_vport == -1) { |
964 | pointer_vport = viewport_create(pointer_x, pointer_y, |
959 | pointer_vport = viewport_create(pointer_x, pointer_y, |
965 | pointer_width, pointer_height); |
960 | pointer_width, pointer_height); |
966 | if (pointer_vport < 0) |
961 | if (pointer_vport < 0) |
967 | return; |
962 | return; |
968 | } else { |
963 | } else { |
969 | viewports[pointer_vport].x = pointer_x; |
964 | viewports[pointer_vport].x = pointer_x; |
970 | viewports[pointer_vport].y = pointer_y; |
965 | viewports[pointer_vport].y = pointer_y; |
Line 972... | Line 967... | ||
972 | 967 | ||
973 | if (pointer_pixmap == -1) |
968 | if (pointer_pixmap == -1) |
974 | pointer_pixmap = save_vp_to_pixmap(&viewports[pointer_vport]); |
969 | pointer_pixmap = save_vp_to_pixmap(&viewports[pointer_vport]); |
975 | else |
970 | else |
976 | copy_vp_to_pixmap(&viewports[pointer_vport], |
971 | copy_vp_to_pixmap(&viewports[pointer_vport], |
977 | &pixmaps[pointer_pixmap]); |
972 | &pixmaps[pointer_pixmap]); |
978 | 973 | ||
979 | /* Draw cursor */ |
974 | /* Draw cursor */ |
980 | for (i = 0; i < pointer_height; i++) |
975 | for (i = 0; i < pointer_height; i++) |
981 | for (j = 0; j < pointer_width; j++) { |
976 | for (j = 0; j < pointer_width; j++) { |
982 | bytepos = i * ((pointer_width - 1) / 8 + 1) + j / 8; |
977 | bytepos = i * ((pointer_width - 1) / 8 + 1) + j / 8; |
983 | visibility = pointer_mask_bits[bytepos] & |
978 | visibility = pointer_mask_bits[bytepos] & |
984 | (1 << (j % 8)); |
979 | (1 << (j % 8)); |
985 | if (visibility) { |
980 | if (visibility) { |
986 | color = pointer_bits[bytepos] & (1 << (j % 8)) |
981 | color = pointer_bits[bytepos] & |
987 | ? 0 : 0xffffff; |
982 | (1 << (j % 8)) ? 0 : 0xffffff; |
988 | if (pointer_x + j < screen.xres && pointer_y + |
983 | if (pointer_x + j < screen.xres && pointer_y + |
989 | i < screen.yres) |
984 | i < screen.yres) |
990 | putpixel(&viewports[0], pointer_x + j, |
985 | putpixel(&viewports[0], pointer_x + j, |
991 | pointer_y + i, color); |
986 | pointer_y + i, color); |
992 | } |
987 | } |
993 | } |
988 | } |
994 | pointer_shown = 1; |
989 | pointer_shown = 1; |
995 | } |
990 | } |
996 | 991 | ||
Line 1104... | Line 1099... | ||
1104 | break; |
1099 | break; |
1105 | default: |
1100 | default: |
1106 | handled = 0; |
1101 | handled = 0; |
1107 | } |
1102 | } |
1108 | if (handled) |
1103 | if (handled) |
1109 | ipc_answer_fast(callid, retval, 0, 0); |
1104 | ipc_answer_0(callid, retval); |
1110 | return handled; |
1105 | return handled; |
1111 | } |
1106 | } |
1112 | 1107 | ||
1113 | /** Handler for messages concerning pixmap handling */ |
1108 | /** Handler for messages concerning pixmap handling */ |
1114 | static int |
1109 | static int |
Line 1155... | Line 1150... | ||
1155 | default: |
1150 | default: |
1156 | handled = 0; |
1151 | handled = 0; |
1157 | } |
1152 | } |
1158 | 1153 | ||
1159 | if (handled) |
1154 | if (handled) |
1160 | ipc_answer_fast(callid, retval, 0, 0); |
1155 | ipc_answer_0(callid, retval); |
1161 | return handled; |
1156 | return handled; |
1162 | 1157 | ||
1163 | } |
1158 | } |
1164 | 1159 | ||
1165 | /** Function for handling connections to FB |
1160 | /** Function for handling connections to FB |
Line 1177... | Line 1172... | ||
1177 | 1172 | ||
1178 | int vp = 0; |
1173 | int vp = 0; |
1179 | viewport_t *vport = &viewports[0]; |
1174 | viewport_t *vport = &viewports[0]; |
1180 | 1175 | ||
1181 | if (client_connected) { |
1176 | if (client_connected) { |
1182 | ipc_answer_fast(iid, ELIMIT, 0,0); |
1177 | ipc_answer_0(iid, ELIMIT); |
1183 | return; |
1178 | return; |
1184 | } |
1179 | } |
1185 | client_connected = 1; |
1180 | client_connected = 1; |
1186 | ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ |
1181 | ipc_answer_0(iid, EOK); /* Accept connection */ |
1187 | 1182 | ||
1188 | while (1) { |
1183 | while (1) { |
1189 | if (vport->cursor_active || anims_enabled) |
1184 | if (vport->cursor_active || anims_enabled) |
1190 | callid = async_get_call_timeout(&call, 250000); |
1185 | callid = async_get_call_timeout(&call, 250000); |
1191 | else |
1186 | else |
Line 1220... | Line 1215... | ||
1220 | col = IPC_GET_ARG3(call); |
1215 | col = IPC_GET_ARG3(call); |
1221 | if (row >= vport->rows || col >= vport->cols) { |
1216 | if (row >= vport->rows || col >= vport->cols) { |
1222 | retval = EINVAL; |
1217 | retval = EINVAL; |
1223 | break; |
1218 | break; |
1224 | } |
1219 | } |
1225 | ipc_answer_fast(callid, 0, 0, 0); |
1220 | ipc_answer_0(callid, EOK); |
1226 | 1221 | ||
1227 | draw_char(vport, c, row, col, vport->style, |
1222 | draw_char(vport, c, row, col, vport->style, |
1228 | IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR); |
1223 | IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR); |
1229 | continue; /* msg already answered */ |
1224 | continue; /* msg already answered */ |
1230 | case FB_CLEAR: |
1225 | case FB_CLEAR: |
1231 | clear_port(vport); |
1226 | clear_port(vport); |
1232 | cursor_print(vport); |
1227 | cursor_print(vport); |
1233 | retval = 0; |
1228 | retval = 0; |
Line 1250... | Line 1245... | ||
1250 | vport->cursor_active = IPC_GET_ARG1(call); |
1245 | vport->cursor_active = IPC_GET_ARG1(call); |
1251 | cursor_print(vport); |
1246 | cursor_print(vport); |
1252 | retval = 0; |
1247 | retval = 0; |
1253 | break; |
1248 | break; |
1254 | case FB_GET_CSIZE: |
1249 | case FB_GET_CSIZE: |
1255 | ipc_answer_fast(callid, 0, vport->rows, vport->cols); |
1250 | ipc_answer_2(callid, EOK, vport->rows, vport->cols); |
1256 | continue; |
1251 | continue; |
1257 | case FB_SCROLL: |
1252 | case FB_SCROLL: |
1258 | i = IPC_GET_ARG1(call); |
1253 | i = IPC_GET_ARG1(call); |
1259 | if (i > vport->rows || i < (- (int)vport->rows)) { |
1254 | if (i > vport->rows || i < (- (int)vport->rows)) { |
1260 | retval = EINVAL; |
1255 | retval = EINVAL; |
Line 1272... | Line 1267... | ||
1272 | i = vp; |
1267 | i = vp; |
1273 | if (i < 0 || i >= MAX_VIEWPORTS) { |
1268 | if (i < 0 || i >= MAX_VIEWPORTS) { |
1274 | retval = EINVAL; |
1269 | retval = EINVAL; |
1275 | break; |
1270 | break; |
1276 | } |
1271 | } |
1277 | if (! viewports[i].initialized ) { |
1272 | if (!viewports[i].initialized ) { |
1278 | retval = EADDRNOTAVAIL; |
1273 | retval = EADDRNOTAVAIL; |
1279 | break; |
1274 | break; |
1280 | } |
1275 | } |
1281 | viewports[i].dboffset = 0; |
1276 | viewports[i].dboffset = 0; |
1282 | if (IPC_GET_ARG2(call) == 1 && !viewports[i].dbdata) |
1277 | if (IPC_GET_ARG2(call) == 1 && !viewports[i].dbdata) |
1283 | viewports[i].dbdata = malloc(screen.pixelbytes |
1278 | viewports[i].dbdata = |
1284 | * viewports[i].width * |
1279 | malloc(screen.pixelbytes * |
1285 | viewports[i].height); |
1280 | viewports[i].width * viewports[i].height); |
1286 | else if (IPC_GET_ARG2(call) == 0 && |
1281 | else if (IPC_GET_ARG2(call) == 0 && |
1287 | viewports[i].dbdata) { |
1282 | viewports[i].dbdata) { |
1288 | free(viewports[i].dbdata); |
1283 | free(viewports[i].dbdata); |
1289 | viewports[i].dbdata = NULL; |
1284 | viewports[i].dbdata = NULL; |
1290 | } |
1285 | } |
1291 | retval = 0; |
1286 | retval = 0; |
1292 | break; |
1287 | break; |
Line 1306... | Line 1301... | ||
1306 | cursor_print(vport); |
1301 | cursor_print(vport); |
1307 | retval = 0; |
1302 | retval = 0; |
1308 | break; |
1303 | break; |
1309 | case FB_VIEWPORT_CREATE: |
1304 | case FB_VIEWPORT_CREATE: |
1310 | retval = viewport_create(IPC_GET_ARG1(call) >> 16, |
1305 | retval = viewport_create(IPC_GET_ARG1(call) >> 16, |
1311 | IPC_GET_ARG1(call) & 0xffff, |
1306 | IPC_GET_ARG1(call) & 0xffff, |
1312 | IPC_GET_ARG2(call) >> 16, |
1307 | IPC_GET_ARG2(call) >> 16, |
1313 | IPC_GET_ARG2(call) & 0xffff); |
1308 | IPC_GET_ARG2(call) & 0xffff); |
1314 | break; |
1309 | break; |
1315 | case FB_VIEWPORT_DELETE: |
1310 | case FB_VIEWPORT_DELETE: |
1316 | i = IPC_GET_ARG1(call); |
1311 | i = IPC_GET_ARG1(call); |
1317 | if (i < 0 || i >= MAX_VIEWPORTS) { |
1312 | if (i < 0 || i >= MAX_VIEWPORTS) { |
1318 | retval = EINVAL; |
1313 | retval = EINVAL; |
Line 1333... | Line 1328... | ||
1333 | vport->style.fg_color = IPC_GET_ARG1(call); |
1328 | vport->style.fg_color = IPC_GET_ARG1(call); |
1334 | vport->style.bg_color = IPC_GET_ARG2(call); |
1329 | vport->style.bg_color = IPC_GET_ARG2(call); |
1335 | retval = 0; |
1330 | retval = 0; |
1336 | break; |
1331 | break; |
1337 | case FB_GET_RESOLUTION: |
1332 | case FB_GET_RESOLUTION: |
1338 | ipc_answer_fast(callid, 0, screen.xres,screen.yres); |
1333 | ipc_answer_2(callid, EOK, screen.xres, screen.yres); |
1339 | continue; |
1334 | continue; |
1340 | case FB_POINTER_MOVE: |
1335 | case FB_POINTER_MOVE: |
1341 | pointer_enabled = 1; |
1336 | pointer_enabled = 1; |
1342 | mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call)); |
1337 | mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call)); |
1343 | retval = 0; |
1338 | retval = 0; |
1344 | break; |
1339 | break; |
1345 | default: |
1340 | default: |
1346 | retval = ENOENT; |
1341 | retval = ENOENT; |
1347 | } |
1342 | } |
1348 | ipc_answer_fast(callid,retval, 0, 0); |
1343 | ipc_answer_0(callid, retval); |
1349 | } |
1344 | } |
1350 | } |
1345 | } |
1351 | 1346 | ||
1352 | /** Initialization of framebuffer */ |
1347 | /** Initialization of framebuffer */ |
1353 | int |
1348 | int |
Line 1373... | Line 1368... | ||
1373 | 1368 | ||
1374 | asz = fb_scanline * fb_height; |
1369 | asz = fb_scanline * fb_height; |
1375 | fb_addr = as_get_mappable_page(asz); |
1370 | fb_addr = as_get_mappable_page(asz); |
1376 | 1371 | ||
1377 | physmem_map(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >> |
1372 | physmem_map(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >> |
1378 | PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
1373 | PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
1379 | 1374 | ||
1380 | if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual, |
1375 | if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual, |
1381 | fb_invert_colors)) |
1376 | fb_invert_colors)) |
1382 | return 0; |
1377 | return 0; |
1383 | 1378 | ||
1384 | return -1; |
1379 | return -1; |
1385 | } |
1380 | } |
1386 | 1381 |