aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2007-11-19 05:08:04 +0000
committerKenichi Handa2007-11-19 05:08:04 +0000
commita92ee6bfddb411e567fc9afe430843665dd38262 (patch)
tree0ab2ca22928f4ae4e56e5f6dc78940418e662765 /src
parent00c37e188322b9ba53a484948b648621c4253782 (diff)
downloademacs-a92ee6bfddb411e567fc9afe430843665dd38262.tar.gz
emacs-a92ee6bfddb411e567fc9afe430843665dd38262.zip
(struct xftface_info): Delete the member xft_draw.
(xftfont_prepare_face): Adjusted for the above change. (xftfont_done_face): Likewise. (xftfont_get_xft_draw): New function. (xftfont_draw): Get XftDraw by xftfont_get_xft_draw. (xftfont_end_for_frame): New function. (syms_of_xftfont): Set xftfont_driver.end_for_frame.
Diffstat (limited to 'src')
-rw-r--r--src/xftfont.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/src/xftfont.c b/src/xftfont.c
index 75cc06117c4..441a4b91ba6 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -58,7 +58,6 @@ struct xftface_info
58{ 58{
59 XftColor xft_fg; /* color for face->foreground */ 59 XftColor xft_fg; /* color for face->foreground */
60 XftColor xft_bg; /* color for face->background */ 60 XftColor xft_bg; /* color for face->background */
61 XftDraw *xft_draw;
62}; 61};
63 62
64static void xftfont_get_colors P_ ((FRAME_PTR, struct face *, GC gc, 63static void xftfont_get_colors P_ ((FRAME_PTR, struct face *, GC gc,
@@ -171,6 +170,8 @@ static int xftfont_draw P_ ((struct glyph_string *, int, int, int, int, int));
171 170
172static int xftfont_anchor_point P_ ((struct font *, unsigned, int, 171static int xftfont_anchor_point P_ ((struct font *, unsigned, int,
173 int *, int *)); 172 int *, int *));
173static int xftfont_start_for_frame P_ ((FRAME_PTR f));
174static int xftfont_end_for_frame P_ ((FRAME_PTR f));
174 175
175struct font_driver xftfont_driver; 176struct font_driver xftfont_driver;
176 177
@@ -409,10 +410,6 @@ xftfont_prepare_face (f, face)
409 return -1; 410 return -1;
410 411
411 BLOCK_INPUT; 412 BLOCK_INPUT;
412 xftface_info->xft_draw = XftDrawCreate (FRAME_X_DISPLAY (f),
413 FRAME_X_WINDOW (f),
414 FRAME_X_VISUAL (f),
415 FRAME_X_COLORMAP (f));
416 xftfont_get_colors (f, face, face->gc, NULL, 413 xftfont_get_colors (f, face, face->gc, NULL,
417 &xftface_info->xft_fg, &xftface_info->xft_bg); 414 &xftface_info->xft_fg, &xftface_info->xft_bg);
418 UNBLOCK_INPUT; 415 UNBLOCK_INPUT;
@@ -438,12 +435,9 @@ xftfont_done_face (f, face)
438 xftface_info = (struct xftface_info *) face->extra; 435 xftface_info = (struct xftface_info *) face->extra;
439 if (xftface_info) 436 if (xftface_info)
440 { 437 {
441 BLOCK_INPUT;
442 XftDrawDestroy (xftface_info->xft_draw);
443 UNBLOCK_INPUT;
444 free (xftface_info); 438 free (xftface_info);
439 face->extra = NULL;
445 } 440 }
446 face->extra = NULL;
447} 441}
448 442
449static unsigned 443static unsigned
@@ -483,6 +477,27 @@ xftfont_text_extents (font, code, nglyphs, metrics)
483 return extents.xOff; 477 return extents.xOff;
484} 478}
485 479
480static XftDraw *
481xftfont_get_xft_draw (f)
482 FRAME_PTR f;
483{
484 XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver);;
485
486 if (! xft_draw)
487 {
488 BLOCK_INPUT;
489 xft_draw= XftDrawCreate (FRAME_X_DISPLAY (f),
490 FRAME_X_WINDOW (f),
491 FRAME_X_VISUAL (f),
492 FRAME_X_COLORMAP (f));
493 UNBLOCK_INPUT;
494 if (! xft_draw)
495 abort ();
496 font_put_frame_data (f, &xftfont_driver, xft_draw);
497 }
498 return xft_draw;
499}
500
486static int 501static int
487xftfont_draw (s, from, to, x, y, with_background) 502xftfont_draw (s, from, to, x, y, with_background)
488 struct glyph_string *s; 503 struct glyph_string *s;
@@ -492,7 +507,7 @@ xftfont_draw (s, from, to, x, y, with_background)
492 struct face *face = s->face; 507 struct face *face = s->face;
493 struct xftfont_info *xftfont_info = (struct xftfont_info *) s->font_info; 508 struct xftfont_info *xftfont_info = (struct xftfont_info *) s->font_info;
494 struct xftface_info *xftface_info = NULL; 509 struct xftface_info *xftface_info = NULL;
495 XftDraw *xft_draw = NULL; 510 XftDraw *xft_draw = xftfont_get_xft_draw (f);
496 FT_UInt *code; 511 FT_UInt *code;
497 XftColor fg, bg; 512 XftColor fg, bg;
498 XRectangle r; 513 XRectangle r;
@@ -500,18 +515,10 @@ xftfont_draw (s, from, to, x, y, with_background)
500 int i; 515 int i;
501 516
502 if (s->font_info == face->font_info) 517 if (s->font_info == face->font_info)
503 { 518 xftface_info = (struct xftface_info *) face->extra;
504 xftface_info = (struct xftface_info *) face->extra;
505 xft_draw = xftface_info->xft_draw;
506 }
507 xftfont_get_colors (f, face, s->gc, xftface_info, 519 xftfont_get_colors (f, face, s->gc, xftface_info,
508 &fg, with_background ? &bg : NULL); 520 &fg, with_background ? &bg : NULL);
509 BLOCK_INPUT; 521 BLOCK_INPUT;
510 if (! xft_draw)
511 xft_draw = XftDrawCreate (FRAME_X_DISPLAY (f),
512 FRAME_X_WINDOW (f),
513 FRAME_X_VISUAL (f),
514 FRAME_X_COLORMAP (f));
515 if (s->num_clips > 0) 522 if (s->num_clips > 0)
516 XftDrawSetClipRectangles (xft_draw, 0, 0, s->clip, s->num_clips); 523 XftDrawSetClipRectangles (xft_draw, 0, 0, s->clip, s->num_clips);
517 else 524 else
@@ -531,8 +538,6 @@ xftfont_draw (s, from, to, x, y, with_background)
531 538
532 XftDrawGlyphs (xft_draw, &fg, xftfont_info->xftfont, 539 XftDrawGlyphs (xft_draw, &fg, xftfont_info->xftfont,
533 x, y, code, len); 540 x, y, code, len);
534 if (s->font_info != face->font_info)
535 XftDrawDestroy (xft_draw);
536 UNBLOCK_INPUT; 541 UNBLOCK_INPUT;
537 542
538 return len; 543 return len;
@@ -559,6 +564,21 @@ xftfont_anchor_point (font, code, index, x, y)
559 return 0; 564 return 0;
560} 565}
561 566
567static int
568xftfont_end_for_frame (f)
569 FRAME_PTR f;
570{
571 XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver);
572
573 if (xft_draw)
574 {
575 BLOCK_INPUT;
576 XftDrawDestroy (xft_draw);
577 UNBLOCK_INPUT;
578 font_put_frame_data (f, &xftfont_driver, NULL);
579 }
580 return 0;
581}
562 582
563void 583void
564syms_of_xftfont () 584syms_of_xftfont ()
@@ -578,6 +598,7 @@ syms_of_xftfont ()
578 xftfont_driver.text_extents = xftfont_text_extents; 598 xftfont_driver.text_extents = xftfont_text_extents;
579 xftfont_driver.draw = xftfont_draw; 599 xftfont_driver.draw = xftfont_draw;
580 xftfont_driver.anchor_point = xftfont_anchor_point; 600 xftfont_driver.anchor_point = xftfont_anchor_point;
601 xftfont_driver.end_for_frame = xftfont_end_for_frame;
581 602
582 register_font_driver (&xftfont_driver, NULL); 603 register_font_driver (&xftfont_driver, NULL);
583} 604}