diff options
| author | Manolo Gouy <Manolo> | 2016-02-19 12:40:24 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-02-19 12:40:24 +0000 |
| commit | 1b5e231c902ab198c577989db44946797ebd4893 (patch) | |
| tree | 211751e0eceda308df4e51d94511362f5e0b55f6 /src/drivers/Quartz | |
| parent | 6d766cc6814a9e7a04c0b147c7a3cbdc0817dfd4 (diff) | |
Rename Fl_Graphics_Driver::set_gc(void*) to gc(void*) and Fl_Graphics_Driver::get_gc() to gc().
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11191 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Quartz')
9 files changed, 200 insertions, 199 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx index 657e7eb26..8f14af883 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx @@ -25,13 +25,13 @@ const char *Fl_Quartz_Graphics_Driver::class_id = "Fl_Quartz_Graphics_Driver"; /* Reference to the current CGContext For back-compatibility only. The preferred procedure to get this reference is - Fl_Surface_Device::surface()->driver()->get_gc(). + Fl_Surface_Device::surface()->driver()->gc(). */ CGContextRef fl_gc = 0; void Fl_Graphics_Driver::global_gc() { - fl_gc = (CGContextRef)get_gc(); + fl_gc = (CGContextRef)gc(); } /* @@ -128,13 +128,13 @@ void fl_begin_offscreen(Fl_Offscreen ctx) { _ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); if (stack_ix<stack_max) { - stack_gc[stack_ix] = (CGContextRef)fl_graphics_driver->get_gc(); + stack_gc[stack_ix] = (CGContextRef)fl_graphics_driver->gc(); stack_window[stack_ix] = fl_window; } else fprintf(stderr, "FLTK CGContext Stack overflow error\n"); stack_ix++; - fl_graphics_driver->set_gc(ctx); + fl_graphics_driver->gc(ctx); fl_window = 0; CGContextSaveGState(ctx); fl_graphics_driver->push_no_clip(); @@ -145,7 +145,7 @@ void fl_begin_offscreen(Fl_Offscreen ctx) { */ void fl_end_offscreen() { fl_graphics_driver->pop_clip(); - CGContextRef gc = (CGContextRef)fl_graphics_driver->get_gc(); + CGContextRef gc = (CGContextRef)fl_graphics_driver->gc(); CGContextRestoreGState(gc); // matches CGContextSaveGState in fl_begin_offscreen() CGContextFlush(gc); @@ -154,7 +154,7 @@ void fl_end_offscreen() { else fprintf(stderr, "FLTK CGContext Stack underflow error\n"); if (stack_ix<stack_max) { - fl_graphics_driver->set_gc(stack_gc[stack_ix]); + fl_graphics_driver->gc(stack_gc[stack_ix]); fl_window = stack_window[stack_ix]; } _ss->set_current(); diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h index 3e069040f..b5565e30a 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h @@ -39,13 +39,14 @@ This class is implemented only on the Mac OS X platform. */ class Fl_Quartz_Graphics_Driver : public Fl_Graphics_Driver { - CGContextRef gc; +protected: + CGContextRef gc_; public: static const char *class_id; const char *class_name() {return class_id;}; virtual int has_feature(driver_feature mask) { return mask & NATIVE; } - virtual void set_gc(void *ctxt) {if (ctxt != gc) global_gc(); gc = (CGContextRef)ctxt; } - virtual void *get_gc() {return gc;} + virtual void gc(void *ctxt) {if (ctxt != gc_) global_gc(); gc_ = (CGContextRef)ctxt; } + virtual void *gc() {return gc_;} char can_do_alpha_blending(); // --- bitmap stuff diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx index 4b1a164df..d0f63fcee 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx @@ -30,42 +30,42 @@ void Fl_Quartz_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) if (w <= 0 || h <= 0) return; a1 = (-a1)/180.0f*M_PI; a2 = (-a2)/180.0f*M_PI; float cx = x + 0.5f*w - 0.5f, cy = y + 0.5f*h - 0.5f; - CGContextSetShouldAntialias(gc, true); + CGContextSetShouldAntialias(gc_, true); if (w!=h) { - CGContextSaveGState(gc); - CGContextTranslateCTM(gc, cx, cy); - CGContextScaleCTM(gc, w-1.0f, h-1.0f); - CGContextAddArc(gc, 0, 0, 0.5, a1, a2, 1); - CGContextRestoreGState(gc); + CGContextSaveGState(gc_); + CGContextTranslateCTM(gc_, cx, cy); + CGContextScaleCTM(gc_, w-1.0f, h-1.0f); + CGContextAddArc(gc_, 0, 0, 0.5, a1, a2, 1); + CGContextRestoreGState(gc_); } else { float r = (w+h)*0.25f-0.5f; - CGContextAddArc(gc, cx, cy, r, a1, a2, 1); + CGContextAddArc(gc_, cx, cy, r, a1, a2, 1); } - CGContextStrokePath(gc); - CGContextSetShouldAntialias(gc, false); + CGContextStrokePath(gc_); + CGContextSetShouldAntialias(gc_, false); } void Fl_Quartz_Graphics_Driver::pie(int x,int y,int w,int h,double a1,double a2) { if (w <= 0 || h <= 0) return; a1 = (-a1)/180.0f*M_PI; a2 = (-a2)/180.0f*M_PI; float cx = x + 0.5f*w - 0.5f, cy = y + 0.5f*h - 0.5f; - CGContextSetShouldAntialias(gc, true); + CGContextSetShouldAntialias(gc_, true); if (w!=h) { - CGContextSaveGState(gc); - CGContextTranslateCTM(gc, cx, cy); - CGContextScaleCTM(gc, w, h); - CGContextAddArc(gc, 0, 0, 0.5, a1, a2, 1); - CGContextAddLineToPoint(gc, 0, 0); - CGContextClosePath(gc); - CGContextRestoreGState(gc); + CGContextSaveGState(gc_); + CGContextTranslateCTM(gc_, cx, cy); + CGContextScaleCTM(gc_, w, h); + CGContextAddArc(gc_, 0, 0, 0.5, a1, a2, 1); + CGContextAddLineToPoint(gc_, 0, 0); + CGContextClosePath(gc_); + CGContextRestoreGState(gc_); } else { float r = (w+h)*0.25f; - CGContextAddArc(gc, cx, cy, r, a1, a2, 1); - CGContextAddLineToPoint(gc, cx, cy); - CGContextClosePath(gc); + CGContextAddArc(gc_, cx, cy, r, a1, a2, 1); + CGContextAddLineToPoint(gc_, cx, cy); + CGContextClosePath(gc_); } - CGContextFillPath(gc); - CGContextSetShouldAntialias(gc, false); + CGContextFillPath(gc_); + CGContextSetShouldAntialias(gc_, false); } #endif // FL_CFG_GFX_QUARTZ diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_color.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_color.cxx index c321419ee..f9dc9e484 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_color.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_color.cxx @@ -53,12 +53,12 @@ void Fl_Quartz_Graphics_Driver::color(Fl_Color i) { g = c>>16; b = c>> 8; } - if (!gc) return; // no context yet? We will assign the color later. + if (!gc_) return; // no context yet? We will assign the color later. float fr = r/255.0f; float fg = g/255.0f; float fb = b/255.0f; - CGContextSetRGBFillColor(gc, fr, fg, fb, 1.0f); - CGContextSetRGBStrokeColor(gc, fr, fg, fb, 1.0f); + CGContextSetRGBFillColor(gc_, fr, fg, fb, 1.0f); + CGContextSetRGBStrokeColor(gc_, fr, fg, fb, 1.0f); } void Fl_Quartz_Graphics_Driver::color(uchar r, uchar g, uchar b) { @@ -66,9 +66,9 @@ void Fl_Quartz_Graphics_Driver::color(uchar r, uchar g, uchar b) { float fr = r/255.0f; float fg = g/255.0f; float fb = b/255.0f; - if (!gc) return; // no context yet? We will assign the color later. - CGContextSetRGBFillColor(gc, fr, fg, fb, 1.0f); - CGContextSetRGBStrokeColor(gc, fr, fg, fb, 1.0f); + if (!gc_) return; // no context yet? We will assign the color later. + CGContextSetRGBFillColor(gc_, fr, fg, fb, 1.0f); + CGContextSetRGBStrokeColor(gc_, fr, fg, fb, 1.0f); } // FIXME: this function should not be here! It's not part of the driver. diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx index 1d909b488..48e2c8f19 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx @@ -580,7 +580,7 @@ if (fl_mac_os_version >= Fl_X::CoreText_threshold) { // activate the current GC iSize = sizeof(CGContextRef); iTag = kATSUCGContextTag; - iValuePtr = &gc; + iValuePtr = &gc_; ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr); // now measure the bounding box err = ATSUSetTextPointerLocation(layout, txt, kATSUFromTextBeginning, n, n); @@ -632,10 +632,10 @@ if (fl_mac_os_version >= Fl_X::CoreText_threshold) { CFRelease(str16); CTLineRef ctline = CTLineCreateWithAttributedString(mastr); CFRelease(mastr); - CGContextSetTextPosition(gc, 0, 0); - CGContextSetShouldAntialias(gc, true); - CGRect rect = CTLineGetImageBounds(ctline, gc); - CGContextSetShouldAntialias(gc, false); + CGContextSetTextPosition(gc_, 0, 0); + CGContextSetShouldAntialias(gc_, true); + CGRect rect = CTLineGetImageBounds(ctline, gc_); + CGContextSetShouldAntialias(gc_, false); CFRelease(ctline); dx = floor(rect.origin.x + 0.5); dy = floor(- rect.origin.y - rect.size.height + 0.5); @@ -657,7 +657,7 @@ else { // activate the current GC iSize = sizeof(CGContextRef); iTag = kATSUCGContextTag; - iValuePtr = &gc; + iValuePtr = &gc_; ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr); // now measure the bounding box err = ATSUSetTextPointerLocation(layout, txt, kATSUFromTextBeginning, n, n); @@ -692,6 +692,7 @@ static CGColorRef flcolortocgcolor(Fl_Color i) static void fl_mac_draw(const char *str, int n, float x, float y, Fl_Graphics_Driver *driver) { // convert to UTF-16 first UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n); + CGContextRef gc = (CGContextRef)driver->gc(); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if (fl_mac_os_version >= Fl_X::CoreText_threshold) { CFMutableStringRef str16 = CFStringCreateMutableWithExternalCharactersNoCopy(NULL, uniStr, n, n, kCFAllocatorNull); @@ -704,7 +705,6 @@ static void fl_mac_draw(const char *str, int n, float x, float y, Fl_Graphics_Dr CFRelease(color); CTLineRef ctline = CTLineCreateWithAttributedString(mastr); CFRelease(mastr); - CGContextRef gc = (CGContextRef)driver->get_gc(); CGContextSetTextMatrix(gc, font_mx); CGContextSetTextPosition(gc, x, y); CGContextSetShouldAntialias(gc, true); @@ -746,11 +746,11 @@ void Fl_Quartz_Graphics_Driver::draw(const char* str, int n, int x, int y) { } void Fl_Quartz_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) { - CGContextSaveGState(gc); - CGContextTranslateCTM(gc, x, y); - CGContextRotateCTM(gc, - angle*(M_PI/180) ); + CGContextSaveGState(gc_); + CGContextTranslateCTM(gc_, x, y); + CGContextRotateCTM(gc_, - angle*(M_PI/180) ); draw(str, n, 0, 0); - CGContextRestoreGState(gc); + CGContextRestoreGState(gc_); } void Fl_Quartz_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) { diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx index a36f34c82..e45e1abcb 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx @@ -3,7 +3,7 @@ // // MacOS image drawing code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2012 by Bill Spitzak and others. +// Copyright 1998-2016 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -142,18 +142,18 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, } void Fl_Quartz_Graphics_Driver::draw_image(const uchar* buf, int x, int y, int w, int h, int d, int l){ - innards(buf,x,y,w,h,d,l,(d<3&&d>-3),0,0,gc); + innards(buf,x,y,w,h,d,l,(d<3&&d>-3),0,0,gc_); } void Fl_Quartz_Graphics_Driver::draw_image(Fl_Draw_Image_Cb cb, void* data, int x, int y, int w, int h,int d) { - innards(0,x,y,w,h,d,0,(d<3&&d>-3),cb,data,gc); + innards(0,x,y,w,h,d,0,(d<3&&d>-3),cb,data,gc_); } void Fl_Quartz_Graphics_Driver::draw_image_mono(const uchar* buf, int x, int y, int w, int h, int d, int l){ - innards(buf,x,y,w,h,d,l,1,0,0,gc); + innards(buf,x,y,w,h,d,l,1,0,0,gc_); } void Fl_Quartz_Graphics_Driver::draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int x, int y, int w, int h,int d) { - innards(0,x,y,w,h,d,0,1,cb,data,gc); + innards(0,x,y,w,h,d,0,1,cb,data,gc_); } void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) { @@ -166,7 +166,7 @@ void Fl_Quartz_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int if (bm->start(XP, YP, WP, HP, cx, cy, X, Y, W, H)) { return; } - if (bm->id_ && gc) { + if (bm->id_ && gc_) { draw_CGImage((CGImageRef)bm->id_, X,Y,W,H, cx, cy, bm->w(), bm->h()); } } @@ -223,7 +223,7 @@ void Fl_Quartz_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, CGColorSpaceRelease(lut); CGDataProviderRelease(src); } - if (img->id_ && gc) { + if (img->id_ && gc_) { if (!img->alloc_array && has_feature(PRINTER) && !CGImageGetShouldInterpolate((CGImageRef)img->id_)) { // When printing, the image data is used when the page is completed, that is, after return from this function. // If the image has alloc_array = 0, we must protect against image data being freed before it is used: @@ -252,12 +252,12 @@ int Fl_Quartz_Graphics_Driver::draw_scaled(Fl_Image *img, int XP, int YP, int WP fl_clip_box(XP,YP,WP,HP,X,Y,W,H); // X,Y,W,H will give the unclipped area of XP,YP,WP,HP if (W == 0 || H == 0) return 1; fl_push_no_clip(); // remove the FLTK clip that can't be rescaled - CGContextSaveGState(gc); - CGContextClipToRect(gc, CGRectMake(X, Y, W, H)); // this clip path will be rescaled & translated - CGContextTranslateCTM(gc, XP, YP); - CGContextScaleCTM(gc, float(WP)/img->w(), float(HP)/img->h()); + CGContextSaveGState(gc_); + CGContextClipToRect(gc_, CGRectMake(X, Y, W, H)); // this clip path will be rescaled & translated + CGContextTranslateCTM(gc_, XP, YP); + CGContextScaleCTM(gc_, float(WP)/img->w(), float(HP)/img->h()); img->draw(0, 0, img->w(), img->h(), 0, 0); - CGContextRestoreGState(gc); + CGContextRestoreGState(gc_); fl_pop_clip(); // restore FLTK's clip return 1; } @@ -317,14 +317,14 @@ fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, cons void Fl_Quartz_Graphics_Driver::draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh) { CGRect rect = CGRectMake(x, y, w, h); - CGContextSaveGState(gc); - CGContextClipToRect(gc, CGRectOffset(rect, -0.5, -0.5 )); + CGContextSaveGState(gc_); + CGContextClipToRect(gc_, CGRectOffset(rect, -0.5, -0.5 )); // move graphics context to origin of vertically reversed image // The 0.5 here cancels the 0.5 offset present in Quartz graphics contexts. // Thus, image and surface pixels are in phase if there's no scaling. - CGContextTranslateCTM(gc, rect.origin.x - srcx - 0.5, rect.origin.y - srcy + sh - 0.5); - CGContextScaleCTM(gc, 1, -1); - CGAffineTransform at = CGContextGetCTM(gc); + CGContextTranslateCTM(gc_, rect.origin.x - srcx - 0.5, rect.origin.y - srcy + sh - 0.5); + CGContextScaleCTM(gc_, 1, -1); + CGAffineTransform at = CGContextGetCTM(gc_); if (at.a == at.d && at.b == 0 && at.c == 0) { // proportional scaling, no rotation // We handle x2 and /2 scalings that occur when drawing to // a double-resolution bitmap, and when drawing a double-resolution bitmap to display. @@ -345,10 +345,10 @@ void Fl_Quartz_Graphics_Driver::draw_CGImage(CGImageRef cgimg, int x, int y, int deltay = (at.ty - round(at.ty))*2; } } - if (doit) CGContextTranslateCTM(gc, -deltax, -deltay); + if (doit) CGContextTranslateCTM(gc_, -deltax, -deltay); } - CGContextDrawImage(gc, CGRectMake(0, 0, sw, sh), cgimg); - CGContextRestoreGState(gc); + CGContextDrawImage(gc_, CGRectMake(0, 0, sw, sh), cgimg); + CGContextRestoreGState(gc_); } // diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx index 9231b0581..134f6b2be 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx @@ -94,7 +94,7 @@ void Fl_Quartz_Graphics_Driver::line_style(int style, int width, char* dashes) { fl_quartz_line_pattern = 0; fl_quartz_line_pattern_size = 0; } - fl_quartz_restore_line_style_((CGContextRef)get_gc()); + fl_quartz_restore_line_style_((CGContextRef)gc()); } #endif // FL_CFG_GFX_QUARTZ diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx index e641767d4..277abfdfb 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(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(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(gc, rect); - if ( (!has_feature(PRINTER)) && fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(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(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(gc, true); - CGContextMoveToPoint(gc, x, y); - CGContextAddLineToPoint(gc, x1, y1); - CGContextStrokePath(gc); - if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(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(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); + 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(gc, true); - CGContextMoveToPoint(gc, x, y); - CGContextAddLineToPoint(gc, x1, y); - CGContextStrokePath(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(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_)); + 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(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(gc, true); - CGContextMoveToPoint(gc, x, y); - CGContextAddLineToPoint(gc, x1, y); - CGContextAddLineToPoint(gc, x1, y2); - CGContextStrokePath(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(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)); + 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(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(gc, true); - CGContextMoveToPoint(gc, x, y); - CGContextAddLineToPoint(gc, x1, y); - CGContextAddLineToPoint(gc, x1, y2); - CGContextAddLineToPoint(gc, x3, y2); - CGContextStrokePath(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(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_)); + 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(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(gc, true); - CGContextMoveToPoint(gc, x, y); - CGContextAddLineToPoint(gc, x, y1); - CGContextStrokePath(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(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)); + 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(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(gc, true); - CGContextMoveToPoint(gc, x, y); - CGContextAddLineToPoint(gc, x, y1); - CGContextAddLineToPoint(gc, x2, y1); - CGContextStrokePath(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(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_)); + 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(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(gc, true); - CGContextMoveToPoint(gc, x, y); - CGContextAddLineToPoint(gc, x, y1); - CGContextAddLineToPoint(gc, x2, y1); - CGContextAddLineToPoint(gc, x2, y3); - CGContextStrokePath(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(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)); + 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(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(gc, true); - CGContextMoveToPoint(gc, x, y); - CGContextAddLineToPoint(gc, x1, y1); - CGContextAddLineToPoint(gc, x2, y2); - CGContextClosePath(gc); - CGContextStrokePath(gc); - CGContextSetShouldAntialias(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(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); + 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(gc, true); - CGContextMoveToPoint(gc, x, y); - CGContextAddLineToPoint(gc, x1, y1); - CGContextAddLineToPoint(gc, x2, y2); - CGContextClosePath(gc); - CGContextFillPath(gc); - CGContextSetShouldAntialias(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(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); + 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 @@ -271,28 +271,28 @@ 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 || gc ) { // clipping for a true window or an offscreen buffer - if (gc) { - CGContextRestoreGState(gc); - CGContextSaveGState(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(gc); - CGAffineTransform at = CGContextGetCTM(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(gc, offset, hgt-offset); - CGContextScaleCTM(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_(gc); + fl_quartz_restore_line_style_(gc_); if (r) { //apply program clip - CGContextClipToRects(gc, r->rects, r->count); + CGContextClipToRects(gc_, r->rects, r->count); } } } diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx index 6400c5056..1ff8755e8 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx @@ -41,13 +41,13 @@ void Fl_Quartz_Graphics_Driver::vertex(double x,double y) { } void Fl_Quartz_Graphics_Driver::end_points() { - if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, true); + if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true); for (int i=0; i<n; i++) { - CGContextMoveToPoint(gc, p[i].x, p[i].y); - CGContextAddLineToPoint(gc, p[i].x, p[i].y); - CGContextStrokePath(gc); + CGContextMoveToPoint(gc_, p[i].x, p[i].y); + CGContextAddLineToPoint(gc_, p[i].x, p[i].y); + CGContextStrokePath(gc_); } - if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc, false); + if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false); } void Fl_Quartz_Graphics_Driver::end_line() { @@ -56,12 +56,12 @@ void Fl_Quartz_Graphics_Driver::end_line() { return; } if (n<=1) return; - CGContextSetShouldAntialias(gc, true); - CGContextMoveToPoint(gc, p[0].x, p[0].y); + CGContextSetShouldAntialias(gc_, true); + CGContextMoveToPoint(gc_, p[0].x, p[0].y); for (int i=1; i<n; i++) - CGContextAddLineToPoint(gc, p[i].x, p[i].y); - CGContextStrokePath(gc); - CGContextSetShouldAntialias(gc, false); + CGContextAddLineToPoint(gc_, p[i].x, p[i].y); + CGContextStrokePath(gc_); + CGContextSetShouldAntialias(gc_, false); } void Fl_Quartz_Graphics_Driver::end_loop() { @@ -77,13 +77,13 @@ void Fl_Quartz_Graphics_Driver::end_polygon() { return; } if (n<=1) return; - CGContextSetShouldAntialias(gc, true); - CGContextMoveToPoint(gc, p[0].x, p[0].y); + CGContextSetShouldAntialias(gc_, true); + CGContextMoveToPoint(gc_, p[0].x, p[0].y); for (int i=1; i<n; i++) - CGContextAddLineToPoint(gc, p[i].x, p[i].y); - CGContextClosePath(gc); - CGContextFillPath(gc); - CGContextSetShouldAntialias(gc, false); + CGContextAddLineToPoint(gc_, p[i].x, p[i].y); + CGContextClosePath(gc_); + CGContextFillPath(gc_); + CGContextSetShouldAntialias(gc_, false); } void Fl_Quartz_Graphics_Driver::begin_complex_polygon() { @@ -108,13 +108,13 @@ void Fl_Quartz_Graphics_Driver::end_complex_polygon() { return; } if (n<=1) return; - CGContextSetShouldAntialias(gc, true); - CGContextMoveToPoint(gc, p[0].x, p[0].y); + CGContextSetShouldAntialias(gc_, true); + CGContextMoveToPoint(gc_, p[0].x, p[0].y); for (int i=1; i<n; i++) - CGContextAddLineToPoint(gc, p[i].x, p[i].y); - CGContextClosePath(gc); - CGContextFillPath(gc); - CGContextSetShouldAntialias(gc, false); + CGContextAddLineToPoint(gc_, p[i].x, p[i].y); + CGContextClosePath(gc_); + CGContextFillPath(gc_); + CGContextSetShouldAntialias(gc_, false); } void Fl_Quartz_Graphics_Driver::circle(double x, double y,double r) { @@ -129,10 +129,10 @@ void Fl_Quartz_Graphics_Driver::circle(double x, double y,double r) { // Quartz warning: circle won't scale to current matrix! // Last argument must be 0 (counter-clockwise) or it draws nothing under __LP64__ !!!! - CGContextSetShouldAntialias(gc, true); - CGContextAddArc(gc, xt, yt, (w+h)*0.25f, 0, 2.0f*M_PI, 0); - (what == POLYGON ? CGContextFillPath : CGContextStrokePath)(gc); - CGContextSetShouldAntialias(gc, false); + CGContextSetShouldAntialias(gc_, true); + CGContextAddArc(gc_, xt, yt, (w+h)*0.25f, 0, 2.0f*M_PI, 0); + (what == POLYGON ? CGContextFillPath : CGContextStrokePath)(gc_); + CGContextSetShouldAntialias(gc_, false); } #endif // FL_CFG_GFX_QUARTZ |
