Complete the platform-neutral implementation of fl_XXX_offscreen() functions.
It is necessary to have a stack of the fl_begin_offscreen() calls, so that nested such calls apply fl_end_offscreen() to the matching fl_begin_offscreen(). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11289 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
3f401f4477
commit
e7a0f7c5d0
@ -221,7 +221,6 @@ public:
|
||||
// --- implementation is in src/fl_image.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_font.cxx
|
||||
virtual Fl_Bitmask create_bitmask(int w, int h, const uchar *array) = 0;
|
||||
virtual fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array) { return 0; }
|
||||
virtual void uncache(Fl_Pixmap *img) { }
|
||||
virtual fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array) { return 0; }
|
||||
virtual void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_) { }
|
||||
virtual void delete_bitmask(Fl_Bitmask bm) = 0;
|
||||
|
@ -132,7 +132,6 @@ Fl_Offscreen Fl_Image_Surface::get_offscreen_before_delete() {
|
||||
|
||||
static Fl_Image_Surface **offscreen_api_surface = NULL;
|
||||
static int count_offscreens = 0;
|
||||
static int current_offscreen;
|
||||
|
||||
static int find_slot(void) { // return an available slot to memorize an Fl_Image_Surface::Helper object
|
||||
static int max = 0;
|
||||
@ -175,14 +174,21 @@ void fl_delete_offscreen(Fl_Offscreen ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
static int stack_current_offscreen[16];
|
||||
static int stack_height = 0;
|
||||
|
||||
/** Send all subsequent drawing commands to this offscreen buffer.
|
||||
\param ctx the offscreen buffer.
|
||||
*/
|
||||
void fl_begin_offscreen(Fl_Offscreen ctx) {
|
||||
for (current_offscreen = 0; current_offscreen < count_offscreens; current_offscreen++) {
|
||||
if (offscreen_api_surface[current_offscreen] &&
|
||||
offscreen_api_surface[current_offscreen]->offscreen() == ctx) {
|
||||
offscreen_api_surface[current_offscreen]->set_current();
|
||||
for (int i = 0; i < count_offscreens; i++) {
|
||||
if (offscreen_api_surface[i] && offscreen_api_surface[i]->offscreen() == ctx) {
|
||||
offscreen_api_surface[i]->set_current();
|
||||
if (stack_height < sizeof(stack_current_offscreen)/sizeof(int)) {
|
||||
stack_current_offscreen[stack_height++] = i;
|
||||
} else {
|
||||
fprintf(stderr, "FLTK fl_begin_offscreen Stack overflow error\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -191,7 +197,10 @@ void fl_begin_offscreen(Fl_Offscreen ctx) {
|
||||
/** Quit sending drawing commands to the current offscreen buffer.
|
||||
*/
|
||||
void fl_end_offscreen() {
|
||||
offscreen_api_surface[current_offscreen]->end_current();
|
||||
if (stack_height > 0) {
|
||||
int i = stack_current_offscreen[--stack_height];
|
||||
offscreen_api_surface[i]->end_current();
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -101,11 +101,7 @@ Fl_Pixmap::~Fl_Pixmap() {
|
||||
|
||||
void Fl_Pixmap::uncache() {
|
||||
if (id_) {
|
||||
#ifdef __APPLE__
|
||||
fl_graphics_driver->uncache(this);
|
||||
#else
|
||||
fl_delete_offscreen((Fl_Offscreen)id_);
|
||||
#endif
|
||||
id_ = 0;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,6 @@ public:
|
||||
void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
|
||||
void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
|
||||
fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array);
|
||||
void uncache(Fl_Pixmap *img);
|
||||
fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array);
|
||||
void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_);
|
||||
void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/Fl_Printer.H>
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Image_Surface.H>
|
||||
|
||||
#define MAXBUFFER 0x40000 // 256k
|
||||
|
||||
@ -273,25 +272,13 @@ 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_Image_Surface *surface = new Fl_Image_Surface(w,h);
|
||||
surface->set_current();
|
||||
Fl_Offscreen id = fl_create_offscreen(w, h);
|
||||
fl_begin_offscreen(id);
|
||||
fl_draw_pixmap(data, 0, 0, FL_BLACK);
|
||||
surface->end_current();
|
||||
Fl_Offscreen id = surface->get_offscreen_before_delete();
|
||||
delete surface;
|
||||
fl_end_offscreen();
|
||||
return (fl_uintptr_t)id;
|
||||
}
|
||||
|
||||
void Fl_Quartz_Graphics_Driver::uncache(Fl_Pixmap *img)
|
||||
{
|
||||
if (img->id_) {
|
||||
void *data = CGBitmapContextGetData((CGContextRef)img->id_);
|
||||
free(data);
|
||||
CGContextRelease((CGContextRef)img->id_);
|
||||
img->id_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Fl_Quartz_Graphics_Driver::draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh)
|
||||
{
|
||||
CGRect rect = CGRectMake(x, y, w, h);
|
||||
|
Loading…
x
Reference in New Issue
Block a user