void ConEndOutput(console_t *console) { assert(console->x >= console->str_x); assert(console->y == console->str_y); if (console->x != console->str_x) { if (console->cookie == current->cookie) { FontDrawText(console->font, &surf, console->rect.left + console->str_x * console->char_width, console->rect.top + console->str_y * console->char_height, console->buf_chars + console->str_x + console->str_y * console->width, console->x - console->str_x, console->fg_colour, console->bg_colour); } } }
void GmgrDrawText(gfx_h hgfx, const rect_t *rect, const wchar_t *str, size_t length) { point_t size; videomode_t mode; gmgr_surface_t *surface; gfx_t *gfx; rect_t clip; int ax1, ay1, ax2, ay2; unsigned i; gfx = GmgrLockGraphics(hgfx); if (gfx == NULL) return; FontGetTextSize(gmgr_font, str, length, &size); if (size.x < rect->right - rect->left) size.x = rect->right - rect->left; if (size.y < rect->bottom - rect->top) size.y = rect->bottom - rect->top; mode = gmgr_screen->mode; mode.width = size.x; mode.height = size.y; mode.bytesPerLine = (mode.bitsPerPixel * size.x) / 8; surface = GmgrCreateMemorySurface(&mode, GMGR_SURFACE_SHARED); if (surface == NULL) { GmgrUnlockGraphics(gfx); return; } FontDrawText(gmgr_font, &surface->surf, 0, 0, str, length, gfx->colour_pen, gfx->colour_fill); for (i = 0; i < gfx->clip.num_rects; i++) { clip = gfx->clip.rects[i]; ay1 = max(rect->top, clip.top); ay2 = min(rect->bottom, clip.bottom); if (ay2 > ay1) { ax1 = max(clip.left, rect->left); ax2 = min(clip.right, rect->right); if (ax2 > ax1) { rect_t dest; int src_x, src_y; dest.left = ax1; dest.top = ay1; dest.right = ax2; dest.bottom = ay2; src_x = dest.left - rect->left; src_y = dest.top - rect->top; gfx->surface->surf.vtbl->SurfBltMemoryToScreen(&gfx->surface->surf, &dest, (uint8_t*) surface->base + src_y * surface->mode.bytesPerLine + (src_x * surface->mode.bitsPerPixel) / 8, surface->mode.bytesPerLine); } } } GmgrCloseSurface(surface); GmgrUnlockGraphics(gfx); }