diff options
author | StapleButter <thetotalworm@gmail.com> | 2017-10-03 01:29:35 +0200 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2017-10-03 01:29:35 +0200 |
commit | fbe4e4938ba32566941220874ced571ef8da00a5 (patch) | |
tree | a9748b76a79539f39a8d289b414544c5c44be449 /src/libui_sdl | |
parent | 5450c7cc3ded21b2ffe83210ec0584e5bec7bf93 (diff) |
finally finish cairo bitmap support. asdsfdfgfsgf
Diffstat (limited to 'src/libui_sdl')
-rw-r--r-- | src/libui_sdl/libui/unix/draw.c | 17 |
1 files changed, 15 insertions, 2 deletions
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) |