diff --git a/FL/wayland.H b/FL/wayland.H index 9d2b48925..34098a9d5 100644 --- a/FL/wayland.H +++ b/FL/wayland.H @@ -35,7 +35,7 @@ extern FL_EXPORT struct wld_window *fl_wl_xid(const Fl_Window *win); /** Returns the Fl_Window corresponding to a given the platform-specific window reference */ extern FL_EXPORT Fl_Window *fl_wl_find(struct wld_window *); /** Returns the cairo context associated to the current window or Fl_Image_Surface */ -extern FL_EXPORT cairo_t *fl_wl_cairo(); +extern FL_EXPORT cairo_t *fl_wl_gc(); /** Returns the wl_compositor of the current Wayland session. This allows, for example, to create a wl_surface with \code diff --git a/FL/x11.H b/FL/x11.H index a86b605f2..73af4e7fc 100644 --- a/FL/x11.H +++ b/FL/x11.H @@ -32,7 +32,8 @@ extern Window fl_x11_xid(const Fl_Window *win); extern Fl_Window *fl_x11_find(Window xid); /** Returns the X11-specific currently active graphics context. */ extern GC fl_x11_gc(); - +/** Returns the Cairo-specific currently active graphics context (OPTION_USE_CAIRO=On) */ +extern cairo_t* fl_cairo_gc(); #else // ! FL_DOXYGEN #ifndef FL_PLATFORM_H @@ -65,6 +66,10 @@ extern FL_EXPORT Colormap fl_colormap; // drawing functions: extern FL_EXPORT GC fl_gc; +#if FLTK_USE_CAIRO + typedef struct _cairo cairo_t; + extern FL_EXPORT cairo_t* fl_cairo_gc(); +#endif extern FL_EXPORT GC fl_x11_gc(); FL_EXPORT ulong fl_xpixel(Fl_Color i); FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b); diff --git a/documentation/src/osissues.dox b/documentation/src/osissues.dox index fe25ca2b4..998a8a54d 100644 --- a/documentation/src/osissues.dox +++ b/documentation/src/osissues.dox @@ -1013,11 +1013,11 @@ struct wl_surface *fl_wl_surface(struct wld_window *wld_win) Returns a pointer to the struct wl_surface corresponding to a show()'n top-level window or subwindow. -cairo_t *fl_wl_cairo(void) +cairo_t *fl_wl_gc() \par Drawing natively to a Wayland window : Within an overridden Fl_Widget::draw() method, or after a call to Fl_Window::make_current(), it's possible to draw -using the Cairo library. Function \c fl_wl_cairo() returns the adequate +using the Cairo library. Function \c fl_wl_gc() returns the adequate \c cairo_t* value. Regular FLTK coordinates, with top-left origin, are to be used. All FLTK-defined drawing functions (e.g., fl_rect(), fl_draw()) can be used too. diff --git a/src/drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx index d673c3dfa..3ad9a0d88 100644 --- a/src/drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx @@ -62,3 +62,7 @@ void Fl_X11_Cairo_Graphics_Driver::gc(void *value) { void *Fl_X11_Cairo_Graphics_Driver::gc() { return gc_; } + +extern FL_EXPORT cairo_t* fl_cairo_gc() { + return ((Fl_Cairo_Graphics_Driver*)fl_graphics_driver)->cr(); +} diff --git a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H index 5e3b13f8b..b9dbb78be 100644 --- a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H @@ -80,8 +80,6 @@ public: static void buffer_release(struct wld_window *window); static void buffer_commit(struct wld_window *window, struct flCairoRegion *r = NULL); static void cairo_init(struct fl_wld_buffer *buffer, int width, int height, int stride, cairo_format_t format); - void *gc() FL_OVERRIDE; - void gc(void *gc) FL_OVERRIDE; }; #endif // FL_WAYLAND_GRAPHICS_DRIVER_H diff --git a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx index d9eedb317..9b26f8439 100644 --- a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx @@ -208,12 +208,3 @@ void Fl_Wayland_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_O cairo_surface_destroy(surf); cairo_restore(cairo_); } - - -void Fl_Wayland_Graphics_Driver::gc(void *off) {} // equivalent is done by set_buffer() - - -void *Fl_Wayland_Graphics_Driver::gc() { - return buffer_; -} - diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index 37d6e4842..e65229624 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -1817,7 +1817,7 @@ FL_EXPORT struct wl_surface *fl_wl_surface(struct wld_window *xid) { } -cairo_t *fl_wl_cairo() { +cairo_t *fl_wl_gc() { return ((Fl_Cairo_Graphics_Driver*)fl_graphics_driver)->cr(); }