Browse Source

Fix Cairo callback drawing (needs flush)

This commit adds a cairo_surface flush after calling the draw callback.
This fixes the test/cairo_test demo program under Windows.

At least under Windows the Cairo callback used in Fl_Cairo_Window
didn't draw anything with current Windows 10, MinGW (32-bit) and
Cairo 1.15.12 for Windows. It worked well under Linux though. Anyway,
the flush should do no harm.
pull/26/head
Albrecht Schlosser 7 years ago
parent
commit
8ba982ae37
  1. 13
      FL/Fl_Cairo_Window.H

13
FL/Fl_Cairo_Window.H

@ -59,10 +59,15 @@ protected: @@ -59,10 +59,15 @@ protected:
/** Overloaded to provide cairo callback support */
void draw() {
Fl_Double_Window::draw();
// manual method ? if yes explicitly get a cairo_context here
if (!Fl::cairo_autolink_context())
Fl::cairo_make_current(this);
if (draw_cb_) draw_cb_(this, Fl::cairo_cc());
if (draw_cb_) { // call the Cairo draw callback
// manual method ? if yes explicitly get a cairo_context here
if (!Fl::cairo_autolink_context())
Fl::cairo_make_current(this);
draw_cb_(this, Fl::cairo_cc());
// flush cairo drawings: necessary at least for Windows
cairo_surface_t *s = cairo_get_target(Fl::cairo_cc());
cairo_surface_flush(s);
}
}
public:

Loading…
Cancel
Save