aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2008-05-04 19:46:16 +0000
committerMiles Bader2008-05-04 19:46:16 +0000
commitf67e15be8d94718b2e2ea7da68eb0b2dc94ce016 (patch)
treeb7cdaa984d777c3bd0425f2ca2612d9a1de0d832
parentf8a295058a5682dbc70f48f376fe51a18d21281a (diff)
parent092a8af3e7cc0d72c417f9eb19c7ac61ef782a87 (diff)
downloademacs-f67e15be8d94718b2e2ea7da68eb0b2dc94ce016.tar.gz
emacs-f67e15be8d94718b2e2ea7da68eb0b2dc94ce016.zip
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1142
-rw-r--r--ChangeLog7
-rwxr-xr-xconfigure140
-rw-r--r--configure.in1
-rw-r--r--src/ChangeLog49
-rw-r--r--src/config.in3
-rw-r--r--src/image.c399
-rw-r--r--src/macgui.h11
-rw-r--r--src/macterm.c99
-rw-r--r--src/macterm.h8
-rw-r--r--src/s/darwin.h24
10 files changed, 698 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index d5ab34f6252..f42a3a36bca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
12008-05-04 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * configure.in: Check availability of AvailabilityMacros.h
4 if HAVE_CARBON.
5
6 * configure: Regenerate.
7
12008-05-03 Glenn Morris <rgm@gnu.org> 82008-05-03 Glenn Morris <rgm@gnu.org>
2 9
3 * configure.in (x_libraries): Remove standard 64-bit directories - 10 * configure.in (x_libraries): Remove standard 64-bit directories -
diff --git a/configure b/configure
index 529e3af5a57..170eb393dea 100755
--- a/configure
+++ b/configure
@@ -15020,6 +15020,146 @@ cat >>confdefs.h <<\_ACEOF
15020#define HAVE_CARBON 1 15020#define HAVE_CARBON 1
15021_ACEOF 15021_ACEOF
15022 15022
15023
15024for ac_header in AvailabilityMacros.h
15025do
15026as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
15027if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
15028 { echo "$as_me:$LINENO: checking for $ac_header" >&5
15029echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
15030if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
15031 echo $ECHO_N "(cached) $ECHO_C" >&6
15032fi
15033ac_res=`eval echo '${'$as_ac_Header'}'`
15034 { echo "$as_me:$LINENO: result: $ac_res" >&5
15035echo "${ECHO_T}$ac_res" >&6; }
15036else
15037 # Is the header compilable?
15038{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
15039echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
15040cat >conftest.$ac_ext <<_ACEOF
15041/* confdefs.h. */
15042_ACEOF
15043cat confdefs.h >>conftest.$ac_ext
15044cat >>conftest.$ac_ext <<_ACEOF
15045/* end confdefs.h. */
15046$ac_includes_default
15047#include <$ac_header>
15048_ACEOF
15049rm -f conftest.$ac_objext
15050if { (ac_try="$ac_compile"
15051case "(($ac_try" in
15052 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15053 *) ac_try_echo=$ac_try;;
15054esac
15055eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15056 (eval "$ac_compile") 2>conftest.er1
15057 ac_status=$?
15058 grep -v '^ *+' conftest.er1 >conftest.err
15059 rm -f conftest.er1
15060 cat conftest.err >&5
15061 echo "$as_me:$LINENO: \$? = $ac_status" >&5
15062 (exit $ac_status); } && {
15063 test -z "$ac_c_werror_flag" ||
15064 test ! -s conftest.err
15065 } && test -s conftest.$ac_objext; then
15066 ac_header_compiler=yes
15067else
15068 echo "$as_me: failed program was:" >&5
15069sed 's/^/| /' conftest.$ac_ext >&5
15070
15071 ac_header_compiler=no
15072fi
15073
15074rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15075{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
15076echo "${ECHO_T}$ac_header_compiler" >&6; }
15077
15078# Is the header present?
15079{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
15080echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
15081cat >conftest.$ac_ext <<_ACEOF
15082/* confdefs.h. */
15083_ACEOF
15084cat confdefs.h >>conftest.$ac_ext
15085cat >>conftest.$ac_ext <<_ACEOF
15086/* end confdefs.h. */
15087#include <$ac_header>
15088_ACEOF
15089if { (ac_try="$ac_cpp conftest.$ac_ext"
15090case "(($ac_try" in
15091 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15092 *) ac_try_echo=$ac_try;;
15093esac
15094eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15095 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
15096 ac_status=$?
15097 grep -v '^ *+' conftest.er1 >conftest.err
15098 rm -f conftest.er1
15099 cat conftest.err >&5
15100 echo "$as_me:$LINENO: \$? = $ac_status" >&5
15101 (exit $ac_status); } >/dev/null && {
15102 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
15103 test ! -s conftest.err
15104 }; then
15105 ac_header_preproc=yes
15106else
15107 echo "$as_me: failed program was:" >&5
15108sed 's/^/| /' conftest.$ac_ext >&5
15109
15110 ac_header_preproc=no
15111fi
15112
15113rm -f conftest.err conftest.$ac_ext
15114{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
15115echo "${ECHO_T}$ac_header_preproc" >&6; }
15116
15117# So? What about this header?
15118case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
15119 yes:no: )
15120 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
15121echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
15122 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
15123echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
15124 ac_header_preproc=yes
15125 ;;
15126 no:yes:* )
15127 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
15128echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
15129 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
15130echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
15131 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
15132echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
15133 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
15134echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
15135 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
15136echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
15137 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
15138echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
15139
15140 ;;
15141esac
15142{ echo "$as_me:$LINENO: checking for $ac_header" >&5
15143echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
15144if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
15145 echo $ECHO_N "(cached) $ECHO_C" >&6
15146else
15147 eval "$as_ac_Header=\$ac_header_preproc"
15148fi
15149ac_res=`eval echo '${'$as_ac_Header'}'`
15150 { echo "$as_me:$LINENO: result: $ac_res" >&5
15151echo "${ECHO_T}$ac_res" >&6; }
15152
15153fi
15154if test `eval echo '${'$as_ac_Header'}'` = yes; then
15155 cat >>confdefs.h <<_ACEOF
15156#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
15157_ACEOF
15158
15159fi
15160
15161done
15162
15023 ## Specify the install directory 15163 ## Specify the install directory
15024 carbon_appdir= 15164 carbon_appdir=
15025 if test "${carbon_appdir_x}" != ""; then 15165 if test "${carbon_appdir_x}" != ""; then
diff --git a/configure.in b/configure.in
index bbaca559148..2e3aa63edc5 100644
--- a/configure.in
+++ b/configure.in
@@ -2230,6 +2230,7 @@ AC_CHECK_HEADER(malloc/malloc.h, [AC_DEFINE(HAVE_MALLOC_MALLOC_H, 1, [Define to
2230### Use Mac OS X Carbon API to implement GUI. 2230### Use Mac OS X Carbon API to implement GUI.
2231if test "${HAVE_CARBON}" = "yes"; then 2231if test "${HAVE_CARBON}" = "yes"; then
2232 AC_DEFINE(HAVE_CARBON, 1, [Define to 1 if you are using the Carbon API on Mac OS X.]) 2232 AC_DEFINE(HAVE_CARBON, 1, [Define to 1 if you are using the Carbon API on Mac OS X.])
2233 AC_CHECK_HEADERS(AvailabilityMacros.h)
2233 ## Specify the install directory 2234 ## Specify the install directory
2234 carbon_appdir= 2235 carbon_appdir=
2235 if test "${carbon_appdir_x}" != ""; then 2236 if test "${carbon_appdir_x}" != ""; then
diff --git a/src/ChangeLog b/src/ChangeLog
index 1bf4586c26a..48ee2eeca69 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,52 @@
12008-05-04 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * image.c [USE_MAC_IMAGE_IO] (image_load_image_io):
4 Create bitmap context in native byte order.
5
6 * macterm.c (XDrawLine)
7 (XCreatePixmapFromBitmapData) [USE_MAC_IMAGE_IO]: Create bitmap
8 context in native byte order.
9
102008-05-04 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
11
12 * config.in: Regenerate.
13
14 * image.c (PIX_MASK_DRAW, PIX_MASK_RETAIN) [USE_MAC_IMAGE_IO]:
15 New definitions for Image I/O support.
16 (XGetImage, XPutPixel, XGetPixel, XDestroyImage)
17 (mac_create_cg_image_from_image, x_create_x_image_and_pixmap)
18 [USE_MAC_IMAGE_IO]: Add implementations for Image I/O support.
19 (mac_data_provider_release_data, image_load_image_io)
20 [USE_MAC_IMAGE_IO]: New functions.
21 (CGImageCreateWithPNGDataProviderProcType) [MAC_OSX]: Remove typedef.
22 (MyCGImageCreateWithPNGDataProvider) [MAC_OSX]: Remove variable.
23 (init_image_func_pointer) [MAC_OSX]: Remove function.
24 (image_load_quartz2d) [MAC_OSX]: Check availability of
25 CGImageCreateWithPNGDataProvider at compile time.
26 Use lowercase `false' for boolean constant.
27 (png_load, jpeg_load, tiff_load, gif_load) [USE_MAC_IMAGE_IO]:
28 Use image_load_image_io.
29 (png_load) [!USE_MAC_IMAGE_IO && MAC_OSX]:
30 Don't check MyCGImageCreateWithPNGDataProvider.
31 (init_image) [MAC_OSX && TARGET_API_MAC_CARBON]:
32 Don't call init_image_func_pointer.
33
34 * macgui.h (Pixmap) [USE_MAC_IMAGE_IO]: New definition for Image I/O.
35
36 * macterm.c (mac_cg_color_space_rgb) [USE_CG_DRAWING]:
37 Make variable non-static.
38 (XDrawLine, XCreatePixmap, XCreatePixmapFromBitmapData, XFreePixmap)
39 [USE_MAC_IMAGE_IO]: Add implementations for Image I/O support.
40
41 * macterm.h (ARGB_TO_ULONG, ALPHA_FROM_ULONG): New macros.
42 (RED_FROM_ULONG): Mask off higher bits.
43 (mac_cg_color_space_rgb) [USE_MAC_IMAGE_IO]: New extern.
44
45 * s/darwin.h [HAVE_CARBON && HAVE_AVAILABILITYMACROS_H]:
46 Include AvailabilityMacros.h.
47 (USE_MAC_IMAGE_IO, LIBS_IMAGE) [HAVE_CARBON]: New defines.
48 (LIBS_CARBON) [HAVE_CARBON]: Use LIBS_IMAGE.
49
12008-05-03 Stefan Monnier <monnier@iro.umontreal.ca> 502008-05-03 Stefan Monnier <monnier@iro.umontreal.ca>
2 51
3 * chartab.c (Fset_char_table_range): If range is t, really set all 52 * chartab.c (Fset_char_table_range): If range is t, really set all
diff --git a/src/config.in b/src/config.in
index 2ed107fc288..6c51c6e91ed 100644
--- a/src/config.in
+++ b/src/config.in
@@ -90,6 +90,9 @@ Boston, MA 02110-1301, USA. */
90/* Define to 1 if ALSA is available. */ 90/* Define to 1 if ALSA is available. */
91#undef HAVE_ALSA 91#undef HAVE_ALSA
92 92
93/* Define to 1 if you have the <AvailabilityMacros.h> header file. */
94#undef HAVE_AVAILABILITYMACROS_H
95
93/* Define to 1 if you have the `bcmp' function. */ 96/* Define to 1 if you have the `bcmp' function. */
94#undef HAVE_BCMP 97#undef HAVE_BCMP
95 98
diff --git a/src/image.c b/src/image.c
index fbf6a15cef6..48b223c6c76 100644
--- a/src/image.c
+++ b/src/image.c
@@ -115,10 +115,15 @@ typedef struct mac_bitmap_record Bitmap_Record;
115 115
116#define RGB_PIXEL_COLOR unsigned long 116#define RGB_PIXEL_COLOR unsigned long
117 117
118#if USE_MAC_IMAGE_IO
119#define PIX_MASK_DRAW 255
120#define PIX_MASK_RETAIN 0
121#else
118/* A black pixel in a mask bitmap/pixmap means ``draw a source 122/* A black pixel in a mask bitmap/pixmap means ``draw a source
119 pixel''. A white pixel means ``retain the current pixel''. */ 123 pixel''. A white pixel means ``retain the current pixel''. */
120#define PIX_MASK_DRAW RGB_TO_ULONG(0,0,0) 124#define PIX_MASK_DRAW RGB_TO_ULONG(0,0,0)
121#define PIX_MASK_RETAIN RGB_TO_ULONG(255,255,255) 125#define PIX_MASK_RETAIN RGB_TO_ULONG(255,255,255)
126#endif
122 127
123#define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual 128#define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual
124#define x_defined_color mac_defined_color 129#define x_defined_color mac_defined_color
@@ -166,6 +171,7 @@ XGetImage (display, pixmap, x, y, width, height, plane_mask, format)
166 unsigned long plane_mask; /* not used */ 171 unsigned long plane_mask; /* not used */
167 int format; /* not used */ 172 int format; /* not used */
168{ 173{
174#if !USE_MAC_IMAGE_IO
169#if GLYPH_DEBUG 175#if GLYPH_DEBUG
170 xassert (x == 0 && y == 0); 176 xassert (x == 0 && y == 0);
171 { 177 {
@@ -177,6 +183,7 @@ XGetImage (display, pixmap, x, y, width, height, plane_mask, format)
177#endif 183#endif
178 184
179 LockPixels (GetGWorldPixMap (pixmap)); 185 LockPixels (GetGWorldPixMap (pixmap));
186#endif
180 187
181 return pixmap; 188 return pixmap;
182} 189}
@@ -187,6 +194,12 @@ XPutPixel (ximage, x, y, pixel)
187 int x, y; 194 int x, y;
188 unsigned long pixel; 195 unsigned long pixel;
189{ 196{
197#if USE_MAC_IMAGE_IO
198 if (ximage->bits_per_pixel == 32)
199 ((unsigned int *)(ximage->data + y * ximage->bytes_per_line))[x] = pixel;
200 else
201 ((unsigned char *)(ximage->data + y * ximage->bytes_per_line))[x] = pixel;
202#else
190 PixMapHandle pixmap = GetGWorldPixMap (ximage); 203 PixMapHandle pixmap = GetGWorldPixMap (ximage);
191 short depth = GetPixDepth (pixmap); 204 short depth = GetPixDepth (pixmap);
192 205
@@ -227,6 +240,7 @@ XPutPixel (ximage, x, y, pixel)
227 240
228 SetGWorld (old_port, old_gdh); 241 SetGWorld (old_port, old_gdh);
229 } 242 }
243#endif
230} 244}
231 245
232static unsigned long 246static unsigned long
@@ -234,6 +248,12 @@ XGetPixel (ximage, x, y)
234 XImagePtr ximage; 248 XImagePtr ximage;
235 int x, y; 249 int x, y;
236{ 250{
251#if USE_MAC_IMAGE_IO
252 if (ximage->bits_per_pixel == 32)
253 return ((unsigned int *)(ximage->data + y * ximage->bytes_per_line))[x];
254 else
255 return ((unsigned char *)(ximage->data + y * ximage->bytes_per_line))[x];
256#else
237 PixMapHandle pixmap = GetGWorldPixMap (ximage); 257 PixMapHandle pixmap = GetGWorldPixMap (ximage);
238 short depth = GetPixDepth (pixmap); 258 short depth = GetPixDepth (pixmap);
239 259
@@ -271,21 +291,80 @@ XGetPixel (ximage, x, y)
271 SetGWorld (old_port, old_gdh); 291 SetGWorld (old_port, old_gdh);
272 return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8); 292 return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8);
273 } 293 }
294#endif
274} 295}
275 296
276static void 297static void
277XDestroyImage (ximg) 298XDestroyImage (ximg)
278 XImagePtr ximg; 299 XImagePtr ximg;
279{ 300{
301#if !USE_MAC_IMAGE_IO
280 UnlockPixels (GetGWorldPixMap (ximg)); 302 UnlockPixels (GetGWorldPixMap (ximg));
303#endif
281} 304}
282 305
283#if USE_CG_DRAWING 306#if USE_CG_DRAWING
307#if USE_MAC_IMAGE_IO
308void
309mac_data_provider_release_data (info, data, size)
310 void *info;
311 const void *data;
312 size_t size;
313{
314 xfree ((void *)data);
315}
316#endif
317
284static CGImageRef 318static CGImageRef
285mac_create_cg_image_from_image (f, img) 319mac_create_cg_image_from_image (f, img)
286 struct frame *f; 320 struct frame *f;
287 struct image *img; 321 struct image *img;
288{ 322{
323#if USE_MAC_IMAGE_IO
324 XImagePtr ximg = img->pixmap;
325 CGDataProviderRef provider;
326 CGImageRef result;
327
328 if (img->mask)
329 {
330 int x, y;
331 unsigned long color, alpha;
332
333 for (y = 0; y < ximg->height; y++)
334 for (x = 0; x < ximg->width; x++)
335 {
336 color = XGetPixel (ximg, x, y);
337 alpha = XGetPixel (img->mask, x, y);
338 XPutPixel (ximg, x, y,
339 ARGB_TO_ULONG (alpha,
340 RED_FROM_ULONG (color)
341 * alpha / PIX_MASK_DRAW,
342 GREEN_FROM_ULONG (color)
343 * alpha / PIX_MASK_DRAW,
344 BLUE_FROM_ULONG (color)
345 * alpha / PIX_MASK_DRAW));
346 }
347 xfree (img->mask->data);
348 img->mask->data = NULL;
349 }
350 BLOCK_INPUT;
351 provider = CGDataProviderCreateWithData (NULL, ximg->data,
352 ximg->bytes_per_line * ximg->height,
353 mac_data_provider_release_data);
354 ximg->data = NULL;
355 result = CGImageCreate (ximg->width, ximg->height, 8, 32,
356 ximg->bytes_per_line, mac_cg_color_space_rgb,
357 (img->mask ? kCGImageAlphaPremultipliedFirst
358 : kCGImageAlphaNoneSkipFirst)
359#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
360 | kCGBitmapByteOrder32Host
361#endif
362 , provider, NULL, 0, kCGRenderingIntentDefault);
363 CGDataProviderRelease (provider);
364 UNBLOCK_INPUT;
365
366 return result;
367#else
289 Pixmap mask; 368 Pixmap mask;
290 CGImageRef result = NULL; 369 CGImageRef result = NULL;
291 370
@@ -320,6 +399,7 @@ mac_create_cg_image_from_image (f, img)
320 UNBLOCK_INPUT; 399 UNBLOCK_INPUT;
321 400
322 return result; 401 return result;
402#endif
323} 403}
324#endif /* USE_CG_DRAWING */ 404#endif /* USE_CG_DRAWING */
325#endif /* MAC_OS */ 405#endif /* MAC_OS */
@@ -2301,7 +2381,9 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap)
2301 return 0; 2381 return 0;
2302 } 2382 }
2303 2383
2384#if !USE_MAC_IMAGE_IO
2304 LockPixels (GetGWorldPixMap (*pixmap)); 2385 LockPixels (GetGWorldPixMap (*pixmap));
2386#endif
2305 *ximg = *pixmap; 2387 *ximg = *pixmap;
2306 return 1; 2388 return 1;
2307 2389
@@ -2454,6 +2536,256 @@ slurp_file (file, size)
2454 MAC Image Load Functions 2536 MAC Image Load Functions
2455 ***********************************************************************/ 2537 ***********************************************************************/
2456 2538
2539#if USE_MAC_IMAGE_IO
2540static int
2541image_load_image_io (f, img, type)
2542 struct frame *f;
2543 struct image *img;
2544 CFStringRef type;
2545{
2546 CFDictionaryRef options, src_props = NULL, props = NULL;
2547 CFStringRef keys[2];
2548 CFTypeRef values[2];
2549 Lisp_Object specified_file, specified_data;
2550 CGImageSourceRef source = NULL;
2551 size_t count;
2552 CGImageRef image = NULL;
2553 int loop_count = -1;
2554 double delay_time = -1.0;
2555 int width, height;
2556 XImagePtr ximg = NULL;
2557 CGContextRef context;
2558 CGRect rectangle;
2559 int has_alpha_p, gif_p;
2560
2561 gif_p = UTTypeEqual (type, kUTTypeGIF);
2562
2563 keys[0] = kCGImageSourceTypeIdentifierHint;
2564 values[0] = (CFTypeRef) type;
2565 keys[1] = kCGImageSourceShouldCache;
2566 values[1] = (CFTypeRef) kCFBooleanFalse;
2567 options = CFDictionaryCreate (NULL, (const void **) keys,
2568 (const void **) values,
2569 sizeof (keys) / sizeof (keys[0]),
2570 &kCFTypeDictionaryKeyCallBacks,
2571 &kCFTypeDictionaryValueCallBacks);
2572 if (options == NULL)
2573 {
2574 image_error ("Error creating options for image `%s'", img->spec, Qnil);
2575 return 0;
2576 }
2577
2578 /* Open the file. */
2579 specified_file = image_spec_value (img->spec, QCfile, NULL);
2580 specified_data = image_spec_value (img->spec, QCdata, NULL);
2581
2582 if (NILP (specified_data))
2583 {
2584 Lisp_Object file;
2585 CFStringRef path;
2586 CFURLRef url;
2587
2588 file = x_find_image_file (specified_file);
2589 if (!STRINGP (file))
2590 {
2591 image_error ("Cannot find image file `%s'", specified_file, Qnil);
2592 return 0;
2593 }
2594 path = cfstring_create_with_utf8_cstring (SDATA (file));
2595 if (path)
2596 {
2597 url = CFURLCreateWithFileSystemPath (NULL, path,
2598 kCFURLPOSIXPathStyle, 0);
2599 CFRelease (path);
2600 if (url)
2601 {
2602 source = CGImageSourceCreateWithURL (url, NULL);
2603 CFRelease (url);
2604 }
2605 }
2606 }
2607 else
2608 {
2609 CFDataRef data = CFDataCreate (NULL, SDATA (specified_data),
2610 SBYTES (specified_data));
2611
2612 if (data)
2613 {
2614 source = CGImageSourceCreateWithData (data, options);
2615 CFRelease (data);
2616 }
2617 }
2618 CFRelease (options);
2619
2620 if (source)
2621 {
2622 CFStringRef real_type = CGImageSourceGetType (source);
2623
2624 if (real_type && UTTypeEqual (type, real_type))
2625 src_props = CGImageSourceCopyProperties (source, NULL);
2626 if (src_props)
2627 {
2628 EMACS_INT ino = 0;
2629
2630 count = CGImageSourceGetCount (source);
2631 if (gif_p)
2632 {
2633 Lisp_Object image = image_spec_value (img->spec, QCindex, NULL);
2634
2635 if (INTEGERP (image))
2636 ino = XFASTINT (image);
2637 }
2638 if (ino >= 0 && ino < count)
2639 {
2640 props = CGImageSourceCopyPropertiesAtIndex (source, ino, NULL);
2641 if (props)
2642 image = CGImageSourceCreateImageAtIndex (source, ino, NULL);
2643 }
2644 }
2645 CFRelease (source);
2646 }
2647
2648 if (image == NULL)
2649 {
2650 if (src_props)
2651 CFRelease (src_props);
2652 if (props)
2653 CFRelease (props);
2654 image_error ("Error reading image `%s'", img->spec, Qnil);
2655 return 0;
2656 }
2657 else
2658 {
2659 CFBooleanRef boolean;
2660
2661 if (CFDictionaryGetValueIfPresent (props, kCGImagePropertyHasAlpha,
2662 (const void **) &boolean))
2663 has_alpha_p = CFBooleanGetValue (boolean);
2664 if (gif_p)
2665 {
2666 CFDictionaryRef dict;
2667 CFNumberRef number;
2668
2669 dict = CFDictionaryGetValue (src_props,
2670 kCGImagePropertyGIFDictionary);
2671 if (dict
2672 && CFDictionaryGetValueIfPresent (dict,
2673 kCGImagePropertyGIFLoopCount,
2674 (const void **) &number))
2675 CFNumberGetValue (number, kCFNumberIntType, &loop_count);
2676
2677 dict = CFDictionaryGetValue (props, kCGImagePropertyGIFDictionary);
2678 if (dict
2679 && CFDictionaryGetValueIfPresent (dict,
2680 kCGImagePropertyGIFDelayTime,
2681 (const void **) &number))
2682 CFNumberGetValue (number, kCFNumberDoubleType, &delay_time);
2683 }
2684 CFRelease (src_props);
2685 CFRelease (props);
2686 }
2687
2688 width = img->width = CGImageGetWidth (image);
2689 height = img->height = CGImageGetHeight (image);
2690
2691 if (!check_image_size (f, width, height))
2692 {
2693 CGImageRelease (image);
2694 image_error ("Invalid image size", Qnil, Qnil);
2695 return 0;
2696 }
2697
2698 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
2699 {
2700 CGImageRelease (image);
2701 image_error ("Out of memory (%s)", img->spec, Qnil);
2702 return 0;
2703 }
2704 rectangle = CGRectMake (0, 0, width, height);
2705
2706 context = CGBitmapContextCreate (ximg->data, ximg->width, ximg->height, 8,
2707 ximg->bytes_per_line,
2708 mac_cg_color_space_rgb,
2709 kCGImageAlphaNoneSkipFirst
2710#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
2711 | kCGBitmapByteOrder32Host
2712#endif
2713 );
2714 if (has_alpha_p)
2715 {
2716 Lisp_Object specified_bg;
2717 XColor color;
2718
2719 specified_bg = image_spec_value (img->spec, QCbackground, NULL);
2720 if (!STRINGP (specified_bg)
2721 || !mac_defined_color (f, SDATA (specified_bg), &color, 0))
2722 {
2723 color.pixel = FRAME_BACKGROUND_PIXEL (f);
2724 color.red = RED16_FROM_ULONG (color.pixel);
2725 color.green = GREEN16_FROM_ULONG (color.pixel);
2726 color.blue = BLUE16_FROM_ULONG (color.pixel);
2727 }
2728 CGContextSetRGBFillColor (context, color.red / 65535.0,
2729 color.green / 65535.0,
2730 color.blue / 65535.0, 1.0);
2731 CGContextFillRect (context, rectangle);
2732 }
2733 CGContextDrawImage (context, rectangle, image);
2734 CGContextRelease (context);
2735 CGImageRelease (image);
2736
2737 /* Save GIF image extension data for `image-extension-data'.
2738 Format is (count IMAGES
2739 0xff "NETSCAPE2.0" 0x00 DATA_SUB_BLOCK_FOR_LOOP_COUNT
2740 0xf9 GRAPHIC_CONTROL_EXTENSION_BLOCK). */
2741 if (gif_p)
2742 {
2743 img->data.lisp_val = Qnil;
2744 if (delay_time >= 0)
2745 {
2746 Lisp_Object gce = make_uninit_string (4);
2747 int centisec = delay_time * 100.0 + 0.5;
2748
2749 /* Fill the delay time field. */
2750 SSET (gce, 1, centisec & 0xff);
2751 SSET (gce, 2, (centisec >> 8) & 0xff);
2752 /* We don't know about other fields. */
2753 SSET (gce, 0, 0);
2754 SSET (gce, 3, 0);
2755 img->data.lisp_val = Fcons (make_number (0xf9),
2756 Fcons (gce,
2757 img->data.lisp_val));
2758 }
2759 if (loop_count >= 0)
2760 {
2761 Lisp_Object data_sub_block = make_uninit_string (3);
2762
2763 SSET (data_sub_block, 0, 0x01);
2764 SSET (data_sub_block, 1, loop_count & 0xff);
2765 SSET (data_sub_block, 2, (loop_count >> 8) & 0xff);
2766 img->data.lisp_val = Fcons (make_number (0),
2767 Fcons (data_sub_block,
2768 img->data.lisp_val));
2769 img->data.lisp_val = Fcons (make_number (0xff),
2770 Fcons (build_string ("NETSCAPE2.0"),
2771 img->data.lisp_val));
2772 }
2773 if (count > 1)
2774 img->data.lisp_val = Fcons (Qcount,
2775 Fcons (make_number (count),
2776 img->data.lisp_val));
2777 }
2778
2779 /* Maybe fill in the background field while we have ximg handy. */
2780 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
2781 IMAGE_BACKGROUND (img, f, ximg);
2782
2783 /* Put the image into the pixmap. */
2784 x_put_x_image (f, ximg, img->pixmap, width, height);
2785 x_destroy_x_image (ximg);
2786 return 1;
2787}
2788#else /* !USE_MAC_IMAGE_IO */
2457static int image_load_quicktime P_ ((struct frame *, struct image *img, 2789static int image_load_quicktime P_ ((struct frame *, struct image *img,
2458 OSType)); 2790 OSType));
2459#ifdef MAC_OSX 2791#ifdef MAC_OSX
@@ -2666,30 +2998,6 @@ image_load_quicktime (f, img, type)
2666 2998
2667 2999
2668#ifdef MAC_OSX 3000#ifdef MAC_OSX
2669/* Load a PNG/JPEG image using Quartz 2D decoding routines.
2670 CGImageCreateWithPNGDataProvider is provided after Mac OS X 10.2.
2671 So don't use this function directly but determine at runtime
2672 whether it exists. */
2673typedef CGImageRef (*CGImageCreateWithPNGDataProviderProcType)
2674 (CGDataProviderRef, const float [], bool, CGColorRenderingIntent);
2675static CGImageCreateWithPNGDataProviderProcType MyCGImageCreateWithPNGDataProvider;
2676
2677
2678static void
2679init_image_func_pointer ()
2680{
2681 if (NSIsSymbolNameDefined ("_CGImageCreateWithPNGDataProvider"))
2682 {
2683 MyCGImageCreateWithPNGDataProvider
2684 = (CGImageCreateWithPNGDataProviderProcType)
2685 NSAddressOfSymbol (NSLookupAndBindSymbol
2686 ("_CGImageCreateWithPNGDataProvider"));
2687 }
2688 else
2689 MyCGImageCreateWithPNGDataProvider = NULL;
2690}
2691
2692
2693static int 3001static int
2694image_load_quartz2d (f, img, png_p) 3002image_load_quartz2d (f, img, png_p)
2695 struct frame *f; 3003 struct frame *f;
@@ -2737,11 +3045,13 @@ image_load_quartz2d (f, img, png_p)
2737 source = CGDataProviderCreateWithData (NULL, SDATA (specified_data), 3045 source = CGDataProviderCreateWithData (NULL, SDATA (specified_data),
2738 SBYTES (specified_data), NULL); 3046 SBYTES (specified_data), NULL);
2739 3047
3048#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
2740 if (png_p) 3049 if (png_p)
2741 image = (*MyCGImageCreateWithPNGDataProvider) (source, NULL, FALSE, 3050 image = CGImageCreateWithPNGDataProvider (source, NULL, false,
2742 kCGRenderingIntentDefault); 3051 kCGRenderingIntentDefault);
2743 else 3052 else
2744 image = CGImageCreateWithJPEGDataProvider (source, NULL, FALSE, 3053#endif
3054 image = CGImageCreateWithJPEGDataProvider (source, NULL, false,
2745 kCGRenderingIntentDefault); 3055 kCGRenderingIntentDefault);
2746 3056
2747 CGDataProviderRelease (source); 3057 CGDataProviderRelease (source);
@@ -2805,6 +3115,7 @@ image_load_quartz2d (f, img, png_p)
2805 return 1; 3115 return 1;
2806} 3116}
2807#endif 3117#endif
3118#endif /* !USE_MAC_IMAGE_IO */
2808 3119
2809#endif /* MAC_OS */ 3120#endif /* MAC_OS */
2810 3121
@@ -4275,8 +4586,8 @@ xpm_scan (s, end, beg, len)
4275 if (isalpha (c) || c == '_' || c == '-' || c == '+') 4586 if (isalpha (c) || c == '_' || c == '-' || c == '+')
4276 { 4587 {
4277 *beg = *s - 1; 4588 *beg = *s - 1;
4278 while (*s < end && 4589 while (*s < end
4279 (c = **s, isalnum (c) || c == '_' || c == '-' || c == '+')) 4590 && (c = **s, isalnum (c) || c == '_' || c == '-' || c == '+'))
4280 ++*s; 4591 ++*s;
4281 *len = *s - *beg; 4592 *len = *s - *beg;
4282 return XPM_TK_IDENT; 4593 return XPM_TK_IDENT;
@@ -6622,12 +6933,13 @@ png_load (f, img)
6622 struct frame *f; 6933 struct frame *f;
6623 struct image *img; 6934 struct image *img;
6624{ 6935{
6625#ifdef MAC_OSX 6936#if USE_MAC_IMAGE_IO
6626 if (MyCGImageCreateWithPNGDataProvider) 6937 return image_load_image_io (f, img, kUTTypePNG);
6627 return image_load_quartz2d (f, img, 1); 6938#elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
6628 else 6939 return image_load_quartz2d (f, img, 1);
6940#else
6941 return image_load_quicktime (f, img, kQTFileTypePNG);
6629#endif 6942#endif
6630 return image_load_quicktime (f, img, kQTFileTypePNG);
6631} 6943}
6632#endif /* MAC_OS */ 6944#endif /* MAC_OS */
6633 6945
@@ -7200,7 +7512,9 @@ jpeg_load (f, img)
7200 struct frame *f; 7512 struct frame *f;
7201 struct image *img; 7513 struct image *img;
7202{ 7514{
7203#ifdef MAC_OSX 7515#if USE_MAC_IMAGE_IO
7516 return image_load_image_io (f, img, kUTTypeJPEG);
7517#elif defined (MAC_OSX)
7204 return image_load_quartz2d (f, img, 0); 7518 return image_load_quartz2d (f, img, 0);
7205#else 7519#else
7206 return image_load_quicktime (f, img, kQTFileTypeJPEG); 7520 return image_load_quicktime (f, img, kQTFileTypeJPEG);
@@ -7625,7 +7939,11 @@ tiff_load (f, img)
7625 struct frame *f; 7939 struct frame *f;
7626 struct image *img; 7940 struct image *img;
7627{ 7941{
7942#if USE_MAC_IMAGE_IO
7943 return image_load_image_io (f, img, kUTTypeTIFF);
7944#else
7628 return image_load_quicktime (f, img, kQTFileTypeTIFF); 7945 return image_load_quicktime (f, img, kQTFileTypeTIFF);
7946#endif
7629} 7947}
7630#endif /* MAC_OS */ 7948#endif /* MAC_OS */
7631 7949
@@ -8061,6 +8379,9 @@ gif_load (f, img)
8061 struct frame *f; 8379 struct frame *f;
8062 struct image *img; 8380 struct image *img;
8063{ 8381{
8382#if USE_MAC_IMAGE_IO
8383 return image_load_image_io (f, img, kUTTypeGIF);
8384#else /* !USE_MAC_IMAGE_IO */
8064 Lisp_Object specified_file, file; 8385 Lisp_Object specified_file, file;
8065 Lisp_Object specified_data; 8386 Lisp_Object specified_data;
8066 OSErr err; 8387 OSErr err;
@@ -8189,8 +8510,8 @@ gif_load (f, img)
8189 time_scale = GetMediaTimeScale (media); 8510 time_scale = GetMediaTimeScale (media);
8190 8511
8191 specified_bg = image_spec_value (img->spec, QCbackground, NULL); 8512 specified_bg = image_spec_value (img->spec, QCbackground, NULL);
8192 if (!STRINGP (specified_bg) || 8513 if (!STRINGP (specified_bg)
8193 !mac_defined_color (f, SDATA (specified_bg), &color, 0)) 8514 || !mac_defined_color (f, SDATA (specified_bg), &color, 0))
8194 { 8515 {
8195 color.pixel = FRAME_BACKGROUND_PIXEL (f); 8516 color.pixel = FRAME_BACKGROUND_PIXEL (f);
8196 color.red = RED16_FROM_ULONG (color.pixel); 8517 color.red = RED16_FROM_ULONG (color.pixel);
@@ -8259,6 +8580,7 @@ gif_load (f, img)
8259 if (dh) 8580 if (dh)
8260 DisposeHandle (dh); 8581 DisposeHandle (dh);
8261 return 0; 8582 return 0;
8583#endif /* !USE_MAC_IMAGE_IO */
8262} 8584}
8263#endif /* MAC_OS */ 8585#endif /* MAC_OS */
8264 8586
@@ -9264,9 +9586,6 @@ meaning don't clear the cache. */);
9264void 9586void
9265init_image () 9587init_image ()
9266{ 9588{
9267#if defined (MAC_OSX) && TARGET_API_MAC_CARBON
9268 init_image_func_pointer ();
9269#endif
9270} 9589}
9271 9590
9272/* arch-tag: 123c2a5e-14a8-4c53-ab95-af47d7db49b9 9591/* arch-tag: 123c2a5e-14a8-4c53-ab95-af47d7db49b9
diff --git a/src/macgui.h b/src/macgui.h
index 41ac28f49ec..9d4eb0ed9f4 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -154,7 +154,18 @@ typedef int Selection;
154#define mac_get_global_mouse GetGlobalMouse 154#define mac_get_global_mouse GetGlobalMouse
155#define mac_is_window_toolbar_visible IsWindowToolbarVisible 155#define mac_is_window_toolbar_visible IsWindowToolbarVisible
156#define mac_rect_make(f, x, y, w, h) CGRectMake (x, y, w, h) 156#define mac_rect_make(f, x, y, w, h) CGRectMake (x, y, w, h)
157
158#if USE_MAC_IMAGE_IO
159typedef struct _XImage
160{
161 int width, height; /* size of image */
162 char *data; /* pointer to image data */
163 int bytes_per_line; /* accelarator to next line */
164 int bits_per_pixel; /* bits per pixel (ZPixmap) */
165} *Pixmap;
166#else
157typedef GWorldPtr Pixmap; 167typedef GWorldPtr Pixmap;
168#endif
158 169
159#define Cursor ThemeCursor 170#define Cursor ThemeCursor
160#define No_Cursor (-1) 171#define No_Cursor (-1)
diff --git a/src/macterm.c b/src/macterm.c
index b458444f977..671ac1010d2 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -335,7 +335,7 @@ static struct terminal *mac_create_terminal P_ ((struct mac_display_info *dpyinf
335static int max_fringe_bmp = 0; 335static int max_fringe_bmp = 0;
336static CGImageRef *fringe_bmp = 0; 336static CGImageRef *fringe_bmp = 0;
337 337
338static CGColorSpaceRef mac_cg_color_space_rgb; 338CGColorSpaceRef mac_cg_color_space_rgb;
339#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 339#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
340static CGColorRef mac_cg_color_black; 340static CGColorRef mac_cg_color_black;
341#endif 341#endif
@@ -508,6 +508,48 @@ XDrawLine (display, p, gc, x1, y1, x2, y2)
508 GC gc; 508 GC gc;
509 int x1, y1, x2, y2; 509 int x1, y1, x2, y2;
510{ 510{
511#if USE_MAC_IMAGE_IO
512 CGContextRef context;
513 XImagePtr ximg = p;
514 CGColorSpaceRef color_space;
515 CGImageAlphaInfo alpha_info;
516 CGFloat gx1 = x1, gy1 = y1, gx2 = x2, gy2 = y2;
517
518 if (y1 != y2)
519 gx1 += 0.5f, gx2 += 0.5f;
520 if (x1 != x2)
521 gy1 += 0.5f, gy2 += 0.5f;
522
523 if (ximg->bits_per_pixel == 32)
524 {
525 color_space = mac_cg_color_space_rgb;
526 alpha_info = (kCGImageAlphaNoneSkipFirst
527#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
528 | kCGBitmapByteOrder32Host
529#endif
530 );
531 }
532 else
533 {
534 color_space = NULL;
535 alpha_info = kCGImageAlphaOnly;
536 }
537 if (color_space == NULL)
538 return;
539 context = CGBitmapContextCreate (ximg->data, ximg->width,
540 ximg->height, 8,
541 ximg->bytes_per_line, color_space,
542 alpha_info);
543 if (ximg->bits_per_pixel == 32)
544 CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND (context, gc);
545 else
546 CGContextSetGrayStrokeColor (context, gc->xgcv.foreground / 255.0f, 1.0);
547 CGContextMoveToPoint (context, gx1, gy1);
548 CGContextAddLineToPoint (context, gx2, gy2);
549 CGContextClosePath (context);
550 CGContextStrokePath (context);
551 CGContextRelease (context);
552#else
511 CGrafPtr old_port; 553 CGrafPtr old_port;
512 GDHandle old_gdh; 554 GDHandle old_gdh;
513 555
@@ -537,6 +579,7 @@ XDrawLine (display, p, gc, x1, y1, x2, y2)
537 UnlockPixels (GetGWorldPixMap (p)); 579 UnlockPixels (GetGWorldPixMap (p));
538 580
539 SetGWorld (old_port, old_gdh); 581 SetGWorld (old_port, old_gdh);
582#endif
540} 583}
541 584
542 585
@@ -748,6 +791,17 @@ XCreatePixmap (display, w, width, height, depth)
748 unsigned int width, height; 791 unsigned int width, height;
749 unsigned int depth; 792 unsigned int depth;
750{ 793{
794#if USE_MAC_IMAGE_IO
795 XImagePtr ximg;
796
797 ximg = xmalloc (sizeof (*ximg));
798 ximg->width = width;
799 ximg->height = height;
800 ximg->bits_per_pixel = depth == 1 ? 8 : 32;
801 ximg->bytes_per_line = width * (ximg->bits_per_pixel / 8);
802 ximg->data = xmalloc (ximg->bytes_per_line * height);
803 return ximg;
804#else
751 Pixmap pixmap; 805 Pixmap pixmap;
752 Rect r; 806 Rect r;
753 QDErr err; 807 QDErr err;
@@ -768,6 +822,7 @@ XCreatePixmap (display, w, width, height, depth)
768 if (err != noErr) 822 if (err != noErr)
769 return NULL; 823 return NULL;
770 return pixmap; 824 return pixmap;
825#endif
771} 826}
772 827
773 828
@@ -782,6 +837,38 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
782{ 837{
783 Pixmap pixmap; 838 Pixmap pixmap;
784 BitMap bitmap; 839 BitMap bitmap;
840#if USE_MAC_IMAGE_IO
841 CGDataProviderRef provider;
842 CGImageRef image_mask;
843 CGContextRef context;
844
845 pixmap = XCreatePixmap (display, w, width, height, depth);
846 if (pixmap == NULL)
847 return NULL;
848
849 mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height);
850 provider = CGDataProviderCreateWithData (NULL, bitmap.baseAddr,
851 bitmap.rowBytes * height, NULL);
852 image_mask = CGImageMaskCreate (width, height, 1, 1, bitmap.rowBytes,
853 provider, NULL, 0);
854 CGDataProviderRelease (provider);
855
856 context = CGBitmapContextCreate (pixmap->data, width, height, 8,
857 pixmap->bytes_per_line,
858 mac_cg_color_space_rgb,
859 kCGImageAlphaNoneSkipFirst
860#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
861 | kCGBitmapByteOrder32Host
862#endif
863 );
864
865 CG_SET_FILL_COLOR (context, fg);
866 CGContextFillRect (context, CGRectMake (0, 0, width, height));
867 CG_SET_FILL_COLOR (context, bg);
868 CGContextDrawImage (context, CGRectMake (0, 0, width, height), image_mask);
869 CGContextRelease (context);
870 CGImageRelease (image_mask);
871#else
785 CGrafPtr old_port; 872 CGrafPtr old_port;
786 GDHandle old_gdh; 873 GDHandle old_gdh;
787 static GC gc = NULL; 874 static GC gc = NULL;
@@ -810,6 +897,7 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
810#endif /* not TARGET_API_MAC_CARBON */ 897#endif /* not TARGET_API_MAC_CARBON */
811 UnlockPixels (GetGWorldPixMap (pixmap)); 898 UnlockPixels (GetGWorldPixMap (pixmap));
812 SetGWorld (old_port, old_gdh); 899 SetGWorld (old_port, old_gdh);
900#endif
813 mac_free_bitmap (&bitmap); 901 mac_free_bitmap (&bitmap);
814 902
815 return pixmap; 903 return pixmap;
@@ -821,7 +909,16 @@ XFreePixmap (display, pixmap)
821 Display *display; 909 Display *display;
822 Pixmap pixmap; 910 Pixmap pixmap;
823{ 911{
912#if USE_MAC_IMAGE_IO
913 if (pixmap)
914 {
915 if (pixmap->data)
916 xfree (pixmap->data);
917 xfree (pixmap);
918 }
919#else
824 DisposeGWorld (pixmap); 920 DisposeGWorld (pixmap);
921#endif
825} 922}
826 923
827 924
diff --git a/src/macterm.h b/src/macterm.h
index 6a000451785..00b01e452da 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -25,8 +25,10 @@ Boston, MA 02110-1301, USA. */
25#include "frame.h" 25#include "frame.h"
26 26
27#define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b)) 27#define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b))
28#define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
28 29
29#define RED_FROM_ULONG(color) ((color) >> 16) 30#define ALPHA_FROM_ULONG(color) ((color) >> 24)
31#define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
30#define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff) 32#define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
31#define BLUE_FROM_ULONG(color) ((color) & 0xff) 33#define BLUE_FROM_ULONG(color) ((color) & 0xff)
32 34
@@ -649,6 +651,10 @@ extern int mac_quit_char_key_p P_ ((UInt32, UInt32));
649#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0 651#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
650#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0 652#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
651 653
654#if USE_MAC_IMAGE_IO
655extern CGColorSpaceRef mac_cg_color_space_rgb;
656#endif
657
652/* Defined in macselect.c */ 658/* Defined in macselect.c */
653 659
654extern void x_clear_frame_selections P_ ((struct frame *)); 660extern void x_clear_frame_selections P_ ((struct frame *));
diff --git a/src/s/darwin.h b/src/s/darwin.h
index dee3480c783..2e7e4e40be4 100644
--- a/src/s/darwin.h
+++ b/src/s/darwin.h
@@ -265,9 +265,31 @@ Boston, MA 02110-1301, USA. */
265/* Indicate that we are compiling for Mac OS X. */ 265/* Indicate that we are compiling for Mac OS X. */
266#define C_SWITCH_SYSTEM -fpascal-strings -DMAC_OSX 266#define C_SWITCH_SYSTEM -fpascal-strings -DMAC_OSX
267 267
268#ifdef HAVE_CARBON
269
270#ifdef HAVE_AVAILABILITYMACROS_H
271#include <AvailabilityMacros.h>
272#endif
273
274/* Whether to use the Image I/O framework for reading images. */
275#ifndef USE_MAC_IMAGE_IO
276#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1040 || MAC_OS_X_VERSION_MIN_REQUIRED < 1020)
277#define USE_MAC_IMAGE_IO 1
278#endif
279#endif
280
281/* If the Image I/O framework is not used, fall back on QuickTime. */
282#if USE_MAC_IMAGE_IO
283#define LIBS_IMAGE
284#else
285#define LIBS_IMAGE -framework QuickTime
286#endif
287
288#endif /* HAVE_CARBON */
289
268/* Link in the Carbon lib. */ 290/* Link in the Carbon lib. */
269#ifdef HAVE_CARBON 291#ifdef HAVE_CARBON
270#define LIBS_CARBON -framework Carbon -framework QuickTime 292#define LIBS_CARBON -framework Carbon LIBS_IMAGE
271#else 293#else
272#define LIBS_CARBON 294#define LIBS_CARBON
273#endif 295#endif