diff options
| author | YAMAMOTO Mitsuharu | 2015-02-16 10:20:26 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2015-02-16 10:20:26 +0900 |
| commit | 426af0ef9f2008d78633a2f3c1daf1ddbe9d8e6e (patch) | |
| tree | 64b72006336d199a2b1b5cd1a84dfbd35312c326 /src | |
| parent | 022d7cda41e8c0db381b22bef0d48671b5725e9c (diff) | |
| download | emacs-426af0ef9f2008d78633a2f3c1daf1ddbe9d8e6e.tar.gz emacs-426af0ef9f2008d78633a2f3c1daf1ddbe9d8e6e.zip | |
Implement wave-style variant of underlining for cairo.
* xterm.c (x_draw_horizontal_wave) [USE_CAIRO]: New function.
(x_draw_underwave) [USE_CAIRO]: Use it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 2 | ||||
| -rw-r--r-- | src/xterm.c | 46 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index d9b24768ef7..5df51b487bd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | * xterm.c (x_draw_window_divider): Use x_fill_rectangle instead of | 3 | * xterm.c (x_draw_window_divider): Use x_fill_rectangle instead of |
| 4 | XFillRectangle. | 4 | XFillRectangle. |
| 5 | (x_draw_horizontal_wave) [USE_CAIRO]: New function. | ||
| 6 | (x_draw_underwave) [USE_CAIRO]: Use it. | ||
| 5 | 7 | ||
| 6 | 2015-02-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 8 | 2015-02-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
| 7 | 9 | ||
diff --git a/src/xterm.c b/src/xterm.c index 04d6c061892..ae421a8d795 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -875,6 +875,47 @@ x_fill_trapezoid_for_relief (f, gc, x, y, width, height, top_p) | |||
| 875 | cairo_fill (cr); | 875 | cairo_fill (cr); |
| 876 | x_end_cr_clip (f); | 876 | x_end_cr_clip (f); |
| 877 | } | 877 | } |
| 878 | |||
| 879 | static void | ||
| 880 | x_draw_horizontal_wave (struct frame *f, GC gc, int x, int y, | ||
| 881 | int width, int height, int wave_length) | ||
| 882 | { | ||
| 883 | cairo_t *cr; | ||
| 884 | double dx = wave_length, dy = height - 1; | ||
| 885 | int xoffset, n; | ||
| 886 | |||
| 887 | cr = x_begin_cr_clip (f, gc); | ||
| 888 | x_set_cr_source_with_gc_foreground (f, gc); | ||
| 889 | cairo_rectangle (cr, x, y, width, height); | ||
| 890 | cairo_clip (cr); | ||
| 891 | |||
| 892 | if (x >= 0) | ||
| 893 | { | ||
| 894 | xoffset = x % (wave_length * 2); | ||
| 895 | if (xoffset == 0) | ||
| 896 | xoffset = wave_length * 2; | ||
| 897 | } | ||
| 898 | else | ||
| 899 | xoffset = x % (wave_length * 2) + wave_length * 2; | ||
| 900 | n = (width + xoffset) / wave_length + 1; | ||
| 901 | if (xoffset > wave_length) | ||
| 902 | { | ||
| 903 | xoffset -= wave_length; | ||
| 904 | --n; | ||
| 905 | y += height - 1; | ||
| 906 | dy = -dy; | ||
| 907 | } | ||
| 908 | |||
| 909 | cairo_move_to (cr, x - xoffset + 0.5, y + 0.5); | ||
| 910 | while (--n >= 0) | ||
| 911 | { | ||
| 912 | cairo_rel_line_to (cr, dx, dy); | ||
| 913 | dy = -dy; | ||
| 914 | } | ||
| 915 | cairo_set_line_width (cr, 1); | ||
| 916 | cairo_stroke (cr); | ||
| 917 | x_end_cr_clip (f); | ||
| 918 | } | ||
| 878 | #endif | 919 | #endif |
| 879 | 920 | ||
| 880 | 921 | ||
| @@ -3255,6 +3296,10 @@ static void | |||
| 3255 | x_draw_underwave (struct glyph_string *s) | 3296 | x_draw_underwave (struct glyph_string *s) |
| 3256 | { | 3297 | { |
| 3257 | int wave_height = 3, wave_length = 2; | 3298 | int wave_height = 3, wave_length = 2; |
| 3299 | #ifdef USE_CAIRO | ||
| 3300 | x_draw_horizontal_wave (s->f, s->gc, s->x, s->ybase - wave_height + 3, | ||
| 3301 | s->width, wave_height, wave_length); | ||
| 3302 | #else /* not USE_CAIRO */ | ||
| 3258 | int dx, dy, x0, y0, width, x1, y1, x2, y2, xmax; | 3303 | int dx, dy, x0, y0, width, x1, y1, x2, y2, xmax; |
| 3259 | bool odd; | 3304 | bool odd; |
| 3260 | XRectangle wave_clip, string_clip, final_clip; | 3305 | XRectangle wave_clip, string_clip, final_clip; |
| @@ -3304,6 +3349,7 @@ x_draw_underwave (struct glyph_string *s) | |||
| 3304 | 3349 | ||
| 3305 | /* Restore previous clipping rectangle(s) */ | 3350 | /* Restore previous clipping rectangle(s) */ |
| 3306 | XSetClipRectangles (s->display, s->gc, 0, 0, s->clip, s->num_clips, Unsorted); | 3351 | XSetClipRectangles (s->display, s->gc, 0, 0, s->clip, s->num_clips, Unsorted); |
| 3352 | #endif /* not USE_CAIRO */ | ||
| 3307 | } | 3353 | } |
| 3308 | 3354 | ||
| 3309 | 3355 | ||