static void fb_hHookConScrollGfx (FB_GFXCTX *context, int x1, int y1, int x2, int y2, int lines, int *dirty_start, int *dirty_end ) { int h = y2 - y1; int w = x2 - x1; int clear_row, clear_start = 0, clear_end = 0; if( lines==0 ) return; clear_end = y2; if( lines >= h || lines < 0 ) { clear_start = y1; } else { int y_src = y1 + lines; int y_dst = y1; h -= lines; clear_start = y1 + h; while( h-- ) fb_hPixelCpy(context->line[y_dst++], context->line[y_src++], w); } for( clear_row=clear_start; clear_row!=clear_end; ++clear_row ) context->pixel_set(context->line[clear_row], context->bg_color, w); fb_hSetDirty( dirty_start, dirty_end, y1, y2 ); }
/*:::::*/ FBCALL void fb_GfxPaint(void *target, float fx, float fy, unsigned int color, unsigned int border_color, FBSTRING *pattern, int mode, int flags) { FB_GFXCTX *context = fb_hGetContext(); int size, x, y; unsigned char data[256], *dest, *src; SPAN **span, *s, *tail, *head; if (!__fb_gfx) return; fb_hPrepareTarget(context, target); if (flags & DEFAULT_COLOR_1) color = context->fg_color; else color = fb_hFixColor(context->target_bpp, color); if (flags & DEFAULT_COLOR_2) border_color = color; else border_color = fb_hFixColor(context->target_bpp, border_color); fb_hSetPixelTransfer(context,color); fb_hFixRelative(context, flags, &fx, &fy, NULL, NULL); fb_hTranslateCoord(context, fx, fy, &x, &y); fb_hMemSet(data, 0, sizeof(data)); if ((mode == PAINT_TYPE_PATTERN) && (pattern)) { fb_hMemCpy(data, pattern->data, MIN(256, FB_STRSIZE(pattern))); } if (pattern) { /* del if temp */ fb_hStrDelTemp( pattern ); } if ((x < context->view_x) || (x >= context->view_x + context->view_w) || (y < context->view_y) || (y >= context->view_y + context->view_h)) return; if (context->get_pixel(context, x, y) == border_color) return; size = sizeof(SPAN *) * (context->view_y + context->view_h); span = (SPAN **)malloc(size); fb_hMemSet(span, 0, size); tail = head = add_span(context, span, &x, y, border_color); /* Find all spans to paint */ while (tail) { if (tail->y - 1 >= context->view_y) { for (x = tail->x1; x <= tail->x2; x++) { if (context->get_pixel(context, x, tail->y - 1) != border_color) { s = add_span(context, span, &x, tail->y - 1, border_color); if (s) { head->next = s; head = s; } } } } if (tail->y + 1 < context->view_y + context->view_h) { for (x = tail->x1; x <= tail->x2; x++) { if (context->get_pixel(context, x, tail->y + 1) != border_color) { s = add_span(context, span, &x, tail->y + 1, border_color); if (s) { head->next = s; head = s; } } } } tail = tail->next; } DRIVER_LOCK(); /* Fill spans */ for (y = context->view_y; y < context->view_y + context->view_h; y++) { for (s = tail = span[y]; s; s = s->row_next, free(tail), tail = s) { dest = context->line[s->y] + (s->x1 * context->target_bpp); if (mode == PAINT_TYPE_FILL) context->pixel_set(dest, color, s->x2 - s->x1 + 1); else { src = data + (((s->y & 0x7) << 3) * context->target_bpp); if (s->x1 & 0x7) { if ((s->x1 & ~0x7) == (s->x2 & ~0x7)) size = s->x2 - s->x1 + 1; else size = 8 - (s->x1 & 0x7); fb_hPixelCpy(dest, src + ((s->x1 & 0x7) * context->target_bpp), size); dest += size * context->target_bpp; } s->x2++; for (x = (s->x1 + 7) >> 3; x < (s->x2 & ~0x7) >> 3; x++) { fb_hPixelCpy(dest, src, 8); dest += 8 * context->target_bpp; } if ((s->x2 & 0x7) && ((s->x1 & ~0x7) != (s->x2 & ~0x7))) fb_hPixelCpy(dest, src, s->x2 & 0x7); } if (__fb_gfx->framebuffer == context->line[0]) __fb_gfx->dirty[context->view_y + y] = TRUE; } } free(span); DRIVER_UNLOCK(); }
/*:::::*/ static int gfx_get(void *target, float fx1, float fy1, float fx2, float fy2, unsigned char *dest, int coord_type, FBARRAY *array, int usenewheader ) { FB_GFXCTX *context = fb_hGetContext(); PUT_HEADER *header; int x1, y1, x2, y2, w, h, pitch; if (!__fb_gfx) return fb_ErrorSetNum(FB_RTERROR_ILLEGALFUNCTIONCALL); fb_hPrepareTarget(context, target); fb_hSetPixelTransfer(context, MASK_A_32); fb_hFixRelative(context, coord_type, &fx1, &fy1, &fx2, &fy2); fb_hTranslateCoord(context, fx1, fy1, &x1, &y1); fb_hTranslateCoord(context, fx2, fy2, &x2, &y2); fb_hFixCoordsOrder(&x1, &y1, &x2, &y2); if ((x1 < context->view_x) || (y1 < context->view_y) || (x2 >= context->view_x + context->view_w) || (y2 >= context->view_y + context->view_h)) return fb_ErrorSetNum(FB_RTERROR_ILLEGALFUNCTIONCALL); w = x2 - x1 + 1; h = y2 - y1 + 1; header = (PUT_HEADER *)dest; if (!usenewheader) { /* use old-style header for compatibility */ header->old.bpp = context->target_bpp; header->old.width = w; header->old.height = h; pitch = w * context->target_bpp; dest += 4; } else { /* use new-style header */ header->type = PUT_HEADER_NEW; header->width = w; header->height = h; header->bpp = context->target_bpp; pitch = header->pitch = ((w * context->target_bpp) + 0xF) & ~0xF; dest += sizeof(PUT_HEADER); } if( array != NULL ) { if ((array->size > 0) && ((intptr_t)dest + (pitch * h) > (intptr_t)array->data + array->size)) return fb_ErrorSetNum(FB_RTERROR_ILLEGALFUNCTIONCALL); } DRIVER_LOCK(); for (; y1 <= y2; y1++) { fb_hPixelCpy(dest, context->line[y1] + (x1 * context->target_bpp), w); dest += pitch; } DRIVER_UNLOCK(); return fb_ErrorSetNum( FB_RTERROR_OK ); }