diff options
| author | Manolo Gouy <Manolo> | 2016-03-26 14:36:11 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-03-26 14:36:11 +0000 |
| commit | 915d6c643a8b4e31ea79fdad81761d26b42530f5 (patch) | |
| tree | 8756c72f988596beb8e55382f40ff04142816057 /src/drivers | |
| parent | e86e4a6ab0e3ad8ccbb694909383f5d72b9b4c92 (diff) | |
Isolate the definition of the 3 public, OS-dependent types (Fl_Offscreen, Fl_Region, Fl_Bitmask).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11432 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers')
28 files changed, 127 insertions, 34 deletions
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm index 525e545c0..188828da4 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm +++ b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm @@ -22,6 +22,7 @@ #include "../Quartz/Fl_Quartz_Printer_Graphics_Driver.H" #include <FL/Fl.H> +#include <FL/x.H> #include <FL/fl_ask.H> #include <FL/fl_draw.H> #import <Cocoa/Cocoa.h> diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx index f3fba0131..22a819dcb 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx +++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx @@ -23,6 +23,7 @@ #include <FL/Fl_Overlay_Window.H> #include <FL/fl_draw.H> #include <FL/Fl.H> +#include <FL/x.H> Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *w) diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.H b/src/drivers/Darwin/Fl_Darwin_System_Driver.H index 370a06316..05bd41e9f 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.H +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.H @@ -27,10 +27,14 @@ #include <FL/Fl_System_Driver.H> +typedef struct CGContext* Fl_Offscreen; +typedef struct CGImage* Fl_Bitmask; +typedef struct flCocoaRegion* Fl_Region; + /* Move everything here that manages the system interface. - There is excatly one system driver. + There is exactly one system driver. - filename and pathname management - directory and file access diff --git a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx index 1f6149052..c7f3d401a 100644 --- a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx @@ -20,6 +20,7 @@ #ifdef FL_CFG_GFX_GDI #include <FL/Fl_Copy_Surface.H> +#include <FL/x.H> #include "Fl_GDI_Graphics_Driver.H" #include <windows.h> diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H index a25274e08..4d4a50bd1 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H @@ -42,8 +42,11 @@ protected: uchar **mask_bitmap_; uchar **mask_bitmap() {return mask_bitmap_;} void mask_bitmap(uchar **value) { mask_bitmap_ = value; } + int p_size; + POINT *p; public: - Fl_GDI_Graphics_Driver() {mask_bitmap_ = NULL;} + Fl_GDI_Graphics_Driver() {mask_bitmap_ = NULL; gc_ = NULL; p_size = 0; p = NULL;} + virtual ~Fl_GDI_Graphics_Driver() { if (p) free(p); } virtual int has_feature(driver_feature mask) { return mask & NATIVE; } char can_do_alpha_blending(); virtual void gc(void *ctxt) {if (ctxt != gc_) global_gc(); gc_ = (HDC)ctxt;} @@ -76,6 +79,8 @@ public: #endif void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); protected: + void transformed_vertex0(int x, int y); + void fixloop(); // --- implementation is in src/fl_rect.cxx which includes src/cfg_gfx/gdi_rect.cxx void point(int x, int y); void rect(int x, int y, int w, int h); diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx index 15defb9eb..4af0b129f 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx @@ -21,6 +21,7 @@ #include "../../config_lib.h" #include "Fl_GDI_Graphics_Driver.H" #include <FL/Fl.H> +#include <FL/x.H> /* Reference to the current device context @@ -150,6 +151,23 @@ void Fl_Graphics_Driver::add_rectangle_to_region(Fl_Region r, int X, int Y, int XDestroyRegion(R); } +void Fl_GDI_Graphics_Driver::transformed_vertex0(int x, int y) { + if (!n || x != p[n-1].x || y != p[n-1].y) { + if (n >= p_size) { + p_size = p ? 2*p_size : 16; + p = (POINT*)realloc((void*)p, p_size*sizeof(*p)); + } + p[n].x = x; + p[n].y = y; + n++; + } +} + +void Fl_GDI_Graphics_Driver::fixloop() { // remove equal points from closed path + while (n>2 && p[n-1].x == p[0].x && p[n-1].y == p[0].y) n--; +} + + // // End of "$Id$". // diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_arci.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_arci.cxx index 23aa0c542..83f7fbeda 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_arci.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_arci.cxx @@ -33,6 +33,7 @@ #include "Fl_GDI_Graphics_Driver.H" #include <FL/math.h> +#include <FL/x.h> void Fl_GDI_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) { if (w <= 0 || h <= 0) return; diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx index fdff2fe1b..3ef206488 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx @@ -140,7 +140,7 @@ void Fl_GDI_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2, } void Fl_GDI_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int y2) { - XPoint p[3]; + POINT p[3]; p[0].x = x; p[0].y = y; p[1].x = x1; p[1].y = y1; p[2].x = x2; p[2].y = y2; @@ -149,7 +149,7 @@ void Fl_GDI_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int y } void Fl_GDI_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) { - XPoint p[4]; + POINT p[4]; p[0].x = x; p[0].y = y; p[1].x = x1; p[1].y = y1; p[2].x = x2; p[2].y = y2; diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx index e5d857f7e..e4ce856b1 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx @@ -33,11 +33,11 @@ void Fl_GDI_Graphics_Driver::transformed_vertex(double xf, double yf) { - transformed_vertex0(COORD_T(rint(xf)), COORD_T(rint(yf))); + transformed_vertex0(int(rint(xf)), int(rint(yf))); } void Fl_GDI_Graphics_Driver::vertex(double x,double y) { - transformed_vertex0(COORD_T(x*m.a + y*m.c + m.x), COORD_T(x*m.b + y*m.d + m.y)); + transformed_vertex0(int(x*m.a + y*m.c + m.x), int(x*m.b + y*m.d + m.y)); } void Fl_GDI_Graphics_Driver::end_points() { @@ -54,7 +54,7 @@ void Fl_GDI_Graphics_Driver::end_line() { void Fl_GDI_Graphics_Driver::end_loop() { fixloop(); - if (n>2) transformed_vertex((COORD_T)p[0].x, (COORD_T)p[0].y); + if (n>2) transformed_vertex((int)p[0].x, (int)p[0].y); end_line(); } @@ -79,7 +79,7 @@ void Fl_GDI_Graphics_Driver::begin_complex_polygon() { void Fl_GDI_Graphics_Driver::gap() { while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--; if (n > gap_+2) { - transformed_vertex((COORD_T)p[gap_].x, (COORD_T)p[gap_].y); + transformed_vertex((int)p[gap_].x, (int)p[gap_].y); counts[numcount++] = n-gap_; gap_ = n; } else { diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H index 23986e848..775253178 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H +++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H @@ -56,7 +56,7 @@ public: void pop_clip(); void restore_clip(); // --- implementation is in src/fl_vertex.cxx which includes src/cfg_gfx/xxx_rect.cxx - void transformed_vertex0(COORD_T x, COORD_T y); + //void transformed_vertex0(double x, double y); void transformed_vertex(double xf, double yf); void vertex(double x, double y); void begin_points(); diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx index bb6b03dcf..cbbb68f14 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx +++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx @@ -99,12 +99,8 @@ void Fl_OpenGL_Graphics_Driver::transformed_vertex(double xf, double yf) { glVertex2d(xf, yf); } -void Fl_OpenGL_Graphics_Driver::transformed_vertex0(COORD_T x, COORD_T y) { - glVertex2d(x, y); -} - void Fl_OpenGL_Graphics_Driver::vertex(double x,double y) { - transformed_vertex0(x*m.a + y*m.c + m.x, x*m.b + y*m.d + m.y); + transformed_vertex(x*m.a + y*m.c + m.x, x*m.b + y*m.d + m.y); } void Fl_OpenGL_Graphics_Driver::circle(double cx, double cy, double r) { diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.H b/src/drivers/Posix/Fl_Posix_System_Driver.H index bf4fb6c92..3df22092c 100644 --- a/src/drivers/Posix/Fl_Posix_System_Driver.H +++ b/src/drivers/Posix/Fl_Posix_System_Driver.H @@ -27,10 +27,14 @@ #include <FL/Fl_System_Driver.H> +typedef unsigned long Fl_Offscreen; +typedef unsigned long Fl_Bitmask; +typedef struct _XRegion *Fl_Region; + /* Move everything here that manages the system interface. - There is excatly one system driver. + There is exactly one system driver. - filename and pathname management - directory and file access diff --git a/src/drivers/PostScript/Fl_PostScript.cxx b/src/drivers/PostScript/Fl_PostScript.cxx index 7de93e48c..35eb6f77a 100644 --- a/src/drivers/PostScript/Fl_PostScript.cxx +++ b/src/drivers/PostScript/Fl_PostScript.cxx @@ -18,6 +18,7 @@ #include <config.h> #include <FL/Fl.H> +#include <FL/x.H> #include <FL/fl_ask.H> #include <FL/fl_draw.H> #include <stdio.h> diff --git a/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.cxx index 8488d5b8e..da400e5d3 100644 --- a/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.cxx @@ -20,6 +20,7 @@ #ifdef FL_CFG_GFX_QUARTZ #include <FL/Fl_Copy_Surface.H> +#include <FL/x.H> #include "Fl_Quartz_Graphics_Driver.H" class Fl_Quartz_Copy_Surface_Driver : public Fl_Copy_Surface_Driver { diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H index 94bbf000c..7530c331f 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H @@ -26,12 +26,7 @@ #define FL_QUARTZ_GRAPHICS_DRIVER_H #include <FL/Fl_Graphics_Driver.H> - -// typedef what the x,y fields in a point are: -// FIXME: this is still defined in Fl_Device.H, but should be invisible to the user -//typedef float COORD_T; -//typedef struct { float x; float y; } QPoint; - +#include <ApplicationServices/ApplicationServices.h> /** \brief The Mac OS X-specific graphics class. @@ -41,7 +36,12 @@ class Fl_Quartz_Graphics_Driver : public Fl_Graphics_Driver { protected: CGContextRef gc_; + int p_size; + typedef struct { float x; float y; } XPOINT; + XPOINT *p; public: + Fl_Quartz_Graphics_Driver() : Fl_Graphics_Driver(), gc_(NULL), p_size(0), p(NULL) {} + virtual ~Fl_Quartz_Graphics_Driver() { if (p) free(p); } virtual int has_feature(driver_feature mask) { return mask & NATIVE; } virtual void gc(void *ctxt) {if (ctxt != gc_) global_gc(); gc_ = (CGContextRef)ctxt; } virtual void *gc() {return gc_;} @@ -64,6 +64,8 @@ public: void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); void draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh); protected: + void transformed_vertex0(float x, float y); + void fixloop(); // --- implementation is in src/fl_rect.cxx which includes src/cfg_gfx/quartz_rect.cxx void point(int x, int y); void rect(int x, int y, int w, int h); @@ -122,6 +124,8 @@ protected: int descent(); }; +extern float fl_quartz_line_width_; + #endif // FL_QUARTZ_GRAPHICS_DRIVER_H // diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx index 6fdc3461e..a829534d3 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx @@ -19,6 +19,7 @@ #include "../../config_lib.h" #include "Fl_Quartz_Graphics_Driver.H" +#include <FL/x.H> /* Reference to the current CGContext For back-compatibility only. The preferred procedure to get this reference is diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx index d0f63fcee..7dc6d7268 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx @@ -20,6 +20,7 @@ #ifdef FL_CFG_GFX_QUARTZ #include "Fl_Quartz_Graphics_Driver.h" +#include <FL/x.H> /** \file quartz_arci.cxx diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx index 7e0b22dec..8840d4a4f 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx @@ -22,6 +22,7 @@ #include "Fl_Quartz_Graphics_Driver.h" #include <math.h> #include <FL/Fl.H> +#include <FL/x.H> #include <FL/fl_utf8.h> Fl_Fontdesc* fl_fonts = NULL; 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 134f6b2be..a9583474b 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx @@ -20,6 +20,7 @@ #ifdef FL_CFG_GFX_QUARTZ #include <FL/fl_draw.H> +#include <FL/x.H> extern int fl_line_width_; diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx index 277abfdfb..41c4c5cdd 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx @@ -21,6 +21,7 @@ #ifdef FL_CFG_GFX_QUARTZ #include <FL/Fl.H> +#include <FL/x.H> /** diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx index 1ff8755e8..0de553c87 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx @@ -33,11 +33,11 @@ void Fl_Quartz_Graphics_Driver::transformed_vertex(double xf, double yf) { - transformed_vertex0(COORD_T(xf), COORD_T(yf)); + transformed_vertex0(float(xf), float(yf)); } void Fl_Quartz_Graphics_Driver::vertex(double x,double y) { - transformed_vertex0(COORD_T(x*m.a + y*m.c + m.x), COORD_T(x*m.b + y*m.d + m.y)); + transformed_vertex0(float(x*m.a + y*m.c + m.x), float(x*m.b + y*m.d + m.y)); } void Fl_Quartz_Graphics_Driver::end_points() { @@ -66,7 +66,7 @@ void Fl_Quartz_Graphics_Driver::end_line() { void Fl_Quartz_Graphics_Driver::end_loop() { fixloop(); - if (n>2) transformed_vertex((COORD_T)p[0].x, (COORD_T)p[0].y); + if (n>2) transformed_vertex((float)p[0].x, (float)p[0].y); end_line(); } @@ -94,7 +94,7 @@ void Fl_Quartz_Graphics_Driver::begin_complex_polygon() { void Fl_Quartz_Graphics_Driver::gap() { while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--; if (n > gap_+2) { - transformed_vertex((COORD_T)p[gap_].x, (COORD_T)p[gap_].y); + transformed_vertex((float)p[gap_].x, (float)p[gap_].y); gap_ = n; } else { n = gap_; @@ -135,6 +135,23 @@ void Fl_Quartz_Graphics_Driver::circle(double x, double y,double r) { CGContextSetShouldAntialias(gc_, false); } +void Fl_Quartz_Graphics_Driver::transformed_vertex0(float x, float y) { + if (!n || x != p[n-1].x || y != p[n-1].y) { + if (n >= p_size) { + p_size = p ? 2*p_size : 16; + p = (XPOINT*)realloc((void*)p, p_size*sizeof(*p)); + } + p[n].x = x; + p[n].y = y; + n++; + } +} + +void Fl_Quartz_Graphics_Driver::fixloop() { // remove equal points from closed path + while (n>2 && p[n-1].x == p[0].x && p[n-1].y == p[0].y) n--; +} + + #endif // FL_CFG_GFX_QUARTZ // diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H index accc6d29b..691f3c507 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H @@ -27,10 +27,15 @@ #include <FL/Fl_System_Driver.H> +typedef struct HBITMAP__ *HBITMAP; +typedef HBITMAP Fl_Offscreen; +typedef HBITMAP Fl_Bitmask; +typedef struct HRGN__ *Fl_Region; + /* Move everything here that manages the system interface. - There is excatly one system driver. + There is exactly one system driver. - filename and pathname management - directory and file access diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx index cad3f3c4b..79939410a 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx @@ -28,6 +28,7 @@ #include <FL/fl_draw.H> #include <FL/fl_ask.H> #include <FL/Fl.H> +#include <FL/x.H> #include <string.h> #if HAVE_DLFCN_H #include <dlfcn.h> diff --git a/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx index 8615fbb8b..3cb07dbd5 100644 --- a/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx @@ -21,6 +21,7 @@ #ifdef FL_CFG_GFX_XLIB #include <FL/Fl_Copy_Surface.H> #include <FL/Fl.H> +#include <FL/x.H> #include <FL/fl_draw.H> #include "Fl_Translated_Xlib_Graphics_Driver.H" diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H index d9f0d7135..4d4a1ab30 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H @@ -26,6 +26,7 @@ #define FL_CFG_GFX_XLIB_H #include <FL/Fl_Graphics_Driver.H> +#include <FL/x.H> /** \brief The Xlib-specific graphics class. @@ -38,8 +39,12 @@ protected: uchar **mask_bitmap_; uchar **mask_bitmap() {return mask_bitmap_;} void mask_bitmap(uchar **value) { mask_bitmap_ = value; } + int p_size; + typedef struct {short x, y;} XPOINT; + XPOINT *p; public: Fl_Xlib_Graphics_Driver(void); + virtual ~Fl_Xlib_Graphics_Driver() { if (p) free(p); } virtual int has_feature(driver_feature mask) { return mask & NATIVE; } virtual void *gc() { return gc_; } virtual void gc(void *value); @@ -75,6 +80,8 @@ public: void copy_offscreen_with_alpha(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); #endif protected: + void transformed_vertex0(short x, short y); + void fixloop(); // --- implementation is in src/fl_rect.cxx which includes src/cfg_gfx/xlib_rect.cxx void point(int x, int y); void rect(int x, int y, int w, int h); diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx index 967712490..aa82393fe 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx @@ -20,6 +20,7 @@ #include "../../config_lib.h" #include "Fl_Xlib_Graphics_Driver.H" #include <FL/fl_draw.H> +#include <FL/x.H> #include <string.h> @@ -51,6 +52,8 @@ GC Fl_Xlib_Graphics_Driver::gc_ = NULL; Fl_Xlib_Graphics_Driver::Fl_Xlib_Graphics_Driver(void) { mask_bitmap_ = NULL; + p_size = 0; + p = NULL; } void Fl_Xlib_Graphics_Driver::gc(void *value) { @@ -105,6 +108,22 @@ void Fl_Graphics_Driver::add_rectangle_to_region(Fl_Region r, int X, int Y, int XUnionRectWithRegion(&R, r, r); } +void Fl_Xlib_Graphics_Driver::transformed_vertex0(short x, short y) { + if (!n || x != p[n-1].x || y != p[n-1].y) { + if (n >= p_size) { + p_size = p ? 2*p_size : 16; + p = (XPOINT*)realloc((void*)p, p_size*sizeof(*p)); + } + p[n].x = x; + p[n].y = y; + n++; + } +} + +void Fl_Xlib_Graphics_Driver::fixloop() { // remove equal points from closed path + while (n>2 && p[n-1].x == p[0].x && p[n-1].y == p[0].y) n--; +} + // // End of "$Id$". // diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx index a47e605b6..fcad6fd5f 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx @@ -19,6 +19,7 @@ #include <config.h> #include "Fl_Xlib_Graphics_Driver.H" #include <FL/fl_draw.H> +#include <FL/x.H> /** \file Fl_Xlib_Graphics_Driver_arci.cxx diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx index 99f1da627..05c58eb8d 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx @@ -31,15 +31,15 @@ void Fl_Xlib_Graphics_Driver::transformed_vertex(double xf, double yf) { - transformed_vertex0(COORD_T(rint(xf)), COORD_T(rint(yf))); + transformed_vertex0(short(rint(xf)), short(rint(yf))); } void Fl_Xlib_Graphics_Driver::vertex(double x,double y) { - transformed_vertex0(COORD_T(x*m.a + y*m.c + m.x), COORD_T(x*m.b + y*m.d + m.y)); + transformed_vertex0(short(x*m.a + y*m.c + m.x), short(x*m.b + y*m.d + m.y)); } void Fl_Xlib_Graphics_Driver::end_points() { - if (n>1) XDrawPoints(fl_display, fl_window, gc_, p, n, 0); + if (n>1) XDrawPoints(fl_display, fl_window, gc_, (XPoint*)p, n, 0); } void Fl_Xlib_Graphics_Driver::end_line() { @@ -47,12 +47,12 @@ void Fl_Xlib_Graphics_Driver::end_line() { end_points(); return; } - if (n>1) XDrawLines(fl_display, fl_window, gc_, p, n, 0); + if (n>1) XDrawLines(fl_display, fl_window, gc_, (XPoint*)p, n, 0); } void Fl_Xlib_Graphics_Driver::end_loop() { fixloop(); - if (n>2) transformed_vertex((COORD_T)p[0].x, (COORD_T)p[0].y); + if (n>2) transformed_vertex((short)p[0].x, (short)p[0].y); end_line(); } @@ -62,7 +62,7 @@ void Fl_Xlib_Graphics_Driver::end_polygon() { end_line(); return; } - if (n>2) XFillPolygon(fl_display, fl_window, gc_, p, n, Convex, 0); + if (n>2) XFillPolygon(fl_display, fl_window, gc_, (XPoint*)p, n, Convex, 0); } void Fl_Xlib_Graphics_Driver::begin_complex_polygon() { @@ -73,7 +73,7 @@ void Fl_Xlib_Graphics_Driver::begin_complex_polygon() { void Fl_Xlib_Graphics_Driver::gap() { while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--; if (n > gap_+2) { - transformed_vertex((COORD_T)p[gap_].x, (COORD_T)p[gap_].y); + transformed_vertex((short)p[gap_].x, (short)p[gap_].y); gap_ = n; } else { n = gap_; @@ -86,7 +86,7 @@ void Fl_Xlib_Graphics_Driver::end_complex_polygon() { end_line(); return; } - if (n>2) XFillPolygon(fl_display, fl_window, gc_, p, n, 0, 0); + if (n>2) XFillPolygon(fl_display, fl_window, gc_, (XPoint*)p, n, 0, 0); } // shortcut the closed circles so they use XDrawArc: |
