diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-04-10 13:14:04 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-04-10 13:14:04 +0200 |
| commit | 7a0bebb22fba0e2ed260b513421f6082a1c27a9e (patch) | |
| tree | 2dd0a5b06a4f404767527722bb3de2b08a3db05c /src | |
| parent | 22a5dc3085836f17c0e895040b7dac4a7a0919c5 (diff) | |
New virtual member function bool Fl_Surface_Device::is_current()
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Copy_Surface.cxx | 9 | ||||
| -rw-r--r-- | src/Fl_Device.cxx | 4 | ||||
| -rw-r--r-- | src/Fl_Image_Surface.cxx | 8 | ||||
| -rw-r--r-- | src/Fl_Printer.cxx | 4 | ||||
| -rw-r--r-- | src/Fl_Widget_Surface.cxx | 14 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx | 1 | ||||
| -rw-r--r-- | src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx | 1 |
8 files changed, 37 insertions, 5 deletions
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;} }; |
