mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
libui: add parameter to uiDrawBitmapDraw() to specify filtering
This commit is contained in:
parent
b58a5334fa
commit
18bcefe83b
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user