Subversion Repositories HelenOS

Rev

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

Rev 3726 Rev 3739
Line 137... Line 137...
137
static pixmap_t pixmaps[MAX_PIXMAPS];
137
static pixmap_t pixmaps[MAX_PIXMAPS];
138
static viewport_t viewports[128];
138
static viewport_t viewports[128];
139
 
139
 
140
static bool client_connected = false;  /**< Allow only 1 connection */
140
static bool client_connected = false;  /**< Allow only 1 connection */
141
 
141
 
-
 
142
static void draw_glyph(unsigned int x, unsigned int y, bool cursor,
-
 
143
    uint8_t *glyphs, uint8_t glyph);
142
static void draw_glyph(viewport_t *vport, bool cursor, unsigned int col,
144
static void draw_vp_glyph(viewport_t *vport, bool cursor, unsigned int col,
143
    unsigned int row);
145
    unsigned int row);
144
 
146
 
145
 
147
 
146
#define RED(x, bits)                 ((x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1))
148
#define RED(x, bits)                 ((x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1))
147
#define GREEN(x, bits)               ((x >> (8 + 8 - bits)) & ((1 << bits) - 1))
149
#define GREEN(x, bits)               ((x >> (8 + 8 - bits)) & ((1 << bits) - 1))
Line 267... Line 269...
267
{
269
{
268
    unsigned int row, col;
270
    unsigned int row, col;
269
 
271
 
270
    for (row = 0; row < vport->rows; row++) {
272
    for (row = 0; row < vport->rows; row++) {
271
        for (col = 0; col < vport->cols; col++) {
273
        for (col = 0; col < vport->cols; col++) {
272
            draw_glyph(vport, false, col, row);
274
            draw_vp_glyph(vport, false, col, row);
273
        }
275
        }
274
    }
276
    }
275
 
277
 
276
    if (COL2X(vport->cols) < vport->width) {
278
    if (COL2X(vport->cols) < vport->width) {
277
        draw_filled_rect(
279
        draw_filled_rect(
Line 307... Line 309...
307
 *
309
 *
308
 */
310
 */
309
static void vport_scroll(viewport_t *vport, int lines)
311
static void vport_scroll(viewport_t *vport, int lines)
310
{
312
{
311
    unsigned int row, col;
313
    unsigned int row, col;
-
 
314
    unsigned int x, y;
-
 
315
    uint8_t glyph;
-
 
316
 
-
 
317
    /*
-
 
318
     * Redraw.
-
 
319
     */
-
 
320
 
-
 
321
    y = vport->y;
-
 
322
    for (row = 0; row < vport->rows; row++) {
-
 
323
        x = vport->x;
-
 
324
        for (col = 0; col < vport->cols; col++) {
-
 
325
            if ((row + lines >= 0) && (row + lines < vport->rows)) {
-
 
326
                glyph = vport->backbuf[BB_POS(vport, col, row + lines)];
-
 
327
 
-
 
328
                if (vport->backbuf[BB_POS(vport, col, row)] == glyph) {
-
 
329
                    x += FONT_WIDTH;
-
 
330
                    continue;
-
 
331
                }
-
 
332
            } else {
-
 
333
                glyph = 0;
-
 
334
            }
-
 
335
 
-
 
336
            draw_glyph(x, y, false, vport->glyphs, glyph);
-
 
337
            x += FONT_WIDTH;
-
 
338
        }
-
 
339
        y += FONT_SCANLINES;
-
 
340
    }
312
 
341
 
313
    /*
342
    /*
314
     * Scroll backbuffer.
343
     * Scroll backbuffer.
315
     */
344
     */
316
 
345
 
317
    if (lines > 0) {
346
    if (lines > 0) {
318
        memcpy(vport->backbuf, vport->backbuf + vport->cols * lines,
347
        memmove(vport->backbuf, vport->backbuf + vport->cols * lines,
319
            vport->cols * (vport->rows - lines));
348
            vport->cols * (vport->rows - lines));
320
        memset(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)],
349
        memset(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)],
321
            0, vport->cols * lines);
350
            0, vport->cols * lines);
322
    } else {
351
    } else {
323
        memcpy(vport->backbuf - vport->cols * lines, vport->backbuf,
352
        memmove(vport->backbuf - vport->cols * lines, vport->backbuf,
324
            vport->cols * (vport->rows + lines));
353
            vport->cols * (vport->rows + lines));
325
        memset(vport->backbuf, 0, - vport->cols * lines);
354
        memset(vport->backbuf, 0, - vport->cols * lines);
326
    }
355
    }
327
 
-
 
328
    /*
-
 
329
     * Redraw.
-
 
330
     */
-
 
331
 
-
 
332
    for (row = 0; row < vport->rows; row++) {
-
 
333
        for (col = 0; col < vport->cols; col++) {
-
 
334
            draw_glyph(vport, false, col, row);
-
 
335
        }
-
 
336
    }
-
 
337
}
356
}
338
 
357
 
339
/** Render glyphs
358
/** Render glyphs
340
 *
359
 *
341
 * Convert glyphs from device independent font
360
 * Convert glyphs from device independent font
Line 513... Line 532...
513
   
532
   
514
    return true;
533
    return true;
515
}
534
}
516
 
535
 
517
 
536
 
-
 
537
/** Draw a glyph.
-
 
538
 *
-
 
539
 * @param x  x coordinate of top-left corner on screen.
-
 
540
 * @param y  y coordinate of top-left corner on screen.
-
 
541
 * @param cursor Draw glyph with cursor
-
 
542
 * @param glyphs Pointer to font bitmap.
-
 
543
 * @param glyph  Code of the glyph to draw.
-
 
544
 *
-
 
545
 */
-
 
546
static void draw_glyph(unsigned int x, unsigned int y, bool cursor,
-
 
547
    uint8_t *glyphs, uint8_t glyph)
-
 
548
{
-
 
549
    unsigned int yd;
-
 
550
   
-
 
551
    for (yd = 0; yd < FONT_SCANLINES; yd++)
-
 
552
        memcpy(&screen.fb_addr[FB_POS(x, y + yd)],
-
 
553
            &glyphs[GLYPH_POS(glyph, yd, cursor)], screen.glyphscanline);
-
 
554
}
-
 
555
 
518
/** Draw glyph at given position relative to viewport
556
/** Draw glyph at specified position in viewport.
519
 *
557
 *
520
 * @param vport  Viewport identification
558
 * @param vport  Viewport identification
521
 * @param cursor Draw glyph with cursor
559
 * @param cursor Draw glyph with cursor
522
 * @param col    Screen position relative to viewport
560
 * @param col    Screen position relative to viewport
523
 * @param row    Screen position relative to viewport
561
 * @param row    Screen position relative to viewport
524
 *
562
 *
525
 */
563
 */
526
static void draw_glyph(viewport_t *vport, bool cursor, unsigned int col, unsigned int row)
564
static void draw_vp_glyph(viewport_t *vport, bool cursor, unsigned int col,
-
 
565
    unsigned int row)
527
{
566
{
528
    unsigned int x = vport->x + COL2X(col);
567
    unsigned int x = vport->x + COL2X(col);
529
    unsigned int y = vport->y + ROW2Y(row);
568
    unsigned int y = vport->y + ROW2Y(row);
530
    unsigned int yd;
569
    uint8_t glyph;
531
   
-
 
532
    uint8_t glyph = vport->backbuf[BB_POS(vport, col, row)];
-
 
533
   
570
   
534
    for (yd = 0; yd < FONT_SCANLINES; yd++)
-
 
535
        memcpy(&screen.fb_addr[FB_POS(x, y + yd)],
571
    glyph = vport->backbuf[BB_POS(vport, col, row)];
536
            &vport->glyphs[GLYPH_POS(glyph, yd, cursor)], screen.glyphscanline);
572
    draw_glyph(x, y, cursor, vport->glyphs, glyph);
537
}
573
}
538
 
574
 
539
 
575
 
540
/** Hide cursor if it is shown
576
/** Hide cursor if it is shown
541
 *
577
 *
542
 */
578
 */
543
static void cursor_hide(viewport_t *vport)
579
static void cursor_hide(viewport_t *vport)
544
{
580
{
545
    if ((vport->cursor_active) && (vport->cursor_shown)) {
581
    if ((vport->cursor_active) && (vport->cursor_shown)) {
546
        draw_glyph(vport, false, vport->cur_col, vport->cur_row);
582
        draw_vp_glyph(vport, false, vport->cur_col, vport->cur_row);
547
        vport->cursor_shown = false;
583
        vport->cursor_shown = false;
548
    }
584
    }
549
}
585
}
550
 
586
 
551
 
587
 
Line 554... Line 590...
554
 */
590
 */
555
static void cursor_show(viewport_t *vport)
591
static void cursor_show(viewport_t *vport)
556
{
592
{
557
    /* Do not check for cursor_shown */
593
    /* Do not check for cursor_shown */
558
    if (vport->cursor_active) {
594
    if (vport->cursor_active) {
559
        draw_glyph(vport, true, vport->cur_col, vport->cur_row);
595
        draw_vp_glyph(vport, true, vport->cur_col, vport->cur_row);
560
        vport->cursor_shown = true;
596
        vport->cursor_shown = true;
561
    }
597
    }
562
}
598
}
563
 
599
 
564
 
600
 
Line 588... Line 624...
588
    if ((vport->cursor_active) && (vport->cursor_shown) &&
624
    if ((vport->cursor_active) && (vport->cursor_shown) &&
589
        ((vport->cur_col != col) || (vport->cur_row != row)))
625
        ((vport->cur_col != col) || (vport->cur_row != row)))
590
        cursor_hide(vport);
626
        cursor_hide(vport);
591
   
627
   
592
    vport->backbuf[BB_POS(vport, col, row)] = c;
628
    vport->backbuf[BB_POS(vport, col, row)] = c;
593
    draw_glyph(vport, false, col, row);
629
    draw_vp_glyph(vport, false, col, row);
594
   
630
   
595
    vport->cur_col = col;
631
    vport->cur_col = col;
596
    vport->cur_row = row;
632
    vport->cur_row = row;
597
   
633
   
598
    vport->cur_col++;
634
    vport->cur_col++;
Line 625... Line 661...
625
       
661
       
626
        // TODO: use data[i].style
662
        // TODO: use data[i].style
627
       
663
       
628
        if (glyph != data[i].character) {
664
        if (glyph != data[i].character) {
629
            vport->backbuf[BB_POS(vport, col, row)] = data[i].character;
665
            vport->backbuf[BB_POS(vport, col, row)] = data[i].character;
630
            draw_glyph(vport, false, col, row);
666
            draw_vp_glyph(vport, false, col, row);
631
        }
667
        }
632
    }
668
    }
633
    cursor_show(vport);
669
    cursor_show(vport);
634
}
670
}
635
 
671