libui: add parameter to uiDrawBitmapDraw() to specify filtering

This commit is contained in:
StapleButter 2017-12-07 02:41:46 +01:00
parent b58a5334fa
commit 18bcefe83b
3 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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);

View File

@ -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)