From dd937784a3e3c79c5270cbfdb15a9f8df1600cde Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 1 Aug 2022 06:24:15 +0000 Subject: [PATCH] Improve frame synchronization support on Haiku * src/ftcrfont.c (ftcrfont_draw): * src/haikufns.c (haiku_set_background_color): * src/haikuterm.c (haiku_clip_to_string): (haiku_clip_to_string_exactly): (haiku_clear_frame_area): (haiku_clear_frame): (haiku_draw_box_rect): (haiku_draw_relief_rect): (haiku_draw_underwave): (haiku_draw_text_decoration): (haiku_draw_plain_background): (haiku_draw_stipple_background): (haiku_draw_glyph_string_foreground): (haiku_draw_glyphless_glyph_string_foreground): (haiku_draw_stretch_glyph_string): (haiku_start_clip): (haiku_end_clip): (haiku_clip_to_row): (haiku_draw_composite_glyph_string_foreground): (haiku_draw_image_glyph_string): (haiku_draw_glyph_string): (haiku_after_update_window_line): (haiku_draw_hollow_cursor): (haiku_draw_bar_cursor): (haiku_draw_vertical_window_border): (haiku_draw_window_divider): (haiku_scroll_bar_create): (haiku_set_horizontal_scroll_bar): (haiku_set_vertical_scroll_bar): (haiku_draw_fringe_bitmap): (haiku_scroll_run): (haiku_read_socket): (haiku_flash): (haiku_clear_under_internal_border): (haiku_scroll_bar_remove): * src/haikuterm.h (MAKE_FRAME_DIRTY): (FRAME_CR_CONTEXT): Don't dirty frames if not necessary. --- src/ftcrfont.c | 2 +- src/haikufns.c | 6 ++-- src/haikuterm.c | 88 ++++++++++++++++++++++++------------------------- src/haikuterm.h | 5 +-- 4 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/ftcrfont.c b/src/ftcrfont.c index 6bb41110d5c..119ec284094 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c @@ -567,7 +567,7 @@ ftcrfont_draw (struct glyph_string *s, unblock_input (); return 0; } - BView_cr_dump_clipping (FRAME_HAIKU_VIEW (f), cr); + BView_cr_dump_clipping (FRAME_HAIKU_DRAWABLE (f), cr); #endif if (with_background) diff --git a/src/haikufns.c b/src/haikufns.c index 64aa2fde4a1..aaa4e866228 100644 --- a/src/haikufns.c +++ b/src/haikufns.c @@ -1505,9 +1505,9 @@ haiku_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval if (FRAME_HAIKU_VIEW (f)) { - BView_draw_lock (FRAME_HAIKU_VIEW (f), false, 0, 0, 0, 0); - BView_SetViewColor (FRAME_HAIKU_VIEW (f), background); - BView_draw_unlock (FRAME_HAIKU_VIEW (f)); + BView_draw_lock (FRAME_HAIKU_DRAWABLE (f), false, 0, 0, 0, 0); + BView_SetViewColor (FRAME_HAIKU_DRAWABLE (f), background); + BView_draw_unlock (FRAME_HAIKU_DRAWABLE (f)); FRAME_OUTPUT_DATA (f)->cursor_fg = background; update_face_from_frame_parameter (f, Qbackground_color, arg); diff --git a/src/haikuterm.c b/src/haikuterm.c index f2bee1263d3..c2d4e34ba25 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -163,15 +163,15 @@ haiku_clip_to_string (struct glyph_string *s) /* If n[FOO].width is 0, it means to not draw at all, so set the clipping to some impossible value. */ if (r[0].width <= 0) - BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), + BView_ClipToRect (FRAME_HAIKU_DRAWABLE (s->f), FRAME_PIXEL_WIDTH (s->f), FRAME_PIXEL_HEIGHT (s->f), 10, 10); else { - BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), r[0].x, + BView_ClipToRect (FRAME_HAIKU_DRAWABLE (s->f), r[0].x, r[0].y, r[0].width, r[0].height); - BView_invalidate_region (FRAME_HAIKU_VIEW (s->f), r[0].x, + BView_invalidate_region (FRAME_HAIKU_DRAWABLE (s->f), r[0].x, r[0].y, r[0].width, r[0].height); } } @@ -181,15 +181,15 @@ haiku_clip_to_string (struct glyph_string *s) /* If n[FOO].width is 0, it means to not draw at all, so set the clipping to some impossible value. */ if (r[1].width <= 0) - BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), + BView_ClipToRect (FRAME_HAIKU_DRAWABLE (s->f), FRAME_PIXEL_WIDTH (s->f), FRAME_PIXEL_HEIGHT (s->f), 10, 10); else { - BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), r[1].x, r[1].y, + BView_ClipToRect (FRAME_HAIKU_DRAWABLE (s->f), r[1].x, r[1].y, r[1].width, r[1].height); - BView_invalidate_region (FRAME_HAIKU_VIEW (s->f), r[1].x, + BView_invalidate_region (FRAME_HAIKU_DRAWABLE (s->f), r[1].x, r[1].y, r[1].width, r[1].height); } } @@ -198,9 +198,9 @@ haiku_clip_to_string (struct glyph_string *s) static void haiku_clip_to_string_exactly (struct glyph_string *s, struct glyph_string *dst) { - BView_ClipToRect (FRAME_HAIKU_VIEW (s->f), s->x, s->y, + BView_ClipToRect (FRAME_HAIKU_DRAWABLE (s->f), s->x, s->y, s->width, s->height); - BView_invalidate_region (FRAME_HAIKU_VIEW (s->f), s->x, + BView_invalidate_region (FRAME_HAIKU_DRAWABLE (s->f), s->x, s->y, s->width, s->height); } @@ -246,7 +246,7 @@ static void haiku_clear_frame_area (struct frame *f, int x, int y, int width, int height) { - void *vw = FRAME_HAIKU_VIEW (f); + void *vw = FRAME_HAIKU_DRAWABLE (f); block_input (); BView_draw_lock (vw, true, x, y, width, height); BView_StartClip (vw); @@ -261,7 +261,7 @@ haiku_clear_frame_area (struct frame *f, int x, int y, static void haiku_clear_frame (struct frame *f) { - void *view = FRAME_HAIKU_VIEW (f); + void *view = FRAME_HAIKU_DRAWABLE (f); mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f))); @@ -596,7 +596,7 @@ haiku_draw_box_rect (struct glyph_string *s, int left_x, int top_y, int right_x, int bottom_y, int hwidth, int vwidth, bool left_p, bool right_p, struct haiku_rect *clip_rect) { - void *view = FRAME_HAIKU_VIEW (s->f); + void *view = FRAME_HAIKU_DRAWABLE (s->f); struct face *face = s->face; BView_SetHighColor (view, face->box_color); @@ -660,7 +660,7 @@ haiku_draw_relief_rect (struct glyph_string *s, int left_x, int top_y, uint32_t color_white, color_black; void *view; - view = FRAME_HAIKU_VIEW (s->f); + view = FRAME_HAIKU_DRAWABLE (s->f); haiku_calculate_relief_colors (s, &color_white, &color_black); BView_SetHighColor (view, raised_p ? color_white : color_black); @@ -769,7 +769,7 @@ haiku_draw_underwave (struct glyph_string *s, int width, int x) dy = wave_height - 1; y = s->ybase - wave_height + 3; xmax = x + width; - view = FRAME_HAIKU_VIEW (s->f); + view = FRAME_HAIKU_DRAWABLE (s->f); BView_StartClip (view); haiku_clip_to_string (s); @@ -811,7 +811,7 @@ haiku_draw_text_decoration (struct glyph_string *s, struct face *face, if (s->hl == DRAW_CURSOR) haiku_merge_cursor_foreground (s, &cursor_color, NULL); - void *view = FRAME_HAIKU_VIEW (s->f); + void *view = FRAME_HAIKU_DRAWABLE (s->f); if (face->underline) { @@ -1013,7 +1013,7 @@ static void haiku_draw_plain_background (struct glyph_string *s, struct face *face, int x, int y, int width, int height) { - void *view = FRAME_HAIKU_VIEW (s->f); + void *view = FRAME_HAIKU_DRAWABLE (s->f); unsigned long cursor_color; if (s->hl == DRAW_CURSOR) @@ -1075,7 +1075,7 @@ haiku_draw_stipple_background (struct glyph_string *s, struct face *face, unsigned long foreground, background; void *view; - view = FRAME_HAIKU_VIEW (s->f); + view = FRAME_HAIKU_DRAWABLE (s->f); rec = haiku_get_bitmap_rec (s->f, s->face->stipple); if (explicit_colors_p) @@ -1173,7 +1173,7 @@ haiku_draw_glyph_string_foreground (struct glyph_string *s) else x = s->x; - void *view = FRAME_HAIKU_VIEW (s->f); + void *view = FRAME_HAIKU_DRAWABLE (s->f); if (s->font_not_found_p) { @@ -1289,9 +1289,9 @@ haiku_draw_glyphless_glyph_string_foreground (struct glyph_string *s) else color = s->face->foreground; - BView_SetHighColor (FRAME_HAIKU_VIEW (s->f), color); - BView_SetPenSize (FRAME_HAIKU_VIEW (s->f), 1); - BView_StrokeRectangle (FRAME_HAIKU_VIEW (s->f), + BView_SetHighColor (FRAME_HAIKU_DRAWABLE (s->f), color); + BView_SetPenSize (FRAME_HAIKU_DRAWABLE (s->f), 1); + BView_StrokeRectangle (FRAME_HAIKU_DRAWABLE (s->f), x, s->ybase - glyph->ascent, glyph->pixel_width, glyph->ascent + glyph->descent); @@ -1335,7 +1335,7 @@ haiku_draw_stretch_glyph_string (struct glyph_string *s) if (s->row->reversed_p) x -= width; - void *view = FRAME_HAIKU_VIEW (s->f); + void *view = FRAME_HAIKU_DRAWABLE (s->f); unsigned long cursor_color; haiku_merge_cursor_foreground (s, NULL, &cursor_color); @@ -1401,14 +1401,14 @@ haiku_draw_stretch_glyph_string (struct glyph_string *s) static void haiku_start_clip (struct glyph_string *s) { - void *view = FRAME_HAIKU_VIEW (s->f); + void *view = FRAME_HAIKU_DRAWABLE (s->f); BView_StartClip (view); } static void haiku_end_clip (struct glyph_string *s) { - void *view = FRAME_HAIKU_VIEW (s->f); + void *view = FRAME_HAIKU_DRAWABLE (s->f); BView_EndClip (view); } @@ -1428,7 +1428,7 @@ haiku_clip_to_row (struct window *w, struct glyph_row *row, width = window_width; height = row->visible_height; - BView_ClipToRect (FRAME_HAIKU_VIEW (f), x, y, width, height); + BView_ClipToRect (FRAME_HAIKU_DRAWABLE (f), x, y, width, height); } static void @@ -1448,7 +1448,7 @@ haiku_draw_composite_glyph_string_foreground (struct glyph_string *s) { int i, j, x; struct font *font = s->font; - void *view = FRAME_HAIKU_VIEW (s->f); + void *view = FRAME_HAIKU_DRAWABLE (s->f); struct face *face = s->face; /* If first glyph of S has a left box line, start drawing the text @@ -1670,7 +1670,7 @@ haiku_draw_image_glyph_string (struct glyph_string *s) if (s->slice.y == 0) y += box_line_vwidth; - view = FRAME_HAIKU_VIEW (s->f); + view = FRAME_HAIKU_DRAWABLE (s->f); bitmap = s->img->pixmap; s->stippled_p = face->stipple != 0; @@ -1803,7 +1803,7 @@ haiku_draw_image_glyph_string (struct glyph_string *s) static void haiku_draw_glyph_string (struct glyph_string *s) { - void *view = FRAME_HAIKU_VIEW (s->f);; + void *view = FRAME_HAIKU_DRAWABLE (s->f);; struct face *face = s->face; block_input (); @@ -2001,7 +2001,7 @@ haiku_after_update_window_line (struct window *w, block_input (); if (face) { - void *view = FRAME_HAIKU_VIEW (f); + void *view = FRAME_HAIKU_DRAWABLE (f); BView_draw_lock (view, false, 0, 0, 0, 0); BView_StartClip (view); BView_SetHighColor (view, (face->background_defaulted_p @@ -2010,7 +2010,7 @@ haiku_after_update_window_line (struct window *w, BView_FillRectangle (view, 0, y, width, height); BView_FillRectangle (view, FRAME_PIXEL_WIDTH (f) - width, y, width, height); - BView_invalidate_region (FRAME_HAIKU_VIEW (f), + BView_invalidate_region (FRAME_HAIKU_DRAWABLE (f), 0, y, width, height); BView_invalidate_region (view, FRAME_PIXEL_WIDTH (f) - width, y, width, height); @@ -2075,7 +2075,7 @@ haiku_draw_hollow_cursor (struct window *w, struct glyph_row *row) void *view; f = XFRAME (WINDOW_FRAME (w)); - view = FRAME_HAIKU_VIEW (f); + view = FRAME_HAIKU_DRAWABLE (f); /* Get the glyph the cursor is on. If we can't tell because the current matrix is invalid or such, give up. */ @@ -2148,7 +2148,7 @@ haiku_draw_bar_cursor (struct window *w, struct glyph_row *row, } else { - view = FRAME_HAIKU_VIEW (f); + view = FRAME_HAIKU_DRAWABLE (f); face = FACE_FROM_ID (f, cursor_glyph->face_id); /* If the glyph's background equals the color we normally draw @@ -2334,7 +2334,7 @@ haiku_draw_vertical_window_border (struct window *w, struct face *face; face = FACE_FROM_ID_OR_NULL (f, VERTICAL_BORDER_FACE_ID); - void *view = FRAME_HAIKU_VIEW (f); + void *view = FRAME_HAIKU_DRAWABLE (f); BView_draw_lock (view, true, x, y_0, 1, y_1); BView_StartClip (view); if (face) @@ -2384,7 +2384,7 @@ haiku_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1) unsigned long color_last = (face_last ? face_last->foreground : FRAME_FOREGROUND_PIXEL (f)); - void *view = FRAME_HAIKU_VIEW (f); + void *view = FRAME_HAIKU_DRAWABLE (f); BView_draw_lock (view, true, x0, y0, x1 - x0 + 1, y1 - y0 + 1); BView_StartClip (view); @@ -2554,7 +2554,7 @@ haiku_scroll_bar_create (struct window *w, int left, int top, void *view; f = XFRAME (WINDOW_FRAME (w)); - view = FRAME_HAIKU_VIEW (f); + view = FRAME_HAIKU_DRAWABLE (f); block_input (); bar = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, prev, PVEC_OTHER); @@ -2604,7 +2604,7 @@ haiku_set_horizontal_scroll_bar (struct window *w, int portion, int whole, int p width = window_width; top = WINDOW_SCROLL_BAR_AREA_Y (w); height = WINDOW_CONFIG_SCROLL_BAR_HEIGHT (w); - view = FRAME_HAIKU_VIEW (WINDOW_XFRAME (w)); + view = FRAME_HAIKU_DRAWABLE (WINDOW_XFRAME (w)); block_input (); @@ -2663,7 +2663,7 @@ haiku_set_vertical_scroll_bar (struct window *w, int portion, int whole, int pos left = WINDOW_SCROLL_BAR_AREA_X (w); width = WINDOW_SCROLL_BAR_AREA_WIDTH (w); - view = FRAME_HAIKU_VIEW (WINDOW_XFRAME (w)); + view = FRAME_HAIKU_DRAWABLE (WINDOW_XFRAME (w)); block_input (); if (NILP (w->vertical_scroll_bar)) @@ -2712,7 +2712,7 @@ haiku_draw_fringe_bitmap (struct window *w, struct glyph_row *row, uint32 col; f = XFRAME (WINDOW_FRAME (w)); - view = FRAME_HAIKU_VIEW (f); + view = FRAME_HAIKU_DRAWABLE (f); face = p->face; block_input (); @@ -2828,7 +2828,7 @@ static void haiku_scroll_run (struct window *w, struct run *run) { struct frame *f = XFRAME (w->frame); - void *view = FRAME_HAIKU_VIEW (f); + void *view = FRAME_HAIKU_DRAWABLE (f); int x, y, width, height, from_y, to_y, bottom_y; window_box (w, ANY_AREA, &x, &y, &width, &height); @@ -3211,9 +3211,9 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) continue; } - BView_draw_lock (FRAME_HAIKU_VIEW (f), false, 0, 0, 0, 0); - BView_resize_to (FRAME_HAIKU_VIEW (f), width, height); - BView_draw_unlock (FRAME_HAIKU_VIEW (f)); + BView_draw_lock (FRAME_HAIKU_DRAWABLE (f), false, 0, 0, 0, 0); + BView_resize_to (FRAME_HAIKU_DRAWABLE (f), width, height); + BView_draw_unlock (FRAME_HAIKU_DRAWABLE (f)); if (width != FRAME_PIXEL_WIDTH (f) || height != FRAME_PIXEL_HEIGHT (f) @@ -4126,7 +4126,7 @@ haiku_flash (struct frame *f) int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f); int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f); int width = flash_right - flash_left; - void *view = FRAME_HAIKU_VIEW (f); + void *view = FRAME_HAIKU_DRAWABLE (f); object_wait_info info; bigtime_t wakeup; @@ -4454,7 +4454,7 @@ haiku_clear_under_internal_border (struct frame *f) ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID) : INTERNAL_BORDER_FACE_ID)); struct face *face = FACE_FROM_ID_OR_NULL (f, face_id); - void *view = FRAME_HAIKU_VIEW (f); + void *view = FRAME_HAIKU_DRAWABLE (f); block_input (); BView_draw_lock (view, true, 0, 0, FRAME_PIXEL_WIDTH (f), @@ -4496,7 +4496,7 @@ haiku_scroll_bar_remove (struct scroll_bar *bar) struct frame *f; f = WINDOW_XFRAME (XWINDOW (bar->window)); - view = FRAME_HAIKU_VIEW (f); + view = FRAME_HAIKU_DRAWABLE (f); block_input (); BView_forget_scroll_bar (view, bar->left, bar->top, diff --git a/src/haikuterm.h b/src/haikuterm.h index 02a364f6712..b603c0a482f 100644 --- a/src/haikuterm.h +++ b/src/haikuterm.h @@ -275,7 +275,8 @@ struct scroll_bar #define MAKE_FRAME_DIRTY(f) (FRAME_DIRTY_P (f) = 1) #define FRAME_OUTPUT_DATA(f) ((f)->output_data.haiku) #define FRAME_HAIKU_WINDOW(f) (FRAME_OUTPUT_DATA (f)->window) -#define FRAME_HAIKU_VIEW(f) ((MAKE_FRAME_DIRTY (f)), FRAME_OUTPUT_DATA (f)->view) +#define FRAME_HAIKU_VIEW(f) (FRAME_OUTPUT_DATA (f)->view) +#define FRAME_HAIKU_DRAWABLE(f) ((MAKE_FRAME_DIRTY (f)), FRAME_HAIKU_VIEW (f)) #define FRAME_HAIKU_MENU_BAR(f) (FRAME_OUTPUT_DATA (f)->menubar) #define FRAME_DISPLAY_INFO(f) (FRAME_OUTPUT_DATA (f)->display_info) #define FRAME_FONT(f) (FRAME_OUTPUT_DATA (f)->font) @@ -287,7 +288,7 @@ struct scroll_bar #ifdef USE_BE_CAIRO #define FRAME_CR_CONTEXT(f) \ (FRAME_HAIKU_VIEW (f) \ - ? EmacsView_cairo_context (FRAME_HAIKU_VIEW (f)) \ + ? EmacsView_cairo_context (FRAME_HAIKU_DRAWABLE (f)) \ : NULL) #endif -- 2.39.2