summaryrefslogtreecommitdiff
path: root/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.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_image.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_image.cxx')
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
index e1fa62e42..a36f34c82 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
@@ -51,7 +51,7 @@ static void dataReleaseCB(void *info, const void *data, size_t size)
*/
static void innards(const uchar *buf, int X, int Y, int W, int H,
int delta, int linedelta, int mono,
- Fl_Draw_Image_Cb cb, void* userdata)
+ Fl_Draw_Image_Cb cb, void* userdata, CGContextRef gc)
{
if (!linedelta) linedelta = W*delta;
@@ -79,7 +79,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
lut = CGColorSpaceCreateDeviceGray();
else
lut = CGColorSpaceCreateDeviceRGB();
- // a release callback is necessary when the fl_gc is a print context because the image data
+ // a release callback is necessary when the gc is a print context because the image data
// must be kept until the page is closed. Thus tmpBuf can't be deleted here. It's too early.
CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, linedelta*H,
tmpBuf ? dataReleaseCB : NULL
@@ -98,7 +98,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
CGDataProviderRelease(src);
if (img) return; // else fall through to slow mode
// following the very save (and very slow) way to write the image into the give port
- CGContextSetShouldAntialias(fl_gc, false);
+ CGContextSetShouldAntialias(gc, false);
if ( cb )
{
uchar *tmpBuf = new uchar[ W*4 ];
@@ -112,9 +112,9 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
{ fl_color( src[0], src[0], src[0] ); }
else
{ fl_color( src[0], src[1], src[2] ); }
- CGContextMoveToPoint(fl_gc, X+j, Y+i);
- CGContextAddLineToPoint(fl_gc, X+j, Y+i);
- CGContextStrokePath(fl_gc);
+ CGContextMoveToPoint(gc, X+j, Y+i);
+ CGContextAddLineToPoint(gc, X+j, Y+i);
+ CGContextStrokePath(gc);
src+=delta;
}
}
@@ -131,29 +131,29 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
fl_color( src[0], src[0], src[0] );
else
fl_color( src[0], src[1], src[2] );
- CGContextMoveToPoint(fl_gc, X+j, Y+i);
- CGContextAddLineToPoint(fl_gc, X+j, Y+i);
- CGContextStrokePath(fl_gc);
+ CGContextMoveToPoint(gc, X+j, Y+i);
+ CGContextAddLineToPoint(gc, X+j, Y+i);
+ CGContextStrokePath(gc);
src += delta;
}
}
}
- CGContextSetShouldAntialias(fl_gc, true);
+ CGContextSetShouldAntialias(gc, true);
}
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);
+ 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);
+ 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);
+ 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);
+ 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_ && fl_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_ && fl_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(fl_gc);
- CGContextClipToRect(fl_gc, CGRectMake(X, Y, W, H)); // this clip path will be rescaled & translated
- CGContextTranslateCTM(fl_gc, XP, YP);
- CGContextScaleCTM(fl_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(fl_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(fl_gc);
- CGContextClipToRect(fl_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(fl_gc, rect.origin.x - srcx - 0.5, rect.origin.y - srcy + sh - 0.5);
- CGContextScaleCTM(fl_gc, 1, -1);
- CGAffineTransform at = CGContextGetCTM(fl_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(fl_gc, -deltax, -deltay);
+ if (doit) CGContextTranslateCTM(gc, -deltax, -deltay);
}
- CGContextDrawImage(fl_gc, CGRectMake(0, 0, sw, sh), cgimg);
- CGContextRestoreGState(fl_gc);
+ CGContextDrawImage(gc, CGRectMake(0, 0, sw, sh), cgimg);
+ CGContextRestoreGState(gc);
}
//