summaryrefslogtreecommitdiff
path: root/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-02-18 16:21:51 +0000
committerManolo Gouy <Manolo>2016-02-18 16:21:51 +0000
commitf33b45f1d30653fb5da4817089e38ff0a2413cfb (patch)
tree9edc759690defa581b00b6ada80bb334f4ac5da8 /src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx
parent6ce27012a9412c4964e0ae40c81ea92ff39a61d3 (diff)
Remove all uses of the fl_gc global variable. Towards a clean driver model.
fl_gc remains usable by the application as a hook into the system. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11189 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx')
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx212
1 files changed, 106 insertions, 106 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx
index debf15606..e641767d4 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx
@@ -38,162 +38,162 @@ extern float fl_quartz_line_width_;
// --- line and polygon drawing with integer coordinates
void Fl_Quartz_Graphics_Driver::point(int x, int y) {
- CGContextFillRect(fl_gc, CGRectMake(x - 0.5, y - 0.5, 1, 1) );
+ CGContextFillRect(gc, CGRectMake(x - 0.5, y - 0.5, 1, 1) );
}
void Fl_Quartz_Graphics_Driver::rect(int x, int y, int w, int h) {
if (w<=0 || h<=0) return;
- if ( (!has_feature(PRINTER)) && fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+ if ( (!has_feature(PRINTER)) && fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, true);
CGRect rect = CGRectMake(x, y, w-1, h-1);
- CGContextStrokeRect(fl_gc, rect);
- if ( (!has_feature(PRINTER)) && fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+ CGContextStrokeRect(gc, rect);
+ if ( (!has_feature(PRINTER)) && fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::rectf(int x, int y, int w, int h) {
if (w<=0 || h<=0) return;
CGRect rect = CGRectMake(x - 0.5, y - 0.5, w , h);
- CGContextFillRect(fl_gc, rect);
+ CGContextFillRect(gc, rect);
}
void Fl_Quartz_Graphics_Driver::line(int x, int y, int x1, int y1) {
- if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x1, y1);
- CGContextStrokePath(fl_gc);
- if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x1, y1);
+ CGContextStrokePath(gc);
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) {
- if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x1, y1);
- CGContextAddLineToPoint(fl_gc, x2, y2);
- CGContextStrokePath(fl_gc);
- if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x1, y1);
+ CGContextAddLineToPoint(gc, x2, y2);
+ CGContextStrokePath(gc);
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::xyline(int x, int y, int x1) {
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x1, y);
- CGContextStrokePath(fl_gc);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x1, y);
+ CGContextStrokePath(gc);
if (Fl_Display_Device::high_resolution()) {
/* On retina displays, all xyline() and yxline() functions produce lines that are half-unit
(or one pixel) too short at both ends. This is corrected by filling at both ends rectangles
of size one unit by line-width.
*/
- CGContextFillRect(fl_gc, CGRectMake(x-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
- CGContextFillRect(fl_gc, CGRectMake(x1-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
+ CGContextFillRect(gc, CGRectMake(x-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
+ CGContextFillRect(gc, CGRectMake(x1-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
}
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::xyline(int x, int y, int x1, int y2) {
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x1, y);
- CGContextAddLineToPoint(fl_gc, x1, y2);
- CGContextStrokePath(fl_gc);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x1, y);
+ CGContextAddLineToPoint(gc, x1, y2);
+ CGContextStrokePath(gc);
if (Fl_Display_Device::high_resolution()) {
- CGContextFillRect(fl_gc, CGRectMake(x-0.5, y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
- CGContextFillRect(fl_gc, CGRectMake(x1 - fl_quartz_line_width_/2, y2-0.5, fl_quartz_line_width_, 1));
+ CGContextFillRect(gc, CGRectMake(x-0.5, y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
+ CGContextFillRect(gc, CGRectMake(x1 - fl_quartz_line_width_/2, y2-0.5, fl_quartz_line_width_, 1));
}
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) {
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x1, y);
- CGContextAddLineToPoint(fl_gc, x1, y2);
- CGContextAddLineToPoint(fl_gc, x3, y2);
- CGContextStrokePath(fl_gc);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x1, y);
+ CGContextAddLineToPoint(gc, x1, y2);
+ CGContextAddLineToPoint(gc, x3, y2);
+ CGContextStrokePath(gc);
if (Fl_Display_Device::high_resolution()) {
- CGContextFillRect(fl_gc, CGRectMake(x-0.5, y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
- CGContextFillRect(fl_gc, CGRectMake(x3-0.5, y2 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
+ CGContextFillRect(gc, CGRectMake(x-0.5, y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
+ CGContextFillRect(gc, CGRectMake(x3-0.5, y2 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
}
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::yxline(int x, int y, int y1) {
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x, y1);
- CGContextStrokePath(fl_gc);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x, y1);
+ CGContextStrokePath(gc);
if (Fl_Display_Device::high_resolution()) {
- CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
- CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y1-0.5, fl_quartz_line_width_, 1));
+ CGContextFillRect(gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
+ CGContextFillRect(gc, CGRectMake(x - fl_quartz_line_width_/2, y1-0.5, fl_quartz_line_width_, 1));
}
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::yxline(int x, int y, int y1, int x2) {
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x, y1);
- CGContextAddLineToPoint(fl_gc, x2, y1);
- CGContextStrokePath(fl_gc);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x, y1);
+ CGContextAddLineToPoint(gc, x2, y1);
+ CGContextStrokePath(gc);
if (Fl_Display_Device::high_resolution()) {
- CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
- CGContextFillRect(fl_gc, CGRectMake(x2-0.5, y1 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
+ CGContextFillRect(gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
+ CGContextFillRect(gc, CGRectMake(x2-0.5, y1 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
}
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) {
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x, y1);
- CGContextAddLineToPoint(fl_gc, x2, y1);
- CGContextAddLineToPoint(fl_gc, x2, y3);
- CGContextStrokePath(fl_gc);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x, y1);
+ CGContextAddLineToPoint(gc, x2, y1);
+ CGContextAddLineToPoint(gc, x2, y3);
+ CGContextStrokePath(gc);
if (Fl_Display_Device::high_resolution()) {
- CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
- CGContextFillRect(fl_gc, CGRectMake(x2 - fl_quartz_line_width_/2, y3-0.5, fl_quartz_line_width_, 1));
+ CGContextFillRect(gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
+ CGContextFillRect(gc, CGRectMake(x2 - fl_quartz_line_width_/2, y3-0.5, fl_quartz_line_width_, 1));
}
- if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+ if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2) {
- CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x1, y1);
- CGContextAddLineToPoint(fl_gc, x2, y2);
- CGContextClosePath(fl_gc);
- CGContextStrokePath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, false);
+ CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x1, y1);
+ CGContextAddLineToPoint(gc, x2, y2);
+ CGContextClosePath(gc);
+ CGContextStrokePath(gc);
+ CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
- CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x1, y1);
- CGContextAddLineToPoint(fl_gc, x2, y2);
- CGContextAddLineToPoint(fl_gc, x3, y3);
- CGContextClosePath(fl_gc);
- CGContextStrokePath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, false);
+ CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x1, y1);
+ CGContextAddLineToPoint(gc, x2, y2);
+ CGContextAddLineToPoint(gc, x3, y3);
+ CGContextClosePath(gc);
+ CGContextStrokePath(gc);
+ CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int y2) {
- CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x1, y1);
- CGContextAddLineToPoint(fl_gc, x2, y2);
- CGContextClosePath(fl_gc);
- CGContextFillPath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, false);
+ CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x1, y1);
+ CGContextAddLineToPoint(gc, x2, y2);
+ CGContextClosePath(gc);
+ CGContextFillPath(gc);
+ CGContextSetShouldAntialias(gc, false);
}
void Fl_Quartz_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
- CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x1, y1);
- CGContextAddLineToPoint(fl_gc, x2, y2);
- CGContextAddLineToPoint(fl_gc, x3, y3);
- CGContextClosePath(fl_gc);
- CGContextFillPath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, false);
+ CGContextSetShouldAntialias(gc, true);
+ CGContextMoveToPoint(gc, x, y);
+ CGContextAddLineToPoint(gc, x1, y1);
+ CGContextAddLineToPoint(gc, x2, y2);
+ CGContextAddLineToPoint(gc, x3, y3);
+ CGContextClosePath(gc);
+ CGContextFillPath(gc);
+ CGContextSetShouldAntialias(gc, false);
}
// --- clipping
@@ -265,34 +265,34 @@ void Fl_Quartz_Graphics_Driver::pop_clip() {
restore_clip();
}
-// helper function to manage the current CGContext fl_gc
-extern void fl_quartz_restore_line_style_();
+// helper function to manage the current CGContext gc
+extern void fl_quartz_restore_line_style_(CGContextRef gc);
void Fl_Quartz_Graphics_Driver::restore_clip() {
fl_clip_state_number++;
Fl_Region r = rstack[rstackptr];
- if ( fl_window || fl_gc ) { // clipping for a true window or an offscreen buffer
- if (fl_gc) {
- CGContextRestoreGState(fl_gc);
- CGContextSaveGState(fl_gc);
+ if ( fl_window || gc ) { // clipping for a true window or an offscreen buffer
+ if (gc) {
+ CGContextRestoreGState(gc);
+ CGContextSaveGState(gc);
}
// FLTK has only one global graphics state.
// This copies the FLTK state into the current Quartz context
if ( ! fl_window ) { // a bitmap context
- CGFloat hgt = CGBitmapContextGetHeight(fl_gc);
- CGAffineTransform at = CGContextGetCTM(fl_gc);
+ CGFloat hgt = CGBitmapContextGetHeight(gc);
+ CGAffineTransform at = CGContextGetCTM(gc);
CGFloat offset = 0.5;
if (at.a != 1 && at.a == at.d && at.b == 0 && at.c == 0) { // proportional scaling, no rotation
hgt /= at.a;
offset /= at.a;
}
- CGContextTranslateCTM(fl_gc, offset, hgt-offset);
- CGContextScaleCTM(fl_gc, 1.0f, -1.0f); // now 0,0 is top-left point of the context
+ CGContextTranslateCTM(gc, offset, hgt-offset);
+ CGContextScaleCTM(gc, 1.0f, -1.0f); // now 0,0 is top-left point of the context
}
color(color());
- fl_quartz_restore_line_style_();
+ fl_quartz_restore_line_style_(gc);
if (r) { //apply program clip
- CGContextClipToRects(fl_gc, r->rects, r->count);
+ CGContextClipToRects(gc, r->rects, r->count);
}
}
}