summaryrefslogtreecommitdiff
path: root/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2018-03-15 16:52:27 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2018-03-15 16:52:27 +0000
commit726cb77717e00de9cd6d9accad0a69f4ae7a6859 (patch)
treeb74cffe58b721b02bc749e34a86004e783385d8f /src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
parent7d985f842ac3e396dfcc3418f56f7f0c3a98d659 (diff)
Improve X11 coordinate clipping.
Make clipping methods non-virtual so they can be inlined. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12753 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H')
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
index 96126cf21..91badcb47 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
@@ -153,24 +153,35 @@ protected:
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)
+ // Scaling and clipping stuff for internal usage.
+ // Currently specific to Fl_Xlib_Graphics_Driver (16-bit coordinate clipping)
+ // These methods must not be virtual so they can be inlined.
+ // All these methods work with "real" drawing coordinates (after scaling).
- // clipping limits
- virtual int clip_max() { return clip_max_; }
- virtual int clip_min() { return -clip_max_; }
+ // Clipping limits
+ int clip_max() { return clip_max_; }
+ int clip_min() { return -clip_max_; }
- // clip one coordinate (x or y)
- virtual int clip_xy(int x);
+ /*
+ clip_xy() returns a single coordinate value clipped to the 16-bit
+ coordinate space.
- // clip one line
- virtual int clip_line(int &x1, int &y1, int &x2, int &y2);
+ This can be used to draw horizontal and vertical lines that can be
+ handled by X. Each single coordinate value can be clipped individually
+ and the result can be used directly, e.g. in fl_xyline() and fl_yxline().
+ */
+ int clip_xy(int x) {
+ return (x < clip_min() ? clip_min() : (x > clip_max() ? clip_max() : x ));
+ }
- // clip one rectangle
- virtual int clip_rect(int &x, int &y, int &w, int &h);
+ // clip an arbitrary line
+ int clip_line(int &x1, int &y1, int &x2, int &y2);
+
+ // clip a rectangle
+ 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);
+ void draw_clipped_line(int x1, int y1, int x2, int y2);
// --- clipping
void push_clip(int x, int y, int w, int h);