Exemplo n.º 1
0
void fb_hResetCharCells(FB_GFXCTX *context, int do_alloc)
{
    int i;

    if( __fb_gfx!=NULL ) {
        /* Free the previously allocated character cells */
        if( __fb_gfx->con_pages!=NULL ) {
            for (i = 0; i < __fb_gfx->num_pages; i++) {
                free(__fb_gfx->con_pages[i]);
            }
            free(__fb_gfx->con_pages);
        }

        if( do_alloc ) {
            size_t text_size = __fb_gfx->text_w * __fb_gfx->text_h;

            /* Allocate memory for all character cells */
            __fb_gfx->con_pages = (GFX_CHAR_CELL **)malloc(sizeof(GFX_CHAR_CELL *) * __fb_gfx->num_pages);
            for (i = 0; i < __fb_gfx->num_pages; i++) {
                __fb_gfx->con_pages[i] =
                    (GFX_CHAR_CELL *)calloc(1, sizeof(GFX_CHAR_CELL) * text_size);
            }

            /* Reset all character cells with default values */
            fb_hClearCharCells( 0, 0,
                                __fb_gfx->text_w, __fb_gfx->text_h,
                                context->work_page,
                                32,
                                context->fg_color, context->bg_color );
        } else {
            __fb_gfx->con_pages = NULL;
        }
    }
}
Exemplo n.º 2
0
static void fb_hHookConScroll
	(
		fb_ConHooks *handle,
		int x1, int y1,
		int x2, int y2,
		int rows
	)
{
    int w = x2 - x1 + 1;
    int h = y2 - y1 + 1;
    int clear_start, clear_end;
    fb_PrintInfo *pInfo = (fb_PrintInfo*) handle->Opaque;
    int font_w = __fb_gfx->font->w;
    int font_h = __fb_gfx->font->h;
    fb_hHookConScrollGfx( pInfo->context, x1 * font_w, y1 * font_h,
                          (x2 + 1) * font_w, (y2 + 1) * font_h,
                          rows * font_h,
                          &pInfo->dirty_start, &pInfo->dirty_end );

    /* Don't foget to update the character cells */
    clear_end = y2 + 1;
    if( rows >= h ) {
        clear_start = y1;
    } else {
        int y_src = y1 + rows;
        int y_dst = y1;
        size_t con_width = __fb_gfx->text_w;
        GFX_CHAR_CELL *src = __fb_gfx->con_pages[ pInfo->context->work_page ] + y_src * con_width;
        GFX_CHAR_CELL *dst = __fb_gfx->con_pages[ pInfo->context->work_page ] + y_dst * con_width;
        size_t cell_line_width = w * sizeof( GFX_CHAR_CELL );

        h -= rows;
        clear_start = y1 + h;

        while( h-- ) {
            memcpy( dst, src, cell_line_width );
            dst += con_width;
            src += con_width;
        }
    }
    fb_hClearCharCells( x1, clear_start, x2+1, clear_end,
                        pInfo->context->work_page, 32,
                        pInfo->context->fg_color, pInfo->context->bg_color );
    handle->Coord.Y = handle->Border.Bottom;
}