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
This commit is contained in:
parent
7799245100
commit
d67f395031
@ -240,8 +240,11 @@ public:
|
||||
virtual float scale_font_for_PostScript(Fl_Font_Descriptor *desc, int s) { return float(s); }
|
||||
// default implementation may be enough
|
||||
virtual float scale_bitmap_for_PostScript() { return 2; }
|
||||
// each platform implements that its own way
|
||||
// each platform implements these 3 functions its own way
|
||||
static void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h);
|
||||
static Fl_Region XRectangleRegion(int x, int y, int w, int h);
|
||||
static void XDestroyRegion(Fl_Region r);
|
||||
|
||||
protected:
|
||||
// --- implementation is in src/fl_vertex.cxx which includes src/cfg_gfx/xxx_rect.cxx
|
||||
void global_gc(void);
|
||||
|
15
FL/mac.H
15
FL/mac.H
@ -117,20 +117,7 @@ typedef float CGFloat;
|
||||
#endif
|
||||
#endif // CGFLOAT_DEFINED
|
||||
|
||||
extern CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h);
|
||||
inline Fl_Region 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_cgrectmake_cocoa(x, y, w, h);
|
||||
return R;
|
||||
}
|
||||
inline void XDestroyRegion(Fl_Region r) {
|
||||
if(r) {
|
||||
free(r->rects);
|
||||
free(r);
|
||||
}
|
||||
}
|
||||
//extern CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h);
|
||||
extern NSCursor *fl_default_cursor;
|
||||
|
||||
// This object contains all mac-specific stuff about a window:
|
||||
|
11
FL/win32.H
11
FL/win32.H
@ -45,17 +45,6 @@ typedef HWND Window;
|
||||
#define VK_APPS 0x5D
|
||||
#endif
|
||||
|
||||
// some random X equivalents
|
||||
struct XRectangle {int x, y, width, height;};
|
||||
extern Fl_Region XRectangleRegion(int x, int y, int w, int h);
|
||||
inline void XDestroyRegion(Fl_Region r) {DeleteObject(r);}
|
||||
inline void XClipBox(Fl_Region r,XRectangle* rect) {
|
||||
RECT win_rect; GetRgnBox(r,&win_rect);
|
||||
rect->x=win_rect.left;
|
||||
rect->y=win_rect.top;
|
||||
rect->width=win_rect.right-win_rect.left;
|
||||
rect->height=win_rect.bottom-win_rect.top;
|
||||
}
|
||||
// this object contains all win32-specific stuff about a window:
|
||||
// Warning: this object is highly subject to change!
|
||||
class FL_EXPORT Fl_X {
|
||||
|
1
FL/x.H
1
FL/x.H
@ -82,7 +82,6 @@ extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
|
||||
#if defined(FL_LIBRARY) || defined(FL_INTERNALS)
|
||||
extern FL_EXPORT Window fl_message_window;
|
||||
extern FL_EXPORT void *fl_xftfont;
|
||||
FL_EXPORT Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx
|
||||
|
||||
// access to core fonts:
|
||||
// This class provides a "smart pointer" that returns a pointer to an XFontStruct.
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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$".
|
||||
|
@ -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();
|
||||
|
@ -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$".
|
||||
//
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user