int GGI_lin16_putbox(struct ggi_visual *vis, int x, int y, int w, int h, const void *buffer) { const uint16_t *src = buffer; uint8_t *dest; int srcwidth = w; int destwidth = LIBGGI_FB_W_STRIDE(vis); LIBGGICLIP_PUTBOX(vis,x,y,w,h,src,srcwidth, *1); PREPARE_FB(vis); dest = (uint8_t *)LIBGGI_CURWRITE(vis) + (y*destwidth + x*2); /* Width should be in bytes */ w *= 2; /* Optimized full-width case */ if (w == destwidth && x == 0) { memcpy(dest, src, (size_t)(w*h)); return 0; } while (h > 0) { memcpy(dest, src, (size_t)(w)); dest += destwidth; src += srcwidth; h--; } return 0; }
static inline void do_drawhline(ggi_visual *vis, int x, int y, int w) { int i, w32; uint32_t *fb32; uint16_t *fb16; uint32_t val = LIBGGI_GC_FGCOLOR(vis) | (LIBGGI_GC_FGCOLOR(vis) << 16); PREPARE_FB(vis); fb16 = (uint16_t*)((uint8_t*)LIBGGI_CURWRITE(vis) + y*LIBGGI_FB_W_STRIDE(vis) + x*2); if (x%2) { *(fb16++) = val; w--; } w32 = w/2; fb32 = (uint32_t*) fb16; for (i = 0; i < w32; i++) { *(fb32++) = val; } if (w%2) { fb16 = (uint16_t *) fb32; *fb16 = val; } }
static inline void do_drawhline(struct ggi_visual *vis, int x, int y, int w) { uint8_t *fb; uint8_t fg; fb = (uint8_t *) LIBGGI_CURWRITE(vis)+y*LIBGGI_FB_W_STRIDE(vis)+(x/2); fg = (uint8_t) LIBGGI_GC_FGCOLOR(vis) | (LIBGGI_GC_FGCOLOR(vis)<<4); PREPARE_FB(vis); /* x is odd. Read-modify-write right pixel. */ if (x & 0x01) { *fb = (*fb & 0x0f) | (fg & 0xf0); fb++; w--; } memset(fb, fg, (size_t)(w/2)); /* Dangling right pixel. */ if (w & 0x01) { fb += w/2; *fb = (*fb & 0xf0) | (fg & 0x0f); } }
int GGI_lin8_copybox(ggi_visual *vis, int x, int y, int w, int h, int nx, int ny) { uint8_t *src, *dest; int stride = LIBGGI_FB_W_STRIDE(vis); int line; LIBGGICLIP_COPYBOX(vis, x, y, w, h, nx, ny); PREPARE_FB(vis); if (ny < y) { src = (uint8_t *)LIBGGI_CURREAD(vis) + y*stride + x; dest = (uint8_t *)LIBGGI_CURWRITE(vis) + ny*stride + nx; for (line=0; line < h; line++, src += stride, dest += stride) { memmove(dest, src, (size_t)(w)); } } else { src = (uint8_t *)LIBGGI_CURREAD(vis) + (y+h-1)*stride + x; dest = (uint8_t *)LIBGGI_CURWRITE(vis) + (ny+h-1)*stride + nx; for (line=0; line < h; line++, src -= stride, dest -= stride) { memmove(dest, src, (size_t)(w)); } } return 0; }
int GGI_t32_getpixela(ggi_visual *vis, int x, int y, ggi_pixel *pixel) { PREPARE_FB(vis); *pixel = *PIXEL_RADDR(vis, x, y); return 0; }
int GGI_t32_drawpixel_nca(ggi_visual *vis, int x, int y) { PREPARE_FB(vis); *PIXEL_WADDR(vis, x, y) = LIBGGI_GC_FGCOLOR(vis); return 0; }
int GGI_t32_putpixel_nca(ggi_visual *vis, int x, int y, ggi_pixel col) { PREPARE_FB(vis); *PIXEL_WADDR(vis, x, y) = col; return 0; }
int GGI_t16_getpixel_nca(struct ggi_visual *vis, int x, int y, ggi_pixel *pixel) { PREPARE_FB(vis); *pixel = *PIXEL_RADDR(vis, x, y); return 0; }
int GGI_t16_drawpixela(struct ggi_visual *vis, int x, int y) { CHECKXY(vis, x, y); PREPARE_FB(vis); *PIXEL_WADDR(vis, x, y) = LIBGGI_GC_FGCOLOR(vis); return 0; }
int GGI_t16_putpixela(struct ggi_visual *vis, int x, int y, ggi_pixel col) { CHECKXY(vis, x, y); PREPARE_FB(vis); *PIXEL_WADDR(vis, x, y) = col; return 0; }
int GGI_lin32_getpixel_nca(struct ggi_visual *vis,int x,int y,ggi_pixel *pixel) { PREPARE_FB(vis); *pixel = *((uint32_t *) ((uint8_t *)LIBGGI_CURREAD(vis) + y*LIBGGI_FB_R_STRIDE(vis)+x*sizeof(uint32_t))); return 0; }
int GGI_lin32_putpixel_nca(struct ggi_visual *vis,int x,int y,ggi_pixel col) { PREPARE_FB(vis); *((uint32_t *) ((uint8_t *)LIBGGI_CURWRITE(vis) + y*LIBGGI_FB_W_STRIDE(vis)+x*sizeof(uint32_t))) = col; return 0; }
int GGI_lin32_drawpixel_nca(struct ggi_visual *vis,int x,int y) { PREPARE_FB(vis); *((uint32_t *) ((uint8_t *)LIBGGI_CURWRITE(vis) + y*LIBGGI_FB_W_STRIDE(vis)+x*sizeof(uint32_t))) = LIBGGI_GC_FGCOLOR(vis); return 0; }
int GGI_lin16_gethline(ggi_visual *vis, int x, int y, int w, void *buffer) { uint8_t *mem; PREPARE_FB(vis); mem = (uint8_t *)LIBGGI_CURREAD(vis) + y*LIBGGI_FB_R_STRIDE(vis) + x*2; memcpy(buffer, mem, (size_t)(w*2)); return 0; }
int GGI_lin8_crossblit(ggi_visual *src, int sx, int sy, int w, int h, ggi_visual *dst, int dx, int dy) { LIBGGICLIP_COPYBOX(dst,sx,sy,w,h,dx,dy); PREPARE_FB(dst); /* Check if the src-read and dst-write buffers are in the same layout and that the destination pixelformat is sane. */ if (src->r_frame && src->r_frame->layout == dst->w_frame->layout && dst->w_frame->buffer.plb.pixelformat->stdformat != 0) { uint32_t srcformat = src->r_frame->buffer.plb.pixelformat->stdformat; uint32_t dstformat = dst->w_frame->buffer.plb.pixelformat->stdformat; int pixels = w*h; PREPARE_FB(src); /* These are the accelerated cases. If neither suits then * fall back to the default. */ if (srcformat == dstformat && pixels > 512) { if ((dst->palette->clut.size == src->palette->clut.size) && !memcmp(dst->palette->clut.data, src->palette->clut.data, sizeof(ggi_color)*dst->palette->clut.size)) { crossblit_same(src, sx, sy, w, h, dst, dx, dy); } else { crossblit_8_to_8(src, sx, sy, w, h, dst, dx, dy); } return 0; } } fallback(src, sx, sy, w, h, dst, dx, dy); return 0; }
int GGI_lin16_puthline(ggi_visual *vis, int x, int y, int w, const void *buffer) { const uint16_t *buf16 = buffer; uint8_t *mem; LIBGGICLIP_XYW_BUFMOD(vis, x, y, w, buf16, *1); PREPARE_FB(vis); mem = (uint8_t *)LIBGGI_CURWRITE(vis) + y*LIBGGI_FB_W_STRIDE(vis) + x*2; memcpy(mem, buf16, (size_t)(w*2)); return 0; }
int GGI_ilbm_getpixela(ggi_visual *vis, int x, int y, ggi_pixel *pixel) { ggi_pixel col = 0; uint16_t *dest; uint16_t shift = 15 - (x & 15); int plane_add = LIBGGI_R_PLAN(vis).next_plane / 2; int i, depth = GT_DEPTH(LIBGGI_GT(vis)); PREPARE_FB(vis); dest = PIXEL_RADDR(vis, x, y); for (i=0; i < depth; i++) { col |= ((*dest >> shift) & 1) << i; dest += plane_add; } *pixel = col; return 0; }
int GGI_m2164w_crossblit(ggi_visual *src, int sx, int sy, int w, int h, ggi_visual *dst, int dx, int dy) { /* Software clip so we don't read/write unused data. */ LIBGGICLIP_COPYBOX(dst, sx, sy, w, h, dx, dy); if (src->r_frame && src->r_frame->layout == dst->w_frame->layout) { uint32_t srcformat = src->r_frame->buffer.plb.pixelformat->stdformat; PREPARE_FB(src); switch (srcformat) { case GGI_DB_STD_24a32p8r8g8b8: case GGI_DB_STD_24a32p8b8g8r8: dbblit_32bpp(src, sx, sy, w, h, dst, dx, dy, srcformat); return 0; } } return M2164W_PRIV(dst)->crossblit(src, sx, sy, w, h, dst, dx, dy); }
int GGI_lin16_drawbox(struct ggi_visual *vis, int x, int y, int origw, int h) { uint32_t *buf32; uint16_t *buf16; uint32_t val; int linediff, oddx; LIBGGICLIP_XYWH(vis, x, y, origw, h); PREPARE_FB(vis); val = LIBGGI_GC_FGCOLOR(vis) | (LIBGGI_GC_FGCOLOR(vis) << 16); buf16 = (uint16_t*)((uint8_t*)LIBGGI_CURWRITE(vis) + y*LIBGGI_FB_W_STRIDE(vis) + x*2); linediff = LIBGGI_FB_W_STRIDE(vis) - origw*2; if (x%2) oddx = 1; else oddx = 0; while (h--) { int w = origw; if (oddx) { *(buf16++) = val; w--; } buf32 = (uint32_t*) buf16; while (w > 1) { *(buf32++) = val; w -= 2; } buf16 = (uint16_t*) buf32; if (w) { *(buf16++) = val; } buf16 = (uint16_t*) ((uint8_t*)buf16 + linediff); } return 0; }
int GGI_ilbm_putpixel_nca(ggi_visual *vis, int x, int y, ggi_pixel col) { uint16_t *dest; uint16_t mask = 0x8000 >> (x & 15); int plane_add = LIBGGI_W_PLAN(vis).next_plane / 2; int i; PREPARE_FB(vis); dest = PIXEL_WADDR(vis, x, y); for (i=GT_DEPTH(LIBGGI_GT(vis)); i > 0; i--) { if (col & 1) { *dest |= mask; } else { *dest &= ~mask; } col >>= 1; dest += plane_add; } return 0; }
int GGI_lin8_putc(struct ggi_visual *vis, int x, int y, char c) { #define char_width 8 #define char_height 8 int offset, x_run, y_run; uint8_t *bitmap; bitmap = (uint8_t *)(font) + ( c * char_height ); x_run = char_width; y_run = char_height; offset = 0; { int delta; delta = LIBGGI_GC(vis)->cliptl.x - x; if ( delta > 0 ) { if ( delta >= x_run ) { return 0; } else { x_run -= delta; offset += delta; x += delta; } } delta = ( x + x_run ) - LIBGGI_GC(vis)->clipbr.x; if ( delta > 0 ) { if ( delta >= x_run ) { return 0; } else { x_run -= delta; } } delta = LIBGGI_GC(vis)->cliptl.y - y; if ( delta > 0 ) { if ( delta >= y_run ) { return 0; } else { y_run -= delta; bitmap += delta; y += delta; } } delta = ( y + y_run ) - LIBGGI_GC(vis)->clipbr.y; if ( delta > 0 ) { if ( delta >= y_run ) { return 0; } else { y_run -= delta; } } } { int y_iter; register uint8_t *fb; int add_stride; PREPARE_FB(vis); add_stride = LIBGGI_FB_W_STRIDE(vis); fb = (uint8_t *)LIBGGI_CURWRITE(vis) + ( y * add_stride ) + x; add_stride -= x_run; y_run += y; x_run += x; for ( y_iter = y ; y_iter < y_run ; y_iter++, bitmap++, fb += add_stride ) { register int x_iter; register uint8_t row; row = *bitmap << offset; for ( x_iter = x ; x_iter < x_run ; x_iter++, row <<= 1, fb++ ) { *fb = ( row & 128 ) ? (uint8_t)LIBGGI_GC_FGCOLOR(vis) : (uint8_t)LIBGGI_GC_BGCOLOR(vis); } } } return 0; #undef char_width #undef char_height }