summaryrefslogtreecommitdiff
path: root/FL
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-02-27 13:52:27 +0000
committerManolo Gouy <Manolo>2016-02-27 13:52:27 +0000
commit0b406baa0f05d8b829d2c35b10c8450e7628be53 (patch)
tree62d91890f7194e00ea9f40e89f640c7c013c7b45 /FL
parent5d24872dc40e1047cea6337d8823718ac2acd575 (diff)
Rewrite all fl_XXX_offscreen() functions so they use an Fl_Image_Surface object.
These functions become therefore platform-independent. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11241 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL')
-rw-r--r--FL/Fl_Graphics_Driver.H2
-rw-r--r--FL/Fl_Image_Surface.H23
-rw-r--r--FL/fl_draw.H16
-rw-r--r--FL/mac.H5
-rw-r--r--FL/win32.H7
-rw-r--r--FL/x.H14
6 files changed, 37 insertions, 30 deletions
diff --git a/FL/Fl_Graphics_Driver.H b/FL/Fl_Graphics_Driver.H
index 4f42af878..4d2f675b9 100644
--- a/FL/Fl_Graphics_Driver.H
+++ b/FL/Fl_Graphics_Driver.H
@@ -253,11 +253,11 @@ public:
virtual void gc(void*) {}
/** Returns the driver-specific graphics context, of NULL if there's none. */
virtual void *gc(void) {return NULL;}
-protected:
/** Support for pixmap drawing */
virtual uchar **mask_bitmap() { return 0; }
/** Support for pixmap drawing */
virtual void mask_bitmap(uchar **) {}
+protected:
// --- implementation is in src/fl_vertex.cxx which includes src/cfg_gfx/xxx_rect.cxx
virtual void transformed_vertex0(COORD_T x, COORD_T y);
virtual void fixloop();
diff --git a/FL/Fl_Image_Surface.H b/FL/Fl_Image_Surface.H
index b335b79a5..3a62fb081 100644
--- a/FL/Fl_Image_Surface.H
+++ b/FL/Fl_Image_Surface.H
@@ -45,27 +45,38 @@
\endcode
*/
class FL_EXPORT Fl_Image_Surface : public Fl_Widget_Surface {
+ friend Fl_Offscreen fl_create_offscreen(int, int);
+#ifndef FL_DOXYGEN
+ friend Fl_Offscreen fl_create_offscreen_with_alpha(int, int);//X11 only
+#endif
+ friend void fl_begin_offscreen(Fl_Offscreen);
+ friend void fl_end_offscreen(void);
+ friend void fl_delete_offscreen(Fl_Offscreen);
private:
Fl_Offscreen offscreen;
int width;
int height;
+ Fl_Surface_Device *previous;
+ Window pre_window;
+#if defined(__APPLE__)
+ int was_high;
+#endif
+ Fl_Image_Surface(Fl_Offscreen pixmap, int w, int h); // for X11 only
+ void initialize_(Fl_Offscreen pixmap, int w, int h, int high_res);
+ void end_current();
#ifdef __APPLE__ // PORTME: Fl_Surface_Driver - platform image surface driver
#elif defined(WIN32)
- HDC _sgc;
- Window _sw;
- Fl_Surface_Device *_ss;
+ HDC _sgc;
int _savedc;
#elif defined(FL_PORTING)
# pragma message "FL_PORTING: define variables to hold image data for Fl_Image_Surface"
#else
- Fl_Surface_Device *previous;
- Window pre_window;
#endif
protected:
void translate(int x, int y);
void untranslate();
public:
- Fl_Image_Surface(int w, int h, int highres = 0);
+ Fl_Image_Surface(int w, int h, int high_res = 0);
~Fl_Image_Surface();
void set_current();
Fl_RGB_Image *image();
diff --git a/FL/fl_draw.H b/FL/fl_draw.H
index f108ce420..ecd6c1410 100644
--- a/FL/fl_draw.H
+++ b/FL/fl_draw.H
@@ -494,6 +494,22 @@ inline double fl_transform_dy(double x, double y) {return fl_graphics_driver->tr
\param[in] xf,yf transformed coordinate
*/
inline void fl_transformed_vertex(double xf, double yf) {fl_graphics_driver->transformed_vertex(xf,yf); }
+
+/** Copy a rectangular area of the given offscreen buffer into the current drawing destination.
+ \param x,y position where to draw the copied rectangle
+ \param w,h size of the copied rectangle
+ \param pixmap offscreen buffer containing the rectangle to copy
+ \param srcx,srcy origin in offscreen buffer of rectangle to copy
+ */
+inline void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
+ fl_graphics_driver->copy_offscreen(x, y, w, h, pixmap, srcx, srcy);
+}
+
+FL_EXPORT Fl_Offscreen fl_create_offscreen(int w, int h);
+FL_EXPORT void fl_begin_offscreen(Fl_Offscreen b);
+FL_EXPORT void fl_end_offscreen(void);
+FL_EXPORT void fl_delete_offscreen(Fl_Offscreen bitmap);
+
/** @} */
/** \addtogroup fl_attributes
diff --git a/FL/mac.H b/FL/mac.H
index 7de2b2008..594ff7384 100644
--- a/FL/mac.H
+++ b/FL/mac.H
@@ -219,11 +219,6 @@ void fl_clip_region(Fl_Region);
extern Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
extern Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
extern void fl_delete_bitmask(Fl_Bitmask bm);
-extern Fl_Offscreen fl_create_offscreen(int w, int h);
-extern void fl_copy_offscreen(int x,int y,int w,int h, Fl_Offscreen gWorld, int srcx,int srcy);
-extern void fl_delete_offscreen(Fl_Offscreen gWorld);
-extern void fl_begin_offscreen(Fl_Offscreen gWorld);
-extern void fl_end_offscreen();
extern int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
extern void fl_open_display();
diff --git a/FL/win32.H b/FL/win32.H
index a7b4ce430..4043e1ee4 100644
--- a/FL/win32.H
+++ b/FL/win32.H
@@ -131,9 +131,8 @@ extern FL_EXPORT MSG fl_msg;
extern FL_EXPORT HDC fl_GetDC(Window);
extern FL_EXPORT HDC fl_makeDC(HBITMAP);
-// off-screen pixmaps: create, destroy, draw into, copy to window
typedef HBITMAP Fl_Offscreen;
-#define fl_create_offscreen(w, h) \
+/*#define fl_create_offscreen(w, h) \
CreateCompatibleBitmap( (fl_graphics_driver->gc() ? (HDC)fl_graphics_driver->gc() : fl_GetDC(0) ) , w, h)
# define fl_begin_offscreen(b) \
@@ -146,9 +145,7 @@ Fl_Display_Device::display_device()->set_current(); \
# define fl_end_offscreen() \
fl_pop_clip(); RestoreDC((HDC)fl_graphics_driver->gc(), _savedc); DeleteDC((HDC)fl_graphics_driver->gc()); _ss->set_current(); fl_window=_sw; fl_graphics_driver->gc(_sgc);
-
-FL_EXPORT void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy);
-#define fl_delete_offscreen(bitmap) DeleteObject(bitmap)
+#define fl_delete_offscreen(bitmap) DeleteObject(bitmap)*/
// Bitmap masks
typedef HBITMAP Fl_Bitmask;
diff --git a/FL/x.H b/FL/x.H
index cbab3dc4d..393f57935 100644
--- a/FL/x.H
+++ b/FL/x.H
@@ -76,20 +76,8 @@ FL_EXPORT int fl_handle(const XEvent&);
extern FL_EXPORT const XEvent* fl_xevent;
extern FL_EXPORT ulong fl_event_time;
-// off-screen pixmaps: create, destroy, draw into, copy to window:
typedef ulong Fl_Offscreen;
-# define fl_create_offscreen(w,h) XCreatePixmap(fl_display, RootWindow(fl_display, fl_screen), w, h, fl_visual->depth)
-# define fl_create_offscreen_with_alpha(w,h) XCreatePixmap(fl_display, RootWindow(fl_display, fl_screen), w, h, 32)
-// begin/end are macros that save the old state in local variables:
-# define fl_begin_offscreen(pixmap) \
- Window _sw=fl_window; fl_window=pixmap; \
- Fl_Surface_Device *_ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); \
- fl_push_no_clip()
-# define fl_end_offscreen() \
- fl_pop_clip(); fl_window = _sw; _ss->set_current()
-
-extern FL_EXPORT void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
-# define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap)
+extern FL_EXPORT Fl_Offscreen fl_create_offscreen_with_alpha(int,int);
// Bitmap masks
typedef ulong Fl_Bitmask;