summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Copy_Surface.H10
-rw-r--r--FL/Fl_Device.H1
-rw-r--r--FL/Fl_Image_Surface.H11
-rw-r--r--FL/Fl_Printer.H1
-rw-r--r--src/Fl_Copy_Surface.cxx9
-rw-r--r--src/Fl_Device.cxx4
-rw-r--r--src/Fl_Image_Surface.cxx8
-rw-r--r--src/Fl_Printer.cxx4
-rw-r--r--src/Fl_Widget_Surface.cxx14
-rw-r--r--src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx1
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H1
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx1
12 files changed, 50 insertions, 15 deletions
diff --git a/FL/Fl_Copy_Surface.H b/FL/Fl_Copy_Surface.H
index afbe2e290..9fb5021c7 100644
--- a/FL/Fl_Copy_Surface.H
+++ b/FL/Fl_Copy_Surface.H
@@ -56,6 +56,7 @@ public:
Fl_Copy_Surface(int w, int h);
~Fl_Copy_Surface();
void set_current();
+ virtual bool is_current();
/** Returns the pixel width of the copy surface */
int w();
/** Returns the pixel height of the copy surface */
@@ -87,11 +88,10 @@ protected:
int height;
Fl_Copy_Surface_Driver(int w, int h) : Fl_Widget_Surface(NULL), width(w), height(h) {}
virtual ~Fl_Copy_Surface_Driver() {}
- virtual void set_current() {}
- virtual void translate(int x, int y) {}
- virtual void untranslate() {}
- int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
- virtual Fl_RGB_Image *image() {return NULL;}
+ virtual void set_current() = 0;
+ virtual void translate(int x, int y) = 0;
+ virtual void untranslate() = 0;
+ int printable_rect(int *w, int *h);
/** Each platform implements this function its own way.
It returns an object implementing all virtual functions
of class Fl_Copy_Surface_Driver for the plaform.
diff --git a/FL/Fl_Device.H b/FL/Fl_Device.H
index d2b9cfabb..fc3664408 100644
--- a/FL/Fl_Device.H
+++ b/FL/Fl_Device.H
@@ -77,6 +77,7 @@ protected:
Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver; }
public:
virtual void set_current(void);
+ virtual bool is_current();
/** \brief Sets the graphics driver of this drawing surface. */
inline void driver(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver;};
/** \brief Returns the graphics driver of this drawing surface. */
diff --git a/FL/Fl_Image_Surface.H b/FL/Fl_Image_Surface.H
index 3ec0f93cf..34121d043 100644
--- a/FL/Fl_Image_Surface.H
+++ b/FL/Fl_Image_Surface.H
@@ -76,6 +76,7 @@ public:
Fl_Image_Surface(int w, int h, int high_res = 0, Fl_Offscreen off = 0);
~Fl_Image_Surface();
void set_current();
+ virtual bool is_current();
Fl_RGB_Image *image();
Fl_Shared_Image *highres_image();
void origin(int *x, int *y);
@@ -106,11 +107,11 @@ protected:
int external_offscreen;
Fl_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off) : Fl_Widget_Surface(NULL), width(w), height(h), offscreen(off) {external_offscreen = (off != 0);}
virtual ~Fl_Image_Surface_Driver() {}
- virtual void set_current() {}
- virtual void translate(int x, int y) {}
- virtual void untranslate() {}
- int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
- virtual Fl_RGB_Image *image() {return NULL;}
+ virtual void set_current() = 0;
+ virtual void translate(int x, int y) = 0;
+ virtual void untranslate() = 0;
+ int printable_rect(int *w, int *h);
+ virtual Fl_RGB_Image *image() = 0;
/** Each platform implements this function its own way.
It returns an object implementing all virtual functions
of class Fl_Image_Surface_Driver for the plaform.
diff --git a/FL/Fl_Printer.H b/FL/Fl_Printer.H
index 825f765d9..8d3219783 100644
--- a/FL/Fl_Printer.H
+++ b/FL/Fl_Printer.H
@@ -105,6 +105,7 @@ public:
void end_job (void);
void draw_decorated_window(Fl_Window *win, int x_offset, int y_offset);
void set_current(void);
+ virtual bool is_current();
/** \name These attributes are useful for the Linux/Unix platform only.
\{
diff --git a/src/Fl_Copy_Surface.cxx b/src/Fl_Copy_Surface.cxx
index 3f1ef2314..0ebe3ee0f 100644
--- a/src/Fl_Copy_Surface.cxx
+++ b/src/Fl_Copy_Surface.cxx
@@ -38,6 +38,10 @@ void Fl_Copy_Surface::set_current() {
if (platform_surface) platform_surface->set_current();
}
+bool Fl_Copy_Surface::is_current() {
+ return surface() == platform_surface;
+}
+
void Fl_Copy_Surface::translate(int x, int y) {
if (platform_surface) platform_surface->translate(x, y);
}
@@ -59,6 +63,11 @@ int Fl_Copy_Surface::printable_rect(int *w, int *h) {
return 1;
}
+int Fl_Copy_Surface_Driver::printable_rect(int *w, int *h) {
+ *w = width; *h = height;
+ return 0;
+}
+
//
// End of "$Id$".
//
diff --git a/src/Fl_Device.cxx b/src/Fl_Device.cxx
index 1166c7582..db632d74c 100644
--- a/src/Fl_Device.cxx
+++ b/src/Fl_Device.cxx
@@ -72,6 +72,10 @@ void Fl_Surface_Device::set_current(void)
Fl_Surface_Device* Fl_Surface_Device::surface_; // the current target surface of graphics operations
+/** Is this surface the current drawing surface? */
+bool Fl_Surface_Device::is_current() {
+ return surface_ == this;
+}
Fl_Surface_Device::~Fl_Surface_Device()
{
diff --git a/src/Fl_Image_Surface.cxx b/src/Fl_Image_Surface.cxx
index fe38405a7..7dc079db8 100644
--- a/src/Fl_Image_Surface.cxx
+++ b/src/Fl_Image_Surface.cxx
@@ -54,6 +54,10 @@ void Fl_Image_Surface::set_current() {
if (platform_surface) platform_surface->set_current();
}
+bool Fl_Image_Surface::is_current() {
+ return surface() == platform_surface;
+}
+
void Fl_Image_Surface::translate(int x, int y) {
if (platform_surface) platform_surface->translate(x, y);
}
@@ -72,6 +76,10 @@ Fl_Offscreen Fl_Image_Surface::offscreen() {
int Fl_Image_Surface::printable_rect(int *w, int *h) {return platform_surface->printable_rect(w, h);}
+int Fl_Image_Surface_Driver::printable_rect(int *w, int *h) {
+ *w = width; *h = height;
+ return 0;
+}
/** Returns an image made of all drawings sent to the Fl_Image_Surface object.
The returned object contains its own copy of the RGB data.
diff --git a/src/Fl_Printer.cxx b/src/Fl_Printer.cxx
index d787e0365..390f1e6e1 100644
--- a/src/Fl_Printer.cxx
+++ b/src/Fl_Printer.cxx
@@ -214,6 +214,10 @@ void Fl_Printer::set_current(void)
printer->set_current();
}
+bool Fl_Printer::is_current() {
+ return surface() == printer;
+}
+
Fl_Printer::~Fl_Printer(void)
{
delete printer;
diff --git a/src/Fl_Widget_Surface.cxx b/src/Fl_Widget_Surface.cxx
index 23597732b..79e4fb33e 100644
--- a/src/Fl_Widget_Surface.cxx
+++ b/src/Fl_Widget_Surface.cxx
@@ -47,6 +47,8 @@ void Fl_Widget_Surface::draw(Fl_Widget* widget, int delta_x, int delta_y)
{
int old_x, old_y, new_x, new_y, is_window;
if ( ! widget->visible() ) return;
+ bool need_push = !is_current();
+ if (need_push) Fl_Surface_Device::push_current(this);
is_window = (widget->as_window() != NULL);
uchar old_damage = widget->damage();
widget->damage(FL_DAMAGE_ALL);
@@ -87,6 +89,7 @@ void Fl_Widget_Surface::draw(Fl_Widget* widget, int delta_x, int delta_y)
}
if ((old_damage & FL_DAMAGE_CHILD) == 0) widget->clear_damage(old_damage);
else widget->damage(FL_DAMAGE_ALL);
+ if (need_push) Fl_Surface_Device::pop_current();
}
@@ -150,7 +153,8 @@ void Fl_Widget_Surface::origin(int x, int y) {
*/
void Fl_Widget_Surface::print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x, int delta_y)
{
- Fl_Surface_Device::push_current(Fl_Display_Device::display_device());
+ bool need_push = !Fl_Display_Device::display_device()->is_current();
+ if (need_push) Fl_Surface_Device::push_current(Fl_Display_Device::display_device());
Fl_Window *save_front = Fl::first_window();
win->show();
Fl::check();
@@ -158,9 +162,12 @@ void Fl_Widget_Surface::print_window_part(Fl_Window *win, int x, int y, int w, i
Fl_RGB_Image *img = Fl_Screen_Driver::traverse_to_gl_subwindows(win, x, y, w, h, NULL);
if (img) img->scale(w, h, 1, 1);
if (save_front != win) save_front->show();
- Fl_Surface_Device::pop_current();
+ if (need_push) Fl_Surface_Device::pop_current();
if (img) {
+ need_push = !is_current();
+ if (need_push) Fl_Surface_Device::push_current(this);
img->draw(delta_x, delta_y);
+ if (need_push) Fl_Surface_Device::pop_current();
delete img;
}
}
@@ -187,6 +194,8 @@ void Fl_Widget_Surface::draw_decorated_window(Fl_Window *win, int win_offset_x,
if (win->border() && !win->parent()) {
Fl_Window_Driver::driver(win)->capture_titlebar_and_borders(top, left, bottom, right);
}
+ bool need_push = !is_current();
+ if (need_push) Fl_Surface_Device::push_current(this);
int wsides = left ? left->w() : 0;
int toph = top ? top->h() : 0;
if (top) {
@@ -206,6 +215,7 @@ void Fl_Widget_Surface::draw_decorated_window(Fl_Window *win, int win_offset_x,
delete bottom;
}
this->draw(win, win_offset_x + wsides, win_offset_y + toph);
+ if (need_push) Fl_Surface_Device::pop_current();
}
//
diff --git a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx
index 58fc1a8f2..053c90ff0 100644
--- a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx
+++ b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx
@@ -37,7 +37,6 @@ protected:
void untranslate();
int w() {return width;}
int h() {return height;}
- int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
};
diff --git a/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H b/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H
index b52c574fa..aacf6b749 100644
--- a/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H
+++ b/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H
@@ -39,7 +39,6 @@ protected:
void untranslate();
int w() {return width;}
int h() {return height;}
- int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
};
#endif /* Fl_Quartz_Copy_Surface_Driver_H */
diff --git a/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
index 67ebc5c66..152318d37 100644
--- a/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
@@ -39,7 +39,6 @@ protected:
void untranslate();
int w() {return width;}
int h() {return height;}
- int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
};