diff options
| author | YAMAMOTO Mitsuharu | 2006-03-12 08:20:37 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2006-03-12 08:20:37 +0000 |
| commit | 4ea08bbf4c59e05717168bb275dff04c6a4e9abe (patch) | |
| tree | 269f05130cf03a9fef299c374a228119d584c3d9 /src/macterm.c | |
| parent | 58826ef7132ee12ecddc391df121a27666c5fca6 (diff) | |
| download | emacs-4ea08bbf4c59e05717168bb275dff04c6a4e9abe.tar.gz emacs-4ea08bbf4c59e05717168bb275dff04c6a4e9abe.zip | |
(mac_draw_rectangle, x_draw_glyph_string_foreground)
(x_draw_composite_glyph_string_foreground)
(x_draw_image_foreground): Undo previous changes.
(x_draw_hollow_cursor): Likewise. Subtract 1 from the last
argument of mac_draw_rectangle.
(CG_SET_FILL_COLOR, CG_SET_STROKE_COLOR): New macros.
(mac_draw_string_common, mac_draw_image_string_cg): Use them.
(FRAME_CG_CONTEXT) [USE_CG_DRAWING]: New macro.
(mac_begin_cg_clip, mac_end_cg_clip, mac_prepare_for_quickdraw)
[USE_CG_DRAWING]: New functions.
(mac_draw_line, mac_erase_rectangle, mac_clear_window)
(mac_fill_rectangle, mac_draw_rectangle, mac_draw_string_common)
(mac_draw_image_string_cg) [USE_CG_DRAWING]: Add Quartz 2D drawing part.
(mac_draw_bitmap, mac_invert_rectangle, mac_draw_string_common)
(mac_copy_area, mac_scroll_area, x_scroll_bar_create)
(x_scroll_bar_remove, XTset_vertical_scroll_bar, x_set_window_size)
(XTread_socket) [USE_CG_DRAWING]: Call mac_prepare_for_quickdraw.
Diffstat (limited to 'src/macterm.c')
| -rw-r--r-- | src/macterm.c | 230 |
1 files changed, 196 insertions, 34 deletions
diff --git a/src/macterm.c b/src/macterm.c index 649bfb43ef5..ff24d68840f 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -268,6 +268,72 @@ extern void menubar_selection_callback (FRAME_PTR, int); | |||
| 268 | #define GC_BACK_COLOR(gc) (&(gc)->back_color) | 268 | #define GC_BACK_COLOR(gc) (&(gc)->back_color) |
| 269 | #define GC_FONT(gc) ((gc)->xgcv.font) | 269 | #define GC_FONT(gc) ((gc)->xgcv.font) |
| 270 | #define FRAME_NORMAL_GC(f) ((f)->output_data.mac->normal_gc) | 270 | #define FRAME_NORMAL_GC(f) ((f)->output_data.mac->normal_gc) |
| 271 | #define CG_SET_FILL_COLOR(context, color) \ | ||
| 272 | CGContextSetRGBFillColor (context, \ | ||
| 273 | RED_FROM_ULONG (color) / 255.0f, \ | ||
| 274 | GREEN_FROM_ULONG (color) / 255.0f, \ | ||
| 275 | BLUE_FROM_ULONG (color) / 255.0f, 1.0f) | ||
| 276 | #define CG_SET_STROKE_COLOR(context, color) \ | ||
| 277 | CGContextSetRGBStrokeColor (context, \ | ||
| 278 | RED_FROM_ULONG (color) / 255.0f, \ | ||
| 279 | GREEN_FROM_ULONG (color) / 255.0f, \ | ||
| 280 | BLUE_FROM_ULONG (color) / 255.0f, 1.0f) | ||
| 281 | #if USE_CG_DRAWING | ||
| 282 | #define FRAME_CG_CONTEXT(f) ((f)->output_data.mac->cg_context) | ||
| 283 | |||
| 284 | static CGContextRef | ||
| 285 | mac_begin_cg_clip (f, gc) | ||
| 286 | struct frame *f; | ||
| 287 | GC gc; | ||
| 288 | { | ||
| 289 | CGContextRef context = FRAME_CG_CONTEXT (f); | ||
| 290 | |||
| 291 | if (!context) | ||
| 292 | { | ||
| 293 | QDBeginCGContext (GetWindowPort (FRAME_MAC_WINDOW (f)), &context); | ||
| 294 | FRAME_CG_CONTEXT (f) = context; | ||
| 295 | } | ||
| 296 | |||
| 297 | CGContextSaveGState (context); | ||
| 298 | CGContextTranslateCTM (context, 0, FRAME_PIXEL_HEIGHT (f)); | ||
| 299 | CGContextScaleCTM (context, 1, -1); | ||
| 300 | if (gc && gc->n_clip_rects) | ||
| 301 | CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects); | ||
| 302 | |||
| 303 | return context; | ||
| 304 | } | ||
| 305 | |||
| 306 | static void | ||
| 307 | mac_end_cg_clip (f) | ||
| 308 | struct frame *f; | ||
| 309 | { | ||
| 310 | CGContextRestoreGState (FRAME_CG_CONTEXT (f)); | ||
| 311 | } | ||
| 312 | |||
| 313 | void | ||
| 314 | mac_prepare_for_quickdraw (f) | ||
| 315 | struct frame *f; | ||
| 316 | { | ||
| 317 | if (f == NULL) | ||
| 318 | { | ||
| 319 | Lisp_Object rest, frame; | ||
| 320 | FOR_EACH_FRAME (rest, frame) | ||
| 321 | if (FRAME_MAC_P (XFRAME (frame))) | ||
| 322 | mac_prepare_for_quickdraw (XFRAME (frame)); | ||
| 323 | } | ||
| 324 | else | ||
| 325 | { | ||
| 326 | CGContextRef context = FRAME_CG_CONTEXT (f); | ||
| 327 | |||
| 328 | if (context) | ||
| 329 | { | ||
| 330 | CGContextSynchronize (context); | ||
| 331 | QDEndCGContext (GetWindowPort (FRAME_MAC_WINDOW (f)), | ||
| 332 | &FRAME_CG_CONTEXT (f)); | ||
| 333 | } | ||
| 334 | } | ||
| 335 | } | ||
| 336 | #endif | ||
| 271 | 337 | ||
| 272 | static RgnHandle saved_port_clip_region = NULL; | 338 | static RgnHandle saved_port_clip_region = NULL; |
| 273 | 339 | ||
| @@ -318,6 +384,18 @@ mac_draw_line (f, gc, x1, y1, x2, y2) | |||
| 318 | GC gc; | 384 | GC gc; |
| 319 | int x1, y1, x2, y2; | 385 | int x1, y1, x2, y2; |
| 320 | { | 386 | { |
| 387 | #if USE_CG_DRAWING | ||
| 388 | CGContextRef context; | ||
| 389 | |||
| 390 | context = mac_begin_cg_clip (f, gc); | ||
| 391 | CG_SET_STROKE_COLOR (context, gc->xgcv.foreground); | ||
| 392 | CGContextBeginPath (context); | ||
| 393 | CGContextMoveToPoint (context, x1 + 0.5f, y1 + 0.5f); | ||
| 394 | CGContextAddLineToPoint (context, x2 + 0.5f, y2 + 0.5f); | ||
| 395 | CGContextClosePath (context); | ||
| 396 | CGContextStrokePath (context); | ||
| 397 | mac_end_cg_clip (f); | ||
| 398 | #else | ||
| 321 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 399 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 322 | 400 | ||
| 323 | RGBForeColor (GC_FORE_COLOR (gc)); | 401 | RGBForeColor (GC_FORE_COLOR (gc)); |
| @@ -326,6 +404,7 @@ mac_draw_line (f, gc, x1, y1, x2, y2) | |||
| 326 | MoveTo (x1, y1); | 404 | MoveTo (x1, y1); |
| 327 | LineTo (x2, y2); | 405 | LineTo (x2, y2); |
| 328 | mac_end_clip (gc); | 406 | mac_end_clip (gc); |
| 407 | #endif | ||
| 329 | } | 408 | } |
| 330 | 409 | ||
| 331 | void | 410 | void |
| @@ -359,6 +438,14 @@ mac_erase_rectangle (f, gc, x, y, width, height) | |||
| 359 | int x, y; | 438 | int x, y; |
| 360 | unsigned int width, height; | 439 | unsigned int width, height; |
| 361 | { | 440 | { |
| 441 | #if USE_CG_DRAWING | ||
| 442 | CGContextRef context; | ||
| 443 | |||
| 444 | context = mac_begin_cg_clip (f, gc); | ||
| 445 | CG_SET_FILL_COLOR (context, gc->xgcv.background); | ||
| 446 | CGContextFillRect (context, CGRectMake (x, y, width, height)); | ||
| 447 | mac_end_cg_clip (f); | ||
| 448 | #else | ||
| 362 | Rect r; | 449 | Rect r; |
| 363 | 450 | ||
| 364 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 451 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| @@ -371,6 +458,7 @@ mac_erase_rectangle (f, gc, x, y, width, height) | |||
| 371 | mac_end_clip (gc); | 458 | mac_end_clip (gc); |
| 372 | 459 | ||
| 373 | RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); | 460 | RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); |
| 461 | #endif | ||
| 374 | } | 462 | } |
| 375 | 463 | ||
| 376 | 464 | ||
| @@ -391,6 +479,16 @@ static void | |||
| 391 | mac_clear_window (f) | 479 | mac_clear_window (f) |
| 392 | struct frame *f; | 480 | struct frame *f; |
| 393 | { | 481 | { |
| 482 | #if USE_CG_DRAWING | ||
| 483 | CGContextRef context; | ||
| 484 | GC gc = FRAME_NORMAL_GC (f); | ||
| 485 | |||
| 486 | context = mac_begin_cg_clip (f, NULL); | ||
| 487 | CG_SET_FILL_COLOR (context, gc->xgcv.background); | ||
| 488 | CGContextFillRect (context, CGRectMake (0, 0, FRAME_PIXEL_WIDTH (f), | ||
| 489 | FRAME_PIXEL_HEIGHT (f))); | ||
| 490 | mac_end_cg_clip (f); | ||
| 491 | #else | ||
| 394 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 492 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 395 | 493 | ||
| 396 | RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); | 494 | RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); |
| @@ -405,6 +503,7 @@ mac_clear_window (f) | |||
| 405 | #else /* not TARGET_API_MAC_CARBON */ | 503 | #else /* not TARGET_API_MAC_CARBON */ |
| 406 | EraseRect (&(FRAME_MAC_WINDOW (f)->portRect)); | 504 | EraseRect (&(FRAME_MAC_WINDOW (f)->portRect)); |
| 407 | #endif /* not TARGET_API_MAC_CARBON */ | 505 | #endif /* not TARGET_API_MAC_CARBON */ |
| 506 | #endif | ||
| 408 | } | 507 | } |
| 409 | 508 | ||
| 410 | 509 | ||
| @@ -425,6 +524,9 @@ mac_draw_bitmap (f, gc, x, y, width, height, bits, overlay_p) | |||
| 425 | bitmap.baseAddr = (char *)bits; | 524 | bitmap.baseAddr = (char *)bits; |
| 426 | SetRect (&(bitmap.bounds), 0, 0, width, height); | 525 | SetRect (&(bitmap.bounds), 0, 0, width, height); |
| 427 | 526 | ||
| 527 | #if USE_CG_DRAWING | ||
| 528 | mac_prepare_for_quickdraw (f); | ||
| 529 | #endif | ||
| 428 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 530 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 429 | 531 | ||
| 430 | RGBForeColor (GC_FORE_COLOR (gc)); | 532 | RGBForeColor (GC_FORE_COLOR (gc)); |
| @@ -571,6 +673,14 @@ mac_fill_rectangle (f, gc, x, y, width, height) | |||
| 571 | int x, y; | 673 | int x, y; |
| 572 | unsigned int width, height; | 674 | unsigned int width, height; |
| 573 | { | 675 | { |
| 676 | #if USE_CG_DRAWING | ||
| 677 | CGContextRef context; | ||
| 678 | |||
| 679 | context = mac_begin_cg_clip (f, gc); | ||
| 680 | CG_SET_FILL_COLOR (context, gc->xgcv.foreground); | ||
| 681 | CGContextFillRect (context, CGRectMake (x, y, width, height)); | ||
| 682 | mac_end_cg_clip (f); | ||
| 683 | #else | ||
| 574 | Rect r; | 684 | Rect r; |
| 575 | 685 | ||
| 576 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 686 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| @@ -581,6 +691,7 @@ mac_fill_rectangle (f, gc, x, y, width, height) | |||
| 581 | mac_begin_clip (gc); | 691 | mac_begin_clip (gc); |
| 582 | PaintRect (&r); /* using foreground color of gc */ | 692 | PaintRect (&r); /* using foreground color of gc */ |
| 583 | mac_end_clip (gc); | 693 | mac_end_clip (gc); |
| 694 | #endif | ||
| 584 | } | 695 | } |
| 585 | 696 | ||
| 586 | 697 | ||
| @@ -593,16 +704,26 @@ mac_draw_rectangle (f, gc, x, y, width, height) | |||
| 593 | int x, y; | 704 | int x, y; |
| 594 | unsigned int width, height; | 705 | unsigned int width, height; |
| 595 | { | 706 | { |
| 707 | #if USE_CG_DRAWING | ||
| 708 | CGContextRef context; | ||
| 709 | |||
| 710 | context = mac_begin_cg_clip (f, gc); | ||
| 711 | CG_SET_STROKE_COLOR (context, gc->xgcv.foreground); | ||
| 712 | CGContextStrokeRect (context, | ||
| 713 | CGRectMake (x + 0.5f, y + 0.5f, width, height)); | ||
| 714 | mac_end_cg_clip (f); | ||
| 715 | #else | ||
| 596 | Rect r; | 716 | Rect r; |
| 597 | 717 | ||
| 598 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 718 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 599 | 719 | ||
| 600 | RGBForeColor (GC_FORE_COLOR (gc)); | 720 | RGBForeColor (GC_FORE_COLOR (gc)); |
| 601 | SetRect (&r, x, y, x + width, y + height); | 721 | SetRect (&r, x, y, x + width + 1, y + height + 1); |
| 602 | 722 | ||
| 603 | mac_begin_clip (gc); | 723 | mac_begin_clip (gc); |
| 604 | FrameRect (&r); /* using foreground color of gc */ | 724 | FrameRect (&r); /* using foreground color of gc */ |
| 605 | mac_end_clip (gc); | 725 | mac_end_clip (gc); |
| 726 | #endif | ||
| 606 | } | 727 | } |
| 607 | 728 | ||
| 608 | 729 | ||
| @@ -672,6 +793,9 @@ mac_invert_rectangle (f, x, y, width, height) | |||
| 672 | { | 793 | { |
| 673 | Rect r; | 794 | Rect r; |
| 674 | 795 | ||
| 796 | #if USE_CG_DRAWING | ||
| 797 | mac_prepare_for_quickdraw (f); | ||
| 798 | #endif | ||
| 675 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 799 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 676 | 800 | ||
| 677 | SetRect (&r, x, y, x + width, y + height); | 801 | SetRect (&r, x, y, x + width, y + height); |
| @@ -717,6 +841,9 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 717 | if (!mac_use_core_graphics) | 841 | if (!mac_use_core_graphics) |
| 718 | { | 842 | { |
| 719 | #endif | 843 | #endif |
| 844 | #if USE_CG_DRAWING | ||
| 845 | mac_prepare_for_quickdraw (f); | ||
| 846 | #endif | ||
| 720 | mac_begin_clip (gc); | 847 | mac_begin_clip (gc); |
| 721 | RGBForeColor (GC_FORE_COLOR (gc)); | 848 | RGBForeColor (GC_FORE_COLOR (gc)); |
| 722 | if (bg_width) | 849 | if (bg_width) |
| @@ -745,6 +872,9 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 745 | ByteCount sizes[] = {sizeof (CGContextRef)}; | 872 | ByteCount sizes[] = {sizeof (CGContextRef)}; |
| 746 | ATSUAttributeValuePtr values[] = {&context}; | 873 | ATSUAttributeValuePtr values[] = {&context}; |
| 747 | 874 | ||
| 875 | #if USE_CG_DRAWING | ||
| 876 | context = mac_begin_cg_clip (f, gc); | ||
| 877 | #else | ||
| 748 | GetPort (&port); | 878 | GetPort (&port); |
| 749 | QDBeginCGContext (port, &context); | 879 | QDBeginCGContext (port, &context); |
| 750 | if (gc->n_clip_rects || bg_width) | 880 | if (gc->n_clip_rects || bg_width) |
| @@ -754,14 +884,10 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 754 | if (gc->n_clip_rects) | 884 | if (gc->n_clip_rects) |
| 755 | CGContextClipToRects (context, gc->clip_rects, | 885 | CGContextClipToRects (context, gc->clip_rects, |
| 756 | gc->n_clip_rects); | 886 | gc->n_clip_rects); |
| 887 | #endif | ||
| 757 | if (bg_width) | 888 | if (bg_width) |
| 758 | { | 889 | { |
| 759 | CGContextSetRGBFillColor | 890 | CG_SET_FILL_COLOR (context, gc->xgcv.background); |
| 760 | (context, | ||
| 761 | RED_FROM_ULONG (gc->xgcv.background) / 255.0f, | ||
| 762 | GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f, | ||
| 763 | BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f, | ||
| 764 | 1.0); | ||
| 765 | CGContextFillRect | 891 | CGContextFillRect |
| 766 | (context, | 892 | (context, |
| 767 | CGRectMake (x, y - FONT_BASE (GC_FONT (gc)), | 893 | CGRectMake (x, y - FONT_BASE (GC_FONT (gc)), |
| @@ -769,13 +895,10 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 769 | } | 895 | } |
| 770 | CGContextScaleCTM (context, 1, -1); | 896 | CGContextScaleCTM (context, 1, -1); |
| 771 | CGContextTranslateCTM (context, 0, -port_height); | 897 | CGContextTranslateCTM (context, 0, -port_height); |
| 898 | #if !USE_CG_DRAWING | ||
| 772 | } | 899 | } |
| 773 | CGContextSetRGBFillColor | 900 | #endif |
| 774 | (context, | 901 | CG_SET_FILL_COLOR (context, gc->xgcv.foreground); |
| 775 | RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f, | ||
| 776 | GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f, | ||
| 777 | BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f, | ||
| 778 | 1.0); | ||
| 779 | err = ATSUSetLayoutControls (text_layout, | 902 | err = ATSUSetLayoutControls (text_layout, |
| 780 | sizeof (tags) / sizeof (tags[0]), | 903 | sizeof (tags) / sizeof (tags[0]), |
| 781 | tags, sizes, values); | 904 | tags, sizes, values); |
| @@ -783,8 +906,13 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 783 | ATSUDrawText (text_layout, | 906 | ATSUDrawText (text_layout, |
| 784 | kATSUFromTextBeginning, kATSUToTextEnd, | 907 | kATSUFromTextBeginning, kATSUToTextEnd, |
| 785 | Long2Fix (x), Long2Fix (port_height - y)); | 908 | Long2Fix (x), Long2Fix (port_height - y)); |
| 909 | #if USE_CG_DRAWING | ||
| 910 | mac_end_cg_clip (f); | ||
| 911 | context = NULL; | ||
| 912 | #else | ||
| 786 | CGContextSynchronize (context); | 913 | CGContextSynchronize (context); |
| 787 | QDEndCGContext (port, &context); | 914 | QDEndCGContext (port, &context); |
| 915 | #endif | ||
| 788 | #if 0 | 916 | #if 0 |
| 789 | /* This doesn't work on Mac OS X 10.1. */ | 917 | /* This doesn't work on Mac OS X 10.1. */ |
| 790 | ATSUClearLayoutControls (text_layout, | 918 | ATSUClearLayoutControls (text_layout, |
| @@ -806,6 +934,9 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) | |||
| 806 | if (mac_use_core_graphics) | 934 | if (mac_use_core_graphics) |
| 807 | savedFlags = SwapQDTextFlags (kQDUseCGTextRendering); | 935 | savedFlags = SwapQDTextFlags (kQDUseCGTextRendering); |
| 808 | #endif | 936 | #endif |
| 937 | #if USE_CG_DRAWING | ||
| 938 | mac_prepare_for_quickdraw (f); | ||
| 939 | #endif | ||
| 809 | mac_begin_clip (gc); | 940 | mac_begin_clip (gc); |
| 810 | RGBForeColor (GC_FORE_COLOR (gc)); | 941 | RGBForeColor (GC_FORE_COLOR (gc)); |
| 811 | #ifdef MAC_OS8 | 942 | #ifdef MAC_OS8 |
| @@ -1113,6 +1244,9 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width) | |||
| 1113 | buf++; | 1244 | buf++; |
| 1114 | } | 1245 | } |
| 1115 | 1246 | ||
| 1247 | #if USE_CG_DRAWING | ||
| 1248 | context = mac_begin_cg_clip (f, gc); | ||
| 1249 | #else | ||
| 1116 | QDBeginCGContext (port, &context); | 1250 | QDBeginCGContext (port, &context); |
| 1117 | if (gc->n_clip_rects || bg_width) | 1251 | if (gc->n_clip_rects || bg_width) |
| 1118 | { | 1252 | { |
| @@ -1120,14 +1254,10 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width) | |||
| 1120 | CGContextScaleCTM (context, 1, -1); | 1254 | CGContextScaleCTM (context, 1, -1); |
| 1121 | if (gc->n_clip_rects) | 1255 | if (gc->n_clip_rects) |
| 1122 | CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects); | 1256 | CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects); |
| 1257 | #endif | ||
| 1123 | if (bg_width) | 1258 | if (bg_width) |
| 1124 | { | 1259 | { |
| 1125 | CGContextSetRGBFillColor | 1260 | CG_SET_FILL_COLOR (context, gc->xgcv.background); |
| 1126 | (context, | ||
| 1127 | RED_FROM_ULONG (gc->xgcv.background) / 255.0f, | ||
| 1128 | GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f, | ||
| 1129 | BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f, | ||
| 1130 | 1.0); | ||
| 1131 | CGContextFillRect | 1261 | CGContextFillRect |
| 1132 | (context, | 1262 | (context, |
| 1133 | CGRectMake (gx, y - FONT_BASE (GC_FONT (gc)), | 1263 | CGRectMake (gx, y - FONT_BASE (GC_FONT (gc)), |
| @@ -1135,12 +1265,10 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width) | |||
| 1135 | } | 1265 | } |
| 1136 | CGContextScaleCTM (context, 1, -1); | 1266 | CGContextScaleCTM (context, 1, -1); |
| 1137 | CGContextTranslateCTM (context, 0, -port_height); | 1267 | CGContextTranslateCTM (context, 0, -port_height); |
| 1268 | #if !USE_CG_DRAWING | ||
| 1138 | } | 1269 | } |
| 1139 | CGContextSetRGBFillColor (context, | 1270 | #endif |
| 1140 | RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f, | 1271 | CG_SET_FILL_COLOR (context, gc->xgcv.foreground); |
| 1141 | GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f, | ||
| 1142 | BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f, | ||
| 1143 | 1.0); | ||
| 1144 | CGContextSetFont (context, GC_FONT (gc)->cg_font); | 1272 | CGContextSetFont (context, GC_FONT (gc)->cg_font); |
| 1145 | CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize); | 1273 | CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize); |
| 1146 | if (GC_FONT (gc)->mac_fontsize <= cg_text_anti_aliasing_threshold) | 1274 | if (GC_FONT (gc)->mac_fontsize <= cg_text_anti_aliasing_threshold) |
| @@ -1155,8 +1283,12 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width) | |||
| 1155 | gx += advances[i].width; | 1283 | gx += advances[i].width; |
| 1156 | } | 1284 | } |
| 1157 | #endif | 1285 | #endif |
| 1286 | #if USE_CG_DRAWING | ||
| 1287 | mac_end_cg_clip (f); | ||
| 1288 | #else | ||
| 1158 | CGContextSynchronize (context); | 1289 | CGContextSynchronize (context); |
| 1159 | QDEndCGContext (port, &context); | 1290 | QDEndCGContext (port, &context); |
| 1291 | #endif | ||
| 1160 | 1292 | ||
| 1161 | return 1; | 1293 | return 1; |
| 1162 | } | 1294 | } |
| @@ -1176,6 +1308,9 @@ mac_copy_area (src, f, gc, src_x, src_y, width, height, dest_x, dest_y) | |||
| 1176 | { | 1308 | { |
| 1177 | Rect src_r, dest_r; | 1309 | Rect src_r, dest_r; |
| 1178 | 1310 | ||
| 1311 | #if USE_CG_DRAWING | ||
| 1312 | mac_prepare_for_quickdraw (f); | ||
| 1313 | #endif | ||
| 1179 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 1314 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 1180 | 1315 | ||
| 1181 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); | 1316 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); |
| @@ -1220,6 +1355,9 @@ mac_copy_area_with_mask (src, mask, f, gc, src_x, src_y, | |||
| 1220 | { | 1355 | { |
| 1221 | Rect src_r, dest_r; | 1356 | Rect src_r, dest_r; |
| 1222 | 1357 | ||
| 1358 | #if USE_CG_DRAWING | ||
| 1359 | mac_prepare_for_quickdraw (f); | ||
| 1360 | #endif | ||
| 1223 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 1361 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 1224 | 1362 | ||
| 1225 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); | 1363 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); |
| @@ -1269,6 +1407,9 @@ mac_scroll_area (f, gc, src_x, src_y, width, height, dest_x, dest_y) | |||
| 1269 | RgnHandle dummy = NewRgn (); /* For avoiding update events. */ | 1407 | RgnHandle dummy = NewRgn (); /* For avoiding update events. */ |
| 1270 | 1408 | ||
| 1271 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); | 1409 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); |
| 1410 | #if USE_CG_DRAWING | ||
| 1411 | mac_prepare_for_quickdraw (f); | ||
| 1412 | #endif | ||
| 1272 | ScrollWindowRect (FRAME_MAC_WINDOW (f), | 1413 | ScrollWindowRect (FRAME_MAC_WINDOW (f), |
| 1273 | &src_r, dest_x - src_x, dest_y - src_y, | 1414 | &src_r, dest_x - src_x, dest_y - src_y, |
| 1274 | kScrollWindowNoOptions, dummy); | 1415 | kScrollWindowNoOptions, dummy); |
| @@ -1527,6 +1668,9 @@ x_flush (f) | |||
| 1527 | { | 1668 | { |
| 1528 | #if TARGET_API_MAC_CARBON | 1669 | #if TARGET_API_MAC_CARBON |
| 1529 | BLOCK_INPUT; | 1670 | BLOCK_INPUT; |
| 1671 | #if USE_CG_DRAWING | ||
| 1672 | mac_prepare_for_quickdraw (f); | ||
| 1673 | #endif | ||
| 1530 | if (f) | 1674 | if (f) |
| 1531 | QDFlushPortBuffer (GetWindowPort (FRAME_MAC_WINDOW (f)), NULL); | 1675 | QDFlushPortBuffer (GetWindowPort (FRAME_MAC_WINDOW (f)), NULL); |
| 1532 | else | 1676 | else |
| @@ -2436,7 +2580,7 @@ x_draw_glyph_string_foreground (s) | |||
| 2436 | { | 2580 | { |
| 2437 | struct glyph *g = s->first_glyph + i; | 2581 | struct glyph *g = s->first_glyph + i; |
| 2438 | mac_draw_rectangle (s->f, s->gc, x, s->y, | 2582 | mac_draw_rectangle (s->f, s->gc, x, s->y, |
| 2439 | g->pixel_width, s->height); | 2583 | g->pixel_width - 1, s->height - 1); |
| 2440 | x += g->pixel_width; | 2584 | x += g->pixel_width; |
| 2441 | } | 2585 | } |
| 2442 | } | 2586 | } |
| @@ -2515,7 +2659,7 @@ x_draw_composite_glyph_string_foreground (s) | |||
| 2515 | { | 2659 | { |
| 2516 | if (s->gidx == 0) | 2660 | if (s->gidx == 0) |
| 2517 | mac_draw_rectangle (s->f, s->gc, x, s->y, | 2661 | mac_draw_rectangle (s->f, s->gc, x, s->y, |
| 2518 | s->width, s->height); | 2662 | s->width - 1, s->height - 1); |
| 2519 | } | 2663 | } |
| 2520 | else | 2664 | else |
| 2521 | { | 2665 | { |
| @@ -3068,15 +3212,15 @@ x_draw_image_foreground (s) | |||
| 3068 | int r = s->img->relief; | 3212 | int r = s->img->relief; |
| 3069 | if (r < 0) r = -r; | 3213 | if (r < 0) r = -r; |
| 3070 | mac_draw_rectangle (s->f, s->gc, x - r, y - r, | 3214 | mac_draw_rectangle (s->f, s->gc, x - r, y - r, |
| 3071 | s->slice.width + r*2, | 3215 | s->slice.width + r*2 - 1, |
| 3072 | s->slice.height + r*2); | 3216 | s->slice.height + r*2 - 1); |
| 3073 | } | 3217 | } |
| 3074 | } | 3218 | } |
| 3075 | } | 3219 | } |
| 3076 | else | 3220 | else |
| 3077 | /* Draw a rectangle if image could not be loaded. */ | 3221 | /* Draw a rectangle if image could not be loaded. */ |
| 3078 | mac_draw_rectangle (s->f, s->gc, x, y, | 3222 | mac_draw_rectangle (s->f, s->gc, x, y, |
| 3079 | s->slice.width, s->slice.height); | 3223 | s->slice.width - 1, s->slice.height - 1); |
| 3080 | } | 3224 | } |
| 3081 | 3225 | ||
| 3082 | 3226 | ||
| @@ -4593,6 +4737,9 @@ x_scroll_bar_create (w, top, left, width, height, disp_top, disp_height) | |||
| 4593 | r.right = left + width; | 4737 | r.right = left + width; |
| 4594 | r.bottom = disp_top + disp_height; | 4738 | r.bottom = disp_top + disp_height; |
| 4595 | 4739 | ||
| 4740 | #if USE_CG_DRAWING | ||
| 4741 | mac_prepare_for_quickdraw (f); | ||
| 4742 | #endif | ||
| 4596 | #if TARGET_API_MAC_CARBON | 4743 | #if TARGET_API_MAC_CARBON |
| 4597 | ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", | 4744 | ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", |
| 4598 | #if USE_TOOLKIT_SCROLL_BARS | 4745 | #if USE_TOOLKIT_SCROLL_BARS |
| @@ -4719,6 +4866,9 @@ x_scroll_bar_remove (bar) | |||
| 4719 | 4866 | ||
| 4720 | BLOCK_INPUT; | 4867 | BLOCK_INPUT; |
| 4721 | 4868 | ||
| 4869 | #if USE_CG_DRAWING | ||
| 4870 | mac_prepare_for_quickdraw (f); | ||
| 4871 | #endif | ||
| 4722 | /* Destroy the Mac scroll bar control */ | 4872 | /* Destroy the Mac scroll bar control */ |
| 4723 | DisposeControl (SCROLL_BAR_CONTROL_HANDLE (bar)); | 4873 | DisposeControl (SCROLL_BAR_CONTROL_HANDLE (bar)); |
| 4724 | 4874 | ||
| @@ -4815,6 +4965,9 @@ XTset_vertical_scroll_bar (w, portion, whole, position) | |||
| 4815 | for them on the frame, we have to clear "under" them. */ | 4965 | for them on the frame, we have to clear "under" them. */ |
| 4816 | mac_clear_area (f, left, top, width, height); | 4966 | mac_clear_area (f, left, top, width, height); |
| 4817 | 4967 | ||
| 4968 | #if USE_CG_DRAWING | ||
| 4969 | mac_prepare_for_quickdraw (f); | ||
| 4970 | #endif | ||
| 4818 | HideControl (ch); | 4971 | HideControl (ch); |
| 4819 | MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top); | 4972 | MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top); |
| 4820 | SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, | 4973 | SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, |
| @@ -5245,7 +5398,7 @@ x_draw_hollow_cursor (w, row) | |||
| 5245 | /* Compute frame-relative coordinates for phys cursor. */ | 5398 | /* Compute frame-relative coordinates for phys cursor. */ |
| 5246 | x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); | 5399 | x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); |
| 5247 | y = get_phys_cursor_geometry (w, row, cursor_glyph, &h); | 5400 | y = get_phys_cursor_geometry (w, row, cursor_glyph, &h); |
| 5248 | wd = w->phys_cursor_width + 1; | 5401 | wd = w->phys_cursor_width; |
| 5249 | 5402 | ||
| 5250 | /* The foreground of cursor_gc is typically the same as the normal | 5403 | /* The foreground of cursor_gc is typically the same as the normal |
| 5251 | background color, which can cause the cursor box to be invisible. */ | 5404 | background color, which can cause the cursor box to be invisible. */ |
| @@ -5259,7 +5412,7 @@ x_draw_hollow_cursor (w, row) | |||
| 5259 | 5412 | ||
| 5260 | /* Set clipping, draw the rectangle, and reset clipping again. */ | 5413 | /* Set clipping, draw the rectangle, and reset clipping again. */ |
| 5261 | x_clip_to_row (w, row, TEXT_AREA, gc); | 5414 | x_clip_to_row (w, row, TEXT_AREA, gc); |
| 5262 | mac_draw_rectangle (f, gc, x, y, wd, h); | 5415 | mac_draw_rectangle (f, gc, x, y, wd, h - 1); |
| 5263 | mac_reset_clip_rectangles (dpy, gc); | 5416 | mac_reset_clip_rectangles (dpy, gc); |
| 5264 | } | 5417 | } |
| 5265 | 5418 | ||
| @@ -5786,8 +5939,13 @@ x_set_window_size (f, change_gravity, cols, rows) | |||
| 5786 | SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0); | 5939 | SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0); |
| 5787 | #if TARGET_API_MAC_CARBON | 5940 | #if TARGET_API_MAC_CARBON |
| 5788 | if (f->output_data.mac->hourglass_control) | 5941 | if (f->output_data.mac->hourglass_control) |
| 5789 | MoveControl (f->output_data.mac->hourglass_control, | 5942 | { |
| 5790 | pixelwidth - HOURGLASS_WIDTH, 0); | 5943 | #if USE_CG_DRAWING |
| 5944 | mac_prepare_for_quickdraw (f); | ||
| 5945 | #endif | ||
| 5946 | MoveControl (f->output_data.mac->hourglass_control, | ||
| 5947 | pixelwidth - HOURGLASS_WIDTH, 0); | ||
| 5948 | } | ||
| 5791 | #endif | 5949 | #endif |
| 5792 | 5950 | ||
| 5793 | /* Now, strictly speaking, we can't be sure that this is accurate, | 5951 | /* Now, strictly speaking, we can't be sure that this is accurate, |
| @@ -9672,7 +9830,11 @@ XTread_socket (sd, expected, hold_quit) | |||
| 9672 | #if USE_CARBON_EVENTS | 9830 | #if USE_CARBON_EVENTS |
| 9673 | toolbox_dispatcher = GetEventDispatcherTarget (); | 9831 | toolbox_dispatcher = GetEventDispatcherTarget (); |
| 9674 | 9832 | ||
| 9675 | while (!ReceiveNextEvent (0, NULL, kEventDurationNoWait, | 9833 | while ( |
| 9834 | #if USE_CG_DRAWING | ||
| 9835 | mac_prepare_for_quickdraw (NULL), | ||
| 9836 | #endif | ||
| 9837 | !ReceiveNextEvent (0, NULL, kEventDurationNoWait, | ||
| 9676 | kEventRemoveFromQueue, &eventRef)) | 9838 | kEventRemoveFromQueue, &eventRef)) |
| 9677 | #else /* !USE_CARBON_EVENTS */ | 9839 | #else /* !USE_CARBON_EVENTS */ |
| 9678 | while (mac_wait_next_event (&er, 0, true)) | 9840 | while (mac_wait_next_event (&er, 0, true)) |