From 719f8a51be64acce91aa638b3f065dae25ba23cf Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 26 Sep 2023 09:35:51 +0800 Subject: [PATCH] Update Android port * src/androidterm.c (android_clip_to_row) (android_draw_fringe_bitmap, android_draw_hollow_cursor) (android_draw_bar_cursor): Sync with xterm.c. * src/xterm.c (x_draw_fringe_bitmap): Delete unused variables. --- src/androidterm.c | 40 ++++++++++++++++++++++++++++++++++------ src/xterm.c | 1 - 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/androidterm.c b/src/androidterm.c index a60dd50e5db..8940baa286b 100644 --- a/src/androidterm.c +++ b/src/androidterm.c @@ -2440,7 +2440,8 @@ android_reset_clip_rectangles (struct frame *f, struct android_gc *gc) static void android_clip_to_row (struct window *w, struct glyph_row *row, - enum glyph_row_area area, struct android_gc *gc) + enum glyph_row_area area, struct android_gc *gc, + struct android_rectangle *rect_return) { struct android_rectangle clip_rect; int window_x, window_y, window_width; @@ -2454,6 +2455,9 @@ android_clip_to_row (struct window *w, struct glyph_row *row, clip_rect.height = row->visible_height; android_set_clip_rectangles (gc, 0, 0, &clip_rect, 1); + + if (rect_return) + *rect_return = clip_rect; } static void @@ -2463,9 +2467,10 @@ android_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct frame *f = XFRAME (WINDOW_FRAME (w)); struct android_gc *gc = f->output_data.android->normal_gc; struct face *face = p->face; + struct android_rectangle clip_rect; /* Must clip because of partially visible lines. */ - android_clip_to_row (w, row, ANY_AREA, gc); + android_clip_to_row (w, row, ANY_AREA, gc, &clip_rect); if (p->bx >= 0 && !p->overlay_p) { @@ -2499,6 +2504,8 @@ android_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct android_gc_values gcv; unsigned long background, cursor_pixel; int depth; + struct android_rectangle image_rect, dest; + int px, py, pwidth, pheight; drawable = FRAME_ANDROID_DRAWABLE (f); clipmask = ANDROID_NONE; @@ -2506,6 +2513,27 @@ android_draw_fringe_bitmap (struct window *w, struct glyph_row *row, cursor_pixel = f->output_data.android->cursor_pixel; depth = FRAME_DISPLAY_INFO (f)->n_planes; + /* Intersect the destination rectangle with that of the row. + Setting a clip mask overrides the clip rectangles provided by + x_clip_to_row, so clipping must be performed by hand. */ + + image_rect.x = p->x; + image_rect.y = p->y; + image_rect.width = p->wd; + image_rect.height = p->h; + + if (!gui_intersect_rectangles (&clip_rect, &image_rect, &dest)) + /* The entire destination rectangle falls outside the row. */ + goto undo_clip; + + /* Extrapolate the source rectangle from the difference between + the destination and image rectangles. */ + + px = dest.x - image_rect.x; + py = dest.y - image_rect.y; + pwidth = dest.width; + pheight = dest.height; + if (p->wd > 8) bits = (char *) (p->bits + p->dh); else @@ -2533,8 +2561,8 @@ android_draw_fringe_bitmap (struct window *w, struct glyph_row *row, &gcv); } - android_copy_area (pixmap, drawable, gc, 0, 0, p->wd, p->h, - p->x, p->y); + android_copy_area (pixmap, drawable, gc, px, py, + pwidth, pheight, dest.x, dest.y); android_free_pixmap (pixmap); if (p->overlay_p) @@ -4327,7 +4355,7 @@ android_draw_hollow_cursor (struct window *w, struct glyph_row *row) wd -= 1; } /* Set clipping, draw the rectangle, and reset clipping again. */ - android_clip_to_row (w, row, TEXT_AREA, gc); + android_clip_to_row (w, row, TEXT_AREA, gc, NULL); android_draw_rectangle (FRAME_ANDROID_DRAWABLE (f), gc, x, y, wd, h - 1); android_reset_clip_rectangles (f, gc); } @@ -4385,7 +4413,7 @@ android_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, FRAME_DISPLAY_INFO (f)->scratch_cursor_gc = gc; } - android_clip_to_row (w, row, TEXT_AREA, gc); + android_clip_to_row (w, row, TEXT_AREA, gc, NULL); if (kind == BAR_CURSOR) { diff --git a/src/xterm.c b/src/xterm.c index 33e12d48912..c459e5d8d95 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -7916,7 +7916,6 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, memset (&attrs, 0, sizeof attrs); #endif XRectangle image_rect, dest; - int window_x, window_y, window_width; int px, py, pwidth, pheight; /* Intersect the destination rectangle with that of the row. -- 2.39.2