Skip to content

Commit

Permalink
Move intersect_region_and_rect() to the Quartz driver code where it b…
Browse files Browse the repository at this point in the history
…elongs.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11500 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Apr 2, 2016
1 parent d756822 commit 7b37960
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
1 change: 0 additions & 1 deletion FL/mac.H
Expand Up @@ -167,7 +167,6 @@ public:
int set_cursor(const Fl_RGB_Image*, int, int);
static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h);
static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel);
static Fl_Region intersect_region_and_rect(Fl_Region current, int x,int y,int w, int h);
static void *get_carbon_function(const char *name);
static void screen_work_area(int &X, int &Y, int &W, int &H, int n); // compute work area of a given screen
static int next_marked_length; // next length of marked text after current marked text will have been replaced
Expand Down
24 changes: 0 additions & 24 deletions src/Fl_cocoa.mm
Expand Up @@ -3549,30 +3549,6 @@ static int get_plain_text_from_clipboard(int clipboard)
}


// 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 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));
int j = 0;
for(int i = 0; i < current->count; i++) {
CGRect test = CGRectIntersection(current->rects[i], r);
if (!CGRectIsEmpty(test)) outr->rects[j++] = test;
}
if (j) {
outr->count = j;
outr->rects = (CGRect*)realloc(outr->rects, outr->count * sizeof(CGRect));
}
else {
Fl_Graphics_Driver::XDestroyRegion(outr);
outr = Fl_Graphics_Driver::XRectangleRegion(0,0,0,0);
}
return outr;
}

void Fl_Cocoa_Window_Driver::iconize() {
[fl_xid(pWindow) miniaturize:nil];
}
Expand Down
27 changes: 26 additions & 1 deletion src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx
Expand Up @@ -199,14 +199,39 @@ void Fl_Quartz_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, in

// --- clipping

// intersects current and x,y,w,h rectangle and returns result as a new Fl_Region
static Fl_Region intersect_region_and_rect(Fl_Region current, int x,int y,int w, int 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));
int j = 0;
for(int i = 0; i < current->count; i++) {
CGRect test = CGRectIntersection(current->rects[i], r);
if (!CGRectIsEmpty(test)) outr->rects[j++] = test;
}
if (j) {
outr->count = j;
outr->rects = (CGRect*)realloc(outr->rects, outr->count * sizeof(CGRect));
}
else {
Fl_Graphics_Driver::XDestroyRegion(outr);
outr = Fl_Graphics_Driver::XRectangleRegion(0,0,0,0);
}
return outr;
}


void Fl_Quartz_Graphics_Driver::push_clip(int x, int y, int w, int h) {
Fl_Region r;
if (w > 0 && h > 0) {
r = XRectangleRegion(x,y,w,h);
Fl_Region current = rstack[rstackptr];
if (current) {
XDestroyRegion(r);
r = Fl_X::intersect_region_and_rect(current, x,y,w,h);
r = intersect_region_and_rect(current, x,y,w,h);
}
} else { // make empty clip region:
r = XRectangleRegion(0,0,0,0);
Expand Down

0 comments on commit 7b37960

Please sign in to comment.