summaryrefslogtreecommitdiff
path: root/src/drivers
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 /src/drivers
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 'src/drivers')
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx8
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx90
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx3
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx4
4 files changed, 7 insertions, 98 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
index 4a1c6e007..f750e1785 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
@@ -173,7 +173,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
int blocking = h;
{int size = linesize*h;
// when printing, don't limit buffer size not to get a crash in StretchDIBits
- if (size > MAXBUFFER && Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) {
+ if (size > MAXBUFFER && !fl_graphics_driver->has_feature(Fl_Graphics_Driver::PRINTER)) {
size = MAXBUFFER;
blocking = MAXBUFFER/linesize;
}
@@ -251,7 +251,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
}
}
}
- if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) {
+ if (fl_graphics_driver->has_feature(Fl_Graphics_Driver::PRINTER)) {
// if print context, device and logical units are not equal, so SetDIBitsToDevice
// does not do the expected job, whereas StretchDIBits does it.
StretchDIBits(gc, x, y+j-k, w, k, 0, 0, w, k,
@@ -633,11 +633,11 @@ fl_uintptr_t Fl_GDI_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, const c
id = fl_create_offscreen(w, h);
fl_begin_offscreen(id);
uchar *bitmap = 0;
- mask_bitmap(&bitmap);
+ fl_graphics_driver->mask_bitmap(&bitmap);
fl_draw_pixmap(data, 0, 0, FL_BLACK);
extern UINT win_pixmap_bg_color; // computed by fl_draw_pixmap()
img->pixmap_bg_color = win_pixmap_bg_color;
- mask_bitmap(0);
+ fl_graphics_driver->mask_bitmap(0);
if (bitmap) {
img->mask_ = (fl_uintptr_t)fl_create_bitmask(w, h, bitmap);
delete[] bitmap;
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
index 7186a030a..f1b159960 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
@@ -40,16 +40,6 @@ Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver()
return new Fl_Quartz_Graphics_Driver();
}
-#ifndef FL_DOXYGEN
-Fl_Offscreen Fl_Quartz_Graphics_Driver::create_offscreen_with_alpha(int w, int h) {
- void *data = calloc(w*h,4);
- CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
- CGContextRef ctx = CGBitmapContextCreate(data, w, h, 8, w*4, lut, kCGImageAlphaPremultipliedLast);
- CGColorSpaceRelease(lut);
- return (Fl_Offscreen)ctx;
-}
-#endif
-
char Fl_Quartz_Graphics_Driver::can_do_alpha_blending() {
return 1;
}
@@ -80,86 +70,6 @@ void Fl_Quartz_Graphics_Driver::copy_offscreen(int x,int y,int w,int h,Fl_Offscr
CGDataProviderRelease(src_bytes);
}
-/** \addtogroup fl_drawings
- @{
- */
-
-// FIXME: driver system
-/**
- Creation of an offscreen graphics buffer.
- \param w,h width and height in pixels of the buffer.
- \return the created graphics buffer.
- */
-Fl_Offscreen fl_create_offscreen(int w, int h) {
- void *data = calloc(w*h,4);
- CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
- CGContextRef ctx = CGBitmapContextCreate(
- data, w, h, 8, w*4, lut, kCGImageAlphaNoneSkipLast);
- CGColorSpaceRelease(lut);
- return (Fl_Offscreen)ctx;
-}
-
-// FIXME: driver system
-/** Deletion of an offscreen graphics buffer.
- \param ctx the buffer to be deleted.
- */
-void fl_delete_offscreen(Fl_Offscreen ctx) {
- if (!ctx) return;
- void *data = CGBitmapContextGetData((CGContextRef)ctx);
- CFIndex count = CFGetRetainCount(ctx);
- CGContextRelease((CGContextRef)ctx);
- if(count == 1) free(data);
-}
-
-// FIXME: driver system
-const int stack_max = 16;
-static int stack_ix = 0;
-static CGContextRef stack_gc[stack_max];
-static Window stack_window[stack_max];
-static Fl_Surface_Device *_ss;
-
-// FIXME: driver system
-/** Send all subsequent drawing commands to this offscreen buffer.
- \param ctx the offscreen buffer.
- */
-void fl_begin_offscreen(Fl_Offscreen ctx) {
- _ss = Fl_Surface_Device::surface();
- Fl_Display_Device::display_device()->set_current();
- if (stack_ix<stack_max) {
- stack_gc[stack_ix] = (CGContextRef)fl_graphics_driver->gc();
- stack_window[stack_ix] = fl_window;
- } else
- fprintf(stderr, "FLTK CGContext Stack overflow error\n");
- stack_ix++;
-
- fl_graphics_driver->gc(ctx);
- fl_window = 0;
- CGContextSaveGState(ctx);
- fl_graphics_driver->push_no_clip();
-}
-
-// FIXME: driver system
-/** Quit sending drawing commands to the current offscreen buffer.
- */
-void fl_end_offscreen() {
- fl_graphics_driver->pop_clip();
- CGContextRef gc = (CGContextRef)fl_graphics_driver->gc();
-
- CGContextRestoreGState(gc); // matches CGContextSaveGState in fl_begin_offscreen()
- CGContextFlush(gc);
- if (stack_ix>0)
- stack_ix--;
- else
- fprintf(stderr, "FLTK CGContext Stack underflow error\n");
- if (stack_ix<stack_max) {
- fl_graphics_driver->gc(stack_gc[stack_ix]);
- fl_window = stack_window[stack_ix];
- }
- _ss->set_current();
-}
-
-/** @} */
-
//
// End of "$Id$".
//
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
index a72e09b1e..3574adce5 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
@@ -301,8 +301,7 @@ fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Bitmap*, int w, int h, const uc
}
fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, const char *const*data) {
- Fl_Offscreen id;
- id = create_offscreen_with_alpha(w, h);
+ Fl_Offscreen id = fl_create_offscreen(w, h);
fl_begin_offscreen(id);
fl_draw_pixmap(data, 0, 0, FL_BLACK);
fl_end_offscreen();
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
index e1da7df3f..723c22838 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
@@ -812,9 +812,9 @@ fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, const
id = fl_create_offscreen(w, h);
fl_begin_offscreen(id);
uchar *bitmap = 0;
- mask_bitmap(&bitmap);
+ fl_graphics_driver->mask_bitmap(&bitmap);
fl_draw_pixmap(data, 0, 0, FL_BLACK);
- mask_bitmap(0);
+ fl_graphics_driver->mask_bitmap(0);
if (bitmap) {
img->mask_ = (fl_uintptr_t)fl_create_bitmask(w, h, bitmap);
delete[] bitmap;