From e4f030149b07228a06c6e05a7f0b0e19399d4427 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Thu, 7 Dec 2017 02:50:05 +0100 Subject: [PATCH] add option to toggle filtering --- src/Config.cpp | 2 ++ src/Config.h | 1 + src/libui_sdl/libui/ui.h | 2 +- src/libui_sdl/libui/unix/draw.c | 2 +- src/libui_sdl/libui/windows/draw.cpp | 2 +- src/libui_sdl/main.cpp | 14 ++++++++++++-- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Config.cpp b/src/Config.cpp index 213f03de..dfa4416c 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -35,6 +35,7 @@ int ScreenRotation; int ScreenGap; int ScreenLayout; int ScreenSizing; +int ScreenFilter; int DirectBoot; @@ -88,6 +89,7 @@ ConfigEntry ConfigFile[] = {"ScreenGap", 0, &ScreenGap, 0, NULL, 0}, {"ScreenLayout", 0, &ScreenLayout, 0, NULL, 0}, {"ScreenSizing", 0, &ScreenSizing, 0, NULL, 0}, + {"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0}, {"DirectBoot", 0, &DirectBoot, 1, NULL, 0}, diff --git a/src/Config.h b/src/Config.h index c40fa67a..b3d9d64d 100644 --- a/src/Config.h +++ b/src/Config.h @@ -37,6 +37,7 @@ extern int ScreenRotation; extern int ScreenGap; extern int ScreenLayout; extern int ScreenSizing; +extern int ScreenFilter; extern int DirectBoot; diff --git a/src/libui_sdl/libui/ui.h b/src/libui_sdl/libui/ui.h index f9923f89..e5a866d2 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, bool filter); +_UI_EXTERN void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect, int 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 cf5ce7c8..72d42029 100644 --- a/src/libui_sdl/libui/unix/draw.c +++ b/src/libui_sdl/libui/unix/draw.c @@ -185,7 +185,7 @@ void uiDrawBitmapUpdate(uiDrawBitmap* bmp, const void* data) cairo_surface_mark_dirty(bmp->bmp); } -void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect, bool filter) +void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect, int filter) { cairo_save(c->cr); cairo_rectangle(c->cr, dstrect->X, dstrect->Y, dstrect->Width, dstrect->Height); diff --git a/src/libui_sdl/libui/windows/draw.cpp b/src/libui_sdl/libui/windows/draw.cpp index 5294e553..65f25354 100644 --- a/src/libui_sdl/libui/windows/draw.cpp +++ b/src/libui_sdl/libui/windows/draw.cpp @@ -555,7 +555,7 @@ void uiDrawBitmapUpdate(uiDrawBitmap* bmp, const void* data) bmp->bmp->CopyFromMemory(&rekt, data, bmp->Stride); } -void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect, bool filter) +void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect, int 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); diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index d55b864f..841aa9cd 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -310,12 +310,12 @@ void OnAreaDraw(uiAreaHandler* handler, uiArea* area, uiAreaDrawParams* params) uiDrawSave(params->Context); uiDrawTransform(params->Context, &TopScreenTrans); - uiDrawBitmapDraw(params->Context, ScreenBitmap, &top, &TopScreenRect); + uiDrawBitmapDraw(params->Context, ScreenBitmap, &top, &TopScreenRect, Config::ScreenFilter==1); uiDrawRestore(params->Context); uiDrawSave(params->Context); uiDrawTransform(params->Context, &BottomScreenTrans); - uiDrawBitmapDraw(params->Context, ScreenBitmap, &bot, &BottomScreenRect); + uiDrawBitmapDraw(params->Context, ScreenBitmap, &bot, &BottomScreenRect, Config::ScreenFilter==1); uiDrawRestore(params->Context); } @@ -937,6 +937,13 @@ void OnSetScreenSizing(uiMenuItem* item, uiWindow* window, void* param) uiMenuItemSetChecked(MenuItem_ScreenSizing[i], i==ScreenSizing); } +void OnSetScreenFiltering(uiMenuItem* item, uiWindow* window, void* blarg) +{ + int chk = uiMenuItemChecked(item); + if (chk != 0) Config::ScreenFilter = 1; + else Config::ScreenFilter = 0; +} + void ApplyNewSettings() { @@ -1101,6 +1108,9 @@ int main(int argc, char** argv) uiMenuAppendSubmenu(menu, submenu); } + menuitem = uiMenuAppendCheckItem(menu, "Screen filtering"); + uiMenuItemOnClicked(menuitem, OnSetScreenFiltering, NULL); + uiMenuItemSetChecked(menuitem, Config::ScreenFilter==1); uiMenuItemSetChecked(MenuItem_ScreenRot[ScreenRotation], 1); uiMenuItemSetChecked(MenuItem_ScreenGap[ScreenGap], 1);