diff options
| -rw-r--r-- | FL/win32.H | 7 | ||||
| -rw-r--r-- | FL/x.H | 16 | ||||
| -rw-r--r-- | src/Fl_Double_Window.cxx | 28 |
3 files changed, 41 insertions, 10 deletions
diff --git a/FL/win32.H b/FL/win32.H index 8ad6ccf45..cd9233179 100644 --- a/FL/win32.H +++ b/FL/win32.H @@ -121,16 +121,19 @@ extern FL_EXPORT void fl_save_dc( HWND w, HDC dc); // off-screen pixmaps: create, destroy, draw into, copy to window typedef HBITMAP Fl_Offscreen; -#define fl_create_offscreen(w, h) CreateCompatibleBitmap(fl_gc, w, h) +#define fl_create_offscreen(w, h) \ + CreateCompatibleBitmap( (fl_gc ? fl_gc : fl_GetDC(0) ) , w, h) extern FL_EXPORT HDC fl_makeDC(HBITMAP); # define fl_begin_offscreen(b) \ HDC _sgc=fl_gc; Window _sw=fl_window; \ + Fl_Surface_Device *_ss = fl_surface; fl_display_device->set_current(); \ fl_gc=fl_makeDC(b); int _savedc = SaveDC(fl_gc); fl_window=(HWND)b; fl_push_no_clip() # define fl_end_offscreen() \ - fl_pop_clip(); RestoreDC(fl_gc, _savedc); DeleteDC(fl_gc); fl_window=_sw; fl_gc = _sgc + fl_pop_clip(); RestoreDC(fl_gc, _savedc); DeleteDC(fl_gc); _ss->set_current(); fl_window=_sw; fl_gc = _sgc + FL_EXPORT void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy); FL_EXPORT void fl_copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy); @@ -110,16 +110,20 @@ extern FL_EXPORT ulong fl_event_time; // off-screen pixmaps: create, destroy, draw into, copy to window: typedef ulong Fl_Offscreen; -#define fl_create_offscreen(w,h) \ - XCreatePixmap(fl_display, fl_window, w, h, fl_visual->depth) +# define fl_create_offscreen(w,h) \ + XCreatePixmap(fl_display, \ + (fl_surface->type() == Fl_Display_Device::device_type ? \ + fl_window : fl_xid(Fl::first_window()) ) , \ + w, h, fl_visual->depth) // begin/end are macros that save the old state in local variables: # define fl_begin_offscreen(pixmap) \ - Window _sw=fl_window; fl_window=pixmap; fl_push_no_clip() + Window _sw=fl_window; fl_window=pixmap; \ + Fl_Surface_Device *_ss = fl_surface; fl_display_device->set_current(); \ + fl_push_no_clip() # define fl_end_offscreen() \ - fl_pop_clip(); fl_window = _sw + fl_pop_clip(); fl_window = _sw; _ss->set_current() -# define fl_copy_offscreen(x,y,w,h,pixmap,srcx,srcy) \ - XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y) +extern void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); # define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap) // Bitmap masks diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx index 03e0240b8..a09134879 100644 --- a/src/Fl_Double_Window.cxx +++ b/src/Fl_Double_Window.cxx @@ -65,8 +65,28 @@ void Fl_Double_Window::show() { Fl_Window::show(); } +static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); + +void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { + if( fl_graphics_driver == fl_display_device->driver()) { + fl_copy_offscreen_to_display(x, y, w, h, pixmap, srcx, srcy); + } + else { // when copy is not to the display + fl_begin_offscreen(pixmap); + uchar *img = fl_read_image(NULL, srcx, srcy, w, h, 0); + fl_end_offscreen(); + fl_draw_image(img, x, y, w, h, 3, 0); + delete img; + } +} + #if defined(USE_X11) +static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { + XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y); +} + + // maybe someone feels inclined to implement alpha blending on X11? char fl_can_do_alpha_blending() { return 0; @@ -134,7 +154,7 @@ HDC fl_makeDC(HBITMAP bitmap) { return new_gc; } -void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) { +static void fl_copy_offscreen_to_display(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) { HDC new_gc = CreateCompatibleDC(fl_gc); int save = SaveDC(new_gc); SelectObject(new_gc, bitmap); @@ -195,7 +215,7 @@ static void bmProviderRelease (void *src, const void *data, size_t size) if(count == 1) free((void*)data); } -void fl_copy_offscreen(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) { +static void fl_copy_offscreen_to_display(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) { CGContextRef src = (CGContextRef)osrc; void *data = CGBitmapContextGetData(src); int sw = CGBitmapContextGetWidth(src); @@ -230,8 +250,11 @@ const int stack_max = 16; static int stack_ix = 0; static CGContextRef stack_gc[stack_max]; static Window stack_window[stack_max]; +static Fl_Surface_Device *_ss; void fl_begin_offscreen(Fl_Offscreen ctx) { + _ss = fl_surface; + fl_display_device->set_current(); if (stack_ix<stack_max) { stack_gc[stack_ix] = fl_gc; stack_window[stack_ix] = fl_window; @@ -256,6 +279,7 @@ void fl_end_offscreen() { fl_gc = stack_gc[stack_ix]; fl_window = stack_window[stack_ix]; } + _ss->set_current(); } extern void fl_restore_clip(); |
