From dc2fb581b76ea84ebd70a7ced1291dd26b40fc71 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Fri, 9 Mar 2018 22:30:07 +0000 Subject: Improve X11 (16-bit) clipping of lines and rectangles. In FLTK 1.3.x only horizontal and vertical long lines with endpoints outside the 16-bit coordinate space could be drawn with proper X11 coordinate clipping. Now arbitrary lines are clipped so they can be drawn with X11 functions. All rectangles are clipped as well (as in 1.3). Todo: The code needs better documentation and clipping of polygons, circles, curves etc. is still missing. The next step should be the clipping of polygons... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12725 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/drivers/Xlib/Fl_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 8e44e2371..0870ebb2f 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H @@ -59,6 +59,8 @@ private: int stack_x_[20], stack_y_[20]; // translation stack allowing cumulative translations int line_delta_; virtual void set_current_(); +protected: + int xmin, ymin, xmax, ymax; // ranges of valid x/y coordinates, see set_clip_range() protected: virtual void draw_unscaled(Fl_Pixmap *pxm, float s, int XP, int YP, int WP, int HP, int cx, int cy); virtual void draw_unscaled(Fl_Bitmap *pxm, float s, int XP, int YP, int WP, int HP, int cx, int cy); @@ -94,7 +96,6 @@ protected: int p_size; typedef struct {short x, y;} XPOINT; XPOINT *p; - int clip_x(int x); #if USE_XFT static Window draw_window; static struct _XftDraw* draw_; @@ -112,7 +113,7 @@ public: #if USE_XFT static void destroy_xft_draw(Window id); #endif - + // --- bitmap stuff Fl_Bitmask create_bitmask(int w, int h, const uchar *array); void delete_bitmask(Fl_Bitmask bm); @@ -150,6 +151,26 @@ protected: virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3); virtual void polygon_unscaled(float x0, float y0, float x1, float y1, float x2, float y2); virtual void polygon_unscaled(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3); + + // --- clipped drawing (after scaling, with real screen coordinates) + // --- currently specific to Fl_Xlib_Graphics_Driver (16-bit coordinate clipping) + + // clip one coordinate (x or y) --- correct axis (x/y) is important ! + virtual int clip_x(int x); + virtual int clip_y(int y); + + // clip one line + virtual int clip_line(int &x1, int &y1, int &x2, int &y2); + + // clip one rectangle + virtual int clip_rect(int &x, int &y, int &w, int &h); + + // draw a line after clipping (if visible) + virtual void draw_clipped_line(int x1, int y1, int x2, int y2); + + // set_clip_range() - set valid coordinate range (16-bit or current window) + virtual void set_clip_range(); + // --- clipping void push_clip(int x, int y, int w, int h); int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H); -- cgit v1.2.3