diff options
| author | Manolo Gouy <Manolo> | 2017-05-17 11:54:18 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2017-05-17 11:54:18 +0000 |
| commit | f48750b0f482a2155ec5d66b19110d2ac22ce87c (patch) | |
| tree | 7a8f942b83003ea0fd8f63bc351fedcb1c9b8a93 /src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H | |
| parent | 22a5dd4fcf88f1da5343fc31e6e453d986d224a0 (diff) | |
Introduce HiDPI + rescaling support for the X11 platform (+ partial support for WIN32)
Corresponds to STR #3320
1) HiDPI support consists in detecting the adequate scaling factor for the screen on which
FLTK maps a window, and scaling all FLTK units by this factor. FLTK tries to detect the correct
value of this factor at startup (see more details below). Environment variable
FLTK_SCALING_FACTOR can also be used to set this value.
2) Rescaling support consists in changing the scaling factor of all FLTK windows
in reply to ctrl/+/-/0/ keystrokes.
More details for the various platforms :
- X11: Support is very advanced. Some details need still to be improved.
Automatic detection of the correct starting value of the scaling factor works well
with the gnome desktop. The present code contains no support for this on
other desktops. FLTK_SCALING_FACTOR provides a workaround.
-WIN32: Support is incomplete at this point, although many test
applications have partial or complete HiDPI and scaling support.
The current value of the system's scaling factor is correctly detected
at application startup. Apps respond to changes of this value in real time.
Support needs to define the FLTK_HIDPI_SUPPORT preprocessor variable
at compile time. This way, standard builds produce a code with the
default WIN32 HiDPI support, that is, where all graphics goes to an internal
buffer that gets enlarged by the system and then mapped to the HiDPI
display. To experiment with (or develop) the new HiDPI support requires
a modified build procedure in which FLTK_HIDPI_SUPPORT is defined
at compile time. When the support will be complete, the requirement for the
definition of this preprocessor variable will be removed. The present commit
contains support for a single scaling factor. Eventually, per-screen scaling
factors should be implemented, as done for X11.
- MacOS: this commit does not give new HiDPI for this platform.
Eventually, window rescaling in reply to command/+/-/0/ is desirable.
Per-screen scaling factor makes no sense on this platform because
the OS itself takes care of the difference between the resolutions of
traditional and retina displays.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12239 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.H | 105 |
1 files changed, 51 insertions, 54 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H index e71eab3cf..d1f6f3fc9 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H @@ -43,7 +43,7 @@ struct _XRegion { #endif // HAVE_X11_XREGION_H #if USE_PANGO -#include <pango/pangoxft.h> +#include <pango/pango.h> #endif @@ -52,11 +52,27 @@ struct _XRegion { * This class is implemented only on the Xlib platform. */ -class FL_EXPORT Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver { +class FL_EXPORT Fl_Xlib_Graphics_Driver : public Fl_Scalable_Graphics_Driver { private: int offset_x_, offset_y_; // translation between user and graphical coordinates: graphical = user + offset unsigned depth_; // depth of translation stack int stack_x_[20], stack_y_[20]; // translation stack allowing cumulative translations + int line_delta_; +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); + virtual void draw_unscaled(Fl_RGB_Image *img, float s, int XP, int YP, int WP, int HP, int cx, int cy); + virtual void draw_image_unscaled(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); + virtual void draw_image_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); + virtual void draw_image_mono_unscaled(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); + virtual void draw_image_mono_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); +#if HAVE_XRENDER + virtual int draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP); + int scale_and_render_pixmap(Fl_Offscreen pixmap, int depth, double scale_x, double scale_y, int srcx, int srcy, int XP, int YP, int WP, int HP); +#endif + virtual int height_unscaled(); + virtual int descent_unscaled(); + virtual Region scale_clip(float f); #if USE_XFT void drawUCS4(const void *str, int n, int x, int y); #endif @@ -65,16 +81,11 @@ private: static PangoContext *pctxt_; static PangoFontMap *pfmap_; static PangoLayout *playout_; -protected: PangoFontDescription *pfd_; void do_draw(int from_right, const char *str, int n, int x, int y); static PangoContext *context(); static void init_built_in_fonts(); #endif -#if HAVE_XRENDER - int scale_and_render_pixmap(Fl_Offscreen pixmap, int depth, double scale_x, double scale_y, int srcx, int srcy, int XP, int YP, int WP, int HP); -#endif -protected: static GC gc_; uchar **mask_bitmap_; uchar **mask_bitmap() {return mask_bitmap_;} @@ -93,6 +104,7 @@ public: virtual ~Fl_Xlib_Graphics_Driver(); void translate_all(int dx, int dy); void untranslate_all(); + virtual void scale(float f); virtual int has_feature(driver_feature mask) { return mask & NATIVE; } virtual void *gc() { return gc_; } virtual void gc(void *value); @@ -104,51 +116,43 @@ public: // --- bitmap stuff Fl_Bitmask create_bitmask(int w, int h, const uchar *array); void delete_bitmask(Fl_Bitmask bm); - void draw(const char* str, int n, int x, int y); - void draw(int angle, const char *str, int n, int x, int y); - void rtl_draw(const char* str, int n, int x, int y); - void font(Fl_Font face, Fl_Fontsize size); - void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); - void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); - void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy); - void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); - void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); - void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); - void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); -#if HAVE_XRENDER - int draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP); -#endif + virtual void draw_unscaled(const char* str, int n, int x, int y); + virtual void draw_unscaled(int angle, const char *str, int n, int x, int y); + virtual void rtl_draw_unscaled(const char* str, int n, int x, int y); + virtual void font_unscaled(Fl_Font face, Fl_Fontsize size); fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array); fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array); void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_); - double width(const char *str, int n); - double width(unsigned int c); - void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h); - int height(); - int descent(); - void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); + virtual double width_unscaled(const char *str, int n); + virtual double width_unscaled(unsigned int c); + virtual void text_extents_unscaled(const char*, int n, int& dx, int& dy, int& w, int& h); + virtual Fl_Fontsize size_unscaled(); + virtual void copy_offscreen_unscaled(float x, float y, float w, float h, Fl_Offscreen pixmap, float srcx, float srcy); +#if ! defined(FL_DOXYGEN) + void copy_offscreen_with_alpha(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); +#endif void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h); Fl_Region XRectangleRegion(int x, int y, int w, int h); void XDestroyRegion(Fl_Region r); protected: - virtual void transformed_vertex0(short x, short y); + virtual void transformed_vertex0(float x, float 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); - void rectf(int x, int y, int w, int h); - void line(int x, int y, int x1, int y1); - void line(int x, int y, int x1, int y1, int x2, int y2); - void xyline(int x, int y, int x1); - void xyline(int x, int y, int x1, int y2); - void xyline(int x, int y, int x1, int y2, int x3); - void yxline(int x, int y, int y1); - void yxline(int x, int y, int y1, int x2); - void yxline(int x, int y, int y1, int x2, int y3); - void loop(int x0, int y0, int x1, int y1, int x2, int y2); - void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); - void polygon(int x0, int y0, int x1, int y1, int x2, int y2); - void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); + virtual void point_unscaled(float x, float y); + virtual void rect_unscaled(float x, float y, float w, float h); + virtual void rectf_unscaled(float x, float y, float w, float h); + virtual void line_unscaled(float x, float y, float x1, float y1); + virtual void line_unscaled(float x, float y, float x1, float y1, float x2, float y2); + virtual void xyline_unscaled(float x, float y, float x1); + virtual void xyline_unscaled(float x, float y, float x1, float y2); + virtual void xyline_unscaled(float x, float y, float x1, float y2, float x3); + virtual void yxline_unscaled(float x, float y, float y1); + virtual void yxline_unscaled(float x, float y, float y1, float x2); + virtual void yxline_unscaled(float x, float y, float y1, float x2, float y3); + virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2); + 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); // --- 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); @@ -156,25 +160,18 @@ protected: void push_no_clip(); void pop_clip(); void restore_clip(); - // --- implementation is in src/fl_vertex.cxx which includes src/cfg_gfx/xxx_rect.cxx void begin_complex_polygon(); - void transformed_vertex(double xf, double yf); - void vertex(double x, double y); void end_points(); void end_line(); void end_loop(); void end_polygon(); void end_complex_polygon(); void gap(); - void circle(double x, double y, double r); - // --- implementation is in src/fl_arc.cxx which includes src/cfg_gfx/xxx_arc.cxx if needed - // using void Fl_Graphics_Driver::arc(double x, double y, double r, double start, double end); + virtual void ellipse_unscaled(double xt, double yt, double rx, double ry); // --- implementation is in src/fl_arci.cxx which includes src/cfg_gfx/xxx_arci.cxx - void arc(int x, int y, int w, int h, double a1, double a2); - void pie(int x, int y, int w, int h, double a1, double a2); - // --- implementation is in src/fl_line_style.cxx which includes src/cfg_gfx/xxx_line_style.cxx - void line_style(int style, int width=0, char* dashes=0); - // --- implementation is in src/fl_color.cxx which includes src/cfg_gfx/xxx_color.cxx + virtual void arc_unscaled(float x, float y, float w, float h, double a1, double a2); + virtual void pie_unscaled(float x, float y, float w, float h, double a1, double a2); + virtual void line_style_unscaled(int style, float width, char* dashes); void color(Fl_Color c); void set_color(Fl_Color i, unsigned int c); void free_color(Fl_Color i, int overlay); |
