diff options
| author | YAMAMOTO Mitsuharu | 2006-03-15 07:56:16 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2006-03-15 07:56:16 +0000 |
| commit | ad21830e8f4405e3f246f7eef8540d30b87b8b75 (patch) | |
| tree | 62343fe5223f9b5b9874fb3ab219e59b21b9a921 /src | |
| parent | bd8ce5da4eb65e84f6946dfd30c30d9f0ae8ccda (diff) | |
| download | emacs-ad21830e8f4405e3f246f7eef8540d30b87b8b75.tar.gz emacs-ad21830e8f4405e3f246f7eef8540d30b87b8b75.zip | |
(mac_initialize) [USE_CG_DRAWING]: Call mac_init_fringe.
(max_fringe_bmp, fringe_bmp) [USE_CG_DRAWING]: New variables.
(mac_define_fringe_bitmap, mac_destroy_fringe_bitmap)
(mac_draw_cg_image) [USE_CG_DRAWING]: New functions.
(mac_draw_bitmap) [USE_CG_DRAWING]: Remove function.
(x_draw_fringe_bitmap) [USE_CG_DRAWING]: Use mac_draw_cg_image
instead of mac_draw_bitmap.
(x_redisplay_interface) [USE_CG_DRAWING]: Set handlers for
define_fringe_bitmap and destroy_fringe_bitmap.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 16 | ||||
| -rw-r--r-- | src/macterm.c | 116 |
2 files changed, 126 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f6edc410276..3a5f60b813f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | 2006-03-15 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * dispextern.h (mac_init_fringe) [MAC_OS]: Add prototype. | ||
| 4 | |||
| 5 | * fringe.c (mac_init_fringe) [MAC_OS]: New function. | ||
| 6 | |||
| 7 | * macterm.c (mac_initialize) [USE_CG_DRAWING]: Call mac_init_fringe. | ||
| 8 | (max_fringe_bmp, fringe_bmp) [USE_CG_DRAWING]: New variables. | ||
| 9 | (mac_define_fringe_bitmap, mac_destroy_fringe_bitmap) | ||
| 10 | (mac_draw_cg_image) [USE_CG_DRAWING]: New functions. | ||
| 11 | (mac_draw_bitmap) [USE_CG_DRAWING]: Remove function. | ||
| 12 | (x_draw_fringe_bitmap) [USE_CG_DRAWING]: Use mac_draw_cg_image | ||
| 13 | instead of mac_draw_bitmap. | ||
| 14 | (x_redisplay_interface) [USE_CG_DRAWING]: Set handlers for | ||
| 15 | define_fringe_bitmap and destroy_fringe_bitmap. | ||
| 16 | |||
| 1 | 2006-03-14 Chong Yidong <cyd@stupidchicken.com> | 17 | 2006-03-14 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 18 | ||
| 3 | * xterm.c (x_uncatch_errors): Block input for entire function. | 19 | * xterm.c (x_uncatch_errors): Block input for entire function. |
diff --git a/src/macterm.c b/src/macterm.c index ff24d68840f..6bb50bef6ca 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -281,6 +281,11 @@ extern void menubar_selection_callback (FRAME_PTR, int); | |||
| 281 | #if USE_CG_DRAWING | 281 | #if USE_CG_DRAWING |
| 282 | #define FRAME_CG_CONTEXT(f) ((f)->output_data.mac->cg_context) | 282 | #define FRAME_CG_CONTEXT(f) ((f)->output_data.mac->cg_context) |
| 283 | 283 | ||
| 284 | /* Fringe bitmaps. */ | ||
| 285 | |||
| 286 | static int max_fringe_bmp = 0; | ||
| 287 | static CGImageRef *fringe_bmp = 0; | ||
| 288 | |||
| 284 | static CGContextRef | 289 | static CGContextRef |
| 285 | mac_begin_cg_clip (f, gc) | 290 | mac_begin_cg_clip (f, gc) |
| 286 | struct frame *f; | 291 | struct frame *f; |
| @@ -509,6 +514,44 @@ mac_clear_window (f) | |||
| 509 | 514 | ||
| 510 | /* Mac replacement for XCopyArea. */ | 515 | /* Mac replacement for XCopyArea. */ |
| 511 | 516 | ||
| 517 | #if USE_CG_DRAWING | ||
| 518 | static void | ||
| 519 | mac_draw_cg_image (image, f, gc, src_x, src_y, width, height, | ||
| 520 | dest_x, dest_y, overlay_p) | ||
| 521 | CGImageRef image; | ||
| 522 | struct frame *f; | ||
| 523 | GC gc; | ||
| 524 | int src_x, src_y; | ||
| 525 | unsigned int width, height; | ||
| 526 | int dest_x, dest_y, overlay_p; | ||
| 527 | { | ||
| 528 | CGContextRef context; | ||
| 529 | float port_height = FRAME_PIXEL_HEIGHT (f); | ||
| 530 | CGRect dest_rect = CGRectMake (dest_x, dest_y, width, height); | ||
| 531 | |||
| 532 | context = mac_begin_cg_clip (f, gc); | ||
| 533 | if (!overlay_p) | ||
| 534 | { | ||
| 535 | CG_SET_FILL_COLOR (context, gc->xgcv.background); | ||
| 536 | CGContextFillRect (context, dest_rect); | ||
| 537 | } | ||
| 538 | CGContextClipToRect (context, dest_rect); | ||
| 539 | CGContextScaleCTM (context, 1, -1); | ||
| 540 | CGContextTranslateCTM (context, 0, -port_height); | ||
| 541 | if (CGImageIsMask (image)) | ||
| 542 | CG_SET_FILL_COLOR (context, gc->xgcv.foreground); | ||
| 543 | CGContextDrawImage (context, | ||
| 544 | CGRectMake (dest_x - src_x, | ||
| 545 | port_height - (dest_y - src_y | ||
| 546 | + CGImageGetHeight (image)), | ||
| 547 | CGImageGetWidth (image), | ||
| 548 | CGImageGetHeight (image)), | ||
| 549 | image); | ||
| 550 | mac_end_cg_clip (f); | ||
| 551 | } | ||
| 552 | |||
| 553 | #else /* !USE_CG_DRAWING */ | ||
| 554 | |||
| 512 | static void | 555 | static void |
| 513 | mac_draw_bitmap (f, gc, x, y, width, height, bits, overlay_p) | 556 | mac_draw_bitmap (f, gc, x, y, width, height, bits, overlay_p) |
| 514 | struct frame *f; | 557 | struct frame *f; |
| @@ -524,9 +567,6 @@ mac_draw_bitmap (f, gc, x, y, width, height, bits, overlay_p) | |||
| 524 | bitmap.baseAddr = (char *)bits; | 567 | bitmap.baseAddr = (char *)bits; |
| 525 | SetRect (&(bitmap.bounds), 0, 0, width, height); | 568 | SetRect (&(bitmap.bounds), 0, 0, width, height); |
| 526 | 569 | ||
| 527 | #if USE_CG_DRAWING | ||
| 528 | mac_prepare_for_quickdraw (f); | ||
| 529 | #endif | ||
| 530 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 570 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 531 | 571 | ||
| 532 | RGBForeColor (GC_FORE_COLOR (gc)); | 572 | RGBForeColor (GC_FORE_COLOR (gc)); |
| @@ -552,6 +592,7 @@ mac_draw_bitmap (f, gc, x, y, width, height, bits, overlay_p) | |||
| 552 | 592 | ||
| 553 | RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); | 593 | RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); |
| 554 | } | 594 | } |
| 595 | #endif /* !USE_CG_DRAWING */ | ||
| 555 | 596 | ||
| 556 | 597 | ||
| 557 | /* Mac replacement for XCreateBitmapFromBitmapData. */ | 598 | /* Mac replacement for XCreateBitmapFromBitmapData. */ |
| @@ -2001,9 +2042,12 @@ x_draw_fringe_bitmap (w, row, p) | |||
| 2001 | #endif | 2042 | #endif |
| 2002 | } | 2043 | } |
| 2003 | 2044 | ||
| 2004 | if (p->which) | 2045 | if (p->which |
| 2046 | #if USE_CG_DRAWING | ||
| 2047 | && p->which < max_fringe_bmp | ||
| 2048 | #endif | ||
| 2049 | ) | ||
| 2005 | { | 2050 | { |
| 2006 | unsigned short *bits = p->bits + p->dh; | ||
| 2007 | XGCValues gcv; | 2051 | XGCValues gcv; |
| 2008 | 2052 | ||
| 2009 | XGetGCValues (display, face->gc, GCForeground, &gcv); | 2053 | XGetGCValues (display, face->gc, GCForeground, &gcv); |
| @@ -2012,14 +2056,64 @@ x_draw_fringe_bitmap (w, row, p) | |||
| 2012 | ? (p->overlay_p ? face->background | 2056 | ? (p->overlay_p ? face->background |
| 2013 | : f->output_data.mac->cursor_pixel) | 2057 | : f->output_data.mac->cursor_pixel) |
| 2014 | : face->foreground)); | 2058 | : face->foreground)); |
| 2059 | #if USE_CG_DRAWING | ||
| 2060 | mac_draw_cg_image (fringe_bmp[p->which], f, face->gc, 0, p->dh, | ||
| 2061 | p->wd, p->h, p->x, p->y, p->overlay_p); | ||
| 2062 | #else | ||
| 2015 | mac_draw_bitmap (f, face->gc, p->x, p->y, | 2063 | mac_draw_bitmap (f, face->gc, p->x, p->y, |
| 2016 | p->wd, p->h, bits, p->overlay_p); | 2064 | p->wd, p->h, p->bits + p->dh, p->overlay_p); |
| 2065 | #endif | ||
| 2017 | XSetForeground (display, face->gc, gcv.foreground); | 2066 | XSetForeground (display, face->gc, gcv.foreground); |
| 2018 | } | 2067 | } |
| 2019 | 2068 | ||
| 2020 | mac_reset_clip_rectangles (display, face->gc); | 2069 | mac_reset_clip_rectangles (display, face->gc); |
| 2021 | } | 2070 | } |
| 2022 | 2071 | ||
| 2072 | #if USE_CG_DRAWING | ||
| 2073 | static void | ||
| 2074 | mac_define_fringe_bitmap (which, bits, h, wd) | ||
| 2075 | int which; | ||
| 2076 | unsigned short *bits; | ||
| 2077 | int h, wd; | ||
| 2078 | { | ||
| 2079 | unsigned short *mask_bits; | ||
| 2080 | int i; | ||
| 2081 | CGDataProviderRef provider; | ||
| 2082 | |||
| 2083 | if (which >= max_fringe_bmp) | ||
| 2084 | { | ||
| 2085 | i = max_fringe_bmp; | ||
| 2086 | max_fringe_bmp = which + 20; | ||
| 2087 | fringe_bmp = (CGImageRef *) xrealloc (fringe_bmp, max_fringe_bmp * sizeof (CGImageRef)); | ||
| 2088 | while (i < max_fringe_bmp) | ||
| 2089 | fringe_bmp[i++] = 0; | ||
| 2090 | } | ||
| 2091 | |||
| 2092 | for (i = 0; i < h; i++) | ||
| 2093 | bits[i] = ~bits[i]; | ||
| 2094 | provider = CGDataProviderCreateWithData (NULL, bits, | ||
| 2095 | sizeof (unsigned short) * h, NULL); | ||
| 2096 | if (provider) | ||
| 2097 | { | ||
| 2098 | fringe_bmp[which] = CGImageMaskCreate (wd, h, 1, 1, | ||
| 2099 | sizeof (unsigned short), | ||
| 2100 | provider, NULL, 0); | ||
| 2101 | CGDataProviderRelease (provider); | ||
| 2102 | } | ||
| 2103 | } | ||
| 2104 | |||
| 2105 | static void | ||
| 2106 | mac_destroy_fringe_bitmap (which) | ||
| 2107 | int which; | ||
| 2108 | { | ||
| 2109 | if (which >= max_fringe_bmp) | ||
| 2110 | return; | ||
| 2111 | |||
| 2112 | if (fringe_bmp[which]) | ||
| 2113 | CGImageRelease (fringe_bmp[which]); | ||
| 2114 | fringe_bmp[which] = 0; | ||
| 2115 | } | ||
| 2116 | #endif | ||
| 2023 | 2117 | ||
| 2024 | 2118 | ||
| 2025 | /* This is called when starting Emacs and when restarting after | 2119 | /* This is called when starting Emacs and when restarting after |
| @@ -10892,8 +10986,13 @@ static struct redisplay_interface x_redisplay_interface = | |||
| 10892 | x_get_glyph_overhangs, | 10986 | x_get_glyph_overhangs, |
| 10893 | x_fix_overlapping_area, | 10987 | x_fix_overlapping_area, |
| 10894 | x_draw_fringe_bitmap, | 10988 | x_draw_fringe_bitmap, |
| 10989 | #if USE_CG_DRAWING | ||
| 10990 | mac_define_fringe_bitmap, | ||
| 10991 | mac_destroy_fringe_bitmap, | ||
| 10992 | #else | ||
| 10895 | 0, /* define_fringe_bitmap */ | 10993 | 0, /* define_fringe_bitmap */ |
| 10896 | 0, /* destroy_fringe_bitmap */ | 10994 | 0, /* destroy_fringe_bitmap */ |
| 10995 | #endif | ||
| 10897 | mac_per_char_metric, | 10996 | mac_per_char_metric, |
| 10898 | mac_encode_char, | 10997 | mac_encode_char, |
| 10899 | mac_compute_glyph_string_overhangs, | 10998 | mac_compute_glyph_string_overhangs, |
| @@ -10969,6 +11068,11 @@ mac_initialize () | |||
| 10969 | MakeMeTheFrontProcess (); | 11068 | MakeMeTheFrontProcess (); |
| 10970 | #endif | 11069 | #endif |
| 10971 | #endif | 11070 | #endif |
| 11071 | |||
| 11072 | #if USE_CG_DRAWING | ||
| 11073 | mac_init_fringe (); | ||
| 11074 | #endif | ||
| 11075 | |||
| 10972 | UNBLOCK_INPUT; | 11076 | UNBLOCK_INPUT; |
| 10973 | } | 11077 | } |
| 10974 | 11078 | ||