summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-03-30 20:16:40 +0000
committerManolo Gouy <Manolo>2016-03-30 20:16:40 +0000
commitd67f395031b0e9cfb266bf31a4a5e08a2d109e3b (patch)
tree6a38b9180802e79b16af5de3ff031e6d739ac16c /src/drivers
parent7799245100a91b10b9a4ca9c6e818a3cdd8d5dc9 (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/drivers')
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H1
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx2
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx12
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H1
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx22
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx2
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.cxx4
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx6
8 files changed, 43 insertions, 7 deletions
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) {