From f33b45f1d30653fb5da4817089e38ff0a2413cfb Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Thu, 18 Feb 2016 16:21:51 +0000 Subject: 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 --- src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx | 25 +++++++++++- src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h | 6 ++- src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx | 6 +-- src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx | 8 ++-- .../Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx | 22 +++++------ src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx | 45 ++++++++++------------ .../Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx | 4 +- src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx | 44 ++++++++++----------- .../Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx | 10 ++--- 9 files changed, 95 insertions(+), 75 deletions(-) (limited to 'src/drivers/Xlib') diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx index dc8e84d00..b9ac31eff 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx @@ -3,7 +3,7 @@ // // Rectangle drawing routines 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 @@ -29,6 +29,17 @@ const char *Fl_Xlib_Graphics_Driver::class_id = "Fl_Xlib_Graphics_Driver"; +/* Reference to the current graphics context + For back-compatibility only. The preferred procedure to get this pointer is + Fl_Surface_Device::surface()->driver()->get_gc(). + */ +GC fl_gc = 0; + +void Fl_Graphics_Driver::global_gc() +{ + fl_gc = (GC)get_gc(); +} + /* * By linking this module, the following static method will instatiate the @@ -39,13 +50,23 @@ Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver() return new Fl_Xlib_Graphics_Driver(); } +GC Fl_Xlib_Graphics_Driver::gc = NULL; + +Fl_Xlib_Graphics_Driver::Fl_Xlib_Graphics_Driver(void) { + if (!gc) { + fl_open_display(); + // the unique GC used by all X windows + gc = XCreateGC(fl_display, RootWindow(fl_display, fl_screen), 0, 0); + } +} + char Fl_Xlib_Graphics_Driver::can_do_alpha_blending() { return Fl_X::xrender_supported(); } void Fl_Xlib_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { - XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y); + XCopyArea(fl_display, pixmap, fl_window, gc, srcx, srcy, w, h, x, y); } void Fl_Xlib_Graphics_Driver::copy_offscreen_with_alpha(int x, int y, int w, int h, diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h index 8cd086a2a..f1e34cc38 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h @@ -4,7 +4,7 @@ // Definition of classes Fl_Device, Fl_Graphics_Driver, Fl_Surface_Device, Fl_Display_Device // for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2014 by Bill Spitzak and others. +// Copyright 2010-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 @@ -33,10 +33,14 @@ This class is implemented only on the Xlib platform. */ class FL_EXPORT Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver { +protected: + static GC gc; public: static const char *class_id; + Fl_Xlib_Graphics_Driver(void); const char *class_name() {return class_id;}; virtual int has_feature(driver_feature mask) { return mask & NATIVE; } + virtual void *get_gc() { return gc; } char can_do_alpha_blending(); // --- bitmap stuff diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx index 8bc9bfc66..d7ee9a8e2 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx @@ -26,13 +26,13 @@ void Fl_Xlib_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) { if (w <= 0 || h <= 0) return; - XDrawArc(fl_display, fl_window, fl_gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); + XDrawArc(fl_display, fl_window, gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); } void Fl_Xlib_Graphics_Driver::pie(int x,int y,int w,int h,double a1,double a2) { if (w <= 0 || h <= 0) return; - XDrawArc(fl_display, fl_window, fl_gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); - XFillArc(fl_display, fl_window, fl_gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); + XDrawArc(fl_display, fl_window, gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); + XFillArc(fl_display, fl_window, gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); } // diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx index b36ce8a41..56c24bdef 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx @@ -115,15 +115,15 @@ void Fl_Xlib_Graphics_Driver::color(Fl_Color i) { fl_color((uchar)(rgb >> 24), (uchar)(rgb >> 16), (uchar)(rgb >> 8)); } else { Fl_Graphics_Driver::color(i); - if(!fl_gc) return; // don't get a default gc if current window is not yet created/valid - XSetForeground(fl_display, fl_gc, fl_xpixel(i)); + if(!gc) return; // don't get a default gc if current window is not yet created/valid + XSetForeground(fl_display, gc, fl_xpixel(i)); } } void Fl_Xlib_Graphics_Driver::color(uchar r,uchar g,uchar b) { Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) ); - if(!fl_gc) return; // don't get a default gc if current window is not yet created/valid - XSetForeground(fl_display, fl_gc, fl_xpixel(r,g,b)); + if(!gc) return; // don't get a default gc if current window is not yet created/valid + XSetForeground(fl_display, gc, fl_xpixel(r,g,b)); } /** \addtogroup fl_attributes diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx index 691c1f0d2..d275d7bba 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx @@ -642,14 +642,14 @@ double Fl_Xlib_Graphics_Driver::width(unsigned int c) { } void Fl_Xlib_Graphics_Driver::text_extents(const char *c, int n, int &dx, int &dy, int &W, int &H) { - if (font_gc != fl_gc) { + if (font_gc != gc) { if (!font_descriptor()) font(FL_HELVETICA, FL_NORMAL_SIZE); - font_gc = fl_gc; - XSetFont(fl_display, fl_gc, font_descriptor()->font->fid); + font_gc = gc; + XSetFont(fl_display, gc, font_descriptor()->font->fid); } int xx, yy, ww, hh; xx = yy = ww = hh = 0; - if (fl_gc) XUtf8_measure_extents(fl_display, fl_window, font_descriptor()->font, fl_gc, &xx, &yy, &ww, &hh, c, n); + if (gc) XUtf8_measure_extents(fl_display, fl_window, font_descriptor()->font, gc, &xx, &yy, &ww, &hh, c, n); W = ww; H = hh; dx = xx; dy = yy; // This is the safe but mostly wrong thing we used to do... @@ -660,12 +660,12 @@ void Fl_Xlib_Graphics_Driver::text_extents(const char *c, int n, int &dx, int &d } void Fl_Xlib_Graphics_Driver::draw(const char* c, int n, int x, int y) { - if (font_gc != fl_gc) { + if (font_gc != gc) { if (!font_descriptor()) this->font(FL_HELVETICA, FL_NORMAL_SIZE); - font_gc = fl_gc; - XSetFont(fl_display, fl_gc, font_descriptor()->font->fid); + font_gc = gc; + XSetFont(fl_display, gc, font_descriptor()->font->fid); } - if (fl_gc) XUtf8DrawString(fl_display, fl_window, font_descriptor()->font, fl_gc, x, y, c, n); + if (gc) XUtf8DrawString(fl_display, fl_window, font_descriptor()->font, gc, x, y, c, n); } void Fl_Xlib_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) { @@ -674,11 +674,11 @@ void Fl_Xlib_Graphics_Driver::draw(int angle, const char *str, int n, int x, int } void Fl_Xlib_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) { - if (font_gc != fl_gc) { + if (font_gc != gc) { if (!font_descriptor()) this->font(FL_HELVETICA, FL_NORMAL_SIZE); - font_gc = fl_gc; + font_gc = gc; } - if (fl_gc) XUtf8DrawRtlString(fl_display, fl_window, font_descriptor()->font, fl_gc, x, y, c, n); + if (gc) XUtf8DrawRtlString(fl_display, fl_window, font_descriptor()->font, gc, x, y, c, n); } #endif // FL_DOXYGEN // diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx index 924ddec3e..7e41bcb47 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx @@ -456,7 +456,7 @@ static void figure_out_visual() { 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, - const bool alpha) + const bool alpha, GC gc) { if (!linedelta) linedelta = W*delta; @@ -468,7 +468,6 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, if (!bytes_per_pixel) figure_out_visual(); const unsigned oldbpp = bytes_per_pixel; - const GC oldgc = fl_gc; static GC gc32 = None; xi.width = w; xi.height = h; @@ -486,7 +485,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, if (fl_visual->depth != 32) { if (gc32 == None) gc32 = XCreateGC(fl_display, fl_window, 0, NULL); - fl_gc = gc32; + gc = gc32; } } @@ -538,7 +537,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, buf += linedelta; to += linesize; } - XPutImage(fl_display,fl_window,fl_gc, &xi, 0, 0, X+dx, Y+dy+j-k, w, k); + XPutImage(fl_display,fl_window,gc, &xi, 0, 0, X+dx, Y+dy+j-k, w, k); } } else { STORETYPE* linebuf = new STORETYPE[(W*delta+(sizeof(STORETYPE)-1))/sizeof(STORETYPE)]; @@ -550,7 +549,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, conv((uchar*)linebuf, (uchar*)to, w, delta); to += linesize; } - XPutImage(fl_display,fl_window,fl_gc, &xi, 0, 0, X+dx, Y+dy+j-k, w, k); + XPutImage(fl_display,fl_window,gc, &xi, 0, 0, X+dx, Y+dy+j-k, w, k); } delete[] linebuf; @@ -561,10 +560,6 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, bytes_per_pixel = oldbpp; xi.depth = fl_visual->depth; xi.bits_per_pixel = oldbpp * 8; - - if (fl_visual->depth != 32) { - fl_gc = oldgc; - } } } @@ -573,7 +568,7 @@ void Fl_Xlib_Graphics_Driver::draw_image(const uchar* buf, int x, int y, int w, const bool alpha = !!(d & FL_IMAGE_WITH_ALPHA); d &= ~FL_IMAGE_WITH_ALPHA; - innards(buf,x,y,w,h,d,l,(d<3&&d>-3),0,0,alpha); + innards(buf,x,y,w,h,d,l,(d<3&&d>-3),0,0,alpha,gc); } void Fl_Xlib_Graphics_Driver::draw_image(Fl_Draw_Image_Cb cb, void* data, int x, int y, int w, int h,int d) { @@ -581,14 +576,14 @@ void Fl_Xlib_Graphics_Driver::draw_image(Fl_Draw_Image_Cb cb, void* data, const bool alpha = !!(d & FL_IMAGE_WITH_ALPHA); d &= ~FL_IMAGE_WITH_ALPHA; - innards(0,x,y,w,h,d,0,(d<3&&d>-3),cb,data,alpha); + innards(0,x,y,w,h,d,0,(d<3&&d>-3),cb,data,alpha,gc); } void Fl_Xlib_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,0); + innards(buf,x,y,w,h,d,l,1,0,0,0,gc); } void Fl_Xlib_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,0); + innards(0,x,y,w,h,d,0,1,cb,data,0,gc); } void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) { @@ -598,7 +593,7 @@ void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) { } else { uchar c[3]; c[0] = r; c[1] = g; c[2] = b; - innards(c,x,y,w,h,0,0,0,0,0,0); + innards(c,x,y,w,h,0,0,0,0,0,0,(GC)fl_graphics_driver->get_gc()); } } @@ -617,13 +612,13 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP return; } - XSetStipple(fl_display, fl_gc, bm->id_); + XSetStipple(fl_display, gc, bm->id_); int ox = X-cx; if (ox < 0) ox += bm->w(); int oy = Y-cy; if (oy < 0) oy += bm->h(); - XSetTSOrigin(fl_display, fl_gc, ox, oy); - XSetFillStyle(fl_display, fl_gc, FillStippled); - XFillRectangle(fl_display, fl_window, fl_gc, X, Y, W, H); - XSetFillStyle(fl_display, fl_gc, FillSolid); + XSetTSOrigin(fl_display, gc, ox, oy); + XSetFillStyle(fl_display, gc, FillStippled); + XFillRectangle(fl_display, fl_window, gc, X, Y, W, H); + XSetFillStyle(fl_display, gc, FillSolid); } @@ -734,10 +729,10 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, in cx += nx-X; X = nx; cy += ny-Y; Y = ny; // make X use the bitmap as a mask: - XSetClipMask(fl_display, fl_gc, img->mask_); + XSetClipMask(fl_display, gc, img->mask_); int ox = X-cx; if (ox < 0) ox += img->w(); int oy = Y-cy; if (oy < 0) oy += img->h(); - XSetClipOrigin(fl_display, fl_gc, X-cx, Y-cy); + XSetClipOrigin(fl_display, gc, X-cx, Y-cy); } if (img->d() == 4 && fl_can_do_alpha_blending()) @@ -747,7 +742,7 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, in if (img->mask_) { // put the old clip region back - XSetClipOrigin(fl_display, fl_gc, 0, 0); + XSetClipOrigin(fl_display, gc, 0, 0); fl_restore_clip(); } } else { @@ -783,8 +778,8 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int H if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return; if (pxm->mask_) { // make X use the bitmap as a mask: - XSetClipMask(fl_display, fl_gc, pxm->mask_); - XSetClipOrigin(fl_display, fl_gc, X-cx, Y-cy); + XSetClipMask(fl_display, gc, pxm->mask_); + XSetClipOrigin(fl_display, gc, X-cx, Y-cy); if (clip_region()) { // At this point, XYWH is the bounding box of the intersection between // the current clip region and the (portion of the) pixmap we have to draw. @@ -810,7 +805,7 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int H copy_offscreen(X, Y, W, H, pxm->id_, cx, cy); } // put the old clip region back - XSetClipOrigin(fl_display, fl_gc, 0, 0); + XSetClipOrigin(fl_display, gc, 0, 0); restore_clip(); } else copy_offscreen(X, Y, W, H, pxm->id_, cx, cy); diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx index 834682ea3..4aabe44b5 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx @@ -71,10 +71,10 @@ void Fl_Xlib_Graphics_Driver::line_style(int style, int width, char* dashes) { } static int Cap[4] = {CapButt, CapButt, CapRound, CapProjecting}; static int Join[4] = {JoinMiter, JoinMiter, JoinRound, JoinBevel}; - XSetLineAttributes(fl_display, fl_gc, width, + XSetLineAttributes(fl_display, gc, width, ndashes ? LineOnOffDash : LineSolid, Cap[(style>>8)&3], Join[(style>>12)&3]); - if (ndashes) XSetDashes(fl_display, fl_gc, 0, dashes, ndashes); + if (ndashes) XSetDashes(fl_display, gc, 0, dashes, ndashes); } #endif // FL_CFG_GFX_XLIB_LINE_STYLE_CXX diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx index 92328b088..04dbb5b05 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx @@ -162,23 +162,23 @@ Fl_Region XRectangleRegion(int x, int y, int w, int h) { // --- line and polygon drawing with integer coordinates void Fl_Xlib_Graphics_Driver::point(int x, int y) { - XDrawPoint(fl_display, fl_window, fl_gc, clip_x(x), clip_x(y)); + XDrawPoint(fl_display, fl_window, gc, clip_x(x), clip_x(y)); } void Fl_Xlib_Graphics_Driver::rect(int x, int y, int w, int h) { if (w<=0 || h<=0) return; if (!clip_to_short(x, y, w, h)) - XDrawRectangle(fl_display, fl_window, fl_gc, x, y, w-1, h-1); + XDrawRectangle(fl_display, fl_window, gc, x, y, w-1, h-1); } void Fl_Xlib_Graphics_Driver::rectf(int x, int y, int w, int h) { if (w<=0 || h<=0) return; if (!clip_to_short(x, y, w, h)) - XFillRectangle(fl_display, fl_window, fl_gc, x, y, w, h); + XFillRectangle(fl_display, fl_window, gc, x, y, w, h); } void Fl_Xlib_Graphics_Driver::line(int x, int y, int x1, int y1) { - XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y1); + XDrawLine(fl_display, fl_window, gc, x, y, x1, y1); } void Fl_Xlib_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) { @@ -186,18 +186,18 @@ void Fl_Xlib_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) p[0].x = x; p[0].y = y; p[1].x = x1; p[1].y = y1; p[2].x = x2; p[2].y = y2; - XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0); + XDrawLines(fl_display, fl_window, gc, p, 3, 0); } void Fl_Xlib_Graphics_Driver::xyline(int x, int y, int x1) { - XDrawLine(fl_display, fl_window, fl_gc, clip_x(x), clip_x(y), clip_x(x1), clip_x(y)); + XDrawLine(fl_display, fl_window, gc, clip_x(x), clip_x(y), clip_x(x1), clip_x(y)); } void Fl_Xlib_Graphics_Driver::xyline(int x, int y, int x1, int y2) { XPoint p[3]; p[0].x = clip_x(x); p[0].y = p[1].y = clip_x(y); p[1].x = p[2].x = clip_x(x1); p[2].y = clip_x(y2); - XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0); + XDrawLines(fl_display, fl_window, gc, p, 3, 0); } void Fl_Xlib_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) { @@ -205,18 +205,18 @@ void Fl_Xlib_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) { p[0].x = clip_x(x); p[0].y = p[1].y = clip_x(y); p[1].x = p[2].x = clip_x(x1); p[2].y = p[3].y = clip_x(y2); p[3].x = clip_x(x3); - XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); + XDrawLines(fl_display, fl_window, gc, p, 4, 0); } void Fl_Xlib_Graphics_Driver::yxline(int x, int y, int y1) { - XDrawLine(fl_display, fl_window, fl_gc, clip_x(x), clip_x(y), clip_x(x), clip_x(y1)); + XDrawLine(fl_display, fl_window, gc, clip_x(x), clip_x(y), clip_x(x), clip_x(y1)); } void Fl_Xlib_Graphics_Driver::yxline(int x, int y, int y1, int x2) { XPoint p[3]; p[0].x = p[1].x = clip_x(x); p[0].y = clip_x(y); p[1].y = p[2].y = clip_x(y1); p[2].x = clip_x(x2); - XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0); + XDrawLines(fl_display, fl_window, gc, p, 3, 0); } void Fl_Xlib_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) { @@ -224,7 +224,7 @@ void Fl_Xlib_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) { p[0].x = p[1].x = clip_x(x); p[0].y = clip_x(y); p[1].y = p[2].y = clip_x(y1); p[2].x = p[3].x = clip_x(x2); p[3].y = clip_x(y3); - XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); + XDrawLines(fl_display, fl_window, gc, p, 4, 0); } void Fl_Xlib_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2) { @@ -233,7 +233,7 @@ void Fl_Xlib_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2) p[1].x = x1; p[1].y = y1; p[2].x = x2; p[2].y = y2; p[3].x = x; p[3].y = y; - XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); + XDrawLines(fl_display, fl_window, gc, p, 4, 0); } void Fl_Xlib_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) { @@ -243,7 +243,7 @@ void Fl_Xlib_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2, p[2].x = x2; p[2].y = y2; p[3].x = x3; p[3].y = y3; p[4].x = x; p[4].y = y; - XDrawLines(fl_display, fl_window, fl_gc, p, 5, 0); + XDrawLines(fl_display, fl_window, gc, p, 5, 0); } void Fl_Xlib_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int y2) { @@ -252,8 +252,8 @@ void Fl_Xlib_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int p[1].x = x1; p[1].y = y1; p[2].x = x2; p[2].y = y2; p[3].x = x; p[3].y = y; - XFillPolygon(fl_display, fl_window, fl_gc, p, 3, Convex, 0); - XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); + XFillPolygon(fl_display, fl_window, gc, p, 3, Convex, 0); + XDrawLines(fl_display, fl_window, gc, p, 4, 0); } void Fl_Xlib_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) { @@ -263,8 +263,8 @@ void Fl_Xlib_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int p[2].x = x2; p[2].y = y2; p[3].x = x3; p[3].y = y3; p[4].x = x; p[4].y = y; - XFillPolygon(fl_display, fl_window, fl_gc, p, 4, Convex, 0); - XDrawLines(fl_display, fl_window, fl_gc, p, 5, 0); + XFillPolygon(fl_display, fl_window, gc, p, 4, Convex, 0); + XDrawLines(fl_display, fl_window, gc, p, 5, 0); } // --- clipping @@ -285,7 +285,7 @@ void Fl_Xlib_Graphics_Driver::push_clip(int x, int y, int w, int h) { } if (rstackptr < region_stack_max) rstack[++rstackptr] = r; else Fl::warning("Fl_Xlib_Graphics_Driver::push_clip: clip stack overflow!\n"); - fl_restore_clip(); + restore_clip(); } int Fl_Xlib_Graphics_Driver::clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){ @@ -325,7 +325,7 @@ int Fl_Xlib_Graphics_Driver::not_clipped(int x, int y, int w, int h) { void Fl_Xlib_Graphics_Driver::push_no_clip() { if (rstackptr < region_stack_max) rstack[++rstackptr] = 0; else Fl::warning("fl_push_no_cFl_Xlib_Graphics_Driver::push_no_cliplip: clip stack overflow!\n"); - fl_restore_clip(); + restore_clip(); } // pop back to previous clip: @@ -334,14 +334,14 @@ void Fl_Xlib_Graphics_Driver::pop_clip() { Fl_Region oldr = rstack[rstackptr--]; if (oldr) XDestroyRegion(oldr); } else Fl::warning("Fl_Xlib_Graphics_Driver::pop_clip: clip stack underflow!\n"); - fl_restore_clip(); + restore_clip(); } void Fl_Xlib_Graphics_Driver::restore_clip() { fl_clip_state_number++; Fl_Region r = rstack[rstackptr]; - if (r) XSetRegion(fl_display, fl_gc, r); - else XSetClipMask(fl_display, fl_gc, 0); + if (r) XSetRegion(fl_display, gc, r); + else XSetClipMask(fl_display, gc, 0); } #endif // FL_CFG_GFX_XLIB_RECT_CXX diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx index 4c559ad8c..b7d927873 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx @@ -41,7 +41,7 @@ void Fl_Xlib_Graphics_Driver::vertex(double x,double y) { } void Fl_Xlib_Graphics_Driver::end_points() { - if (n>1) XDrawPoints(fl_display, fl_window, fl_gc, p, n, 0); + if (n>1) XDrawPoints(fl_display, fl_window, gc, p, n, 0); } void Fl_Xlib_Graphics_Driver::end_line() { @@ -49,7 +49,7 @@ void Fl_Xlib_Graphics_Driver::end_line() { end_points(); return; } - if (n>1) XDrawLines(fl_display, fl_window, fl_gc, p, n, 0); + if (n>1) XDrawLines(fl_display, fl_window, gc, p, n, 0); } void Fl_Xlib_Graphics_Driver::end_loop() { @@ -64,7 +64,7 @@ void Fl_Xlib_Graphics_Driver::end_polygon() { end_line(); return; } - if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, Convex, 0); + if (n>2) XFillPolygon(fl_display, fl_window, gc, p, n, Convex, 0); } void Fl_Xlib_Graphics_Driver::begin_complex_polygon() { @@ -88,7 +88,7 @@ void Fl_Xlib_Graphics_Driver::end_complex_polygon() { end_line(); return; } - if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, 0, 0); + if (n>2) XFillPolygon(fl_display, fl_window, gc, p, n, 0, 0); } // shortcut the closed circles so they use XDrawArc: @@ -106,7 +106,7 @@ void Fl_Xlib_Graphics_Driver::circle(double x, double y,double r) { int h = (int)rint(yt+ry)-lly; (what == POLYGON ? XFillArc : XDrawArc) - (fl_display, fl_window, fl_gc, llx, lly, w, h, 0, 360*64); + (fl_display, fl_window, gc, llx, lly, w, h, 0, 360*64); } #endif // FL_CFG_GFX_XLIB_VERTEX_CXX -- cgit v1.2.3