diff options
| author | Manolo Gouy <Manolo> | 2016-03-30 20:16:40 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-03-30 20:16:40 +0000 |
| commit | d67f395031b0e9cfb266bf31a4a5e08a2d109e3b (patch) | |
| tree | 6a38b9180802e79b16af5de3ff031e6d739ac16c /src | |
| parent | 7799245100a91b10b9a4ca9c6e818a3cdd8d5dc9 (diff) | |
Rewrite functions XRectangleRegion(), XDestroyRegion() under the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11479 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl.cxx | 8 | ||||
| -rw-r--r-- | src/Fl_cocoa.mm | 16 | ||||
| -rw-r--r-- | src/Fl_win32.cxx | 12 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx | 2 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx | 12 | ||||
| -rw-r--r-- | src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx | 22 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx | 2 | ||||
| -rw-r--r-- | src/drivers/X11/Fl_X11_Window_Driver.cxx | 4 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx | 6 | ||||
| -rw-r--r-- | src/gl_start.cxx | 4 |
12 files changed, 56 insertions, 34 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx index 05e8ba029..cb922858e 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -680,7 +680,7 @@ void Fl::flush() { if (!wi->visible_r()) continue; if (wi->damage()) {i->flush(); wi->clear_damage();} // destroy damage regions for windows that don't use them: - if (i->region) {XDestroyRegion(i->region); i->region = 0;} + if (i->region) {Fl_Graphics_Driver::XDestroyRegion(i->region); i->region = 0;} } } screen_driver()->flush(); @@ -1479,7 +1479,7 @@ void Fl_Widget::damage(uchar fl) { // damage entire window by deleting the region: Fl_X* i = Fl_X::i((Fl_Window*)this); if (!i) return; // window not mapped, so ignore it - if (i->region) {XDestroyRegion(i->region); i->region = 0;} + if (i->region) {Fl_Graphics_Driver::XDestroyRegion(i->region); i->region = 0;} damage_ |= fl; Fl::damage(FL_DAMAGE_CHILD); } @@ -1518,8 +1518,8 @@ void Fl_Widget::damage(uchar fl, int X, int Y, int W, int H) { wi->damage_ |= fl; } else { // create a new region: - if (i->region) XDestroyRegion(i->region); - i->region = XRectangleRegion(X,Y,W,H); + if (i->region) Fl_Graphics_Driver::XDestroyRegion(i->region); + i->region = Fl_Graphics_Driver::XRectangleRegion(X,Y,W,H); wi->damage_ = fl; } Fl::damage(FL_DAMAGE_CHILD); diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index b6be6baba..97f72d388 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -36,6 +36,7 @@ extern "C" { #include <FL/Fl.H> +#include <FL/x.H> #include <FL/Fl_Window_Driver.H> #include <FL/Fl_Window.H> #include <FL/Fl_Tooltip.H> @@ -1945,7 +1946,7 @@ static void handleUpdateEvent( Fl_Window *window ) i->wait_for_expose = 0; if ( i->region ) { - XDestroyRegion(i->region); + Fl_Graphics_Driver::XDestroyRegion(i->region); i->region = 0; } window->clear_damage(FL_DAMAGE_ALL); @@ -3550,8 +3551,8 @@ void Fl_Cocoa_Window_Driver::unmap() { // intersects current and x,y,w,h rectangle and returns result as a new Fl_Region Fl_Region Fl_X::intersect_region_and_rect(Fl_Region current, int x,int y,int w, int h) { - if (current == NULL) return XRectangleRegion(x,y,w,h); - CGRect r = fl_cgrectmake_cocoa(x, y, w, h); + if (current == NULL) return Fl_Graphics_Driver::XRectangleRegion(x,y,w,h); + CGRect r = Fl_Quartz_Graphics_Driver::fl_cgrectmake_cocoa(x, y, w, h); Fl_Region outr = (Fl_Region)malloc(sizeof(*outr)); outr->count = current->count; outr->rects =(CGRect*)malloc(outr->count * sizeof(CGRect)); @@ -3565,8 +3566,8 @@ Fl_Region Fl_X::intersect_region_and_rect(Fl_Region current, int x,int y,int w, outr->rects = (CGRect*)realloc(outr->rects, outr->count * sizeof(CGRect)); } else { - XDestroyRegion(outr); - outr = XRectangleRegion(0,0,0,0); + Fl_Graphics_Driver::XDestroyRegion(outr); + outr = Fl_Graphics_Driver::XRectangleRegion(0,0,0,0); } return outr; } @@ -4262,11 +4263,6 @@ CGImageRef Fl_X::CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, i return img; } -// so a CGRect matches exactly what is denoted x,y,w,h for clipping purposes -CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h) { - return CGRectMake(x - 0.5, y - 0.5, w, h); -} - Window fl_xid(const Fl_Window* w) { Fl_X *temp = Fl_X::i(w); diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 6df0fb769..8bff1c8b0 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -1118,14 +1118,14 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar R = CreateRectRgn(0,0,0,0); int r = GetUpdateRgn(hWnd,R,0); if (r==NULLREGION && !redraw_whole_window) { - XDestroyRegion(R); + Fl_Graphics_Driver::XDestroyRegion(R); break; } if (i->region) { // Also tell WIN32 that we are drawing someplace else as well... CombineRgn(i->region, i->region, R, RGN_OR); - XDestroyRegion(R); + Fl_Graphics_Driver::XDestroyRegion(R); } else { i->region = R; } @@ -2363,14 +2363,6 @@ void fl_cleanup_dc_list(void) { // clean up the list } while(t); } -Fl_Region XRectangleRegion(int x, int y, int w, int h) { - if (Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) return CreateRectRgn(x,y,x+w,y+h); - // because rotation may apply, the rectangle becomes a polygon in device coords - POINT pt[4] = { {x, y}, {x + w, y}, {x + w, y + h}, {x, y + h} }; - LPtoDP((HDC)fl_graphics_driver->gc(), pt, 4); - return CreatePolygonRgn(pt, 4, ALTERNATE); -} - FL_EXPORT Window fl_xid_(const Fl_Window *w) { Fl_X *temp = Fl_X::i(w); return temp ? temp->xid : 0; diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H index f9713f1aa..ca9ef3ae6 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H +++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H @@ -26,7 +26,6 @@ #define FL_COCOA_SCREEN_DRIVER_H #include <FL/Fl_Screen_Driver.H> -#include <FL/x.H> // for XRectangle /* Move everything here that manages the native screen interface. diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx index 4657566da..9f0b497ff 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx +++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx @@ -239,7 +239,7 @@ void Fl_Cocoa_Window_Driver::hide() { Fl_X::q_release_context(ip); if ( ip->xid == fl_window ) fl_window = 0; - if (ip->region) XDestroyRegion(ip->region); + if (ip->region) Fl_Graphics_Driver::XDestroyRegion(ip->region); ip->destroy(); delete ip; } diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx index 54740fc10..f03c38940 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx @@ -166,6 +166,18 @@ void Fl_GDI_Graphics_Driver::fixloop() { // remove equal points from closed pat while (n>2 && p[n-1].x == p[0].x && p[n-1].y == p[0].y) n--; } +Fl_Region Fl_Graphics_Driver::XRectangleRegion(int x, int y, int w, int h) { + if (Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) return CreateRectRgn(x,y,x+w,y+h); + // because rotation may apply, the rectangle becomes a polygon in device coords + POINT pt[4] = { {x, y}, {x + w, y}, {x + w, y + h}, {x, y + h} }; + LPtoDP((HDC)fl_graphics_driver->gc(), pt, 4); + return CreatePolygonRgn(pt, 4, ALTERNATE); +} + +void Fl_Graphics_Driver::XDestroyRegion(Fl_Region r) { + DeleteObject(r); +} + // // End of "$Id$". diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H index 7530c331f..d18484a10 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H @@ -63,6 +63,7 @@ public: void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_); void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); void draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh); + static CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h); protected: void transformed_vertex0(float x, float y); void fixloop(); diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx index a829534d3..c288a5666 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx @@ -71,8 +71,13 @@ void Fl_Quartz_Graphics_Driver::copy_offscreen(int x,int y,int w,int h,Fl_Offscr CGDataProviderRelease(src_bytes); } +// so a CGRect matches exactly what is denoted x,y,w,h for clipping purposes +CGRect Fl_Quartz_Graphics_Driver::fl_cgrectmake_cocoa(int x, int y, int w, int h) { + return CGRectMake(x - 0.5, y - 0.5, w, h); +} + void Fl_Graphics_Driver::add_rectangle_to_region(Fl_Region r, int X, int Y, int W, int H) { - CGRect arg = fl_cgrectmake_cocoa(X, Y, W, H); + CGRect arg = Fl_Quartz_Graphics_Driver::fl_cgrectmake_cocoa(X, Y, W, H); int j; // don't add a rectangle totally inside the Fl_Region for(j = 0; j < r->count; j++) { if(CGRectContainsRect(r->rects[j], arg)) break; @@ -83,6 +88,21 @@ void Fl_Graphics_Driver::add_rectangle_to_region(Fl_Region r, int X, int Y, int } } +Fl_Region Fl_Graphics_Driver::XRectangleRegion(int x, int y, int w, int h) { + Fl_Region R = (Fl_Region)malloc(sizeof(*R)); + R->count = 1; + R->rects = (CGRect *)malloc(sizeof(CGRect)); + *(R->rects) = Fl_Quartz_Graphics_Driver::fl_cgrectmake_cocoa(x, y, w, h); + return R; +} + +void Fl_Graphics_Driver::XDestroyRegion(Fl_Region r) { + if(r) { + free(r->rects); + free(r); + } +} + // // End of "$Id$". // diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx index d79bc26ae..6833b83ec 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx @@ -496,7 +496,7 @@ void Fl_WinAPI_Window_Driver::hide() { # endif } - if (ip->region) XDestroyRegion(ip->region); + if (ip->region) Fl_Graphics_Driver::XDestroyRegion(ip->region); // this little trickery seems to avoid the popup window stacking problem HWND p = GetForegroundWindow(); diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx index 43cff28e9..38b011249 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx @@ -86,7 +86,7 @@ void Fl_X11_Window_Driver::flush_double_dbe(int erase_overlay) } if (i->backbuffer_bad || erase_overlay) { // Make sure we do a complete redraw... - if (i->region) {XDestroyRegion(i->region); i->region = 0;} + if (i->region) {Fl_Graphics_Driver::XDestroyRegion(i->region); i->region = 0;} pWindow->clear_damage(FL_DAMAGE_ALL); i->backbuffer_bad = 0; } @@ -469,7 +469,7 @@ void Fl_X11_Window_Driver::show_menu() void Fl_X11_Window_Driver::hide() { Fl_X* ip = Fl_X::i(pWindow); if (hide_common()) return; - if (ip->region) XDestroyRegion(ip->region); + if (ip->region) Fl_Graphics_Driver::XDestroyRegion(ip->region); # if USE_XFT Fl_Xlib_Graphics_Driver::destroy_xft_draw(ip->xid); # endif diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx index 2d239cc0e..a584bf8e6 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx @@ -150,7 +150,7 @@ static int clip_x (int x) { // Missing X call: (is this the fastest way to init a 1-rectangle region?) // MSWindows equivalent exists, implemented inline in win32.H -Fl_Region XRectangleRegion(int x, int y, int w, int h) { +Fl_Region Fl_Graphics_Driver::XRectangleRegion(int x, int y, int w, int h) { XRectangle R; clip_to_short(x, y, w, h); R.x = x; R.y = y; R.width = w; R.height = h; @@ -159,6 +159,10 @@ Fl_Region XRectangleRegion(int x, int y, int w, int h) { return r; } +void Fl_Graphics_Driver::XDestroyRegion(Fl_Region r) { + ::XDestroyRegion(r); +} + // --- line and polygon drawing with integer coordinates void Fl_Xlib_Graphics_Driver::point(int x, int y) { diff --git a/src/gl_start.cxx b/src/gl_start.cxx index c897e97fa..9eaf36c05 100644 --- a/src/gl_start.cxx +++ b/src/gl_start.cxx @@ -56,8 +56,6 @@ static Fl_Gl_Choice* gl_choice; static Fl_Gl_Choice* gl_choice; #endif -Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx - /** Creates an OpenGL context */ void gl_start() { if (!context) { @@ -91,7 +89,7 @@ void gl_start() { int x, y, w, h; if (fl_clip_box(0, 0, Fl_Window::current()->w(), Fl_Window::current()->h(), x, y, w, h)) { - fl_clip_region(XRectangleRegion(x,y,w,h)); + fl_clip_region(Fl_Graphics_Driver::XRectangleRegion(x,y,w,h)); glScissor(x, Fl_Window::current()->h()-(y+h), w, h); glEnable(GL_SCISSOR_TEST); } else { |
