static void draw_line(struct pseudobuffer *pb, struct terminal *term, int line) { int pos, bdf_padding, glyph_width, margin_right; int col, w, h; uint32_t pixel; struct color_pair_t color_pair; struct cell_t *cellp; for (col = term->cols - 1; col >= 0; col--) { margin_right = (term->cols - 1 - col) * CELL_WIDTH; /* target cell */ cellp = &term->cells[col + line * term->cols]; /* draw sixel bitmap */ if (cellp->has_bitmap) { draw_sixel(pb, line, col, cellp->bitmap); continue; } /* copy current color_pair (maybe changed) */ color_pair = cellp->color_pair; /* check wide character or not */ glyph_width = (cellp->width == HALF) ? CELL_WIDTH: CELL_WIDTH * 2; bdf_padding = my_ceil(glyph_width, BITS_PER_BYTE) * BITS_PER_BYTE - glyph_width; if (cellp->width == WIDE) bdf_padding += CELL_WIDTH; /* check cursor positon */ if ((term->mode & MODE_CURSOR && line == term->cursor.y) && (col == term->cursor.x || (cellp->width == WIDE && (col + 1) == term->cursor.x) || (cellp->width == NEXT_TO_WIDE && (col - 1) == term->cursor.x))) { color_pair.fg = term->default_bg; color_pair.bg = term->cursor_color; } for (h = 0; h < CELL_HEIGHT; h++) { /* if UNDERLINE attribute on, swap bg/fg */ if ((h == (CELL_HEIGHT - 1)) && (cellp->attribute & attr_mask[ATTR_UNDERLINE])) color_pair.bg = color_pair.fg; for (w = 0; w < CELL_WIDTH; w++) { pos = (term->width - 1 - margin_right - w) * pb->bytes_per_pixel + (line * CELL_HEIGHT + h) * pb->line_length; /* set color palette */ if (cellp->glyphp->bitmap[h] & (0x01 << (bdf_padding + w))) pixel = color_list[color_pair.fg]; else pixel = color_list[color_pair.bg]; /* update copy buffer only */ memcpy(pb->buf + pos, &pixel, pb->bytes_per_pixel); } } } term->line_dirty[line] = ((term->mode & MODE_CURSOR) && term->cursor.y == line) ? true: false; }
int mumps_compute_nb_concerned_files(long long block_size, int * nb_concerned_files,long long vaddr){ int file,pos,available_size; long long vaddr_loc; vaddr_loc=vaddr*(long long)mumps_elementary_data_size; mumps_gen_file_info(vaddr_loc,&pos,&file); available_size=mumps_io_max_file_size-pos+1; *nb_concerned_files=(int)my_ceil((double)(my_max(0,((block_size)*(double)(mumps_elementary_data_size))-available_size))/(double)mumps_io_max_file_size)+1; return 0; }
void fb_init(struct framebuffer *fb) { char *path; struct fb_fix_screeninfo finfo; struct fb_var_screeninfo vinfo; if ((path = getenv("FRAMEBUFFER")) != NULL) fb->fd = eopen(path, O_RDWR); else fb->fd = eopen(fb_path, O_RDWR); if (ioctl(fb->fd, FBIOGET_FSCREENINFO, &finfo) < 0) fatal("ioctl: FBIOGET_FSCREENINFO failed"); if (ioctl(fb->fd, FBIOGET_VSCREENINFO, &vinfo) < 0) fatal("ioctl: FBIOGET_VSCREENINFO failed"); /* check screen offset and initialize because linux console change this */ /* if (vinfo.xoffset != 0 || vinfo.yoffset != 0) { vinfo.xoffset = vinfo.yoffset = 0; ioctl(fb->fd, FBIOPUT_VSCREENINFO, &vinfo); } */ fb->width = vinfo.xres; fb->height = vinfo.yres; fb->screen_size = finfo.smem_len; fb->line_length = finfo.line_length; if ((finfo.visual == FB_VISUAL_TRUECOLOR || finfo.visual == FB_VISUAL_DIRECTCOLOR) && (vinfo.bits_per_pixel == 15 || vinfo.bits_per_pixel == 16 || vinfo.bits_per_pixel == 24 || vinfo.bits_per_pixel == 32)) { fb->cmap = fb->cmap_org = NULL; fb->bpp = my_ceil(vinfo.bits_per_pixel, BITS_PER_BYTE); } else if (finfo.visual == FB_VISUAL_PSEUDOCOLOR && vinfo.bits_per_pixel == 8) { cmap_create(&fb->cmap_org); if (ioctl(fb->fd, FBIOGETCMAP, fb->cmap_org) < 0) fatal("ioctl: FBIOGETCMAP failed"); fb->cmap = NULL; fb->bpp = 1; } else /* non packed pixel, mono color, grayscale: not implimented */ fatal("unsupported framebuffer type"); fb->fp = (unsigned char *) emmap(0, fb->screen_size, PROT_WRITE | PROT_READ, MAP_SHARED, fb->fd, 0); fb->buf = (unsigned char *) ecalloc(1, fb->screen_size); fb->vinfo = vinfo; }