diff options
| author | Manolo Gouy <Manolo> | 2016-02-18 16:21:51 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-02-18 16:21:51 +0000 |
| commit | f33b45f1d30653fb5da4817089e38ff0a2413cfb (patch) | |
| tree | 9edc759690defa581b00b6ada80bb334f4ac5da8 /src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx | |
| parent | 6ce27012a9412c4964e0ae40c81ea92ff39a61d3 (diff) | |
Remove all uses of the fl_gc global variable. Towards a clean driver model.
fl_gc remains usable by the application as a hook into the system.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11189 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx')
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx index 3bc9fedbe..74cd6a69d 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx @@ -27,6 +27,17 @@ const char *Fl_GDI_Graphics_Driver::class_id = "Fl_GDI_Graphics_Driver"; // FIXME: move to printer graphics driver const char *Fl_GDI_Printer_Graphics_Driver::class_id = "Fl_GDI_Printer_Graphics_Driver"; +/* Reference to the current device context + For back-compatibility only. The preferred procedure to get this reference is + Fl_Surface_Device::surface()->driver()->get_gc(). + */ +HDC fl_gc = 0; + +void Fl_Graphics_Driver::global_gc() +{ + fl_gc = (HDC)get_gc(); +} + /* * By linking this module, the following static method will instatiate the * MSWindows GDI Graphics driver as the main display driver. @@ -87,7 +98,7 @@ char Fl_GDI_Graphics_Driver::can_do_alpha_blending() { } HDC fl_makeDC(HBITMAP bitmap) { - HDC new_gc = CreateCompatibleDC(fl_gc); + HDC new_gc = CreateCompatibleDC((HDC)fl_graphics_driver->get_gc()); SetTextAlign(new_gc, TA_BASELINE|TA_LEFT); SetBkMode(new_gc, TRANSPARENT); #if USE_COLORMAP @@ -98,26 +109,26 @@ HDC fl_makeDC(HBITMAP bitmap) { } void Fl_GDI_Graphics_Driver::copy_offscreen(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) { - HDC new_gc = CreateCompatibleDC(fl_gc); + HDC new_gc = CreateCompatibleDC(gc); int save = SaveDC(new_gc); SelectObject(new_gc, bitmap); - BitBlt(fl_gc, x, y, w, h, new_gc, srcx, srcy, SRCCOPY); + BitBlt(gc, x, y, w, h, new_gc, srcx, srcy, SRCCOPY); RestoreDC(new_gc, save); DeleteDC(new_gc); } void Fl_GDI_Graphics_Driver::copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) { - HDC new_gc = CreateCompatibleDC(fl_gc); + HDC new_gc = CreateCompatibleDC(gc); int save = SaveDC(new_gc); SelectObject(new_gc, bitmap); BOOL alpha_ok = 0; // first try to alpha blend if ( can_do_alpha_blending() ) { - alpha_ok = fl_alpha_blend(fl_gc, x, y, w, h, new_gc, srcx, srcy, w, h, blendfunc); + alpha_ok = fl_alpha_blend(gc, x, y, w, h, new_gc, srcx, srcy, w, h, blendfunc); } // if that failed (it shouldn't), still copy the bitmap over, but now alpha is 1 if (!alpha_ok) { - BitBlt(fl_gc, x, y, w, h, new_gc, srcx, srcy, SRCCOPY); + BitBlt(gc, x, y, w, h, new_gc, srcx, srcy, SRCCOPY); } RestoreDC(new_gc, save); DeleteDC(new_gc); |
