Fix PicoSDL.

Fixed some issues with Image_Surface and Copy_Surface for PicoSDL. Still have to virtualize the driver concept.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11307 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher
2016-03-07 20:50:18 +00:00
parent b33c9cffd1
commit b6b99d84e9
10 changed files with 64 additions and 29 deletions
+5 -5
View File
@@ -54,18 +54,18 @@ class Fl_Widget;
*/
class FL_EXPORT Fl_Surface_Device {
/** \brief The graphics driver in use by this surface. */
Fl_Graphics_Driver *_driver;
Fl_Graphics_Driver *pGraphicsDriver;
static Fl_Surface_Device *_surface; // the surface that currently receives graphics output
static Fl_Surface_Device *default_surface(); // create surface is none exists yet
static Fl_Surface_Device *default_surface(); // create surface if none exists yet
protected:
/** \brief Constructor that sets the graphics driver to use for the created surface. */
Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver; };
Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver; };
public:
virtual void set_current(void);
/** \brief Sets the graphics driver of this drawing surface. */
inline void driver(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver;};
inline void driver(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver;};
/** \brief Returns the graphics driver of this drawing surface. */
inline Fl_Graphics_Driver *driver() {return _driver; };
inline Fl_Graphics_Driver *driver() {return pGraphicsDriver; };
/** The current drawing surface.
In other words, the Fl_Surface_Device object that currently receives all graphics output */
static inline Fl_Surface_Device *surface() {
+34 -15
View File
@@ -25,24 +25,43 @@
#include <FL/x.H> // for Fl_Offscreen
/** Directs all graphics requests to an Fl_Image.
/**
\brief Directs all graphics requests to an Fl_Image.
After creation of an Fl_Image_Surface object, call set_current() on it, and all subsequent graphics requests
will be recorded in the image. It's possible to draw widgets (using Fl_Image_Surface::draw())
or to use any of the \ref fl_drawings or the \ref fl_attributes.
Finally, call image() on the object to obtain a newly allocated Fl_RGB_Image object.
<br> Fl_GL_Window objects can be drawn in the image as well.
After creation of an Fl_Image_Surface object, call set_current() on it, and all
subsequent graphics requests will be recorded in the image. It's possible to
draw widgets (using Fl_Image_Surface::draw()) or to use any of the
\ref fl_drawings or the \ref fl_attributes. Finally, call image() on the object
to obtain a newly allocated Fl_RGB_Image object.
<br> Usage example:
Fl_GL_Window objects can be drawn in the image as well.
\example
\code
Fl_Widget *g = ...; // a widget you want to draw in an image
Fl_Image_Surface *img_surf = new Fl_Image_Surface(g->w(), g->h()); // create an Fl_Image_Surface object
img_surf->set_current(); // direct graphics requests to the image
fl_color(FL_WHITE); fl_rectf(0, 0, g->w(), g->h()); // draw a white background
img_surf->draw(g); // draw the g widget in the image
Fl_RGB_Image* image = img_surf->image(); // get the resulting image
delete img_surf; // delete the img_surf object
Fl_Display_Device::display_device()->set_current(); // direct graphics requests back to the display
// this is the widget that you want to draw into an image
Fl_Widget *g = ...;
// create an Fl_Image_Surface object
Fl_Image_Surface *image_surface = new Fl_Image_Surface(g->w(), g->h());
// direct all further graphics requests to the image
image_surface->set_current();
// draw a white background
fl_color(FL_WHITE);
fl_rectf(0, 0, g->w(), g->h());
// draw the g widget in the image
image_surface->draw(g);
// get the resulting image
Fl_RGB_Image* image = image_surface->image();
// delete the image_surface object, but not the image itself
delete image_surface;
// direct graphics requests back to the screen
Fl_Display_Device::display_device()->set_current();
\endcode
*/
class FL_EXPORT Fl_Image_Surface : public Fl_Widget_Surface {
+2
View File
@@ -211,6 +211,7 @@ elseif (USE_SDL)
drivers/Pico/Fl_Pico_Window_Driver.cxx
drivers/Pico/Fl_Pico_Graphics_Driver.cxx
drivers/Pico/Fl_Pico_Copy_Surface.cxx
drivers/Pico/Fl_Pico_Image_Surface.cxx
drivers/PicoSDL/Fl_PicoSDL_System_Driver.cxx
drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.cxx
drivers/PicoSDL/Fl_PicoSDL_Window_Driver.cxx
@@ -224,6 +225,7 @@ elseif (USE_SDL)
drivers/Pico/Fl_Pico_Window_Driver.H
drivers/Pico/Fl_Pico_Graphics_Driver.H
drivers/Pico/Fl_Pico_Copy_Surface.H
drivers/Pico/Fl_Pico_Image_Surface.H
drivers/PicoSDL/Fl_PicoSDL_System_Driver.H
drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.H
drivers/PicoSDL/Fl_PicoSDL_Window_Driver.H
+2 -2
View File
@@ -26,9 +26,9 @@
#include <src/drivers/GDI/Fl_GDI_Copy_Surface.H>
#elif defined(USE_SDL)
#include <src/drivers/SDL/Fl_SDL_Copy_Surface.H>
#include <src/drivers/PicoSDL/Fl_PicoSDL_Copy_Surface.H>
#elif defined(FL_PORTING)
#elif defined(FL_PORTING) || defined(USE_SDL)
# pragma message "FL_PORTING: implement class Fl_Copy_Surface::Helper for your platform"
class Fl_Copy_Surface::Helper : public Fl_Widget_Surface { // class model
+2 -2
View File
@@ -55,9 +55,9 @@ bool Fl_Display_Device::high_res_window_ = false;
This surface will receive all future graphics requests. */
void Fl_Surface_Device::set_current(void)
{
fl_graphics_driver = _driver;
fl_graphics_driver = pGraphicsDriver;
_surface = this;
_driver->global_gc();
pGraphicsDriver->global_gc();
}
Fl_Surface_Device* Fl_Surface_Device::_surface; // the current target surface of graphics operations
+2 -3
View File
@@ -27,10 +27,9 @@
#include <src/drivers/GDI/Fl_GDI_Image_Surface.H>
#elif defined(USE_SDL)
#include <src/drivers/SDL/Fl_SDL_Image_Surface.H>
#include <src/drivers/PicoSDL/Fl_PicoSDL_Image_Surface.H>
#elif defined(FL_PORTING)
#elif defined(FL_PORTING) || defined(USE_SDL)
# pragma message "FL_PORTING: implement class Fl_Image_Surface::Helper for your platform"
class Fl_Image_Surface::Helper : public Fl_Widget_Surface { // class model
@@ -0,0 +1 @@
@@ -1 +1,15 @@
class Fl_Copy_Surface::Helper : public Fl_Widget_Surface { // class model
friend class Fl_Copy_Surface;
private:
int width;
int height;
Helper(int w, int h) : Fl_Widget_Surface(NULL), width(w), height(h) {} // to implement
~Helper() {} // to implement
void set_current(){} // to implement
void translate(int x, int y) {} // to implement
void untranslate() {} // to implement
int w() {return width;}
int h() {return height;}
int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
};
@@ -143,8 +143,8 @@ void Fl_Window::resize(int, int, int, int) { }
Fl_Window *Fl_Window::current_;
char fl_show_iconic;
Window fl_window;
void Fl_Image_Surface::translate(int x, int y) { }
void Fl_Image_Surface::untranslate() { }
//void Fl_Image_Surface::translate(int x, int y) { }
//void Fl_Image_Surface::untranslate() { }
/*
#define __APPLE__