Subversion Repositories HelenOS

Rev

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

Rev 2479 Rev 2619
Line 354... Line 354...
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);
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
Line 395... Line 393...
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 662... Line 657...
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 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;
Line 823... Line 818...
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 981... Line 976...
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
            }
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:
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 1278... Line 1273...
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
            }
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