diff options
| author | Manolo Gouy <Manolo> | 2017-06-18 16:01:53 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2017-06-18 16:01:53 +0000 |
| commit | 701fa00c7c54a1260f05ef41ee11592059d9f652 (patch) | |
| tree | e256811b8842ac1376e8b3730c42478162849eb0 /src/drivers/GDI | |
| parent | 2cda5a4fa682372f294a7a8e9e2b90a9fdb15610 (diff) | |
Advancing HiDPI support for the WIN32 platform - still incomplete.
It's still necessary to compile with -DFLTK_HIDPI_SUPPORT
to activate the new HiDPI support.
Default builds get the same HiDPI support as in FLTK 1.3
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12265 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/GDI')
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx | 9 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 2 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx | 32 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx | 10 |
4 files changed, 39 insertions, 14 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx index 1e7584fa8..e3d43664c 100644 --- a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx @@ -60,8 +60,13 @@ Fl_GDI_Copy_Surface_Driver::Fl_GDI_Copy_Surface_Driver(int w, int h) : Fl_Copy_S float factorw = (100.f * hmm) / hdots; float factorh = (100.f * vmm) / vdots; // Global display scaling factor: 1, 1.25, 1.5, 1.75, etc... - float scaling = Fl_WinAPI_Screen_Driver::desktop_scaling_factor(); - +#ifdef FLTK_HIDPI_SUPPORT + float scaling = Fl_Graphics_Driver::default_driver().scale(); + factorw *= scaling; + factorh *= scaling; +#else + float scaling = ((Fl_WinAPI_Screen_Driver*)Fl::screen_driver())->DWM_scaling_factor(0); +#endif RECT rect; rect.left = 0; rect.top = 0; rect.right = (LONG)((w/scaling) * factorw); rect.bottom = (LONG)((h/scaling) * factorh); gc = CreateEnhMetaFile (NULL, NULL, &rect, NULL); if (gc != NULL) { diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H index a641e4c89..0ab48418b 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H @@ -89,7 +89,7 @@ public: void XDestroyRegion(Fl_Region r); void translate_all(int x, int y); void untranslate_all(void); - static HRGN scale_region(HRGN r, float f, bool keep, bool inflate=false); + static HRGN scale_region(HRGN r, float f, Fl_GDI_Graphics_Driver *dr, bool keep/*, bool inflate=false*/); virtual void scale(float f); virtual float scale(); protected: diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx index 00bade1b1..41948b83a 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx @@ -146,7 +146,7 @@ void Fl_GDI_Graphics_Driver::translate_all(int x, int y) { depth = stack_height - 1; } GetWindowOrgEx((HDC)gc(), origins+depth); - SetWindowOrgEx((HDC)gc(), origins[depth].x - x, origins[depth].y - y, NULL); + SetWindowOrgEx((HDC)gc(), origins[depth].x - x*scale_, origins[depth].y - y*scale_, NULL); depth++; } @@ -243,24 +243,44 @@ float Fl_GDI_Graphics_Driver::scale() { /* Rescale region r with factor f and returns the scaled region. The input region is deleted if keep is false. - The input region is inflated by 1 unit before rescaling if inflate is true. + //The input region is inflated by 1 unit before rescaling if inflate is true. Region r is returned unchanged if r is null or f is 1. */ -HRGN Fl_GDI_Graphics_Driver::scale_region(HRGN r, float f, bool keep, bool inflate) { +HRGN Fl_GDI_Graphics_Driver::scale_region(HRGN r, float f, Fl_GDI_Graphics_Driver *dr, bool keep/*, bool inflate*/) { if (r && f != 1) { DWORD size = GetRegionData(r, 0, NULL); RGNDATA *pdata = (RGNDATA*)malloc(size); GetRegionData(r, size, pdata); if (!keep) DeleteObject(r); - if (inflate) { + /*if (inflate) { // seems no longer useful RECT *rects = (RECT*)&(pdata->Buffer); for (DWORD i = 0; i < pdata->rdh.nCount; i++) { InflateRect(rects+i, 1, 1); } + }*/ + POINT pt = {0, 0}; + if (dr && dr->depth >= 1) { // account for both scaling and translation + GetWindowOrgEx((HDC)dr->gc(), &pt); + pt.x *= (f - 1); + pt.y *= (f - 1); } - XFORM xform = {f, 0, 0, f, 0, 0}; + XFORM xform = {f, 0, 0, f, (FLOAT)pt.x , (FLOAT)pt.y}; r = ExtCreateRegion(&xform, size, pdata); free(pdata); + + if (dr && int(f) != f && f > 1) { // needed for clean checkers demo + DWORD size = GetRegionData(r, 0, NULL); + RGNDATA *pdata = (RGNDATA*)malloc(size); + GetRegionData(r, size, pdata); + DeleteObject(r); + RECT *rects = (RECT*)&(pdata->Buffer); + for (DWORD i = 0; i < pdata->rdh.nCount; i++) { + InflateRect(rects+i, 1, 1); + } + r = ExtCreateRegion(NULL, size, pdata); + free(pdata); + } + } return r; } @@ -268,7 +288,7 @@ HRGN Fl_GDI_Graphics_Driver::scale_region(HRGN r, float f, bool keep, bool infla Fl_Region Fl_GDI_Graphics_Driver::scale_clip(float f) { HRGN r = rstack[rstackptr]; - HRGN r2 = scale_region(r, f, true); + HRGN r2 = scale_region(r, f, this, true); return (r == r2 ? NULL : (rstack[rstackptr] = r2, r)); } diff --git a/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx b/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx index e55e69583..904511fe0 100644 --- a/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx @@ -21,6 +21,7 @@ #ifdef FL_CFG_GFX_GDI #include "Fl_GDI_Graphics_Driver.H" +#include "../WinAPI/Fl_WinAPI_Screen_Driver.H" #include <FL/Fl_Image_Surface.H> #include <FL/fl_draw.H> #include <FL/x.H> @@ -55,7 +56,9 @@ Fl_GDI_Image_Surface_Driver::Fl_GDI_Image_Surface_Driver(int w, int h, int high_ w = int(w*d); h = int(h*d); } - offscreen = off ? off : CreateCompatibleBitmap( (fl_graphics_driver->gc() ? (HDC)fl_graphics_driver->gc() : fl_GetDC(0) ) , w, h); + HDC gc = (HDC)Fl_Graphics_Driver::default_driver().gc(); + offscreen = off ? off : CreateCompatibleBitmap( (gc ? gc : fl_GetDC(0) ) , w, h); + if (!offscreen) offscreen = CreateCompatibleBitmap(fl_GetDC(0), w, h); driver(new Fl_GDI_Graphics_Driver); if (d != 1 && high_res) driver()->scale(d); _sgc = NULL; @@ -93,11 +96,8 @@ void Fl_GDI_Image_Surface_Driver::untranslate() { Fl_RGB_Image* Fl_GDI_Image_Surface_Driver::image() { - unsigned char *data; - data = fl_read_image(NULL, 0, 0, width, height, 0); + Fl_RGB_Image *image = Fl::screen_driver()->read_win_rectangle(NULL, 0, 0, width, height, 0); previous->driver()->gc(_sgc); - Fl_RGB_Image *image = new Fl_RGB_Image(data, width, height); - image->alloc_array = 1; return image; } |
