diff options
| author | Po Lu | 2022-02-03 05:16:35 +0000 |
|---|---|---|
| committer | Po Lu | 2022-02-03 05:16:35 +0000 |
| commit | abdb198474e96cc7426196453ebe55dbd2a7c74d (patch) | |
| tree | a8f4fc74d80b33999eb3e95b55e09da52d4f3147 /src | |
| parent | 11ee58de9db67ff2431d243fd7ab83ea8f417cb5 (diff) | |
| download | emacs-abdb198474e96cc7426196453ebe55dbd2a7c74d.tar.gz emacs-abdb198474e96cc7426196453ebe55dbd2a7c74d.zip | |
Simplify box display code on Haiku
* src/haikuterm.c (haiku_calculate_relief_colors): Remove
`rgbout_c' parameter.
(haiku_draw_relief_rect): Push state if performing additional
clipping.
(haiku_draw_string_box): Stop passing clip rects to the relief
drawing functions.
(haiku_draw_glyph_string): Fix calls to haiku_draw_string_box
for new parameters.
Diffstat (limited to 'src')
| -rw-r--r-- | src/haikuterm.c | 52 |
1 files changed, 18 insertions, 34 deletions
diff --git a/src/haikuterm.c b/src/haikuterm.c index a007aeaba66..eb58d1714ea 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c | |||
| @@ -461,9 +461,8 @@ haiku_draw_box_rect (struct glyph_string *s, | |||
| 461 | } | 461 | } |
| 462 | 462 | ||
| 463 | static void | 463 | static void |
| 464 | haiku_calculate_relief_colors (struct glyph_string *s, | 464 | haiku_calculate_relief_colors (struct glyph_string *s, uint32_t *rgbout_w, |
| 465 | uint32_t *rgbout_w, uint32_t *rgbout_b, | 465 | uint32_t *rgbout_b) |
| 466 | uint32_t *rgbout_c) | ||
| 467 | { | 466 | { |
| 468 | struct face *face = s->face; | 467 | struct face *face = s->face; |
| 469 | 468 | ||
| @@ -480,7 +479,6 @@ haiku_calculate_relief_colors (struct glyph_string *s, | |||
| 480 | 479 | ||
| 481 | hsl_color_rgb (h, cs, fmin (1.0, fmax (0.2, l) * 0.6), rgbout_b); | 480 | hsl_color_rgb (h, cs, fmin (1.0, fmax (0.2, l) * 0.6), rgbout_b); |
| 482 | hsl_color_rgb (h, cs, fmin (1.0, fmax (0.2, l) * 1.2), rgbout_w); | 481 | hsl_color_rgb (h, cs, fmin (1.0, fmax (0.2, l) * 1.2), rgbout_w); |
| 483 | hsl_color_rgb (h, cs, fmin (1.0, fmax (0.2, l) * 1.8), rgbout_c); | ||
| 484 | } | 482 | } |
| 485 | 483 | ||
| 486 | static void | 484 | static void |
| @@ -492,16 +490,18 @@ haiku_draw_relief_rect (struct glyph_string *s, | |||
| 492 | { | 490 | { |
| 493 | uint32_t color_white; | 491 | uint32_t color_white; |
| 494 | uint32_t color_black; | 492 | uint32_t color_black; |
| 495 | uint32_t color_corner; | ||
| 496 | 493 | ||
| 497 | haiku_calculate_relief_colors (s, &color_white, &color_black, | 494 | haiku_calculate_relief_colors (s, &color_white, &color_black); |
| 498 | &color_corner); | ||
| 499 | 495 | ||
| 500 | void *view = FRAME_HAIKU_VIEW (s->f); | 496 | void *view = FRAME_HAIKU_VIEW (s->f); |
| 501 | BView_SetHighColor (view, raised_p ? color_white : color_black); | 497 | BView_SetHighColor (view, raised_p ? color_white : color_black); |
| 502 | if (clip_rect) | 498 | if (clip_rect) |
| 503 | BView_ClipToRect (view, clip_rect->x, clip_rect->y, clip_rect->width, | 499 | { |
| 504 | clip_rect->height); | 500 | BView_StartClip (view); |
| 501 | haiku_clip_to_string (s); | ||
| 502 | BView_ClipToRect (view, clip_rect->x, clip_rect->y, clip_rect->width, | ||
| 503 | clip_rect->height); | ||
| 504 | } | ||
| 505 | if (top_p) | 505 | if (top_p) |
| 506 | BView_FillRectangle (view, left_x, top_y, right_x - left_x + 1, hwidth); | 506 | BView_FillRectangle (view, left_x, top_y, right_x - left_x + 1, hwidth); |
| 507 | if (left_p) | 507 | if (left_p) |
| @@ -546,7 +546,7 @@ haiku_draw_relief_rect (struct glyph_string *s, | |||
| 546 | if (vwidth > 1 && right_p) | 546 | if (vwidth > 1 && right_p) |
| 547 | BView_StrokeLine (view, right_x, top_y, right_x, bottom_y); | 547 | BView_StrokeLine (view, right_x, top_y, right_x, bottom_y); |
| 548 | 548 | ||
| 549 | BView_SetHighColor (view, color_corner); | 549 | BView_SetHighColor (view, s->face->background); |
| 550 | 550 | ||
| 551 | /* Omit corner pixels. */ | 551 | /* Omit corner pixels. */ |
| 552 | if (hwidth > 1 || vwidth > 1) | 552 | if (hwidth > 1 || vwidth > 1) |
| @@ -560,6 +560,9 @@ haiku_draw_relief_rect (struct glyph_string *s, | |||
| 560 | if (right_p && bot_p) | 560 | if (right_p && bot_p) |
| 561 | BView_FillRectangle (view, right_x, bottom_y, 1, 1); | 561 | BView_FillRectangle (view, right_x, bottom_y, 1, 1); |
| 562 | } | 562 | } |
| 563 | |||
| 564 | if (clip_rect) | ||
| 565 | BView_EndClip (view); | ||
| 563 | } | 566 | } |
| 564 | 567 | ||
| 565 | static void | 568 | static void |
| @@ -746,13 +749,11 @@ haiku_draw_text_decoration (struct glyph_string *s, struct face *face, | |||
| 746 | } | 749 | } |
| 747 | 750 | ||
| 748 | static void | 751 | static void |
| 749 | haiku_draw_string_box (struct glyph_string *s, int clip_p) | 752 | haiku_draw_string_box (struct glyph_string *s) |
| 750 | { | 753 | { |
| 751 | int hwidth, vwidth, left_x, right_x, top_y, bottom_y, last_x; | 754 | int hwidth, vwidth, left_x, right_x, top_y, bottom_y, last_x; |
| 752 | bool raised_p, left_p, right_p; | 755 | bool raised_p, left_p, right_p; |
| 753 | struct glyph *last_glyph; | 756 | struct glyph *last_glyph; |
| 754 | struct haiku_rect clip_rect; | ||
| 755 | |||
| 756 | struct face *face = s->face; | 757 | struct face *face = s->face; |
| 757 | 758 | ||
| 758 | last_x = ((s->row->full_width_p && !s->w->pseudo_window_p) | 759 | last_x = ((s->row->full_width_p && !s->w->pseudo_window_p) |
| @@ -800,30 +801,13 @@ haiku_draw_string_box (struct glyph_string *s, int clip_p) | |||
| 800 | && (s->next == NULL | 801 | && (s->next == NULL |
| 801 | || s->next->hl != s->hl))); | 802 | || s->next->hl != s->hl))); |
| 802 | 803 | ||
| 803 | get_glyph_string_clip_rect (s, &clip_rect); | ||
| 804 | |||
| 805 | if (face->box == FACE_SIMPLE_BOX) | 804 | if (face->box == FACE_SIMPLE_BOX) |
| 806 | haiku_draw_box_rect (s, left_x, top_y, right_x, bottom_y, hwidth, | 805 | haiku_draw_box_rect (s, left_x, top_y, right_x, bottom_y, hwidth, |
| 807 | vwidth, left_p, right_p, &clip_rect); | 806 | vwidth, left_p, right_p, NULL); |
| 808 | else | 807 | else |
| 809 | haiku_draw_relief_rect (s, left_x, top_y, right_x, bottom_y, hwidth, | 808 | haiku_draw_relief_rect (s, left_x, top_y, right_x, bottom_y, hwidth, |
| 810 | vwidth, raised_p, true, true, left_p, right_p, | 809 | vwidth, raised_p, true, true, left_p, right_p, |
| 811 | &clip_rect, 1); | 810 | NULL, 1); |
| 812 | |||
| 813 | if (clip_p) | ||
| 814 | { | ||
| 815 | void *view = FRAME_HAIKU_VIEW (s->f); | ||
| 816 | |||
| 817 | haiku_draw_text_decoration (s, face, s->width, s->x); | ||
| 818 | BView_ClipToInverseRect (view, left_x, top_y, right_x - left_x + 1, hwidth); | ||
| 819 | if (left_p) | ||
| 820 | BView_ClipToInverseRect (view, left_x, top_y, vwidth, bottom_y - top_y + 1); | ||
| 821 | BView_ClipToInverseRect (view, left_x, bottom_y - hwidth + 1, | ||
| 822 | right_x - left_x + 1, hwidth); | ||
| 823 | if (right_p) | ||
| 824 | BView_ClipToInverseRect (view, right_x - vwidth + 1, | ||
| 825 | top_y, vwidth, bottom_y - top_y + 1); | ||
| 826 | } | ||
| 827 | } | 811 | } |
| 828 | 812 | ||
| 829 | static void | 813 | static void |
| @@ -1506,7 +1490,7 @@ haiku_draw_glyph_string (struct glyph_string *s) | |||
| 1506 | haiku_clip_to_string (s); | 1490 | haiku_clip_to_string (s); |
| 1507 | haiku_maybe_draw_background (s, 1); | 1491 | haiku_maybe_draw_background (s, 1); |
| 1508 | box_filled_p = 1; | 1492 | box_filled_p = 1; |
| 1509 | haiku_draw_string_box (s, 0); | 1493 | haiku_draw_string_box (s); |
| 1510 | } | 1494 | } |
| 1511 | else if (!s->clip_head /* draw_glyphs didn't specify a clip mask. */ | 1495 | else if (!s->clip_head /* draw_glyphs didn't specify a clip mask. */ |
| 1512 | && !s->clip_tail | 1496 | && !s->clip_tail |
| @@ -1559,7 +1543,7 @@ haiku_draw_glyph_string (struct glyph_string *s) | |||
| 1559 | if (!s->for_overlaps) | 1543 | if (!s->for_overlaps) |
| 1560 | { | 1544 | { |
| 1561 | if (!box_filled_p && face->box != FACE_NO_BOX) | 1545 | if (!box_filled_p && face->box != FACE_NO_BOX) |
| 1562 | haiku_draw_string_box (s, 1); | 1546 | haiku_draw_string_box (s); |
| 1563 | else | 1547 | else |
| 1564 | haiku_draw_text_decoration (s, face, s->width, s->x); | 1548 | haiku_draw_text_decoration (s, face, s->width, s->x); |
| 1565 | 1549 | ||