summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2004-08-27 21:57:18 +0000
committerMatthias Melcher <fltk@matthiasm.com>2004-08-27 21:57:18 +0000
commit970bd864334fd3377a10dfadc782e48aea04ca83 (patch)
treee80517679965518ca36c332ee23177d58deed093
parentbc704ad62fb5883469922b1d42142d71f3555fd8 (diff)
Quartz:
- support for Fl_RGB_Image, including alpha rendering git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3794 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/Fl_Image.cxx57
1 files changed, 21 insertions, 36 deletions
diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx
index eb5681d72..37cbb5830 100644
--- a/src/Fl_Image.cxx
+++ b/src/Fl_Image.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Image.cxx,v 1.5.2.3.2.33 2004/08/25 00:20:25 matthiaswm Exp $"
+// "$Id: Fl_Image.cxx,v 1.5.2.3.2.34 2004/08/27 21:57:18 matthiaswm Exp $"
//
// Image drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -124,6 +124,10 @@ Fl_RGB_Image::~Fl_RGB_Image() {
}
void Fl_RGB_Image::uncache() {
+#ifdef __APPLE_QUARTZ__
+ if (id)
+ CGImageRelease((CGImageRef)id);
+#elif
if (id) {
fl_delete_offscreen((Fl_Offscreen)id);
id = 0;
@@ -133,6 +137,7 @@ void Fl_RGB_Image::uncache() {
fl_delete_bitmask((Fl_Bitmask)mask);
mask = 0;
}
+#endif
}
Fl_Image *Fl_RGB_Image::copy(int W, int H) {
@@ -309,6 +314,15 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
if (cy+H > h()) H = h()-cy;
if (H <= 0) return;
if (!id) {
+#ifdef __APPLE_QUARTZ__
+ CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
+ CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, w()*h()*d(), 0L);
+ id = CGImageCreate( w(), h(), 8, d()*8, ld()?ld():w()*d(),
+ lut, (d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
+ src, 0L, false, kCGRenderingIntentDefault);
+ CGColorSpaceRelease(lut);
+ CGDataProviderRelease(src);
+#else
id = fl_create_offscreen(w(), h());
fl_begin_offscreen((Fl_Offscreen)id);
fl_draw_image(array, 0, 0, w(), h(), d(), ld());
@@ -317,6 +331,7 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
if (d() == 2 || d() == 4) {
mask = fl_create_alphamask(w(), h(), d(), ld(), array);
}
+#endif
}
#ifdef WIN32
if (mask) {
@@ -365,40 +380,10 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy);
}
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
- if (mask) {
- Rect src, dst;
- // MRS: STR #114 says we should be using cx, cy, W, and H...
-// src.left = 0; src.right = w();
-// src.top = 0; src.bottom = h();
-// dst.left = X; dst.right = X+w();
-// dst.top = Y; dst.bottom = Y+h();
- src.left = cx; src.right = cx+W;
- src.top = cy; src.bottom = cy+H;
- dst.left = X; dst.right = X+W;
- dst.top = Y; dst.bottom = Y+H;
- RGBColor rgb;
- rgb.red = 0xffff; rgb.green = 0xffff; rgb.blue = 0xffff;
- RGBBackColor(&rgb);
- rgb.red = 0x0000; rgb.green = 0x0000; rgb.blue = 0x0000;
- RGBForeColor(&rgb);
-
-# if 0
- // MRS: This *should* work, but doesn't on my system (iBook); change to
- // "#if 1" and restore the corresponding code in Fl_Bitmap.cxx
- // to test the real alpha channel support.
- CopyDeepMask(GetPortBitMapForCopyBits((GrafPtr)id),
- GetPortBitMapForCopyBits((GrafPtr)mask),
- GetPortBitMapForCopyBits(GetWindowPort(fl_window)),
- &src, &src, &dst, blend, NULL);
-# else // Fallback to screen-door transparency...
- CopyMask(GetPortBitMapForCopyBits((GrafPtr)id),
- GetPortBitMapForCopyBits((GrafPtr)mask),
- GetPortBitMapForCopyBits(GetWindowPort(fl_window)),
- &src, &src, &dst);
-# endif // 0
- } else {
- fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy);
+# warning : Quartz implementation not finished yet
+ if (id && fl_gc) {
+ CGRect rect = { X, Y, w(), h() };
+ CGContextDrawImage(fl_gc, rect, (CGImageRef)id);
}
#else
if (mask) {
@@ -433,5 +418,5 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) {
//
-// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.33 2004/08/25 00:20:25 matthiaswm Exp $".
+// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.34 2004/08/27 21:57:18 matthiaswm Exp $".
//