mirror of
https://github.com/fltk/fltk.git
synced 2026-05-20 04:31:25 +08:00
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.
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user