diff options
| author | Manolo Gouy <Manolo> | 2016-03-19 18:14:58 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-03-19 18:14:58 +0000 |
| commit | f936eb1a962d9578befff4d4cdeac64339644594 (patch) | |
| tree | 3f91ce050b1ee050dbaaf8cc04f99c73bb43cd34 /src/drivers/Xlib | |
| parent | 3dcc91d1f09b78a43f6fa8e8f13fd09076da0476 (diff) | |
Driver-based rewrite of the Fl_Copy_Surface class.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11374 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Xlib')
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Copy_Surface.cxx | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Copy_Surface.cxx b/src/drivers/Xlib/Fl_Xlib_Copy_Surface.cxx index 796fdf5af..8615fbb8b 100644 --- a/src/drivers/Xlib/Fl_Xlib_Copy_Surface.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Copy_Surface.cxx @@ -19,24 +19,51 @@ #include "../../config_lib.h" #ifdef FL_CFG_GFX_XLIB -#include "Fl_Xlib_Copy_Surface.H" +#include <FL/Fl_Copy_Surface.H> #include <FL/Fl.H> #include <FL/fl_draw.H> +#include "Fl_Translated_Xlib_Graphics_Driver.H" -Fl_Copy_Surface::Helper::Helper(int w, int h) : Fl_Widget_Surface(NULL), width(w), height(h) { +class Fl_Xlib_Copy_Surface_Driver : public Fl_Copy_Surface_Driver { + friend class Fl_Copy_Surface_Driver; +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(); + void translate(int x, int y); + void untranslate(); + int w() {return width;} + int h() {return height;} + int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;} +}; + + +Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int h) +{ + return new Fl_Xlib_Copy_Surface_Driver(w, h); +} + + +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()); xid = fl_create_offscreen(w,h); _ss = NULL; Fl_Surface_Device *present_surface = Fl_Surface_Device::surface(); - set_current(); - fl_color(FL_WHITE); - fl_rectf(0, 0, w, h); + Fl_Surface_Device::set_current(); + fl_window = xid; + driver()->color(FL_WHITE); + driver()->rectf(0, 0, w, h); present_surface->set_current(); + fl_window = oldwindow; } -Fl_Copy_Surface::Helper::~Helper() { + +Fl_Xlib_Copy_Surface_Driver::~Fl_Xlib_Copy_Surface_Driver() { fl_pop_clip(); unsigned char *data = fl_read_image(NULL,0,0,width,height,0); fl_window = oldwindow; @@ -46,18 +73,21 @@ Fl_Copy_Surface::Helper::~Helper() { fl_delete_offscreen(xid); } -void Fl_Copy_Surface::Helper::set_current() { - fl_window=xid; + +void Fl_Xlib_Copy_Surface_Driver::set_current() { + fl_window = xid; if (!_ss) _ss = Fl_Surface_Device::surface(); Fl_Surface_Device::set_current(); fl_push_no_clip(); } -void Fl_Copy_Surface::Helper::translate(int x, int y) { + +void Fl_Xlib_Copy_Surface_Driver::translate(int x, int y) { ((Fl_Translated_Xlib_Graphics_Driver*)driver())->translate_all(x, y); } -void Fl_Copy_Surface::Helper::untranslate() { + +void Fl_Xlib_Copy_Surface_Driver::untranslate() { ((Fl_Translated_Xlib_Graphics_Driver*)driver())->untranslate_all(); } |
