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
This commit is contained in:
Albrecht Schlosser 2018-03-15 16:52:27 +00:00
parent 7d985f842a
commit 726cb77717
2 changed files with 23 additions and 32 deletions

View File

@ -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);

View File

@ -188,26 +188,6 @@ int Fl_Xlib_Graphics_Driver::clip_rect(int &x, int &y, int &w, int &h) {
return 0;
}
/*
clip_xy() returns a single coordinate value clipped to the 16-bit
coordinate space.
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().
Note 1: this can't be used for arbitrary lines (neither horizontal nor vertical).
Note 2: may be changed since Fl_Xlib_Graphics_Driver::clip_line() exists.
*/
int Fl_Xlib_Graphics_Driver::clip_xy(int x) {
if (x < clip_min())
x = clip_min();
else if (x > clip_max())
x = clip_max();
return x;
}
// Missing X call: (is this the fastest way to init a 1-rectangle region?)
// Windows equivalent exists, implemented inline in win32.H