summaryrefslogtreecommitdiff
path: root/src/drivers/Xlib
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-12-07 15:09:52 +0000
committerManolo Gouy <Manolo>2016-12-07 15:09:52 +0000
commit43935dffeb7cb54a97b2a8a610c2e453743c0da9 (patch)
tree9f132039b9cf120263bf03965c152ac17853969c /src/drivers/Xlib
parent0a1eed150a9d9215f70f1e50db2ec555199aee7d (diff)
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
Diffstat (limited to 'src/drivers/Xlib')
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx23
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx5
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx3
3 files changed, 13 insertions, 18 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
index c439ddf94..156bd87d3 100644
--- a/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
@@ -28,10 +28,10 @@
class Fl_Xlib_Copy_Surface_Driver : public Fl_Copy_Surface_Driver {
friend class Fl_Copy_Surface_Driver;
+ virtual void end_current_();
protected:
Fl_Offscreen xid;
Window oldwindow;
- Fl_Surface_Device *_ss;
Fl_Xlib_Copy_Surface_Driver(int w, int h);
~Fl_Xlib_Copy_Surface_Driver();
void set_current();
@@ -51,26 +51,22 @@ Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int
Fl_Xlib_Copy_Surface_Driver::Fl_Xlib_Copy_Surface_Driver(int w, int h) : Fl_Copy_Surface_Driver(w, h) {
driver(new Fl_Translated_Xlib_Graphics_Driver());
- Fl::first_window()->make_current();
- oldwindow = fl_xid(Fl::first_window());
+ oldwindow = fl_window;
xid = fl_create_offscreen(w,h);
- _ss = NULL;
- Fl_Surface_Device *present_surface = Fl_Surface_Device::surface();
- Fl_Surface_Device::set_current();
- fl_push_no_clip();
+ driver()->push_no_clip();
fl_window = xid;
driver()->color(FL_WHITE);
driver()->rectf(0, 0, w, h);
- present_surface->set_current();
fl_window = oldwindow;
}
Fl_Xlib_Copy_Surface_Driver::~Fl_Xlib_Copy_Surface_Driver() {
- fl_pop_clip();
+ driver()->pop_clip();
+ bool need_push = (Fl_Surface_Device::surface() != this);
+ if (need_push) Fl_Surface_Device::push_current(this);
unsigned char *data = fl_read_image(NULL,0,0,width,height,0);
- fl_window = oldwindow;
- _ss->set_current();
+ if (need_push) Fl_Surface_Device::pop_current();
Fl_X11_Screen_Driver::copy_image(data, width, height, 1);
delete[] data;
fl_delete_offscreen(xid);
@@ -79,11 +75,14 @@ Fl_Xlib_Copy_Surface_Driver::~Fl_Xlib_Copy_Surface_Driver() {
void Fl_Xlib_Copy_Surface_Driver::set_current() {
+ oldwindow = fl_window;
fl_window = xid;
- if (!_ss) _ss = Fl_Surface_Device::surface();
Fl_Surface_Device::set_current();
}
+void Fl_Xlib_Copy_Surface_Driver::end_current_() {
+ fl_window = oldwindow;
+}
void Fl_Xlib_Copy_Surface_Driver::translate(int x, int y) {
((Fl_Translated_Xlib_Graphics_Driver*)driver())->translate_all(x, y);
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
index 7ecb5471e..96f8b0685 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
@@ -714,10 +714,9 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, in
depth |= FL_IMAGE_WITH_ALPHA;
}
if (surface) {
- Fl_Surface_Device *old_surf = Fl_Surface_Device::surface();
- surface->set_current();
+ Fl_Surface_Device::push_current(surface);
fl_draw_image(img->array, 0, 0, img->w(), img->h(), depth, img->ld());
- old_surf->set_current();
+ Fl_Surface_Device::pop_current();
*Fl_Graphics_Driver::id(img) = surface->get_offscreen_before_delete();
delete surface;
}
diff --git a/src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx
index 022a94066..4ec2bd25d 100644
--- a/src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx
@@ -29,7 +29,6 @@ class Fl_Xlib_Image_Surface_Driver : public Fl_Image_Surface_Driver {
friend class Fl_Image_Surface;
virtual void end_current_();
public:
- Fl_Surface_Device *previous;
Window pre_window;
int was_high;
Fl_Xlib_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off);
@@ -46,7 +45,6 @@ Fl_Image_Surface_Driver *Fl_Image_Surface_Driver::newImageSurfaceDriver(int w, i
}
Fl_Xlib_Image_Surface_Driver::Fl_Xlib_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off) : Fl_Image_Surface_Driver(w, h, high_res, off) {
- previous = 0;
if (!off) {
fl_open_display();
offscreen = XCreatePixmap(fl_display, RootWindow(fl_display, fl_screen), w, h, fl_visual->depth);
@@ -61,7 +59,6 @@ Fl_Xlib_Image_Surface_Driver::~Fl_Xlib_Image_Surface_Driver() {
void Fl_Xlib_Image_Surface_Driver::set_current() {
pre_window = fl_window;
- if (!previous) previous = Fl_Surface_Device::surface();
Fl_Surface_Device::set_current();
fl_window = offscreen;
fl_push_no_clip();