From: Po Lu Date: Thu, 3 Feb 2022 05:16:35 +0000 (+0000) Subject: Simplify box display code on Haiku X-Git-Tag: emacs-29.0.90~2564 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=abdb198474e96cc7426196453ebe55dbd2a7c74d;p=emacs.git 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. --- 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, } static void -haiku_calculate_relief_colors (struct glyph_string *s, - uint32_t *rgbout_w, uint32_t *rgbout_b, - uint32_t *rgbout_c) +haiku_calculate_relief_colors (struct glyph_string *s, uint32_t *rgbout_w, + uint32_t *rgbout_b) { struct face *face = s->face; @@ -480,7 +479,6 @@ haiku_calculate_relief_colors (struct glyph_string *s, hsl_color_rgb (h, cs, fmin (1.0, fmax (0.2, l) * 0.6), rgbout_b); hsl_color_rgb (h, cs, fmin (1.0, fmax (0.2, l) * 1.2), rgbout_w); - hsl_color_rgb (h, cs, fmin (1.0, fmax (0.2, l) * 1.8), rgbout_c); } static void @@ -492,16 +490,18 @@ haiku_draw_relief_rect (struct glyph_string *s, { uint32_t color_white; uint32_t color_black; - uint32_t color_corner; - haiku_calculate_relief_colors (s, &color_white, &color_black, - &color_corner); + haiku_calculate_relief_colors (s, &color_white, &color_black); void *view = FRAME_HAIKU_VIEW (s->f); BView_SetHighColor (view, raised_p ? color_white : color_black); if (clip_rect) - BView_ClipToRect (view, clip_rect->x, clip_rect->y, clip_rect->width, - clip_rect->height); + { + BView_StartClip (view); + haiku_clip_to_string (s); + BView_ClipToRect (view, clip_rect->x, clip_rect->y, clip_rect->width, + clip_rect->height); + } if (top_p) BView_FillRectangle (view, left_x, top_y, right_x - left_x + 1, hwidth); if (left_p) @@ -546,7 +546,7 @@ haiku_draw_relief_rect (struct glyph_string *s, if (vwidth > 1 && right_p) BView_StrokeLine (view, right_x, top_y, right_x, bottom_y); - BView_SetHighColor (view, color_corner); + BView_SetHighColor (view, s->face->background); /* Omit corner pixels. */ if (hwidth > 1 || vwidth > 1) @@ -560,6 +560,9 @@ haiku_draw_relief_rect (struct glyph_string *s, if (right_p && bot_p) BView_FillRectangle (view, right_x, bottom_y, 1, 1); } + + if (clip_rect) + BView_EndClip (view); } static void @@ -746,13 +749,11 @@ haiku_draw_text_decoration (struct glyph_string *s, struct face *face, } static void -haiku_draw_string_box (struct glyph_string *s, int clip_p) +haiku_draw_string_box (struct glyph_string *s) { int hwidth, vwidth, left_x, right_x, top_y, bottom_y, last_x; bool raised_p, left_p, right_p; struct glyph *last_glyph; - struct haiku_rect clip_rect; - struct face *face = s->face; 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) && (s->next == NULL || s->next->hl != s->hl))); - get_glyph_string_clip_rect (s, &clip_rect); - if (face->box == FACE_SIMPLE_BOX) haiku_draw_box_rect (s, left_x, top_y, right_x, bottom_y, hwidth, - vwidth, left_p, right_p, &clip_rect); + vwidth, left_p, right_p, NULL); else haiku_draw_relief_rect (s, left_x, top_y, right_x, bottom_y, hwidth, vwidth, raised_p, true, true, left_p, right_p, - &clip_rect, 1); - - if (clip_p) - { - void *view = FRAME_HAIKU_VIEW (s->f); - - haiku_draw_text_decoration (s, face, s->width, s->x); - BView_ClipToInverseRect (view, left_x, top_y, right_x - left_x + 1, hwidth); - if (left_p) - BView_ClipToInverseRect (view, left_x, top_y, vwidth, bottom_y - top_y + 1); - BView_ClipToInverseRect (view, left_x, bottom_y - hwidth + 1, - right_x - left_x + 1, hwidth); - if (right_p) - BView_ClipToInverseRect (view, right_x - vwidth + 1, - top_y, vwidth, bottom_y - top_y + 1); - } + NULL, 1); } static void @@ -1506,7 +1490,7 @@ haiku_draw_glyph_string (struct glyph_string *s) haiku_clip_to_string (s); haiku_maybe_draw_background (s, 1); box_filled_p = 1; - haiku_draw_string_box (s, 0); + haiku_draw_string_box (s); } else if (!s->clip_head /* draw_glyphs didn't specify a clip mask. */ && !s->clip_tail @@ -1559,7 +1543,7 @@ haiku_draw_glyph_string (struct glyph_string *s) if (!s->for_overlaps) { if (!box_filled_p && face->box != FACE_NO_BOX) - haiku_draw_string_box (s, 1); + haiku_draw_string_box (s); else haiku_draw_text_decoration (s, face, s->width, s->x);