From 43935dffeb7cb54a97b2a8a610c2e453743c0da9 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Wed, 7 Dec 2016 15:09:52 +0000 Subject: Add static void Fl_Surface_Device::push_current(Fl_Surface_Device *new_current) and pop_current() to set/unset the current drawing surface. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12140 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Image_Surface.cxx | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/Fl_Image_Surface.cxx') diff --git a/src/Fl_Image_Surface.cxx b/src/Fl_Image_Surface.cxx index 0dd2f6ff7..c925931ac 100644 --- a/src/Fl_Image_Surface.cxx +++ b/src/Fl_Image_Surface.cxx @@ -146,21 +146,13 @@ void fl_delete_offscreen(Fl_Offscreen ctx) { } } -static Fl_Surface_Device* stack_surface[16]; -static unsigned stack_height = 0; - /** Send all subsequent drawing commands to this offscreen buffer. \param ctx the offscreen buffer. */ void fl_begin_offscreen(Fl_Offscreen ctx) { for (int i = 0; i < count_offscreens; i++) { if (offscreen_api_surface[i] && offscreen_api_surface[i]->offscreen() == ctx) { - if (stack_height < sizeof(stack_surface)/sizeof(void*)) { - stack_surface[stack_height++] = Fl_Surface_Device::surface(); - } else { - fprintf(stderr, "FLTK fl_begin_offscreen Stack overflow error\n"); - } - offscreen_api_surface[i]->set_current(); + Fl_Surface_Device::push_current(offscreen_api_surface[i]); return; } } @@ -169,9 +161,7 @@ void fl_begin_offscreen(Fl_Offscreen ctx) { /** Quit sending drawing commands to the current offscreen buffer. */ void fl_end_offscreen() { - if (stack_height > 0) { - stack_surface[--stack_height]->set_current(); - } + Fl_Surface_Device::pop_current(); } /** @} */ -- cgit v1.2.3