Subversion Repositories HelenOS

Rev

Rev 2015 | Rev 2070 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2015 Rev 2025
Line 159... Line 159...
159
    return (*(int *)src) & 0xffffff;
159
    return (*(int *)src) & 0xffffff;
160
}
160
}
161
 
161
 
162
static void bgr_byte0888(void *dst, int rgb)
162
static void bgr_byte0888(void *dst, int rgb)
163
{
163
{
164
    *((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 | RED(rgb, 8);
164
    *((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 |
-
 
165
        RED(rgb, 8);
165
}
166
}
166
 
167
 
167
static int byte0888_bgr(void *src)
168
static int byte0888_bgr(void *src)
168
{
169
{
169
    int color = *(uint32_t *)(src);
170
    int color = *(uint32_t *)(src);
170
    return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color >> 16) & 0xff);
171
    return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color
-
 
172
        >> 16) & 0xff);
171
}
173
}
172
 
174
 
173
static void rgb_byte888(void *dst, int rgb)
175
static void rgb_byte888(void *dst, int rgb)
174
{
176
{
175
    uint8_t *scr = dst;
177
    uint8_t *scr = dst;
Line 196... Line 198...
196
 
198
 
197
/**  16-bit depth (5:5:5) */
199
/**  16-bit depth (5:5:5) */
198
static void rgb_byte555(void *dst, int rgb)
200
static void rgb_byte555(void *dst, int rgb)
199
{
201
{
200
    /* 5-bit, 5-bits, 5-bits */
202
    /* 5-bit, 5-bits, 5-bits */
201
    *((uint16_t *)(dst)) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb, 5);
203
    *((uint16_t *)(dst)) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 |
-
 
204
        BLUE(rgb, 5);
202
}
205
}
203
 
206
 
204
/** 16-bit depth (5:5:5) */
207
/** 16-bit depth (5:5:5) */
205
static int byte555_rgb(void *src)
208
static int byte555_rgb(void *src)
206
{
209
{
207
    int color = *(uint16_t *)(src);
210
    int color = *(uint16_t *)(src);
208
    return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3);
211
    return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) <<
-
 
212
        (8 + 3)) | ((color & 0x1f) << 3);
209
}
213
}
210
 
214
 
211
/**  16-bit depth (5:6:5) */
215
/**  16-bit depth (5:6:5) */
212
static void rgb_byte565(void *dst, int rgb)
216
static void rgb_byte565(void *dst, int rgb)
213
{
217
{
214
    /* 5-bit, 6-bits, 5-bits */
218
    /* 5-bit, 6-bits, 5-bits */
215
    *((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5);
219
    *((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 |
-
 
220
        BLUE(rgb, 5);
216
}
221
}
217
 
222
 
218
/** 16-bit depth (5:6:5) */
223
/** 16-bit depth (5:6:5) */
219
static int byte565_rgb(void *src)
224
static int byte565_rgb(void *src)
220
{
225
{
221
    int color = *(uint16_t *)(src);
226
    int color = *(uint16_t *)(src);
222
    return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
227
    return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) <<
-
 
228
        (8 + 2)) | ((color & 0x1f) << 3);
223
}
229
}
224
 
230
 
225
/** Put pixel - 8-bit depth (3:2:3) */
231
/** Put pixel - 8-bit depth (3:2:3) */
226
static void rgb_byte8(void *dst, int rgb)
232
static void rgb_byte8(void *dst, int rgb)
227
{
233
{
Line 230... Line 236...
230
 
236
 
231
/** Return pixel color - 8-bit depth (3:2:3) */
237
/** Return pixel color - 8-bit depth (3:2:3) */
232
static int byte8_rgb(void *src)
238
static int byte8_rgb(void *src)
233
{
239
{
234
    int color = *(uint8_t *)src;
240
    int color = *(uint8_t *)src;
235
    return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
241
    return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) <<
-
 
242
        (8 + 6)) | ((color & 0x7) << 5);
236
}
243
}
237
 
244
 
238
/** Put pixel into viewport
245
/** Put pixel into viewport
239
 *
246
 *
240
 * @param vport Viewport identification
247
 * @param vport Viewport identification
241
 * @param x X coord relative to viewport
248
 * @param x X coord relative to viewport
242
 * @param y Y coord relative to viewport
249
 * @param y Y coord relative to viewport
243
 * @param color RGB color
250
 * @param color RGB color
244
 */
251
 */
245
static void putpixel(viewport_t *vport, unsigned int x, unsigned int y, int color)
252
static void putpixel(viewport_t *vport, unsigned int x, unsigned int y, int
-
 
253
    color)
246
{
254
{
247
    int dx = vport->x + x;
255
    int dx = vport->x + x;
248
    int dy = vport->y + y;
256
    int dy = vport->y + y;
249
 
257
 
250
    if (! (vport->paused && vport->dbdata))
258
    if (! (vport->paused && vport->dbdata))
Line 264... Line 272...
264
    int dy = vport->y + y;
272
    int dy = vport->y + y;
265
 
273
 
266
    return COLOR((*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]));
274
    return COLOR((*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]));
267
}
275
}
268
 
276
 
269
static inline void putpixel_mem(char *mem, unsigned int x, unsigned int y,
277
static inline void putpixel_mem(char *mem, unsigned int x, unsigned int y, int
270
                int color)
278
    color)
271
{
279
{
272
    (*screen.rgb2scr)(&mem[POINTPOS(x,y)], COLOR(color));
280
    (*screen.rgb2scr)(&mem[POINTPOS(x,y)], COLOR(color));
273
}
281
}
274
 
282
 
275
static void draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy,
283
static void draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy,
276
               unsigned int width, unsigned int height,
284
    unsigned int width, unsigned int height, int color)
277
               int color)
-
 
278
{
285
{
279
    unsigned int x, y;
286
    unsigned int x, y;
280
    static void *tmpline;
287
    static void *tmpline;
281
 
288
 
282
    if (!tmpline)
289
    if (!tmpline)
Line 294... Line 301...
294
        for (y = sy;y < sy+height; y++)
301
        for (y = sy;y < sy+height; y++)
295
            memcpy(&screen.fbaddress[POINTPOS(sx,y)], tmpline,
302
            memcpy(&screen.fbaddress[POINTPOS(sx,y)], tmpline,
296
                   screen.pixelbytes * width);
303
                   screen.pixelbytes * width);
297
    }
304
    }
298
    if (vport->dbdata) {
305
    if (vport->dbdata) {
299
        for (y=sy;y < sy+height; y++) {
306
        for (y = sy; y < sy + height; y++) {
300
            int rline = (y + vport->dboffset) % vport->height;
307
            int rline = (y + vport->dboffset) % vport->height;
301
            int rpos = (rline * vport->width + sx) * screen.pixelbytes;
308
            int rpos = (rline * vport->width + sx) *
-
 
309
                screen.pixelbytes;
302
            memcpy(&vport->dbdata[rpos], tmpline, screen.pixelbytes * width);
310
            memcpy(&vport->dbdata[rpos], tmpline,
-
 
311
                screen.pixelbytes * width);
303
        }
312
        }
304
    }
313
    }
305
 
314
 
306
}
315
}
307
 
316
 
308
/** Fill viewport with background color */
317
/** Fill viewport with background color */
309
static void clear_port(viewport_t *vport)
318
static void clear_port(viewport_t *vport)
310
{
319
{
311
    draw_rectangle(vport, 0, 0, vport->width, vport->height, vport->style.bg_color);
320
    draw_rectangle(vport, 0, 0, vport->width, vport->height,
-
 
321
        vport->style.bg_color);
312
}
322
}
313
 
323
 
314
/** Scroll unbuffered viewport up/down
324
/** Scroll unbuffered viewport up/down
315
 *
325
 *
316
 * @param vport Viewport to scroll
326
 * @param vport Viewport to scroll
Line 319... Line 329...
319
static void scroll_port_nodb(viewport_t *vport, int lines)
329
static void scroll_port_nodb(viewport_t *vport, int lines)
320
{
330
{
321
    int y;
331
    int y;
322
 
332
 
323
    if (lines > 0) {
333
    if (lines > 0) {
324
        for (y=vport->y; y < vport->y+vport->height - lines; y++)
334
        for (y = vport->y; y < vport->y+vport->height - lines; y++)
325
            memcpy(&screen.fbaddress[POINTPOS(vport->x,y)],
335
            memcpy(&screen.fbaddress[POINTPOS(vport->x,y)],
326
                   &screen.fbaddress[POINTPOS(vport->x,y + lines)],
336
                   &screen.fbaddress[POINTPOS(vport->x,y + lines)],
327
                   screen.pixelbytes * vport->width);
337
                   screen.pixelbytes * vport->width);
328
        draw_rectangle(vport, 0, vport->height - lines,
338
        draw_rectangle(vport, 0, vport->height - lines, vport->width,
329
                   vport->width, lines, vport->style.bg_color);
339
            lines, vport->style.bg_color);
330
    } else if (lines < 0) {
340
    } else if (lines < 0) {
331
        lines = -lines;
341
        lines = -lines;
332
        for (y=vport->y + vport->height-1; y >= vport->y + lines; y--)
342
        for (y = vport->y + vport->height-1; y >= vport->y + lines;
-
 
343
             y--)
333
            memcpy(&screen.fbaddress[POINTPOS(vport->x,y)],
344
            memcpy(&screen.fbaddress[POINTPOS(vport->x,y)],
334
                   &screen.fbaddress[POINTPOS(vport->x,y - lines)],
345
                   &screen.fbaddress[POINTPOS(vport->x,y - lines)],
335
                   screen.pixelbytes * vport->width);
346
                   screen.pixelbytes * vport->width);
336
        draw_rectangle(vport, 0, 0, vport->width, lines, vport->style.bg_color);
347
        draw_rectangle(vport, 0, 0, vport->width, lines,
-
 
348
            vport->style.bg_color);
337
    }
349
    }
338
}
350
}
339
 
351
 
340
/** Refresh given viewport from double buffer */
352
/** Refresh given viewport from double buffer */
341
static void refresh_viewport_db(viewport_t *vport)
353
static void refresh_viewport_db(viewport_t *vport)
Line 405... Line 417...
405
 * @param sx Coordinates of top-left of the character
417
 * @param sx Coordinates of top-left of the character
406
 * @param sy Coordinates of top-left of the character
418
 * @param sy Coordinates of top-left of the character
407
 * @param style Color of the character
419
 * @param style Color of the character
408
 * @param transparent If false, print background color
420
 * @param transparent If false, print background color
409
 */
421
 */
410
static void draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx, unsigned int sy,
422
static void draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx,
411
               style_t style, int transparent)
423
     unsigned int sy, style_t style, int transparent)
412
{
424
{
413
    int i;
425
    int i;
414
    unsigned int y;
426
    unsigned int y;
415
    unsigned int glline;
427
    unsigned int glline;
416
 
428
 
417
    for (y = 0; y < FONT_SCANLINES; y++) {
429
    for (y = 0; y < FONT_SCANLINES; y++) {
418
        glline = fb_font[glyph * FONT_SCANLINES + y];
430
        glline = fb_font[glyph * FONT_SCANLINES + y];
419
        for (i = 0; i < 8; i++) {
431
        for (i = 0; i < 8; i++) {
420
            if (glline & (1 << (7 - i)))
432
            if (glline & (1 << (7 - i)))
421
                putpixel(vport, sx + i, sy + y, style.fg_color);
433
                putpixel(vport, sx + i, sy + y,
-
 
434
                    style.fg_color);
422
            else if (!transparent)
435
            else if (!transparent)
423
                putpixel(vport, sx + i, sy + y, style.bg_color);
436
                putpixel(vport, sx + i, sy + y,
-
 
437
                    style.bg_color);
424
        }
438
        }
425
    }
439
    }
426
}
440
}
427
 
441
 
428
/** Invert character at given position */
442
/** Invert character at given position */
Line 431... Line 445...
431
    unsigned int x;
445
    unsigned int x;
432
    unsigned int y;
446
    unsigned int y;
433
 
447
 
434
    for (x = 0; x < COL_WIDTH; x++)
448
    for (x = 0; x < COL_WIDTH; x++)
435
        for (y = 0; y < FONT_SCANLINES; y++)
449
        for (y = 0; y < FONT_SCANLINES; y++)
436
            invert_pixel(vport, col * COL_WIDTH + x, row * FONT_SCANLINES + y);
450
            invert_pixel(vport, col * COL_WIDTH + x, row *
-
 
451
                FONT_SCANLINES + y);
437
}
452
}
438
 
453
 
439
/***************************************************************/
454
/***************************************************************/
440
/* Stdout specific functions */
455
/* Stdout specific functions */
441
 
456
 
Line 443... Line 458...
443
/** Create new viewport
458
/** Create new viewport
444
 *
459
 *
445
 * @return New viewport number
460
 * @return New viewport number
446
 */
461
 */
447
static int viewport_create(unsigned int x, unsigned int y,unsigned int width,
462
static int viewport_create(unsigned int x, unsigned int y,unsigned int width,
448
               unsigned int height)
463
    unsigned int height)
449
{
464
{
450
    int i;
465
    int i;
451
 
466
 
452
    for (i=0; i < MAX_VIEWPORTS; i++) {
467
    for (i=0; i < MAX_VIEWPORTS; i++) {
453
        if (!viewports[i].initialized)
468
        if (!viewports[i].initialized)
Line 485... Line 500...
485
 * @param visual        Bits per pixel (8, 16, 24, 32)
500
 * @param visual        Bits per pixel (8, 16, 24, 32)
486
 * @param scan          Bytes per one scanline
501
 * @param scan          Bytes per one scanline
487
 * @param invert_colors Inverted colors.
502
 * @param invert_colors Inverted colors.
488
 *
503
 *
489
 */
504
 */
490
static bool screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int scan, unsigned int visual, bool invert_colors)
505
static bool screen_init(void *addr, unsigned int xres, unsigned int yres,
-
 
506
    unsigned int scan, unsigned int visual, bool invert_colors)
491
{
507
{
492
    switch (visual) {
508
    switch (visual) {
493
    case VISUAL_INDIRECT_8:
509
    case VISUAL_INDIRECT_8:
494
        screen.rgb2scr = rgb_byte8;
510
        screen.rgb2scr = rgb_byte8;
495
        screen.scr2rgb = byte8_rgb;
511
        screen.scr2rgb = byte8_rgb;
Line 575... Line 591...
575
 * @param c Character to print
591
 * @param c Character to print
576
 * @param row Screen position relative to viewport
592
 * @param row Screen position relative to viewport
577
 * @param col Screen position relative to viewport
593
 * @param col Screen position relative to viewport
578
 * @param transparent If false, print background color with character
594
 * @param transparent If false, print background color with character
579
 */
595
 */
580
static void draw_char(viewport_t *vport, char c, unsigned int row, unsigned int col,
596
static void draw_char(viewport_t *vport, char c, unsigned int row, unsigned int
581
              style_t style, int transparent)
597
    col, style_t style, int transparent)
582
{
598
{
583
    /* Optimize - do not hide cursor if we are going to overwrite it */
599
    /* Optimize - do not hide cursor if we are going to overwrite it */
584
    if (vport->cursor_active && vport->cursor_shown &&
600
    if (vport->cursor_active && vport->cursor_shown &&
585
        (vport->cur_col != col || vport->cur_row != row))
601
        (vport->cur_col != col || vport->cur_row != row))
586
        invert_char(vport, vport->cur_row, vport->cur_col);
602
        invert_char(vport, vport->cur_row, vport->cur_col);
587
   
603
   
588
    draw_glyph(vport, c, col * COL_WIDTH, row * FONT_SCANLINES, style, transparent);
604
    draw_glyph(vport, c, col * COL_WIDTH, row * FONT_SCANLINES, style,
-
 
605
        transparent);
589
 
606
 
590
    vport->cur_col = col;
607
    vport->cur_col = col;
591
    vport->cur_row = row;
608
    vport->cur_row = row;
592
 
609
 
593
    vport->cur_col++;
610
    vport->cur_col++;
594
    if (vport->cur_col>= vport->cols) {
611
    if (vport->cur_col >= vport->cols) {
595
        vport->cur_col = 0;
612
        vport->cur_col = 0;
596
        vport->cur_row++;
613
        vport->cur_row++;
597
        if (vport->cur_row >= vport->rows)
614
        if (vport->cur_row >= vport->rows)
598
            vport->cur_row--;
615
            vport->cur_row--;
599
    }
616
    }
Line 609... Line 626...
609
{
626
{
610
    int i;
627
    int i;
611
    int col,row;
628
    int col,row;
612
 
629
 
613
    clear_port(vport);
630
    clear_port(vport);
614
    for (i=0; i < vport->cols * vport->rows; i++) {
631
    for (i = 0; i < vport->cols * vport->rows; i++) {
615
        if (data[i].character == ' ' && style_same(data[i].style,vport->style))
632
        if (data[i].character == ' ' && style_same(data[i].style,
-
 
633
            vport->style))
616
            continue;
634
            continue;
617
        col = i % vport->cols;
635
        col = i % vport->cols;
618
        row = i / vport->cols;
636
        row = i / vport->cols;
619
        draw_glyph(vport, data[i].character, col * COL_WIDTH, row * FONT_SCANLINES,
637
        draw_glyph(vport, data[i].character, col * COL_WIDTH, row *
-
 
638
            FONT_SCANLINES, data[i].style,
620
               data[i].style, style_same(data[i].style,vport->style));
639
            style_same(data[i].style,vport->style));
621
    }
640
    }
622
    cursor_print(vport);
641
    cursor_print(vport);
623
}
642
}
624
 
643
 
625
 
644
 
Line 668... Line 687...
668
 
687
 
669
/** Handle shared memory communication calls
688
/** Handle shared memory communication calls
670
 *
689
 *
671
 * Protocol for drawing pixmaps:
690
 * Protocol for drawing pixmaps:
672
 * - FB_PREPARE_SHM(client shm identification)
691
 * - FB_PREPARE_SHM(client shm identification)
673
 * - IPC_M_SEND_AS_AREA
692
 * - IPC_M_AS_AREA_SEND
674
 * - FB_DRAW_PPM(startx,starty)
693
 * - FB_DRAW_PPM(startx,starty)
675
 * - FB_DROP_SHM
694
 * - FB_DROP_SHM
676
 *
695
 *
677
 * Protocol for text drawing
696
 * Protocol for text drawing
678
 * - IPC_M_SEND_AS_AREA
697
 * - IPC_M_AS_AREA_SEND
679
 * - FB_DRAW_TEXT_DATA
698
 * - FB_DRAW_TEXT_DATA
680
 *
699
 *
681
 * @param callid Callid of the current call
700
 * @param callid Callid of the current call
682
 * @param call Current call data
701
 * @param call Current call data
683
 * @param vp Active viewport
702
 * @param vp Active viewport
Line 752... Line 771...
752
        if (x > vport->width || y > vport->height) {
771
        if (x > vport->width || y > vport->height) {
753
            retval = EINVAL;
772
            retval = EINVAL;
754
            break;
773
            break;
755
        }
774
        }
756
       
775
       
757
        ppm_draw(shm, shm_size, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call),
776
        ppm_draw(shm, shm_size, IPC_GET_ARG1(*call),
-
 
777
            IPC_GET_ARG2(*call), vport->width - x, vport->height -
758
             vport->width - x, vport->height - y, (putpixel_cb_t)putpixel, vport);
778
            y, (putpixel_cb_t)putpixel, vport);
759
        break;
779
        break;
760
    case FB_DRAW_TEXT_DATA:
780
    case FB_DRAW_TEXT_DATA:
761
        if (!interbuffer) {
781
        if (!interbuffer) {
762
            retval = EINVAL;
782
            retval = EINVAL;
763
            break;
783
            break;
764
        }
784
        }
765
        if (intersize < vport->cols*vport->rows*sizeof(*interbuffer)) {
785
        if (intersize < vport->cols * vport->rows *
-
 
786
            sizeof(*interbuffer)) {
766
            retval = EINVAL;
787
            retval = EINVAL;
767
            break;
788
            break;
768
        }
789
        }
769
        draw_text_data(vport, interbuffer);
790
        draw_text_data(vport, interbuffer);
770
        break;
791
        break;
Line 790... Line 811...
790
    if (height + vport->y  > screen.yres)
811
    if (height + vport->y  > screen.yres)
791
        height = screen.yres - vport->y;
812
        height = screen.yres - vport->y;
792
 
813
 
793
    rowsize = width * screen.pixelbytes;
814
    rowsize = width * screen.pixelbytes;
794
 
815
 
795
    for (y=0;y < height; y++) {
816
    for (y = 0; y < height; y++) {
796
        tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;
817
        tmp = (vport->y + y) * screen.scanline + vport->x *
-
 
818
            screen.pixelbytes;
797
        memcpy(pmap->data + rowsize*y, screen.fbaddress + tmp, rowsize);
819
        memcpy(pmap->data + rowsize * y, screen.fbaddress + tmp,
-
 
820
            rowsize);
798
    }
821
    }
799
}
822
}
800
 
823
 
801
/** Save viewport to pixmap */
824
/** Save viewport to pixmap */
802
static int save_vp_to_pixmap(viewport_t *vport)
825
static int save_vp_to_pixmap(viewport_t *vport)
Line 849... Line 872...
849
 
872
 
850
    srcrowsize = vport->width * screen.pixelbytes;
873
    srcrowsize = vport->width * screen.pixelbytes;
851
    realrowsize = realwidth * screen.pixelbytes;
874
    realrowsize = realwidth * screen.pixelbytes;
852
 
875
 
853
    for (y=0; y < realheight; y++) {
876
    for (y=0; y < realheight; y++) {
854
        tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;
877
        tmp = (vport->y + y) * screen.scanline + vport->x *
-
 
878
            screen.pixelbytes;
855
        memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize, realrowsize);
879
        memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize,
-
 
880
            realrowsize);
856
    }
881
    }
857
    return 0;
882
    return 0;
858
}
883
}
859
 
884
 
860
/** Tick animation one step forward */
885
/** Tick animation one step forward */
Line 862... Line 887...
862
{
887
{
863
    int i;
888
    int i;
864
    static int counts = 0;
889
    static int counts = 0;
865
   
890
   
866
    /* Limit redrawing */
891
    /* Limit redrawing */
867
    counts = (counts+1) % 8;
892
    counts = (counts + 1) % 8;
868
    if (counts)
893
    if (counts)
869
        return;
894
        return;
870
 
895
 
871
    for (i=0; i < MAX_ANIMATIONS; i++) {
896
    for (i=0; i < MAX_ANIMATIONS; i++) {
872
        if (!animations[i].animlen || !animations[i].initialized || !animations[i].enabled)
897
        if (!animations[i].animlen || !animations[i].initialized ||
-
 
898
            !animations[i].enabled)
873
            continue;
899
            continue;
-
 
900
        draw_pixmap(animations[i].vp,
874
        draw_pixmap(animations[i].vp, animations[i].pixmaps[animations[i].pos]);
901
            animations[i].pixmaps[animations[i].pos]);
875
        animations[i].pos = (animations[i].pos+1) % animations[i].animlen;
902
        animations[i].pos = (animations[i].pos + 1) %
-
 
903
            animations[i].animlen;
876
    }
904
    }
877
}
905
}
878
 
906
 
879
 
907
 
880
static int pointer_x, pointer_y;
908
static int pointer_x, pointer_y;
Line 892... Line 920...
892
    if (pointer_shown || !pointer_enabled)
920
    if (pointer_shown || !pointer_enabled)
893
        return;
921
        return;
894
 
922
 
895
    /* Save image under the cursor */
923
    /* Save image under the cursor */
896
    if (pointer_vport == -1) {
924
    if (pointer_vport == -1) {
897
        pointer_vport = viewport_create(pointer_x, pointer_y, pointer_width, pointer_height);
925
        pointer_vport = viewport_create(pointer_x, pointer_y,
-
 
926
            pointer_width, pointer_height);
898
        if (pointer_vport < 0)
927
        if (pointer_vport < 0)
899
            return;
928
            return;
900
    } else {
929
    } else {
901
        viewports[pointer_vport].x = pointer_x;
930
        viewports[pointer_vport].x = pointer_x;
902
        viewports[pointer_vport].y = pointer_y;
931
        viewports[pointer_vport].y = pointer_y;
903
    }
932
    }
904
 
933
 
905
    if (pointer_pixmap == -1)
934
    if (pointer_pixmap == -1)
906
        pointer_pixmap = save_vp_to_pixmap(&viewports[pointer_vport]);
935
        pointer_pixmap = save_vp_to_pixmap(&viewports[pointer_vport]);
907
    else
936
    else
908
        copy_vp_to_pixmap(&viewports[pointer_vport], &pixmaps[pointer_pixmap]);
937
        copy_vp_to_pixmap(&viewports[pointer_vport],
-
 
938
            &pixmaps[pointer_pixmap]);
909
 
939
 
910
    /* Draw cursor */
940
    /* Draw cursor */
911
    for (i=0; i < pointer_height; i++)
941
    for (i = 0; i < pointer_height; i++)
912
        for (j=0;j < pointer_width; j++) {
942
        for (j = 0; j < pointer_width; j++) {
913
            bytepos = i*((pointer_width-1)/8+1) + j/8;
943
            bytepos = i * ((pointer_width - 1) / 8 + 1) + j / 8;
914
            visibility = pointer_mask_bits[bytepos] & (1 << (j % 8));
944
            visibility = pointer_mask_bits[bytepos] & (1 << (j %
-
 
945
                8));
915
            if (visibility) {
946
            if (visibility) {
916
                color = pointer_bits[bytepos] & (1 << (j % 8)) ? 0 : 0xffffff;
947
                color = pointer_bits[bytepos] & (1 << (j % 8))
-
 
948
                    ? 0 : 0xffffff;
917
                if (pointer_x+j < screen.xres && pointer_y+i < screen.yres)
949
                if (pointer_x + j < screen.xres && pointer_y +
-
 
950
                    i < screen.yres)
918
                    putpixel(&viewports[0], pointer_x+j, pointer_y+i, color);
951
                    putpixel(&viewports[0], pointer_x + j,
-
 
952
                         pointer_y+i, color);
919
            }
953
            }
920
        }
954
        }
921
    pointer_shown = 1;
955
    pointer_shown = 1;
922
}
956
}
923
 
957
 
Line 948... Line 982...
948
    switch (IPC_GET_METHOD(*call)) {
982
    switch (IPC_GET_METHOD(*call)) {
949
    case FB_ANIM_CREATE:
983
    case FB_ANIM_CREATE:
950
        nvp = IPC_GET_ARG1(*call);
984
        nvp = IPC_GET_ARG1(*call);
951
        if (nvp == -1)
985
        if (nvp == -1)
952
            nvp = vp;
986
            nvp = vp;
953
        if (nvp >= MAX_VIEWPORTS || nvp < 0 || !viewports[nvp].initialized) {
987
        if (nvp >= MAX_VIEWPORTS || nvp < 0 ||
-
 
988
            !viewports[nvp].initialized) {
954
            retval = EINVAL;
989
            retval = EINVAL;
955
            break;
990
            break;
956
        }
991
        }
957
        for (i=0; i < MAX_ANIMATIONS; i++) {
992
        for (i = 0; i < MAX_ANIMATIONS; i++) {
958
            if (! animations[i].initialized)
993
            if (!animations[i].initialized)
959
                break;
994
                break;
960
        }
995
        }
961
        if (i == MAX_ANIMATIONS) {
996
        if (i == MAX_ANIMATIONS) {
962
            retval = ELIMIT;
997
            retval = ELIMIT;
963
            break;
998
            break;
Line 977... Line 1012...
977
        }
1012
        }
978
        animations[i].initialized = 0;
1013
        animations[i].initialized = 0;
979
        break;
1014
        break;
980
    case FB_ANIM_ADDPIXMAP:
1015
    case FB_ANIM_ADDPIXMAP:
981
        i = IPC_GET_ARG1(*call);
1016
        i = IPC_GET_ARG1(*call);
982
        if (i >= MAX_ANIMATIONS || i < 0 || !animations[i].initialized) {
1017
        if (i >= MAX_ANIMATIONS || i < 0 ||
-
 
1018
            !animations[i].initialized) {
983
            retval = EINVAL;
1019
            retval = EINVAL;
984
            break;
1020
            break;
985
        }
1021
        }
986
        if (animations[i].animlen == MAX_ANIM_LEN) {
1022
        if (animations[i].animlen == MAX_ANIM_LEN) {
987
            retval = ELIMIT;
1023
            retval = ELIMIT;
988
            break;
1024
            break;
989
        }
1025
        }
990
        newval = IPC_GET_ARG2(*call);
1026
        newval = IPC_GET_ARG2(*call);
991
        if (newval < 0 || newval > MAX_PIXMAPS || !pixmaps[newval].data) {
1027
        if (newval < 0 || newval > MAX_PIXMAPS ||
-
 
1028
            !pixmaps[newval].data) {
992
            retval = EINVAL;
1029
            retval = EINVAL;
993
            break;
1030
            break;
994
        }
1031
        }
995
        animations[i].pixmaps[animations[i].animlen++] = newval;
1032
        animations[i].pixmaps[animations[i].animlen++] = newval;
996
        break;
1033
        break;
Line 1001... Line 1038...
1001
            break;
1038
            break;
1002
        }
1039
        }
1003
        nvp = IPC_GET_ARG2(*call);
1040
        nvp = IPC_GET_ARG2(*call);
1004
        if (nvp == -1)
1041
        if (nvp == -1)
1005
            nvp = vp;
1042
            nvp = vp;
1006
        if (nvp >= MAX_VIEWPORTS || nvp < 0 || !viewports[nvp].initialized) {
1043
        if (nvp >= MAX_VIEWPORTS || nvp < 0 ||
-
 
1044
            !viewports[nvp].initialized) {
1007
            retval = EINVAL;
1045
            retval = EINVAL;
1008
            break;
1046
            break;
1009
        }
1047
        }
1010
        animations[i].vp = nvp;
1048
        animations[i].vp = nvp;
1011
        break;
1049
        break;
Line 1040... Line 1078...
1040
    switch (IPC_GET_METHOD(*call)) {
1078
    switch (IPC_GET_METHOD(*call)) {
1041
    case FB_VP_DRAW_PIXMAP:
1079
    case FB_VP_DRAW_PIXMAP:
1042
        nvp = IPC_GET_ARG1(*call);
1080
        nvp = IPC_GET_ARG1(*call);
1043
        if (nvp == -1)
1081
        if (nvp == -1)
1044
            nvp = vp;
1082
            nvp = vp;
1045
        if (nvp < 0 || nvp >= MAX_VIEWPORTS || !viewports[nvp].initialized) {
1083
        if (nvp < 0 || nvp >= MAX_VIEWPORTS ||
-
 
1084
            !viewports[nvp].initialized) {
1046
            retval = EINVAL;
1085
            retval = EINVAL;
1047
            break;
1086
            break;
1048
        }
1087
        }
1049
        i = IPC_GET_ARG2(*call);
1088
        i = IPC_GET_ARG2(*call);
1050
        retval = draw_pixmap(nvp, i);
1089
        retval = draw_pixmap(nvp, i);
1051
        break;
1090
        break;
1052
    case FB_VP2PIXMAP:
1091
    case FB_VP2PIXMAP:
1053
        nvp = IPC_GET_ARG1(*call);
1092
        nvp = IPC_GET_ARG1(*call);
1054
        if (nvp == -1)
1093
        if (nvp == -1)
1055
            nvp = vp;
1094
            nvp = vp;
1056
        if (nvp < 0 || nvp >= MAX_VIEWPORTS || !viewports[nvp].initialized)
1095
        if (nvp < 0 || nvp >= MAX_VIEWPORTS ||
-
 
1096
            !viewports[nvp].initialized)
1057
            retval = EINVAL;
1097
            retval = EINVAL;
1058
        else
1098
        else
1059
            retval = save_vp_to_pixmap(&viewports[nvp]);
1099
            retval = save_vp_to_pixmap(&viewports[nvp]);
1060
        break;
1100
        break;
1061
    case FB_DROP_PIXMAP:
1101
    case FB_DROP_PIXMAP:
Line 1123... Line 1163...
1123
 
1163
 
1124
        switch (IPC_GET_METHOD(call)) {
1164
        switch (IPC_GET_METHOD(call)) {
1125
        case IPC_M_PHONE_HUNGUP:
1165
        case IPC_M_PHONE_HUNGUP:
1126
            client_connected = 0;
1166
            client_connected = 0;
1127
            /* cleanup other viewports */
1167
            /* cleanup other viewports */
1128
            for (i=1; i < MAX_VIEWPORTS; i++)
1168
            for (i = 1; i < MAX_VIEWPORTS; i++)
1129
                vport->initialized = 0;
1169
                vport->initialized = 0;
1130
            return; /* Exit thread */
1170
            return; /* Exit thread */
1131
 
1171
 
1132
        case FB_PUTCHAR:
1172
        case FB_PUTCHAR:
1133
        case FB_TRANS_PUTCHAR:
1173
        case FB_TRANS_PUTCHAR:
Line 1138... Line 1178...
1138
                retval = EINVAL;
1178
                retval = EINVAL;
1139
                break;
1179
                break;
1140
            }
1180
            }
1141
            ipc_answer_fast(callid,0,0,0);
1181
            ipc_answer_fast(callid,0,0,0);
1142
 
1182
 
1143
            draw_char(vport, c, row, col, vport->style, IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR);
1183
            draw_char(vport, c, row, col, vport->style,
-
 
1184
                IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR);
1144
            continue; /* msg already answered */
1185
            continue; /* msg already answered */
1145
        case FB_CLEAR:
1186
        case FB_CLEAR:
1146
            clear_port(vport);
1187
            clear_port(vport);
1147
            cursor_print(vport);
1188
            cursor_print(vport);
1148
            retval = 0;
1189
            retval = 0;
Line 1193... Line 1234...
1193
                retval = EADDRNOTAVAIL;
1234
                retval = EADDRNOTAVAIL;
1194
                break;
1235
                break;
1195
            }
1236
            }
1196
            viewports[i].dboffset = 0;
1237
            viewports[i].dboffset = 0;
1197
            if (IPC_GET_ARG2(call) == 1 && !viewports[i].dbdata)
1238
            if (IPC_GET_ARG2(call) == 1 && !viewports[i].dbdata)
1198
                viewports[i].dbdata = malloc(screen.pixelbytes*viewports[i].width * viewports[i].height);
1239
                viewports[i].dbdata = malloc(screen.pixelbytes
-
 
1240
                    * viewports[i].width *
-
 
1241
                    viewports[i].height);
1199
            else if (IPC_GET_ARG2(call) == 0 && viewports[i].dbdata) {
1242
            else if (IPC_GET_ARG2(call) == 0 &&
-
 
1243
                viewports[i].dbdata) {
1200
                free(viewports[i].dbdata);
1244
                free(viewports[i].dbdata);
1201
                viewports[i].dbdata = NULL;
1245
                viewports[i].dbdata = NULL;
1202
            }
1246
            }
1203
            retval = 0;
1247
            retval = 0;
1204
            break;
1248
            break;
Line 1218... Line 1262...
1218
            cursor_print(vport);
1262
            cursor_print(vport);
1219
            retval = 0;
1263
            retval = 0;
1220
            break;
1264
            break;
1221
        case FB_VIEWPORT_CREATE:
1265
        case FB_VIEWPORT_CREATE:
1222
            retval = viewport_create(IPC_GET_ARG1(call) >> 16,
1266
            retval = viewport_create(IPC_GET_ARG1(call) >> 16,
1223
                         IPC_GET_ARG1(call) & 0xffff,
1267
                IPC_GET_ARG1(call) & 0xffff, IPC_GET_ARG2(call)
1224
                         IPC_GET_ARG2(call) >> 16,
-
 
1225
                         IPC_GET_ARG2(call) & 0xffff);
1268
                 >> 16, IPC_GET_ARG2(call) & 0xffff);
1226
            break;
1269
            break;
1227
        case FB_VIEWPORT_DELETE:
1270
        case FB_VIEWPORT_DELETE:
1228
            i = IPC_GET_ARG1(call);
1271
            i = IPC_GET_ARG1(call);
1229
            if (i < 0 || i >= MAX_VIEWPORTS) {
1272
            if (i < 0 || i >= MAX_VIEWPORTS) {
1230
                retval = EINVAL;
1273
                retval = EINVAL;
Line 1281... Line 1324...
1281
    fb_scanline = sysinfo_value("fb.scanline");
1324
    fb_scanline = sysinfo_value("fb.scanline");
1282
    fb_visual = sysinfo_value("fb.visual");
1325
    fb_visual = sysinfo_value("fb.visual");
1283
    fb_invert_colors = sysinfo_value("fb.invert-colors");
1326
    fb_invert_colors = sysinfo_value("fb.invert-colors");
1284
 
1327
 
1285
    asz = fb_scanline * fb_height;
1328
    asz = fb_scanline * fb_height;
1286
    fb_addr = as_get_mappable_page(asz, (int) sysinfo_value("fb.address.color"));
1329
    fb_addr = as_get_mappable_page(asz, (int)
-
 
1330
        sysinfo_value("fb.address.color"));
1287
   
1331
   
1288
    physmem_map(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >> PAGE_WIDTH,
1332
    physmem_map(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >>
1289
            AS_AREA_READ | AS_AREA_WRITE);
1333
        PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
1290
 
1334
 
1291
    if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual,
1335
    if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual,
1292
        fb_invert_colors))
1336
        fb_invert_colors))
1293
        return 0;
1337
        return 0;
1294
   
1338