summaryrefslogtreecommitdiff
path: root/src/drivers/Quartz
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/Quartz')
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h13
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx41
2 files changed, 36 insertions, 18 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h
index f72e8be8d..04d214504 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h
@@ -22,14 +22,10 @@
\brief Definition of Apple Quartz graphics driver.
*/
-#include "../../config_lib.h"
-#ifdef FL_CFG_GFX_QUARTZ
-
#ifndef FL_QUARTZ_GRAPHICS_DRIVER_H
#define FL_QUARTZ_GRAPHICS_DRIVER_H
-#include <FL/Fl_Device.H>
-
+#include <FL/Fl_Graphics_Driver.H>
// typedef what the x,y fields in a point are:
// FIXME: this is still defined in Fl_Device.H, but should be invisible to the user
@@ -59,6 +55,10 @@ public:
void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
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);
+ fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array);
+ void uncache(Fl_Bitmap *img, fl_uintptr_t &id_);
+ void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_);
#if ! defined(FL_DOXYGEN)
static Fl_Offscreen create_offscreen_with_alpha(int w, int h);
#endif
@@ -122,11 +122,8 @@ protected:
int descent();
};
-
#endif // FL_QUARTZ_GRAPHICS_DRIVER_H
-#endif // FL_CFG_GFX_QUARTZ
-
//
// End of "$Id: quartz.H 11017 2016-01-20 21:40:12Z matt $".
//
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
index 442b8b29a..9a2180910 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
@@ -17,7 +17,6 @@
//
#include "../../config_lib.h"
-#ifdef FL_CFG_GFX_QUARTZ
#include "Fl_Quartz_Graphics_Driver.h"
@@ -221,12 +220,12 @@ void Fl_Quartz_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP,
// If the CGImage is printed, it is not deallocated until after the end of the page,
// therefore, with img->alloc_array != 0, the RGB image can be safely deleted any time after return from this function.
// The previously unused mask_ member allows to make sure the RGB image data is not deleted by Fl_RGB_Image::uncache().
- if (img->alloc_array) img->mask_ = new bool(true);
- CGDataProviderRef src = CGDataProviderCreateWithData(img->mask_, img->array, ld * img->h(),
+ if (img->alloc_array) img->mask_ = (fl_uintptr_t)new bool(true);
+ CGDataProviderRef src = CGDataProviderCreateWithData((void*)img->mask_, img->array, ld * img->h(),
img->alloc_array?imgProviderReleaseData:NULL);
- img->id_ = CGImageCreate(img->w(), img->h(), 8, img->d()*8, ld,
- lut, (img->d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
- src, 0L, false, kCGRenderingIntentDefault);
+ img->id_ = (fl_uintptr_t)CGImageCreate(img->w(), img->h(), 8, img->d()*8, ld,
+ lut, (img->d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
+ src, 0L, false, kCGRenderingIntentDefault);
CGColorSpaceRelease(lut);
CGDataProviderRelease(src);
}
@@ -244,9 +243,9 @@ void Fl_Quartz_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP,
img->uncache();
CGColorSpaceRef lut = img->d()<=2 ? CGColorSpaceCreateDeviceGray() : CGColorSpaceCreateDeviceRGB();
CGDataProviderRef src = CGDataProviderCreateWithData( NULL, img_bytes, ld * img->h(), imgProviderReleaseData);
- img->id_ = CGImageCreate(img->w(), img->h(), 8, img->d()*8, ld,
- lut, (img->d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
- src, 0L, true, kCGRenderingIntentDefault);
+ img->id_ = (fl_uintptr_t)CGImageCreate(img->w(), img->h(), 8, img->d()*8, ld,
+ lut, (img->d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
+ src, 0L, true, kCGRenderingIntentDefault);
CGColorSpaceRelease(lut);
CGDataProviderRelease(src);
}
@@ -298,9 +297,31 @@ void Fl_Quartz_Graphics_Driver::delete_bitmask(Fl_Bitmask bm) {
if (bm) CGImageRelease((CGImageRef)bm);
}
+void Fl_Quartz_Graphics_Driver::uncache(Fl_RGB_Image*, fl_uintptr_t &id_, fl_uintptr_t &mask_) {
+ if (id_) {
+ if (mask_) *(bool*)mask_ = false;
+ CGImageRelease((CGImageRef)id_);
+ id_ = 0;
+ mask_ = NULL;
+ }
+}
+
+fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Bitmap*, int w, int h, const uchar *array) {
+ return (fl_uintptr_t)create_bitmask(w, h, array);
+}
+void Fl_Quartz_Graphics_Driver::uncache(Fl_Bitmap*, fl_uintptr_t &id_) {
+ delete_bitmask((Fl_Bitmask)id_);
+}
-#endif // FL_CFG_GFX_QUARTZ
+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_begin_offscreen(id);
+ fl_draw_pixmap(data, 0, 0, FL_BLACK);
+ fl_end_offscreen();
+ return (fl_uintptr_t)id;
+}
//
// End of "$Id$".