From 2ddc89fb6167b9c28795a20318576a98783e6c46 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Tue, 25 Apr 2017 12:42:22 +0000 Subject: [PATCH] Add an argument to the private, virtual member function void Fl_Surface_Device::end_current_(). The X11 platform uses this argument to restore the correct clipping state after drawing to an Fl_Image_Surface object. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12226 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- FL/Fl_Device.H | 9 +++++---- src/Fl_Device.cxx | 4 ++-- src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx | 6 +++--- src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx | 6 +++--- src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx | 6 +++--- src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx | 5 +++-- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/FL/Fl_Device.H b/FL/Fl_Device.H index 2f1a8d80f..afa4a458a 100644 --- a/FL/Fl_Device.H +++ b/FL/Fl_Device.H @@ -4,7 +4,7 @@ // Definition of classes Fl_Surface_Device, Fl_Display_Device // for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2016 by Bill Spitzak and others. +// Copyright 2010-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -57,9 +57,10 @@ class FL_EXPORT Fl_Surface_Device { Fl_Graphics_Driver *pGraphicsDriver; static Fl_Surface_Device *surface_; // the surface that currently receives graphics requests static Fl_Surface_Device *default_surface(); // create surface if none exists yet - // Some drawing surfaces (e.g., Fl_XXX_Image_Surface_Driver) re-implement this. - // Gets called each time a surface ceases to be the current drawing surface. - virtual void end_current_() {} + /* Some drawing surfaces (e.g., Fl_XXX_Image_Surface_Driver) re-implement this. + Gets called each time a surface ceases to be the current drawing surface. + The next_current argument gives the drawing surface that will become current next */ + virtual void end_current_(Fl_Surface_Device *next_current) {} protected: /** Constructor that sets the graphics driver to use for the created surface. */ Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver; } diff --git a/src/Fl_Device.cxx b/src/Fl_Device.cxx index 2c3aa1525..b791ee2c0 100644 --- a/src/Fl_Device.cxx +++ b/src/Fl_Device.cxx @@ -3,7 +3,7 @@ // // implementation of Fl_Device class for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2016 by Bill Spitzak and others. +// Copyright 2010-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -50,7 +50,7 @@ is Fl_Surface_Device::push_current( ) / Fl_Surface_Device::pop_current().*/ void Fl_Surface_Device::set_current(void) { - if (surface_) surface_->end_current_(); + if (surface_) surface_->end_current_(this); fl_graphics_driver = pGraphicsDriver; surface_ = this; pGraphicsDriver->global_gc(); diff --git a/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx b/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx index 933593e6d..c94d9e37e 100644 --- a/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx @@ -3,7 +3,7 @@ // // Draw-to-image code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -28,7 +28,7 @@ class Fl_GDI_Image_Surface_Driver : public Fl_Image_Surface_Driver { friend class Fl_Image_Surface; - virtual void end_current_(); + virtual void end_current_(Fl_Surface_Device*); public: Fl_Surface_Device *previous; Window pre_window; @@ -97,7 +97,7 @@ Fl_RGB_Image* Fl_GDI_Image_Surface_Driver::image() } -void Fl_GDI_Image_Surface_Driver::end_current_() +void Fl_GDI_Image_Surface_Driver::end_current_(Fl_Surface_Device*) { HDC gc = (HDC)driver()->gc(); RestoreDC(gc, _savedc); diff --git a/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx index 2404c531f..9dd722fb9 100644 --- a/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx @@ -3,7 +3,7 @@ // // Draw-to-image code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -27,7 +27,7 @@ class Fl_Quartz_Image_Surface_Driver : public Fl_Image_Surface_Driver { friend class Fl_Image_Surface; - virtual void end_current_(); + virtual void end_current_(Fl_Surface_Device*); public: Window pre_window; Fl_Quartz_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off); @@ -105,7 +105,7 @@ Fl_RGB_Image* Fl_Quartz_Image_Surface_Driver::image() return image; } -void Fl_Quartz_Image_Surface_Driver::end_current_() +void Fl_Quartz_Image_Surface_Driver::end_current_(Fl_Surface_Device*) { fl_window = pre_window; } diff --git a/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx index ec2d74214..138564600 100644 --- a/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx @@ -3,7 +3,7 @@ // // Copy-to-clipboard code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -28,7 +28,7 @@ class Fl_Xlib_Copy_Surface_Driver : public Fl_Copy_Surface_Driver { friend class Fl_Copy_Surface_Driver; - virtual void end_current_(); + virtual void end_current_(Fl_Surface_Device*); protected: Fl_Offscreen xid; Window oldwindow; @@ -80,7 +80,7 @@ void Fl_Xlib_Copy_Surface_Driver::set_current() { Fl_Surface_Device::set_current(); } -void Fl_Xlib_Copy_Surface_Driver::end_current_() { +void Fl_Xlib_Copy_Surface_Driver::end_current_(Fl_Surface_Device*) { fl_window = oldwindow; } diff --git a/src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx index d98c129fb..49a84e7d8 100644 --- a/src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx @@ -27,7 +27,7 @@ class Fl_Xlib_Image_Surface_Driver : public Fl_Image_Surface_Driver { friend class Fl_Image_Surface; - virtual void end_current_(); + virtual void end_current_(Fl_Surface_Device *next_current); public: Window pre_window; Fl_Xlib_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off); @@ -79,9 +79,10 @@ Fl_RGB_Image* Fl_Xlib_Image_Surface_Driver::image() return image; } -void Fl_Xlib_Image_Surface_Driver::end_current_() +void Fl_Xlib_Image_Surface_Driver::end_current_(Fl_Surface_Device *next_current) { fl_pop_clip(); + next_current->driver()->restore_clip(); fl_window = pre_window; }