diff options
author | StapleButter <thetotalworm@gmail.com> | 2017-12-07 02:41:46 +0100 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2017-12-07 02:41:46 +0100 |
commit | 18bcefe83be64d389702be04944f27cc7919e1f2 (patch) | |
tree | 7370e5cbc79853fcc89e7d789c4377a92079baf1 | |
parent | b58a5334fae12f28ac3e226114da5fd8ee640d31 (diff) |
libui: add parameter to uiDrawBitmapDraw() to specify filtering
-rw-r--r-- | src/libui_sdl/libui/ui.h | 2 | ||||
-rw-r--r-- | src/libui_sdl/libui/unix/draw.c | 4 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/draw.cpp | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/libui_sdl/libui/ui.h b/src/libui_sdl/libui/ui.h index 908574d..f9923f8 100644 --- a/src/libui_sdl/libui/ui.h +++ b/src/libui_sdl/libui/ui.h @@ -505,7 +505,7 @@ _UI_EXTERN void uiDrawRestore(uiDrawContext *c); // bitmap API _UI_EXTERN uiDrawBitmap* uiDrawNewBitmap(uiDrawContext* c, int width, int height); _UI_EXTERN void uiDrawBitmapUpdate(uiDrawBitmap* bmp, const void* data); -_UI_EXTERN void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect); +_UI_EXTERN void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect, bool filter); _UI_EXTERN void uiDrawFreeBitmap(uiDrawBitmap* bmp); // TODO manage the use of Text, Font, and TextFont, and of the uiDrawText prefix in general diff --git a/src/libui_sdl/libui/unix/draw.c b/src/libui_sdl/libui/unix/draw.c index cbdffea..cf5ce7c 100644 --- a/src/libui_sdl/libui/unix/draw.c +++ b/src/libui_sdl/libui/unix/draw.c @@ -185,10 +185,9 @@ void uiDrawBitmapUpdate(uiDrawBitmap* bmp, const void* data) cairo_surface_mark_dirty(bmp->bmp); } -void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect) +void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect, bool filter) { cairo_save(c->cr); - cairo_rectangle(c->cr, dstrect->X, dstrect->Y, dstrect->Width, dstrect->Height); cairo_translate(c->cr, dstrect->X, dstrect->Y); @@ -201,6 +200,7 @@ void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRe } cairo_set_source_surface(c->cr, bmp->bmp, -srcrect->X, -srcrect->Y); + cairo_pattern_set_filter(cairo_get_source(c->cr), filter ? CAIRO_FILTER_BILINEAR : CAIRO_FILTER_NEAREST); cairo_clip(c->cr); cairo_paint(c->cr); diff --git a/src/libui_sdl/libui/windows/draw.cpp b/src/libui_sdl/libui/windows/draw.cpp index 84b43c5..5294e55 100644 --- a/src/libui_sdl/libui/windows/draw.cpp +++ b/src/libui_sdl/libui/windows/draw.cpp @@ -555,12 +555,12 @@ void uiDrawBitmapUpdate(uiDrawBitmap* bmp, const void* data) bmp->bmp->CopyFromMemory(&rekt, data, bmp->Stride); } -void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect) +void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect, bool filter) { D2D_RECT_F _srcrect = D2D1::RectF(srcrect->X, srcrect->Y, srcrect->X+srcrect->Width, srcrect->Y+srcrect->Height); D2D_RECT_F _dstrect = D2D1::RectF(dstrect->X, dstrect->Y, dstrect->X+dstrect->Width, dstrect->Y+dstrect->Height); - c->rt->DrawBitmap(bmp->bmp, &_dstrect, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, &_srcrect); + c->rt->DrawBitmap(bmp->bmp, &_dstrect, 1.0f, filter ? D2D1_BITMAP_INTERPOLATION_MODE_LINEAR : D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, &_srcrect); } void uiDrawFreeBitmap(uiDrawBitmap* bmp) |