diff options
| author | Po Lu | 2022-01-05 10:34:43 +0000 |
|---|---|---|
| committer | Po Lu | 2022-01-05 10:34:43 +0000 |
| commit | ed62de0d39fc5f4e459a49444af2cda3e0426607 (patch) | |
| tree | 57fbd6a3268a939411724dcbd315c4d62d07aac3 /src | |
| parent | e1626257ab984c129aaeb8de6a1e4ec5ef1d2e13 (diff) | |
| download | emacs-ed62de0d39fc5f4e459a49444af2cda3e0426607.tar.gz emacs-ed62de0d39fc5f4e459a49444af2cda3e0426607.zip | |
Resolve clipping related mysteries on Haiku
* src/ftcrfont.c (ftcrfont_draw):
* src/haikufont.c (haikufont_draw): Remove workarounds for
previously broken clipping code.
* src/haikuterm.c (haiku_clip_to_string): Handle empty clipping
rectangles correctly.
(haiku_clip_to_string_exactly): Stop setting num_clips.
(haiku_draw_glyph_string): Stop saving face when drawing
overhangs.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ftcrfont.c | 7 | ||||
| -rw-r--r-- | src/haikufont.c | 7 | ||||
| -rw-r--r-- | src/haikuterm.c | 68 |
3 files changed, 41 insertions, 41 deletions
diff --git a/src/ftcrfont.c b/src/ftcrfont.c index e8159d11b1c..337e804b895 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c | |||
| @@ -545,13 +545,6 @@ ftcrfont_draw (struct glyph_string *s, | |||
| 545 | return 0; | 545 | return 0; |
| 546 | } | 546 | } |
| 547 | BView_cr_dump_clipping (FRAME_HAIKU_VIEW (f), cr); | 547 | BView_cr_dump_clipping (FRAME_HAIKU_VIEW (f), cr); |
| 548 | |||
| 549 | if (s->left_overhang && s->clip_head && !s->for_overlaps) | ||
| 550 | { | ||
| 551 | cairo_rectangle (cr, s->clip_head->x, 0, | ||
| 552 | FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f)); | ||
| 553 | cairo_clip (cr); | ||
| 554 | } | ||
| 555 | #endif | 548 | #endif |
| 556 | 549 | ||
| 557 | if (with_background) | 550 | if (with_background) |
diff --git a/src/haikufont.c b/src/haikufont.c index e1a09f407c5..e08792be4b3 100644 --- a/src/haikufont.c +++ b/src/haikufont.c | |||
| @@ -983,13 +983,6 @@ haikufont_draw (struct glyph_string *s, int from, int to, | |||
| 983 | s->background_filled_p = 1; | 983 | s->background_filled_p = 1; |
| 984 | } | 984 | } |
| 985 | 985 | ||
| 986 | if (s->left_overhang && s->clip_head && !s->for_overlaps) | ||
| 987 | { | ||
| 988 | /* XXX: Why is this neccessary? */ | ||
| 989 | BView_ClipToRect (view, s->clip_head->x, 0, | ||
| 990 | FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f)); | ||
| 991 | } | ||
| 992 | |||
| 993 | if (s->hl == DRAW_CURSOR) | 986 | if (s->hl == DRAW_CURSOR) |
| 994 | BView_SetHighColor (view, FRAME_OUTPUT_DATA (s->f)->cursor_fg); | 987 | BView_SetHighColor (view, FRAME_OUTPUT_DATA (s->f)->cursor_fg); |
| 995 | else | 988 | else |
diff --git a/src/haikuterm.c b/src/haikuterm.c index b8cb57a8fb0..928b5718551 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c | |||
| @@ -145,15 +145,32 @@ haiku_clip_to_string (struct glyph_string *s) | |||
| 145 | int n = get_glyph_string_clip_rects (s, (struct haiku_rect *) &r, 2); | 145 | int n = get_glyph_string_clip_rects (s, (struct haiku_rect *) &r, 2); |
| 146 | 146 | ||
| 147 | if (n) | 147 | if (n) |
| 148 | BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), r[0].x, r[0].y, | ||
| 149 | r[0].width, r[0].height); | ||
| 150 | if (n > 1) | ||
| 151 | { | 148 | { |
| 152 | BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), r[1].x, r[1].y, | 149 | /* If n[FOO].width is 0, it means to not draw at all, so set the |
| 153 | r[1].width, r[1].height); | 150 | clipping to some impossible value. */ |
| 151 | if (r[0].width <= 0) | ||
| 152 | BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), | ||
| 153 | FRAME_PIXEL_WIDTH (s->f), | ||
| 154 | FRAME_PIXEL_HEIGHT (s->f), | ||
| 155 | 10, 10); | ||
| 156 | else | ||
| 157 | BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), r[0].x, | ||
| 158 | r[0].y, r[0].width, r[0].height); | ||
| 154 | } | 159 | } |
| 155 | 160 | ||
| 156 | s->num_clips = n; | 161 | if (n > 1) |
| 162 | { | ||
| 163 | /* If n[FOO].width is 0, it means to not draw at all, so set the | ||
| 164 | clipping to some impossible value. */ | ||
| 165 | if (r[1].width <= 0) | ||
| 166 | BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), | ||
| 167 | FRAME_PIXEL_WIDTH (s->f), | ||
| 168 | FRAME_PIXEL_HEIGHT (s->f), | ||
| 169 | 10, 10); | ||
| 170 | else | ||
| 171 | BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), r[1].x, r[1].y, | ||
| 172 | r[1].width, r[1].height); | ||
| 173 | } | ||
| 157 | } | 174 | } |
| 158 | 175 | ||
| 159 | static void | 176 | static void |
| @@ -161,7 +178,6 @@ haiku_clip_to_string_exactly (struct glyph_string *s, struct glyph_string *dst) | |||
| 161 | { | 178 | { |
| 162 | BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), s->x, s->y, | 179 | BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), s->x, s->y, |
| 163 | s->width, s->height); | 180 | s->width, s->height); |
| 164 | dst->num_clips = 1; | ||
| 165 | } | 181 | } |
| 166 | 182 | ||
| 167 | static void | 183 | static void |
| @@ -1468,7 +1484,6 @@ haiku_draw_glyph_string (struct glyph_string *s) | |||
| 1468 | haiku_maybe_draw_background (s->next, 1); | 1484 | haiku_maybe_draw_background (s->next, 1); |
| 1469 | else | 1485 | else |
| 1470 | haiku_draw_stretch_glyph_string (s->next); | 1486 | haiku_draw_stretch_glyph_string (s->next); |
| 1471 | next->num_clips = 0; | ||
| 1472 | haiku_end_clip (s); | 1487 | haiku_end_clip (s); |
| 1473 | } | 1488 | } |
| 1474 | } | 1489 | } |
| @@ -1486,9 +1501,13 @@ haiku_draw_glyph_string (struct glyph_string *s) | |||
| 1486 | box_filled_p = 1; | 1501 | box_filled_p = 1; |
| 1487 | haiku_draw_string_box (s, 0); | 1502 | haiku_draw_string_box (s, 0); |
| 1488 | } | 1503 | } |
| 1489 | else if (!s->clip_head && !s->clip_tail && | 1504 | else if (!s->clip_head /* draw_glyphs didn't specify a clip mask. */ |
| 1490 | ((s->prev && s->left_overhang && s->prev->hl != s->hl) || | 1505 | && !s->clip_tail |
| 1491 | (s->next && s->right_overhang && s->next->hl != s->hl))) | 1506 | && ((s->prev && s->prev->hl != s->hl && s->left_overhang) |
| 1507 | || (s->next && s->next->hl != s->hl && s->right_overhang))) | ||
| 1508 | /* We must clip just this glyph. left_overhang part has already | ||
| 1509 | drawn when s->prev was drawn, and right_overhang part will be | ||
| 1510 | drawn later when s->next is drawn. */ | ||
| 1492 | haiku_clip_to_string_exactly (s, s); | 1511 | haiku_clip_to_string_exactly (s, s); |
| 1493 | else | 1512 | else |
| 1494 | haiku_clip_to_string (s); | 1513 | haiku_clip_to_string (s); |
| @@ -1526,15 +1545,18 @@ haiku_draw_glyph_string (struct glyph_string *s) | |||
| 1526 | haiku_maybe_draw_background (s, 1); | 1545 | haiku_maybe_draw_background (s, 1); |
| 1527 | haiku_draw_glyphless_glyph_string_foreground (s); | 1546 | haiku_draw_glyphless_glyph_string_foreground (s); |
| 1528 | break; | 1547 | break; |
| 1548 | default: | ||
| 1549 | emacs_abort (); | ||
| 1529 | } | 1550 | } |
| 1530 | 1551 | ||
| 1531 | if (!box_filled_p && face->box != FACE_NO_BOX) | ||
| 1532 | haiku_draw_string_box (s, 1); | ||
| 1533 | else | ||
| 1534 | haiku_draw_text_decoration (s, face, face->foreground, s->width, s->x); | ||
| 1535 | |||
| 1536 | if (!s->for_overlaps) | 1552 | if (!s->for_overlaps) |
| 1537 | { | 1553 | { |
| 1554 | if (!box_filled_p && face->box != FACE_NO_BOX) | ||
| 1555 | haiku_draw_string_box (s, 1); | ||
| 1556 | else | ||
| 1557 | haiku_draw_text_decoration (s, face, face->foreground, | ||
| 1558 | s->width, s->x); | ||
| 1559 | |||
| 1538 | if (s->prev) | 1560 | if (s->prev) |
| 1539 | { | 1561 | { |
| 1540 | struct glyph_string *prev; | 1562 | struct glyph_string *prev; |
| @@ -1546,11 +1568,10 @@ haiku_draw_glyph_string (struct glyph_string *s) | |||
| 1546 | /* As prev was drawn while clipped to its own area, we | 1568 | /* As prev was drawn while clipped to its own area, we |
| 1547 | must draw the right_overhang part using s->hl now. */ | 1569 | must draw the right_overhang part using s->hl now. */ |
| 1548 | enum draw_glyphs_face save = prev->hl; | 1570 | enum draw_glyphs_face save = prev->hl; |
| 1549 | struct face *save_face = prev->face; | ||
| 1550 | 1571 | ||
| 1551 | prev->hl = s->hl; | 1572 | prev->hl = s->hl; |
| 1552 | prev->face = s->face; | ||
| 1553 | haiku_start_clip (s); | 1573 | haiku_start_clip (s); |
| 1574 | haiku_clip_to_string (s); | ||
| 1554 | haiku_clip_to_string_exactly (s, prev); | 1575 | haiku_clip_to_string_exactly (s, prev); |
| 1555 | if (prev->first_glyph->type == CHAR_GLYPH) | 1576 | if (prev->first_glyph->type == CHAR_GLYPH) |
| 1556 | haiku_draw_glyph_string_foreground (prev); | 1577 | haiku_draw_glyph_string_foreground (prev); |
| @@ -1558,8 +1579,6 @@ haiku_draw_glyph_string (struct glyph_string *s) | |||
| 1558 | haiku_draw_composite_glyph_string_foreground (prev); | 1579 | haiku_draw_composite_glyph_string_foreground (prev); |
| 1559 | haiku_end_clip (s); | 1580 | haiku_end_clip (s); |
| 1560 | prev->hl = save; | 1581 | prev->hl = save; |
| 1561 | prev->face = save_face; | ||
| 1562 | prev->num_clips = 0; | ||
| 1563 | } | 1582 | } |
| 1564 | } | 1583 | } |
| 1565 | 1584 | ||
| @@ -1574,11 +1593,10 @@ haiku_draw_glyph_string (struct glyph_string *s) | |||
| 1574 | /* As next will be drawn while clipped to its own area, | 1593 | /* As next will be drawn while clipped to its own area, |
| 1575 | we must draw the left_overhang part using s->hl now. */ | 1594 | we must draw the left_overhang part using s->hl now. */ |
| 1576 | enum draw_glyphs_face save = next->hl; | 1595 | enum draw_glyphs_face save = next->hl; |
| 1577 | struct face *save_face = next->face; | ||
| 1578 | 1596 | ||
| 1579 | next->hl = s->hl; | 1597 | next->hl = s->hl; |
| 1580 | next->face = s->face; | ||
| 1581 | haiku_start_clip (s); | 1598 | haiku_start_clip (s); |
| 1599 | haiku_clip_to_string (s); | ||
| 1582 | haiku_clip_to_string_exactly (s, next); | 1600 | haiku_clip_to_string_exactly (s, next); |
| 1583 | if (next->first_glyph->type == CHAR_GLYPH) | 1601 | if (next->first_glyph->type == CHAR_GLYPH) |
| 1584 | haiku_draw_glyph_string_foreground (next); | 1602 | haiku_draw_glyph_string_foreground (next); |
| @@ -1586,15 +1604,11 @@ haiku_draw_glyph_string (struct glyph_string *s) | |||
| 1586 | haiku_draw_composite_glyph_string_foreground (next); | 1604 | haiku_draw_composite_glyph_string_foreground (next); |
| 1587 | haiku_end_clip (s); | 1605 | haiku_end_clip (s); |
| 1588 | 1606 | ||
| 1589 | next->background_filled_p = 0; | ||
| 1590 | next->hl = save; | 1607 | next->hl = save; |
| 1591 | next->face = save_face; | 1608 | next->clip_head = s->next; |
| 1592 | next->clip_head = next; | ||
| 1593 | next->num_clips = 0; | ||
| 1594 | } | 1609 | } |
| 1595 | } | 1610 | } |
| 1596 | } | 1611 | } |
| 1597 | s->num_clips = 0; | ||
| 1598 | haiku_end_clip (s); | 1612 | haiku_end_clip (s); |
| 1599 | unblock_input (); | 1613 | unblock_input (); |
| 1600 | } | 1614 | } |