Subversion Repositories HelenOS

Rev

Rev 2025 | Rev 2071 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2025 Rev 2070
Line 147... Line 147...
147
{
147
{
148
    return screen.invert_colors ? ~color : color;
148
    return screen.invert_colors ? ~color : color;
149
}
149
}
150
 
150
 
151
/* Conversion routines between different color representations */
151
/* Conversion routines between different color representations */
-
 
152
static void
152
static void rgb_byte0888(void *dst, int rgb)
153
rgb_byte0888(void *dst, int rgb)
153
{
154
{
154
    *(int *)dst = rgb;
155
    *(int *)dst = rgb;
155
}
156
}
156
 
157
 
-
 
158
static int
157
static int byte0888_rgb(void *src)
159
byte0888_rgb(void *src)
158
{
160
{
159
    return (*(int *)src) & 0xffffff;
161
    return (*(int *)src) & 0xffffff;
160
}
162
}
161
 
163
 
-
 
164
static void
162
static void bgr_byte0888(void *dst, int rgb)
165
bgr_byte0888(void *dst, int rgb)
163
{
166
{
164
    *((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 |
167
    *((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 |
165
        RED(rgb, 8);
168
        RED(rgb, 8);
166
}
169
}
167
 
170
 
-
 
171
static int
168
static int byte0888_bgr(void *src)
172
byte0888_bgr(void *src)
169
{
173
{
170
    int color = *(uint32_t *)(src);
174
    int color = *(uint32_t *)(src);
171
    return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color
175
    return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) |
172
        >> 16) & 0xff);
176
        ((color >> 16) & 0xff);
173
}
177
}
174
 
178
 
-
 
179
static void
175
static void rgb_byte888(void *dst, int rgb)
180
rgb_byte888(void *dst, int rgb)
176
{
181
{
177
    uint8_t *scr = dst;
182
    uint8_t *scr = dst;
178
#if defined(FB_INVERT_ENDIAN)
183
#if defined(FB_INVERT_ENDIAN)
179
    scr[0] = RED(rgb, 8);
184
    scr[0] = RED(rgb, 8);
180
    scr[1] = GREEN(rgb, 8);
185
    scr[1] = GREEN(rgb, 8);
Line 184... Line 189...
184
    scr[1] = GREEN(rgb, 8);
189
    scr[1] = GREEN(rgb, 8);
185
    scr[0] = BLUE(rgb, 8);
190
    scr[0] = BLUE(rgb, 8);
186
#endif
191
#endif
187
}
192
}
188
 
193
 
-
 
194
static int
189
static int byte888_rgb(void *src)
195
byte888_rgb(void *src)
190
{
196
{
191
    uint8_t *scr = src;
197
    uint8_t *scr = src;
192
#if defined(FB_INVERT_ENDIAN)
198
#if defined(FB_INVERT_ENDIAN)
193
    return scr[0] << 16 | scr[1] << 8 | scr[2];
199
    return scr[0] << 16 | scr[1] << 8 | scr[2];
194
#else
200
#else
195
    return scr[2] << 16 | scr[1] << 8 | scr[0];
201
    return scr[2] << 16 | scr[1] << 8 | scr[0];
196
#endif  
202
#endif  
197
}
203
}
198
 
204
 
199
/**  16-bit depth (5:5:5) */
205
/**  16-bit depth (5:5:5) */
-
 
206
static void
200
static void rgb_byte555(void *dst, int rgb)
207
rgb_byte555(void *dst, int rgb)
201
{
208
{
202
    /* 5-bit, 5-bits, 5-bits */
209
    /* 5-bit, 5-bits, 5-bits */
203
    *((uint16_t *)(dst)) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 |
210
    *((uint16_t *)(dst)) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 |
204
        BLUE(rgb, 5);
211
        BLUE(rgb, 5);
205
}
212
}
206
 
213
 
207
/** 16-bit depth (5:5:5) */
214
/** 16-bit depth (5:5:5) */
-
 
215
static int
208
static int byte555_rgb(void *src)
216
byte555_rgb(void *src)
209
{
217
{
210
    int color = *(uint16_t *)(src);
218
    int color = *(uint16_t *)(src);
211
    return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) <<
219
    return (((color >> 10) & 0x1f) << (16 + 3)) |
212
        (8 + 3)) | ((color & 0x1f) << 3);
220
        (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3);
213
}
221
}
214
 
222
 
215
/**  16-bit depth (5:6:5) */
223
/**  16-bit depth (5:6:5) */
-
 
224
static void
216
static void rgb_byte565(void *dst, int rgb)
225
rgb_byte565(void *dst, int rgb)
217
{
226
{
218
    /* 5-bit, 6-bits, 5-bits */
227
    /* 5-bit, 6-bits, 5-bits */
219
    *((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 |
228
    *((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 |
220
        BLUE(rgb, 5);
229
        BLUE(rgb, 5);
221
}
230
}
222
 
231
 
223
/** 16-bit depth (5:6:5) */
232
/** 16-bit depth (5:6:5) */
-
 
233
static int
224
static int byte565_rgb(void *src)
234
byte565_rgb(void *src)
225
{
235
{
226
    int color = *(uint16_t *)(src);
236
    int color = *(uint16_t *)(src);
227
    return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) <<
237
    return (((color >> 11) & 0x1f) << (16 + 3)) |
228
        (8 + 2)) | ((color & 0x1f) << 3);
238
        (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
229
}
239
}
230
 
240
 
231
/** Put pixel - 8-bit depth (3:2:3) */
241
/** Put pixel - 8-bit depth (3:2:3) */
-
 
242
static void
232
static void rgb_byte8(void *dst, int rgb)
243
rgb_byte8(void *dst, int rgb)
233
{
244
{
234
    *(uint8_t *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
245
    *(uint8_t *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
235
}
246
}
236
 
247
 
237
/** Return pixel color - 8-bit depth (3:2:3) */
248
/** Return pixel color - 8-bit depth (3:2:3) */
-
 
249
static int
238
static int byte8_rgb(void *src)
250
byte8_rgb(void *src)
239
{
251
{
240
    int color = *(uint8_t *)src;
252
    int color = *(uint8_t *)src;
241
    return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) <<
253
    return (((color >> 5) & 0x7) << (16 + 5)) |
242
        (8 + 6)) | ((color & 0x7) << 5);
254
        (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
243
}
255
}
244
 
256
 
245
/** Put pixel into viewport
257
/** Put pixel into viewport
246
 *
258
 *
247
 * @param vport Viewport identification
259
 * @param vport Viewport identification
248
 * @param x X coord relative to viewport
260
 * @param x X coord relative to viewport
249
 * @param y Y coord relative to viewport
261
 * @param y Y coord relative to viewport
250
 * @param color RGB color
262
 * @param color RGB color
251
 */
263
 */
-
 
264
static void
252
static void putpixel(viewport_t *vport, unsigned int x, unsigned int y, int
265
putpixel(viewport_t *vport, unsigned int x, unsigned int y, int color)
253
    color)
-
 
254
{
266
{
255
    int dx = vport->x + x;
267
    int dx = vport->x + x;
256
    int dy = vport->y + y;
268
    int dy = vport->y + y;
257
 
269
 
258
    if (! (vport->paused && vport->dbdata))
270
    if (! (vport->paused && vport->dbdata))
259
        (*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)], COLOR(color));
271
        (*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)],
-
 
272
            COLOR(color));
260
 
273
 
261
    if (vport->dbdata) {
274
    if (vport->dbdata) {
262
        int dline = (y + vport->dboffset) % vport->height;
275
        int dline = (y + vport->dboffset) % vport->height;
263
        int doffset = screen.pixelbytes * (dline * vport->width + x);
276
        int doffset = screen.pixelbytes * (dline * vport->width + x);
264
        (*screen.rgb2scr)(&vport->dbdata[doffset], COLOR(color));
277
        (*screen.rgb2scr)(&vport->dbdata[doffset], COLOR(color));
265
    }
278
    }
266
}
279
}
267
 
280
 
268
/** Get pixel from viewport */
281
/** Get pixel from viewport */
-
 
282
static int
269
static int getpixel(viewport_t *vport, unsigned int x, unsigned int y)
283
getpixel(viewport_t *vport, unsigned int x, unsigned int y)
270
{
284
{
271
    int dx = vport->x + x;
285
    int dx = vport->x + x;
272
    int dy = vport->y + y;
286
    int dy = vport->y + y;
273
 
287
 
274
    return COLOR((*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]));
288
    return COLOR((*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx, dy)]));
275
}
289
}
276
 
290
 
-
 
291
static inline void
277
static inline void putpixel_mem(char *mem, unsigned int x, unsigned int y, int
292
putpixel_mem(char *mem, unsigned int x, unsigned int y, int color)
278
    color)
-
 
279
{
293
{
280
    (*screen.rgb2scr)(&mem[POINTPOS(x,y)], COLOR(color));
294
    (*screen.rgb2scr)(&mem[POINTPOS(x,y)], COLOR(color));
281
}
295
}
282
 
296
 
-
 
297
static void
283
static void draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy,
298
draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy,
284
    unsigned int width, unsigned int height, int color)
299
    unsigned int width, unsigned int height, int color)
285
{
300
{
286
    unsigned int x, y;
301
    unsigned int x, y;
287
    static void *tmpline;
302
    static void *tmpline;
288
 
303
 
Line 313... Line 328...
313
    }
328
    }
314
 
329
 
315
}
330
}
316
 
331
 
317
/** Fill viewport with background color */
332
/** Fill viewport with background color */
-
 
333
static void
318
static void clear_port(viewport_t *vport)
334
clear_port(viewport_t *vport)
319
{
335
{
320
    draw_rectangle(vport, 0, 0, vport->width, vport->height,
336
    draw_rectangle(vport, 0, 0, vport->width, vport->height,
321
        vport->style.bg_color);
337
        vport->style.bg_color);
322
}
338
}
323
 
339
 
324
/** Scroll unbuffered viewport up/down
340
/** Scroll unbuffered viewport up/down
325
 *
341
 *
326
 * @param vport Viewport to scroll
342
 * @param vport Viewport to scroll
327
 * @param lines Positive number - scroll up, negative - scroll down
343
 * @param lines Positive number - scroll up, negative - scroll down
328
 */
344
 */
-
 
345
static void
329
static void scroll_port_nodb(viewport_t *vport, int lines)
346
scroll_port_nodb(viewport_t *vport, int lines)
330
{
347
{
331
    int y;
348
    int y;
332
 
349
 
333
    if (lines > 0) {
350
    if (lines > 0) {
334
        for (y = vport->y; y < vport->y+vport->height - lines; y++)
351
        for (y = vport->y; y < vport->y+vport->height - lines; y++)
Line 348... Line 365...
348
            vport->style.bg_color);
365
            vport->style.bg_color);
349
    }
366
    }
350
}
367
}
351
 
368
 
352
/** Refresh given viewport from double buffer */
369
/** Refresh given viewport from double buffer */
-
 
370
static void
353
static void refresh_viewport_db(viewport_t *vport)
371
refresh_viewport_db(viewport_t *vport)
354
{
372
{
355
    unsigned int y, srcy, srcoff, dsty, dstx;
373
    unsigned int y, srcy, srcoff, dsty, dstx;
356
 
374
 
357
    for (y = 0; y < vport->height; y++) {
375
    for (y = 0; y < vport->height; y++) {
358
        srcy = (y + vport->dboffset) % vport->height;
376
        srcy = (y + vport->dboffset) % vport->height;
Line 366... Line 384...
366
               vport->width*screen.pixelbytes);
384
               vport->width*screen.pixelbytes);
367
    }
385
    }
368
}
386
}
369
 
387
 
370
/** Scroll viewport that has double buffering enabled */
388
/** Scroll viewport that has double buffering enabled */
-
 
389
static void
371
static void scroll_port_db(viewport_t *vport, int lines)
390
scroll_port_db(viewport_t *vport, int lines)
372
{
391
{
373
    ++vport->paused;
392
    ++vport->paused;
374
    if (lines > 0) {
393
    if (lines > 0) {
375
        draw_rectangle(vport, 0, 0, vport->width, lines,
394
        draw_rectangle(vport, 0, 0, vport->width, lines,
376
                   vport->style.bg_color);
395
                   vport->style.bg_color);
Line 391... Line 410...
391
   
410
   
392
    refresh_viewport_db(vport);
411
    refresh_viewport_db(vport);
393
}
412
}
394
 
413
 
395
/** Scrolls viewport given number of lines */
414
/** Scrolls viewport given number of lines */
-
 
415
static void
396
static void scroll_port(viewport_t *vport, int lines)
416
scroll_port(viewport_t *vport, int lines)
397
{
417
{
398
    if (vport->dbdata)
418
    if (vport->dbdata)
399
        scroll_port_db(vport, lines);
419
        scroll_port_db(vport, lines);
400
    else
420
    else
401
        scroll_port_nodb(vport, lines);
421
        scroll_port_nodb(vport, lines);
402
   
422
   
403
}
423
}
404
 
424
 
-
 
425
static void
405
static void invert_pixel(viewport_t *vport, unsigned int x, unsigned int y)
426
invert_pixel(viewport_t *vport, unsigned int x, unsigned int y)
406
{
427
{
407
    putpixel(vport, x, y, ~getpixel(vport, x, y));
428
    putpixel(vport, x, y, ~getpixel(vport, x, y));
408
}
429
}
409
 
430
 
410
 
431
 
Line 417... Line 438...
417
 * @param sx Coordinates of top-left of the character
438
 * @param sx Coordinates of top-left of the character
418
 * @param sy Coordinates of top-left of the character
439
 * @param sy Coordinates of top-left of the character
419
 * @param style Color of the character
440
 * @param style Color of the character
420
 * @param transparent If false, print background color
441
 * @param transparent If false, print background color
421
 */
442
 */
-
 
443
static void
422
static void draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx,
444
draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx,
423
     unsigned int sy, style_t style, int transparent)
445
     unsigned int sy, style_t style, int transparent)
424
{
446
{
425
    int i;
447
    int i;
426
    unsigned int y;
448
    unsigned int y;
427
    unsigned int glline;
449
    unsigned int glline;
Line 438... Line 460...
438
        }
460
        }
439
    }
461
    }
440
}
462
}
441
 
463
 
442
/** Invert character at given position */
464
/** Invert character at given position */
-
 
465
static void
443
static void invert_char(viewport_t *vport,unsigned int row, unsigned int col)
466
invert_char(viewport_t *vport,unsigned int row, unsigned int col)
444
{
467
{
445
    unsigned int x;
468
    unsigned int x;
446
    unsigned int y;
469
    unsigned int y;
447
 
470
 
448
    for (x = 0; x < COL_WIDTH; x++)
471
    for (x = 0; x < COL_WIDTH; x++)
Line 457... Line 480...
457
 
480
 
458
/** Create new viewport
481
/** Create new viewport
459
 *
482
 *
460
 * @return New viewport number
483
 * @return New viewport number
461
 */
484
 */
-
 
485
static int
462
static int viewport_create(unsigned int x, unsigned int y,unsigned int width,
486
viewport_create(unsigned int x, unsigned int y,unsigned int width,
463
    unsigned int height)
487
    unsigned int height)
464
{
488
{
465
    int i;
489
    int i;
466
 
490
 
467
    for (i=0; i < MAX_VIEWPORTS; i++) {
491
    for (i = 0; i < MAX_VIEWPORTS; i++) {
Line 489... Line 513...
489
    viewports[i].initialized = 1;
513
    viewports[i].initialized = 1;
490
 
514
 
491
    return i;
515
    return i;
492
}
516
}
493
 
517
 
494
 
-
 
495
/** Initialize framebuffer as a chardev output device
518
/** Initialize framebuffer as a chardev output device
496
 *
519
 *
497
 * @param addr          Address of theframebuffer
520
 * @param addr          Address of theframebuffer
498
 * @param xres          Screen width in pixels
521
 * @param xres          Screen width in pixels
499
 * @param yres          Screen height in pixels
522
 * @param yres          Screen height in pixels
500
 * @param visual        Bits per pixel (8, 16, 24, 32)
523
 * @param visual        Bits per pixel (8, 16, 24, 32)
501
 * @param scan          Bytes per one scanline
524
 * @param scan          Bytes per one scanline
502
 * @param invert_colors Inverted colors.
525
 * @param invert_colors Inverted colors.
503
 *
526
 *
504
 */
527
 */
-
 
528
static bool
505
static bool screen_init(void *addr, unsigned int xres, unsigned int yres,
529
screen_init(void *addr, unsigned int xres, unsigned int yres,
506
    unsigned int scan, unsigned int visual, bool invert_colors)
530
    unsigned int scan, unsigned int visual, bool invert_colors)
507
{
531
{
508
    switch (visual) {
532
    switch (visual) {
509
    case VISUAL_INDIRECT_8:
533
    case VISUAL_INDIRECT_8:
510
        screen.rgb2scr = rgb_byte8;
534
        screen.rgb2scr = rgb_byte8;
Line 556... Line 580...
556
   
580
   
557
    return true;
581
    return true;
558
}
582
}
559
 
583
 
560
/** Hide cursor if it is shown */
584
/** Hide cursor if it is shown */
-
 
585
static void
561
static void cursor_hide(viewport_t *vport)
586
cursor_hide(viewport_t *vport)
562
{
587
{
563
    if (vport->cursor_active && vport->cursor_shown) {
588
    if (vport->cursor_active && vport->cursor_shown) {
564
        invert_char(vport, vport->cur_row, vport->cur_col);
589
        invert_char(vport, vport->cur_row, vport->cur_col);
565
        vport->cursor_shown = 0;
590
        vport->cursor_shown = 0;
566
    }
591
    }
567
}
592
}
568
 
593
 
569
/** Show cursor if cursor showing is enabled */
594
/** Show cursor if cursor showing is enabled */
-
 
595
static void
570
static void cursor_print(viewport_t *vport)
596
cursor_print(viewport_t *vport)
571
{
597
{
572
    /* Do not check for cursor_shown */
598
    /* Do not check for cursor_shown */
573
    if (vport->cursor_active) {
599
    if (vport->cursor_active) {
574
        invert_char(vport, vport->cur_row, vport->cur_col);
600
        invert_char(vport, vport->cur_row, vport->cur_col);
575
        vport->cursor_shown = 1;
601
        vport->cursor_shown = 1;
576
    }
602
    }
577
}
603
}
578
 
604
 
579
/** Invert cursor, if it is enabled */
605
/** Invert cursor, if it is enabled */
-
 
606
static void
580
static void cursor_blink(viewport_t *vport)
607
cursor_blink(viewport_t *vport)
581
{
608
{
582
    if (vport->cursor_shown)
609
    if (vport->cursor_shown)
583
        cursor_hide(vport);
610
        cursor_hide(vport);
584
    else
611
    else
585
        cursor_print(vport);
612
        cursor_print(vport);
Line 591... Line 618...
591
 * @param c Character to print
618
 * @param c Character to print
592
 * @param row Screen position relative to viewport
619
 * @param row Screen position relative to viewport
593
 * @param col Screen position relative to viewport
620
 * @param col Screen position relative to viewport
594
 * @param transparent If false, print background color with character
621
 * @param transparent If false, print background color with character
595
 */
622
 */
-
 
623
static void
596
static void draw_char(viewport_t *vport, char c, unsigned int row, unsigned int
624
draw_char(viewport_t *vport, char c, unsigned int row, unsigned int col,
597
    col, style_t style, int transparent)
625
    style_t style, int transparent)
598
{
626
{
599
    /* Optimize - do not hide cursor if we are going to overwrite it */
627
    /* Optimize - do not hide cursor if we are going to overwrite it */
600
    if (vport->cursor_active && vport->cursor_shown &&
628
    if (vport->cursor_active && vport->cursor_shown &&
601
        (vport->cur_col != col || vport->cur_row != row))
629
        (vport->cur_col != col || vport->cur_row != row))
602
        invert_char(vport, vport->cur_row, vport->cur_col);
630
        invert_char(vport, vport->cur_row, vport->cur_col);
Line 620... Line 648...
620
/** Draw text data to viewport
648
/** Draw text data to viewport
621
 *
649
 *
622
 * @param vport Viewport id
650
 * @param vport Viewport id
623
 * @param data Text data fitting exactly into viewport
651
 * @param data Text data fitting exactly into viewport
624
 */
652
 */
-
 
653
static void
625
static void draw_text_data(viewport_t *vport, keyfield_t *data)
654
draw_text_data(viewport_t *vport, keyfield_t *data)
626
{
655
{
627
    int i;
656
    int i;
628
    int col,row;
657
    int col,row;
629
 
658
 
630
    clear_port(vport);
659
    clear_port(vport);
Line 639... Line 668...
639
            style_same(data[i].style,vport->style));
668
            style_same(data[i].style,vport->style));
640
    }
669
    }
641
    cursor_print(vport);
670
    cursor_print(vport);
642
}
671
}
643
 
672
 
644
 
-
 
645
/** Return first free pixmap */
673
/** Return first free pixmap */
-
 
674
static int
646
static int find_free_pixmap(void)
675
find_free_pixmap(void)
647
{
676
{
648
    int i;
677
    int i;
649
   
678
   
650
    for (i=0;i < MAX_PIXMAPS;i++)
679
    for (i = 0;i < MAX_PIXMAPS;i++)
651
        if (!pixmaps[i].data)
680
        if (!pixmaps[i].data)
652
            return i;
681
            return i;
653
    return -1;
682
    return -1;
654
}
683
}
655
 
684
 
-
 
685
static void
656
static void putpixel_pixmap(int pm, unsigned int x, unsigned int y, int color)
686
putpixel_pixmap(int pm, unsigned int x, unsigned int y, int color)
657
{
687
{
658
    pixmap_t *pmap = &pixmaps[pm];
688
    pixmap_t *pmap = &pixmaps[pm];
659
    int pos = (y * pmap->width + x) * screen.pixelbytes;
689
    int pos = (y * pmap->width + x) * screen.pixelbytes;
660
 
690
 
661
    (*screen.rgb2scr)(&pmap->data[pos],COLOR(color));
691
    (*screen.rgb2scr)(&pmap->data[pos],COLOR(color));
662
}
692
}
663
 
693
 
664
/** Create a new pixmap and return appropriate ID */
694
/** Create a new pixmap and return appropriate ID */
-
 
695
static int
665
static int shm2pixmap(unsigned char *shm, size_t size)
696
shm2pixmap(unsigned char *shm, size_t size)
666
{
697
{
667
    int pm;
698
    int pm;
668
    pixmap_t *pmap;
699
    pixmap_t *pmap;
669
 
700
 
670
    pm = find_free_pixmap();
701
    pm = find_free_pixmap();
Line 703... Line 734...
703
 * @return 0 if the call was not handled byt this function, 1 otherwise
734
 * @return 0 if the call was not handled byt this function, 1 otherwise
704
 *
735
 *
705
 * note: this function is not threads safe, you would have
736
 * note: this function is not threads safe, you would have
706
 * to redefine static variables with __thread
737
 * to redefine static variables with __thread
707
 */
738
 */
-
 
739
static int
708
static int shm_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
740
shm_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
709
{
741
{
710
    static keyfield_t *interbuffer = NULL;
742
    static keyfield_t *interbuffer = NULL;
711
    static size_t intersize = 0;
743
    static size_t intersize = 0;
712
 
744
 
713
    static unsigned char *shm = NULL;
745
    static unsigned char *shm = NULL;
Line 772... Line 804...
772
            retval = EINVAL;
804
            retval = EINVAL;
773
            break;
805
            break;
774
        }
806
        }
775
       
807
       
776
        ppm_draw(shm, shm_size, IPC_GET_ARG1(*call),
808
        ppm_draw(shm, shm_size, IPC_GET_ARG1(*call),
777
            IPC_GET_ARG2(*call), vport->width - x, vport->height -
809
            IPC_GET_ARG2(*call), vport->width - x,
778
            y, (putpixel_cb_t)putpixel, vport);
810
            vport->height - y, (putpixel_cb_t)putpixel, vport);
779
        break;
811
        break;
780
    case FB_DRAW_TEXT_DATA:
812
    case FB_DRAW_TEXT_DATA:
781
        if (!interbuffer) {
813
        if (!interbuffer) {
782
            retval = EINVAL;
814
            retval = EINVAL;
783
            break;
815
            break;
Line 796... Line 828...
796
    if (handled)
828
    if (handled)
797
        ipc_answer_fast(callid, retval, 0, 0);
829
        ipc_answer_fast(callid, retval, 0, 0);
798
    return handled;
830
    return handled;
799
}
831
}
800
 
832
 
-
 
833
static void
801
static void copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap)
834
copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap)
802
{
835
{
803
    int y;
836
    int y;
804
    int rowsize;
837
    int rowsize;
805
    int tmp;
838
    int tmp;
806
    int width = vport->width;
839
    int width = vport->width;
Line 812... Line 845...
812
        height = screen.yres - vport->y;
845
        height = screen.yres - vport->y;
813
 
846
 
814
    rowsize = width * screen.pixelbytes;
847
    rowsize = width * screen.pixelbytes;
815
 
848
 
816
    for (y = 0; y < height; y++) {
849
    for (y = 0; y < height; y++) {
817
        tmp = (vport->y + y) * screen.scanline + vport->x *
850
        tmp = (vport->y + y) * screen.scanline +
818
            screen.pixelbytes;
851
            vport->x * screen.pixelbytes;
819
        memcpy(pmap->data + rowsize * y, screen.fbaddress + tmp,
852
        memcpy(pmap->data + rowsize * y, screen.fbaddress + tmp,
820
            rowsize);
853
            rowsize);
821
    }
854
    }
822
}
855
}
823
 
856
 
824
/** Save viewport to pixmap */
857
/** Save viewport to pixmap */
-
 
858
static int
825
static int save_vp_to_pixmap(viewport_t *vport)
859
save_vp_to_pixmap(viewport_t *vport)
826
{
860
{
827
    int pm;
861
    int pm;
828
    pixmap_t *pmap;
862
    pixmap_t *pmap;
829
 
863
 
830
    pm = find_free_pixmap();
864
    pm = find_free_pixmap();
Line 872... Line 906...
872
 
906
 
873
    srcrowsize = vport->width * screen.pixelbytes;
907
    srcrowsize = vport->width * screen.pixelbytes;
874
    realrowsize = realwidth * screen.pixelbytes;
908
    realrowsize = realwidth * screen.pixelbytes;
875
 
909
 
876
    for (y=0; y < realheight; y++) {
910
    for (y = 0; y < realheight; y++) {
877
        tmp = (vport->y + y) * screen.scanline + vport->x *
911
        tmp = (vport->y + y) * screen.scanline +
878
            screen.pixelbytes;
912
            vport->x * screen.pixelbytes;
879
        memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize,
913
        memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize,
880
            realrowsize);
914
            realrowsize);
881
    }
915
    }
882
    return 0;
916
    return 0;
883
}
917
}
884
 
918
 
885
/** Tick animation one step forward */
919
/** Tick animation one step forward */
-
 
920
static void
886
static void anims_tick(void)
921
anims_tick(void)
887
{
922
{
888
    int i;
923
    int i;
889
    static int counts = 0;
924
    static int counts = 0;
890
   
925
   
891
    /* Limit redrawing */
926
    /* Limit redrawing */
Line 908... Line 943...
908
static int pointer_x, pointer_y;
943
static int pointer_x, pointer_y;
909
static int pointer_shown, pointer_enabled;
944
static int pointer_shown, pointer_enabled;
910
static int pointer_vport = -1;
945
static int pointer_vport = -1;
911
static int pointer_pixmap = -1;
946
static int pointer_pixmap = -1;
912
 
947
 
-
 
948
static void
913
static void mouse_show(void)
949
mouse_show(void)
914
{
950
{
915
    int i,j;
951
    int i, j;
916
    int visibility;
952
    int visibility;
917
    int color;
953
    int color;
918
    int bytepos;
954
    int bytepos;
Line 939... Line 975...
939
 
975
 
940
    /* Draw cursor */
976
    /* Draw cursor */
941
    for (i = 0; i < pointer_height; i++)
977
    for (i = 0; i < pointer_height; i++)
942
        for (j = 0; j < pointer_width; j++) {
978
        for (j = 0; j < pointer_width; j++) {
943
            bytepos = i * ((pointer_width - 1) / 8 + 1) + j / 8;
979
            bytepos = i * ((pointer_width - 1) / 8 + 1) + j / 8;
944
            visibility = pointer_mask_bits[bytepos] & (1 << (j %
980
            visibility = pointer_mask_bits[bytepos] &
945
                8));
981
                (1 << (j % 8));
946
            if (visibility) {
982
            if (visibility) {
947
                color = pointer_bits[bytepos] & (1 << (j % 8))
983
                color = pointer_bits[bytepos] & (1 << (j % 8))
948
                    ? 0 : 0xffffff;
984
                    ? 0 : 0xffffff;
949
                if (pointer_x + j < screen.xres && pointer_y +
985
                if (pointer_x + j < screen.xres && pointer_y +
950
                    i < screen.yres)
986
                    i < screen.yres)
Line 953... Line 989...
953
            }
989
            }
954
        }
990
        }
955
    pointer_shown = 1;
991
    pointer_shown = 1;
956
}
992
}
957
 
993
 
-
 
994
static void
958
static void mouse_hide(void)
995
mouse_hide(void)
959
{
996
{
960
    /* Restore image under the cursor */
997
    /* Restore image under the cursor */
961
    if (pointer_shown) {
998
    if (pointer_shown) {
962
        draw_pixmap(pointer_vport, pointer_pixmap);
999
        draw_pixmap(pointer_vport, pointer_pixmap);
963
        pointer_shown = 0;
1000
        pointer_shown = 0;
964
    }
1001
    }
965
}
1002
}
966
 
1003
 
-
 
1004
static void
967
static void mouse_move(unsigned int x, unsigned int y)
1005
mouse_move(unsigned int x, unsigned int y)
968
{
1006
{
969
    mouse_hide();
1007
    mouse_hide();
970
    pointer_x = x;
1008
    pointer_x = x;
971
    pointer_y = y;
1009
    pointer_y = y;
972
    mouse_show();
1010
    mouse_show();
973
}
1011
}
974
 
1012
 
-
 
1013
static int
975
static int anim_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
1014
anim_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
976
{
1015
{
977
    int handled = 1;
1016
    int handled = 1;
978
    int retval = 0;
1017
    int retval = 0;
979
    int i,nvp;
1018
    int i,nvp;
980
    int newval;
1019
    int newval;
Line 1067... Line 1106...
1067
        ipc_answer_fast(callid, retval, 0, 0);
1106
        ipc_answer_fast(callid, retval, 0, 0);
1068
    return handled;
1107
    return handled;
1069
}
1108
}
1070
 
1109
 
1071
/** Handler for messages concerning pixmap handling */
1110
/** Handler for messages concerning pixmap handling */
-
 
1111
static int
1072
static int pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
1112
pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
1073
{
1113
{
1074
    int handled = 1;
1114
    int handled = 1;
1075
    int retval = 0;
1115
    int retval = 0;
1076
    int i,nvp;
1116
    int i,nvp;
1077
 
1117
 
Line 1120... Line 1160...
1120
}
1160
}
1121
 
1161
 
1122
/** Function for handling connections to FB
1162
/** Function for handling connections to FB
1123
 *
1163
 *
1124
 */
1164
 */
-
 
1165
static void
1125
static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall)
1166
fb_client_connection(ipc_callid_t iid, ipc_call_t *icall)
1126
{
1167
{
1127
    ipc_callid_t callid;
1168
    ipc_callid_t callid;
1128
    ipc_call_t call;
1169
    ipc_call_t call;
1129
    int retval;
1170
    int retval;
1130
    int i;
1171
    int i;
Line 1262... Line 1303...
1262
            cursor_print(vport);
1303
            cursor_print(vport);
1263
            retval = 0;
1304
            retval = 0;
1264
            break;
1305
            break;
1265
        case FB_VIEWPORT_CREATE:
1306
        case FB_VIEWPORT_CREATE:
1266
            retval = viewport_create(IPC_GET_ARG1(call) >> 16,
1307
            retval = viewport_create(IPC_GET_ARG1(call) >> 16,
1267
                IPC_GET_ARG1(call) & 0xffff, IPC_GET_ARG2(call)
1308
                IPC_GET_ARG1(call) & 0xffff,
-
 
1309
                IPC_GET_ARG2(call) >> 16,
1268
                 >> 16, IPC_GET_ARG2(call) & 0xffff);
1310
                IPC_GET_ARG2(call) & 0xffff);
1269
            break;
1311
            break;
1270
        case FB_VIEWPORT_DELETE:
1312
        case FB_VIEWPORT_DELETE:
1271
            i = IPC_GET_ARG1(call);
1313
            i = IPC_GET_ARG1(call);
1272
            if (i < 0 || i >= MAX_VIEWPORTS) {
1314
            if (i < 0 || i >= MAX_VIEWPORTS) {
1273
                retval = EINVAL;
1315
                retval = EINVAL;
Line 1303... Line 1345...
1303
        ipc_answer_fast(callid,retval,0,0);
1345
        ipc_answer_fast(callid,retval, 0, 0);
1304
    }
1346
    }
1305
}
1347
}
1306
 
1348
 
1307
/** Initialization of framebuffer */
1349
/** Initialization of framebuffer */
-
 
1350
int
1308
int fb_init(void)
1351
fb_init(void)
1309
{
1352
{
1310
    void *fb_ph_addr;
1353
    void *fb_ph_addr;
1311
    unsigned int fb_width;
1354
    unsigned int fb_width;
1312
    unsigned int fb_height;
1355
    unsigned int fb_height;
1313
    unsigned int fb_scanline;
1356
    unsigned int fb_scanline;