From fbe4e4938ba32566941220874ced571ef8da00a5 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Tue, 3 Oct 2017 01:29:35 +0200 Subject: finally finish cairo bitmap support. asdsfdfgfsgf --- src/libui_sdl/libui/unix/draw.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libui_sdl/libui/unix/draw.c b/src/libui_sdl/libui/unix/draw.c index acdd8ef..cbdffea 100644 --- a/src/libui_sdl/libui/unix/draw.c +++ b/src/libui_sdl/libui/unix/draw.c @@ -187,11 +187,24 @@ void uiDrawBitmapUpdate(uiDrawBitmap* bmp, const void* data) void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect) { - // TODO: rect + cairo_save(c->cr); - cairo_set_source_surface(c->cr, bmp->bmp, srcrect->X, srcrect->Y); + cairo_rectangle(c->cr, dstrect->X, dstrect->Y, dstrect->Width, dstrect->Height); + cairo_translate(c->cr, dstrect->X, dstrect->Y); + if ((dstrect->Width != srcrect->Width) || (dstrect->Height != srcrect->Height)) + { + // scale shit if needed + double sx = dstrect->Width / (double)srcrect->Width; + double sy = dstrect->Height / (double)srcrect->Height; + cairo_scale(c->cr, sx, sy); + } + + cairo_set_source_surface(c->cr, bmp->bmp, -srcrect->X, -srcrect->Y); + cairo_clip(c->cr); cairo_paint(c->cr); + + cairo_restore(c->cr); } void uiDrawFreeBitmap(uiDrawBitmap* bmp) -- cgit v1.2.3