diff options
| author | Fabien Costantini <fabien@onepost.net> | 2013-12-11 06:16:57 +0000 |
|---|---|---|
| committer | Fabien Costantini <fabien@onepost.net> | 2013-12-11 06:16:57 +0000 |
| commit | 32aba335c601d46561e60d75b1cf91e7ee4215ba (patch) | |
| tree | 085281577500d3237e18a913ab61c60d6bdbe683 | |
| parent | 0e8f2f786b8462aee88e121aeb260794448e35e0 (diff) | |
STR#3012 Fix: cairo_make_current(void*, int, int) would not release previously allocated cc in certain conditions.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10026 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | cairo/Fl_Cairo.cxx | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/cairo/Fl_Cairo.cxx b/cairo/Fl_Cairo.cxx index 7a030ad57..603483e6f 100644 --- a/cairo/Fl_Cairo.cxx +++ b/cairo/Fl_Cairo.cxx @@ -85,6 +85,7 @@ cairo_t * Fl::cairo_make_current(Fl_Window* wi) { Creates transparently a cairo_surface_t object. gc is an HDC context in WIN32, a CGContext* in Quartz, a display on X11 */ + static cairo_surface_t * cairo_create_surface(void * gc, int W, int H) { # if defined(USE_X11) return cairo_xlib_surface_create(fl_display, fl_window, fl_visual->visual, W, H); @@ -133,13 +134,15 @@ cairo_t * Fl::cairo_make_current(void *gc) { cairo_state_.gc(0); // keep track for next time return 0; } - if (gc==Fl::cairo_state_.gc() && fl_window== (Window) Fl::cairo_state_.window()) + if (gc==Fl::cairo_state_.gc() && + fl_window== (Window) Fl::cairo_state_.window() && + cairo_state_.cc()==0) return Fl::cairo_cc(); cairo_state_.gc(fl_gc); // keep track for next time cairo_surface_t * s = cairo_create_surface(gc, W, H); cairo_t * c = cairo_create(s); cairo_surface_destroy(s); - Fl::cairo_cc(c); + cairo_state_.cc(c); return c; } @@ -148,10 +151,17 @@ cairo_t * Fl::cairo_make_current(void *gc) { \note Only available when configure has the --enable-cairo option */ cairo_t * Fl::cairo_make_current(void *gc, int W, int H) { - cairo_surface_t * s = cairo_create_surface(gc, W, H); + if (gc==Fl::cairo_state_.gc() && + fl_window== (Window) Fl::cairo_state_.window() && + cairo_state_.cc()!=0) // no need to create a cc, just return that one + return cairo_state_.cc(); + + // we need to (re-)create a fresh cc ... + cairo_state_.gc(gc); // keep track for next time + cairo_surface_t * s = cairo_create_surface(gc, W, H); cairo_t * c = cairo_create(s); + cairo_state_.cc(c); // and purge any previously owned context cairo_surface_destroy(s); - Fl::cairo_cc(c); return c; } #else |
