Compare commits

...

1 Commits

Author SHA1 Message Date
Juhani Krekelä 63216f7346 Add API for consolidating draw calls into logical draw operations. 2024-01-22 01:59:33 +02:00
16 changed files with 63 additions and 4 deletions

View File

@ -625,6 +625,8 @@ struct graphics_driver atheos_driver = {
ath_draw_vline, ath_draw_vline,
ath_scroll, ath_scroll,
ath_set_clip_area, ath_set_clip_area,
NULL, /* start_draw */
NULL, /* end_draw */
ath_flush, ath_flush,
NULL, /* block */ NULL, /* block */
NULL, /* unblock */ NULL, /* unblock */

12
bfu.c
View File

@ -386,6 +386,7 @@ static void display_menu_item_gfx(struct terminal *term, struct menu *menu, int
struct graphics_device *dev = term->dev; struct graphics_device *dev = term->dev;
int y; int y;
if (it < menu->view || it >= menu->ni || it >= menu->view + menu->nview) return; if (it < menu->view || it >= menu->ni || it >= menu->view + menu->nview) return;
if (drv->start_draw) drv->start_draw(dev);
y = menu->y + G_MENU_TOP_BORDER + (it - menu->view) * G_BFU_FONT_SIZE; y = menu->y + G_MENU_TOP_BORDER + (it - menu->view) * G_BFU_FONT_SIZE;
if (item->hotkey == M_BAR && !get_text_translation(item->text, term)[0]) { if (item->hotkey == M_BAR && !get_text_translation(item->text, term)[0]) {
drv->fill_area(dev, menu->x + (G_MENU_LEFT_BORDER - 1) / 2 + 1, y, menu->x + menu->xw - (G_MENU_LEFT_BORDER + 1) / 2, y + (G_BFU_FONT_SIZE - 1) / 2, bfu_bg_color); drv->fill_area(dev, menu->x + (G_MENU_LEFT_BORDER - 1) / 2 + 1, y, menu->x + menu->xw - (G_MENU_LEFT_BORDER + 1) / 2, y + (G_BFU_FONT_SIZE - 1) / 2, bfu_bg_color);
@ -464,6 +465,7 @@ static void display_menu_item_gfx(struct terminal *term, struct menu *menu, int
drv->fill_area(dev, menu->x + menu->xw - G_MENU_LEFT_BORDER - G_MENU_LEFT_INNER_BORDER, y, menu->x + menu->xw - G_MENU_LEFT_BORDER, y + G_BFU_FONT_SIZE, bfu_fg_color); drv->fill_area(dev, menu->x + menu->xw - G_MENU_LEFT_BORDER - G_MENU_LEFT_INNER_BORDER, y, menu->x + menu->xw - G_MENU_LEFT_BORDER, y + G_BFU_FONT_SIZE, bfu_fg_color);
} }
} }
if (drv->end_draw) drv->end_draw(dev);
} }
static void display_menu_gfx(struct terminal *term, void *menu_) static void display_menu_gfx(struct terminal *term, void *menu_)
@ -480,6 +482,7 @@ static void display_menu_gfx(struct terminal *term, void *menu_)
#define PX2 (menu->x + menu->xw - (G_MENU_LEFT_BORDER + 1) / 2) #define PX2 (menu->x + menu->xw - (G_MENU_LEFT_BORDER + 1) / 2)
#define PY1 (menu->y + (G_MENU_TOP_BORDER - 1) / 2) #define PY1 (menu->y + (G_MENU_TOP_BORDER - 1) / 2)
#define PY2 (menu->y + menu->yw - (G_MENU_TOP_BORDER + 1) / 2) #define PY2 (menu->y + menu->yw - (G_MENU_TOP_BORDER + 1) / 2)
if (drv->start_draw) drv->start_draw(dev);
drv->fill_area(dev, menu->x, menu->y, menu->x + menu->xw, PY1, bfu_bg_color); drv->fill_area(dev, menu->x, menu->y, menu->x + menu->xw, PY1, bfu_bg_color);
drv->fill_area(dev, menu->x, PY1, PX1, PY2 + 1, bfu_bg_color); drv->fill_area(dev, menu->x, PY1, PX1, PY2 + 1, bfu_bg_color);
drv->fill_area(dev, PX2 + 1, PY1, menu->x + menu->xw, PY2 + 1, bfu_bg_color); drv->fill_area(dev, PX2 + 1, PY1, menu->x + menu->xw, PY2 + 1, bfu_bg_color);
@ -494,6 +497,7 @@ static void display_menu_gfx(struct terminal *term, void *menu_)
menu_ptr_set = 0; menu_ptr_set = 0;
for (p = menu->view; p < menu->ni && p < menu->view + menu->nview; p++) display_menu_item_gfx(term, menu, p); for (p = menu->view; p < menu->ni && p < menu->view + menu->nview; p++) display_menu_item_gfx(term, menu, p);
if (!menu_ptr_set) set_window_ptr(menu->win, menu->x, menu->y); if (!menu_ptr_set) set_window_ptr(menu->win, menu->x, menu->y);
if (drv->end_draw) drv->end_draw(dev);
} }
#endif #endif
@ -723,6 +727,7 @@ static void display_mainmenu(struct terminal *term, void *menu_)
} else { } else {
struct graphics_device *dev = term->dev; struct graphics_device *dev = term->dev;
int i, p; int i, p;
if (drv->start_draw) drv->start_draw(dev);
drv->fill_area(dev, 0, 0, p = G_MAINMENU_LEFT_BORDER, G_BFU_FONT_SIZE, bfu_bg_color); drv->fill_area(dev, 0, 0, p = G_MAINMENU_LEFT_BORDER, G_BFU_FONT_SIZE, bfu_bg_color);
for (i = 0; i < menu->ni; i++) { for (i = 0; i < menu->ni; i++) {
int s = i == menu->selected; int s = i == menu->selected;
@ -743,6 +748,7 @@ static void display_mainmenu(struct terminal *term, void *menu_)
} }
} }
drv->fill_area(dev, p, 0, term->x, G_BFU_FONT_SIZE, bfu_bg_color); drv->fill_area(dev, p, 0, term->x, G_BFU_FONT_SIZE, bfu_bg_color);
if (drv->end_draw) drv->end_draw(dev);
#endif #endif
} }
} }
@ -967,6 +973,7 @@ void display_dlg_item(struct dialog_data *dlg, struct dialog_item_data *di, int
} else { } else {
struct rect rr; struct rect rr;
struct graphics_device *dev = term->dev; struct graphics_device *dev = term->dev;
if (drv->start_draw) drv->start_draw(dev);
if (!dlg->s) restrict_clip_area(dev, &rr, dlg->rr.x1, dlg->rr.y1, dlg->rr.x2, dlg->rr.y2); if (!dlg->s) restrict_clip_area(dev, &rr, dlg->rr.x1, dlg->rr.y1, dlg->rr.x2, dlg->rr.y2);
switch (di->item->type) { switch (di->item->type) {
int p, pp; int p, pp;
@ -1075,6 +1082,7 @@ void display_dlg_item(struct dialog_data *dlg, struct dialog_item_data *di, int
internal_error("display_dlg_item: unknown item: %d", di->item->type); internal_error("display_dlg_item: unknown item: %d", di->item->type);
} }
if (!dlg->s) set_clip_area(dev, &rr); if (!dlg->s) set_clip_area(dev, &rr);
if (drv->end_draw) drv->end_draw(dev);
#endif #endif
} }
} }
@ -1230,9 +1238,11 @@ static void redraw_dialog(struct terminal *term, void *dlg_)
} }
#ifdef G #ifdef G
if (F) { if (F) {
if (drv->start_draw) drv->start_draw(term->dev);
set_clip_area(term->dev, &dlg->r); set_clip_area(term->dev, &dlg->r);
for (i = 0; i < dlg->s->m; i++) if (is_rect_valid(&dlg->s->r[i])) for (i = 0; i < dlg->s->m; i++) if (is_rect_valid(&dlg->s->r[i]))
drv->fill_area(term->dev, dlg->s->r[i].x1, dlg->s->r[i].y1, dlg->s->r[i].x2, dlg->s->r[i].y2, bfu_bg_color); drv->fill_area(term->dev, dlg->s->r[i].x1, dlg->s->r[i].y1, dlg->s->r[i].x2, dlg->s->r[i].y2, bfu_bg_color);
if (drv->end_draw) drv->end_draw(term->dev);
mem_free(dlg->s); mem_free(dlg->s);
dlg->s = NULL; dlg->s = NULL;
} }
@ -1791,6 +1801,7 @@ void draw_dlg(struct dialog_data *dlg)
if (TXT_Y < dlg->y + G_DIALOG_TOP_BORDER + G_DIALOG_HLINE_SPACE + 1 - G_BFU_FONT_SIZE) TXT_Y = dlg->y + G_DIALOG_TOP_BORDER + G_DIALOG_HLINE_SPACE + 1 - G_BFU_FONT_SIZE; if (TXT_Y < dlg->y + G_DIALOG_TOP_BORDER + G_DIALOG_HLINE_SPACE + 1 - G_BFU_FONT_SIZE) TXT_Y = dlg->y + G_DIALOG_TOP_BORDER + G_DIALOG_HLINE_SPACE + 1 - G_BFU_FONT_SIZE;
set_window_pos(dlg->win, dlg->x, dlg->y, dlg->x + dlg->xw, dlg->y + dlg->yw); set_window_pos(dlg->win, dlg->x, dlg->y, dlg->x + dlg->xw, dlg->y + dlg->yw);
if (drv->start_draw) drv->start_draw(dev);
restrict_clip_area(dev, &r, TXT_X, TXT_Y, TXT_X + tl, TXT_Y + G_BFU_FONT_SIZE); restrict_clip_area(dev, &r, TXT_X, TXT_Y, TXT_X + tl, TXT_Y + G_BFU_FONT_SIZE);
rt.x1 = TXT_X; rt.x1 = TXT_X;
rt.x2 = TXT_X + tl; rt.x2 = TXT_X + tl;
@ -1837,6 +1848,7 @@ void draw_dlg(struct dialog_data *dlg)
add_to_rect_set(&dlg->s, &dlg->rr); add_to_rect_set(&dlg->s, &dlg->rr);
exclude_rect_from_set(&dlg->s, &rt); exclude_rect_from_set(&dlg->s, &rt);
restrict_clip_area(dev, &dlg->r, dlg->rr.x1, dlg->rr.y1, dlg->rr.x2, dlg->rr.y2); restrict_clip_area(dev, &dlg->r, dlg->rr.x1, dlg->rr.y1, dlg->rr.x2, dlg->rr.y2);
if (drv->end_draw) drv->end_draw(dev);
#endif #endif
} }
} }

2
dip.c
View File

@ -2020,6 +2020,7 @@ void g_print_text(struct graphics_device *device, int x, int y, struct style *st
if (y + style->height <= device->clip.y1 || y >= device->clip.y2) if (y + style->height <= device->clip.y1 || y >= device->clip.y2)
goto o; goto o;
if (style->flags & FF_UNDERLINE || style->flags & FF_STRIKE) { if (style->flags & FF_UNDERLINE || style->flags & FF_STRIKE) {
if (drv->start_draw) drv->start_draw(device);
/* Underline or strike */ /* Underline or strike */
if (!width) { if (!width) {
width = &my_width; width = &my_width;
@ -2050,6 +2051,7 @@ void g_print_text(struct graphics_device *device, int x, int y, struct style *st
set_clip_area(device, &saved_clip); set_clip_area(device, &saved_clip);
} }
style->flags = original_flags; style->flags = original_flags;
if (drv->end_draw) drv->end_draw(device);
return; return;
} }
while (*text) { while (*text) {

View File

@ -793,6 +793,8 @@ struct graphics_driver directfb_driver =
directfb_draw_vline, directfb_draw_vline,
directfb_scroll, directfb_scroll,
directfb_set_clip_area, directfb_set_clip_area,
NULL, /* start_draw */
NULL, /* end_draw */
directfb_flush, directfb_flush,
NULL, /* block */ NULL, /* block */
NULL, /* unblock */ NULL, /* unblock */

View File

@ -2145,6 +2145,8 @@ struct graphics_driver fb_driver = {
fb_draw_vline, fb_draw_vline,
fb_scroll, fb_scroll,
(void (*)(struct graphics_device *dev))NULL, /* set_clip_area */ (void (*)(struct graphics_device *dev))NULL, /* set_clip_area */
NULL, /* start_draw */
NULL, /* end_draw */
(void (*)(struct graphics_device *dev))NULL, /* flush */ (void (*)(struct graphics_device *dev))NULL, /* flush */
fb_block, fb_block,
fb_unblock, fb_unblock,

2
grx.c
View File

@ -559,6 +559,8 @@ struct graphics_driver grx_driver = {
grx_draw_vline, grx_draw_vline,
grx_scroll, grx_scroll,
grx_set_clip_area, grx_set_clip_area,
NULL, /* start_draw */
NULL, /* end_draw */
NULL, NULL,
grx_block, grx_block,
grx_unblock, grx_unblock,

View File

@ -988,6 +988,8 @@ struct graphics_driver haiku_driver = {
be_draw_vline, be_draw_vline,
be_scroll, be_scroll,
be_set_clip_area, be_set_clip_area,
NULL, /* start_draw */
NULL, /* end_draw */
be_flush, be_flush,
NULL, /* block */ NULL, /* block */
NULL, /* unblock */ NULL, /* unblock */

View File

@ -62,7 +62,9 @@ void g_draw_background(struct graphics_device *dev, struct background *bg, int x
} }
if (test_int_overflow(x, xw, &x2)) x2 = MAXINT; if (test_int_overflow(x, xw, &x2)) x2 = MAXINT;
if (test_int_overflow(y, yw, &y2)) y2 = MAXINT; if (test_int_overflow(y, yw, &y2)) y2 = MAXINT;
if (drv->start_draw) drv->start_draw(dev);
drv->fill_area(dev, x, y, x2, y2, color); drv->fill_area(dev, x, y, x2, y2, color);
if (drv->end_draw) drv->end_draw(dev);
} }
static void g_put_chars(void *, unsigned char *, int); static void g_put_chars(void *, unsigned char *, int);

4
img.c
View File

@ -1044,6 +1044,7 @@ int get_foreground(int rgb)
static void draw_frame_mark(struct graphics_device *dev, int x, int y, int xw, int yw, long bg, long fg, int broken) static void draw_frame_mark(struct graphics_device *dev, int x, int y, int xw, int yw, long bg, long fg, int broken)
{ {
if (drv->start_draw) drv->start_draw(dev);
#ifdef DEBUG #ifdef DEBUG
if (xw<1||yw<1) internal_error("zero dimension in draw_frame_mark"); if (xw<1||yw<1) internal_error("zero dimension in draw_frame_mark");
#endif /* #ifdef DEBUG */ #endif /* #ifdef DEBUG */
@ -1101,6 +1102,7 @@ static void draw_frame_mark(struct graphics_device *dev, int x, int y, int xw, i
draw_frame_mark(dev, x + 1, y + 1, xw - 2, yw - 2, bg, fg, 3); draw_frame_mark(dev, x + 1, y + 1, xw - 2, yw - 2, bg, fg, 3);
} }
} }
if (drv->end_draw) drv->end_draw(dev);
} }
static long image_backgronud(struct cached_image *cimg) static long image_backgronud(struct cached_image *cimg)
@ -1126,6 +1128,7 @@ static void draw_picture(struct f_data_c *fdatac, struct g_object_image *goi, in
struct cached_image *cimg = goi->cimg; struct cached_image *cimg = goi->cimg;
struct rect saved; struct rect saved;
if (drv->start_draw) drv->start_draw(dev);
#ifdef DEBUG #ifdef DEBUG
if (goi->cimg->state < 12 || goi->cimg->state >= 16) { if (goi->cimg->state < 12 || goi->cimg->state >= 16) {
fprintf(stderr, "cimg->state=%d\n", cimg->state); fprintf(stderr, "cimg->state=%d\n", cimg->state);
@ -1151,6 +1154,7 @@ static void draw_picture(struct f_data_c *fdatac, struct g_object_image *goi, in
drv->fill_area(dev, x, y + cimg->bmp.y, x + goi->goti.go.xw, y + goi->goti.go.yw, bg); drv->fill_area(dev, x, y + cimg->bmp.y, x + goi->goti.go.xw, y + goi->goti.go.yw, bg);
} }
set_clip_area(dev, &saved); set_clip_area(dev, &saved);
if (drv->end_draw) drv->end_draw(dev);
} }
/* Ensures in buffer there is not newer picture than in bitmap. Allowed to be /* Ensures in buffer there is not newer picture than in bitmap. Allowed to be

View File

@ -1904,6 +1904,7 @@ struct graphics_device {
/*int left, right, top, bottom;*/ /*int left, right, top, bottom;*/
struct rect clip; struct rect clip;
/* right, bottom are coords of the first point that are outside the clipping area */ /* right, bottom are coords of the first point that are outside the clipping area */
int drawing;
void *driver_data; void *driver_data;
@ -1970,6 +1971,9 @@ struct graphics_driver {
/* when set is not NULL rectangles in the set (uncovered area) should be redrawn */ /* when set is not NULL rectangles in the set (uncovered area) should be redrawn */
void (*set_clip_area)(struct graphics_device *dev); void (*set_clip_area)(struct graphics_device *dev);
void (*start_draw)(struct graphics_device *dev);
void (*end_draw)(struct graphics_device *dev);
void (*flush)(struct graphics_device *dev); void (*flush)(struct graphics_device *dev);
int (*block)(struct graphics_device *dev); /* restore old videomode and disable drawing on terminal */ int (*block)(struct graphics_device *dev); /* restore old videomode and disable drawing on terminal */

View File

@ -277,6 +277,8 @@ static int draw_bfu_element(struct terminal * term, int x, int y, unsigned char
struct graphics_device *dev=term->dev; struct graphics_device *dev=term->dev;
struct rect r; struct rect r;
if (drv->start_draw) drv->start_draw(dev);
restrict_clip_area(dev,&r,x,y,x+5*BFU_GRX_WIDTH,y+BFU_GRX_HEIGHT); restrict_clip_area(dev,&r,x,y,x+5*BFU_GRX_WIDTH,y+BFU_GRX_HEIGHT);
switch (type) switch (type)
@ -397,6 +399,7 @@ static int draw_bfu_element(struct terminal * term, int x, int y, unsigned char
} }
set_clip_area(dev, &r); set_clip_area(dev, &r);
if (drv->end_draw) drv->end_draw(dev);
return BFU_ELEMENT_WIDTH; return BFU_ELEMENT_WIDTH;
} }
#endif #endif
@ -1078,11 +1081,13 @@ static void redraw_list_element(struct terminal *term, struct dialog_data *dlg,
struct rect old_area; struct rect old_area;
struct style *stl = l == ld->current_pos ? bfu_style_wb : bfu_style_bw; struct style *stl = l == ld->current_pos ? bfu_style_wb : bfu_style_bw;
if (drv->start_draw) drv->start_draw(term->dev);
restrict_clip_area(term->dev, &old_area, dlg->x + x + DIALOG_LB, y, dlg->x + DIALOG_LB + w, y + G_BFU_FONT_SIZE); restrict_clip_area(term->dev, &old_area, dlg->x + x + DIALOG_LB, y, dlg->x + DIALOG_LB + w, y + G_BFU_FONT_SIZE);
g_print_text(term->dev, dlg->x + x + DIALOG_LB, y, stl, txt, NULL); g_print_text(term->dev, dlg->x + x + DIALOG_LB, y, stl, txt, NULL);
x += g_text_width(stl, txt); x += g_text_width(stl, txt);
drv->fill_area(term->dev, dlg->x + DIALOG_LB + x, y, dlg->x + DIALOG_LB + w, y + G_BFU_FONT_SIZE, bgcolor); drv->fill_area(term->dev, dlg->x + DIALOG_LB + x, y, dlg->x + DIALOG_LB + w, y + G_BFU_FONT_SIZE, bgcolor);
set_clip_area(term->dev, &old_area); set_clip_area(term->dev, &old_area);
if (drv->end_draw) drv->end_draw(term->dev);
} }
#endif #endif
mem_free(txt); mem_free(txt);
@ -1099,6 +1104,7 @@ static void redraw_list(struct terminal *term, void *bla)
int w = dlg->xw - 2 * DIALOG_LB - (F ? sirka_scrollovadla : 0); int w = dlg->xw - 2 * DIALOG_LB - (F ? sirka_scrollovadla : 0);
y = dlg->y + DIALOG_TB; y = dlg->y + DIALOG_TB;
if (drv->start_draw) drv->start_draw(term->dev);
#ifdef G #ifdef G
if (F) { if (F) {
int total = get_total_items(ld); int total = get_total_items(ld);
@ -1123,6 +1129,7 @@ static void redraw_list(struct terminal *term, void *bla)
if (dlg->s) exclude_from_set(&dlg->s, dlg->x + DIALOG_LB, y, dlg->x + DIALOG_LB + w, dlg->y + DIALOG_TB + ld->n_items * G_BFU_FONT_SIZE); if (dlg->s) exclude_from_set(&dlg->s, dlg->x + DIALOG_LB, y, dlg->x + DIALOG_LB + w, dlg->y + DIALOG_TB + ld->n_items * G_BFU_FONT_SIZE);
} }
#endif #endif
if (drv->end_draw) drv->end_draw(term->dev);
} }

View File

@ -2887,6 +2887,8 @@ struct graphics_driver pmshell_driver = {
pm_draw_vline, pm_draw_vline,
pm_scroll, pm_scroll,
NULL, NULL,
NULL, /* start_draw */
NULL, /* end_draw */
pm_flush, pm_flush,
NULL, /* block */ NULL, /* block */
NULL, /* unblock */ NULL, /* unblock */

View File

@ -284,9 +284,11 @@ static void x_print_screen_status(struct terminal *term, void *ses_)
if (ses->st) print_text(term, 0, term->y - 1, (int)strlen(cast_const_char ses->st), ses->st, COLOR_STATUS); if (ses->st) print_text(term, 0, term->y - 1, (int)strlen(cast_const_char ses->st), ses->st, COLOR_STATUS);
#ifdef G #ifdef G
} else { } else {
if (drv->start_draw) drv->start_draw(term->dev);
int l = 0; int l = 0;
if (ses->st) g_print_text(term->dev, 0, term->y - G_BFU_FONT_SIZE, bfu_style_wb_mono, ses->st, &l); if (ses->st) g_print_text(term->dev, 0, term->y - G_BFU_FONT_SIZE, bfu_style_wb_mono, ses->st, &l);
drv->fill_area(term->dev, l, term->y - G_BFU_FONT_SIZE, term->x, term->y, !proxies.only_proxies ? bfu_bg_color : bfu_fg_color); drv->fill_area(term->dev, l, term->y - G_BFU_FONT_SIZE, term->x, term->y, !proxies.only_proxies ? bfu_bg_color : bfu_fg_color);
if (drv->end_draw) drv->end_draw(term->dev);
#endif #endif
} }
} }
@ -666,6 +668,7 @@ void download_window_function(struct dialog_data *dlg)
} else { } else {
unsigned char *q; unsigned char *q;
int p, s, ss, m; int p, s, ss, m;
if (drv->start_draw) drv->start_draw(term->dev);
y += G_BFU_FONT_SIZE; y += G_BFU_FONT_SIZE;
q = download_percentage(down, 1); q = download_percentage(down, 1);
extend_str(&q, 1); extend_str(&q, 1);
@ -683,6 +686,7 @@ void download_window_function(struct dialog_data *dlg)
if (dlg->s) exclude_from_set(&dlg->s, x, y, x + w, y + G_BFU_FONT_SIZE); if (dlg->s) exclude_from_set(&dlg->s, x, y, x + w, y + G_BFU_FONT_SIZE);
mem_free(q); mem_free(q);
y += G_BFU_FONT_SIZE; y += G_BFU_FONT_SIZE;
if (drv->end_draw) drv->end_draw(term->dev);
#endif #endif
} }
} }

View File

@ -2380,6 +2380,8 @@ struct graphics_driver svga_driver = {
NULL, /* draw_vline */ NULL, /* draw_vline */
NULL, /* scroll */ NULL, /* scroll */
NULL, /* set_clip_area */ NULL, /* set_clip_area */
NULL, /* start_draw */
NULL, /* end_draw */
NULL, /* flush */ NULL, /* flush */
vga_block, /* block */ vga_block, /* block */
vga_unblock, /* unblock */ vga_unblock, /* unblock */

View File

@ -476,6 +476,7 @@ static long scroll_bar_bar_color;
void draw_vscroll_bar(struct graphics_device *dev, int x, int y, int yw, int total, int view, int pos) void draw_vscroll_bar(struct graphics_device *dev, int x, int y, int yw, int total, int view, int pos)
{ {
int spos, epos; int spos, epos;
if (drv->start_draw) drv->start_draw(dev);
drv->draw_hline(dev, x, y, x + G_SCROLL_BAR_WIDTH, scroll_bar_frame_color); drv->draw_hline(dev, x, y, x + G_SCROLL_BAR_WIDTH, scroll_bar_frame_color);
drv->draw_vline(dev, x, y, y + yw, scroll_bar_frame_color); drv->draw_vline(dev, x, y, y + yw, scroll_bar_frame_color);
drv->draw_vline(dev, x + G_SCROLL_BAR_WIDTH - 1, y, y + yw, scroll_bar_frame_color); drv->draw_vline(dev, x + G_SCROLL_BAR_WIDTH - 1, y, y + yw, scroll_bar_frame_color);
@ -486,11 +487,13 @@ void draw_vscroll_bar(struct graphics_device *dev, int x, int y, int yw, int tot
drv->fill_area(dev, x + 2, y + 1, x + G_SCROLL_BAR_WIDTH - 2, y + 2 + spos, scroll_bar_area_color); drv->fill_area(dev, x + 2, y + 1, x + G_SCROLL_BAR_WIDTH - 2, y + 2 + spos, scroll_bar_area_color);
drv->fill_area(dev, x + 2, y + 2 + spos, x + G_SCROLL_BAR_WIDTH - 2, y + 2 + epos, scroll_bar_bar_color); drv->fill_area(dev, x + 2, y + 2 + spos, x + G_SCROLL_BAR_WIDTH - 2, y + 2 + epos, scroll_bar_bar_color);
drv->fill_area(dev, x + 2, y + 2 + epos, x + G_SCROLL_BAR_WIDTH - 2, y + yw - 1, scroll_bar_area_color); drv->fill_area(dev, x + 2, y + 2 + epos, x + G_SCROLL_BAR_WIDTH - 2, y + yw - 1, scroll_bar_area_color);
if (drv->end_draw) drv->end_draw(dev);
} }
void draw_hscroll_bar(struct graphics_device *dev, int x, int y, int xw, int total, int view, int pos) void draw_hscroll_bar(struct graphics_device *dev, int x, int y, int xw, int total, int view, int pos)
{ {
int spos, epos; int spos, epos;
if (drv->start_draw) drv->start_draw(dev);
drv->draw_vline(dev, x, y, y + G_SCROLL_BAR_WIDTH, scroll_bar_frame_color); drv->draw_vline(dev, x, y, y + G_SCROLL_BAR_WIDTH, scroll_bar_frame_color);
drv->draw_hline(dev, x, y, x + xw, scroll_bar_frame_color); drv->draw_hline(dev, x, y, x + xw, scroll_bar_frame_color);
drv->draw_hline(dev, x, y + G_SCROLL_BAR_WIDTH - 1, x + xw, scroll_bar_frame_color); drv->draw_hline(dev, x, y + G_SCROLL_BAR_WIDTH - 1, x + xw, scroll_bar_frame_color);
@ -501,6 +504,7 @@ void draw_hscroll_bar(struct graphics_device *dev, int x, int y, int xw, int tot
drv->fill_area(dev, x + 1, y + 2, x + 2 + spos, y + G_SCROLL_BAR_WIDTH - 2, scroll_bar_area_color); drv->fill_area(dev, x + 1, y + 2, x + 2 + spos, y + G_SCROLL_BAR_WIDTH - 2, scroll_bar_area_color);
drv->fill_area(dev, x + 2 + spos, y + 2, x + 2 + epos, y + G_SCROLL_BAR_WIDTH - 2, scroll_bar_bar_color); drv->fill_area(dev, x + 2 + spos, y + 2, x + 2 + epos, y + G_SCROLL_BAR_WIDTH - 2, scroll_bar_bar_color);
drv->fill_area(dev, x + 2 + epos, y + 2, x + xw - 1, y + G_SCROLL_BAR_WIDTH - 2, scroll_bar_area_color); drv->fill_area(dev, x + 2 + epos, y + 2, x + xw - 1, y + G_SCROLL_BAR_WIDTH - 2, scroll_bar_area_color);
if (drv->end_draw) drv->end_draw(dev);
} }
static void g_get_search(struct f_data *f, unsigned char *s) static void g_get_search(struct f_data *f, unsigned char *s)
@ -567,9 +571,11 @@ void draw_graphical_doc(struct terminal *t, struct f_data_c *scr, int active)
vx = vs->view_posx; vx = vs->view_posx;
vy = vs->view_pos; vy = vs->view_pos;
restrict_clip_area(t->dev, &old, scr->xp, scr->yp, scr->xp + xw, scr->yp + yw); restrict_clip_area(t->dev, &old, scr->xp, scr->yp, scr->xp + xw, scr->yp + yw);
if (drv->start_draw) drv->start_draw(t->dev);
if (scr->vsb) draw_vscroll_bar(t->dev, scr->xp + xw - G_SCROLL_BAR_WIDTH, scr->yp, yw - scr->hsb * G_SCROLL_BAR_WIDTH, scr->f_data->y, yw - scr->hsb * G_SCROLL_BAR_WIDTH, vs->view_pos); if (scr->vsb) draw_vscroll_bar(t->dev, scr->xp + xw - G_SCROLL_BAR_WIDTH, scr->yp, yw - scr->hsb * G_SCROLL_BAR_WIDTH, scr->f_data->y, yw - scr->hsb * G_SCROLL_BAR_WIDTH, vs->view_pos);
if (scr->hsb) draw_hscroll_bar(t->dev, scr->xp, scr->yp + yw - G_SCROLL_BAR_WIDTH, xw - scr->vsb * G_SCROLL_BAR_WIDTH, scr->f_data->x, xw - scr->vsb * G_SCROLL_BAR_WIDTH, vs->view_posx); if (scr->hsb) draw_hscroll_bar(t->dev, scr->xp, scr->yp + yw - G_SCROLL_BAR_WIDTH, xw - scr->vsb * G_SCROLL_BAR_WIDTH, scr->f_data->x, xw - scr->vsb * G_SCROLL_BAR_WIDTH, vs->view_posx);
if (scr->vsb && scr->hsb) drv->fill_area(t->dev, scr->xp + xw - G_SCROLL_BAR_WIDTH, scr->yp + yw - G_SCROLL_BAR_WIDTH, scr->xp + xw, scr->yp + yw, scroll_bar_frame_color); if (scr->vsb && scr->hsb) drv->fill_area(t->dev, scr->xp + xw - G_SCROLL_BAR_WIDTH, scr->yp + yw - G_SCROLL_BAR_WIDTH, scr->xp + xw, scr->yp + yw, scroll_bar_frame_color);
if (drv->end_draw) drv->end_draw(t->dev);
restrict_clip_area(t->dev, NULL, scr->xp, scr->yp, scr->xp + xw - scr->vsb * G_SCROLL_BAR_WIDTH, scr->yp + yw - scr->hsb * G_SCROLL_BAR_WIDTH); restrict_clip_area(t->dev, NULL, scr->xp, scr->yp, scr->xp + xw - scr->vsb * G_SCROLL_BAR_WIDTH, scr->yp + yw - scr->hsb * G_SCROLL_BAR_WIDTH);
/*debug("buu: %d %d %d, %d %d %d", scr->xl, vx, xw, scr->yl, vy, yw);*/ /*debug("buu: %d %d %d, %d %d %d", scr->xl, vx, xw, scr->yl, vy, yw);*/
if (drv->flags & GD_DONT_USE_SCROLL && overwrite_instead_of_scroll) goto rrr; if (drv->flags & GD_DONT_USE_SCROLL && overwrite_instead_of_scroll) goto rrr;
@ -1326,6 +1332,7 @@ void draw_title(struct f_data_c *f)
int b, z, w; int b, z, w;
struct graphics_device *dev = f->ses->term->dev; struct graphics_device *dev = f->ses->term->dev;
unsigned char *title = stracpy(!drv->set_title && f->f_data && f->f_data->title && f->f_data->title[0] ? f->f_data->title : NULL); unsigned char *title = stracpy(!drv->set_title && f->f_data && f->f_data->title && f->f_data->title[0] ? f->f_data->title : NULL);
if (drv->start_draw) drv->start_draw(dev);
if (!title) { if (!title) {
if (f->rq && f->rq->url) if (f->rq && f->rq->url)
title = display_url(f->ses->term, f->rq->url, 1); title = display_url(f->ses->term, f->rq->url, 1);
@ -1342,6 +1349,7 @@ void draw_title(struct f_data_c *f)
g_print_text(dev, b, 0, !proxies.only_proxies ? bfu_style_bw : bfu_style_wb, title, &b); g_print_text(dev, b, 0, !proxies.only_proxies ? bfu_style_bw : bfu_style_wb, title, &b);
drv->fill_area(dev, b, 0, dev->size.x2, G_BFU_FONT_SIZE, !proxies.only_proxies ? bfu_bg_color : bfu_fg_color); drv->fill_area(dev, b, 0, dev->size.x2, G_BFU_FONT_SIZE, !proxies.only_proxies ? bfu_bg_color : bfu_fg_color);
mem_free(title); mem_free(title);
if (drv->end_draw) drv->end_draw(dev);
} }
static struct f_data *srch_f_data; static struct f_data *srch_f_data;

10
x.c
View File

@ -2985,12 +2985,12 @@ struct graphics_driver x_driver = {
x_init_device, x_init_device,
x_shutdown_device, x_shutdown_device,
x_shutdown_driver, x_shutdown_driver,
NULL, NULL, /* emergency_shutdown */
x_after_fork, x_after_fork,
x_get_driver_param, x_get_driver_param,
x_get_af_unix_name, x_get_af_unix_name,
NULL, NULL, /* get_margin */
NULL, NULL, /* set_margin */
x_get_empty_bitmap, x_get_empty_bitmap,
x_register_bitmap, x_register_bitmap,
x_prepare_strip, x_prepare_strip,
@ -3002,7 +3002,9 @@ struct graphics_driver x_driver = {
x_draw_hline, x_draw_hline,
x_draw_vline, x_draw_vline,
x_scroll, x_scroll,
NULL, NULL, /* set_clip_area */
NULL, /* start_draw */
NULL, /* end_draw */
x_flush, x_flush,
NULL, /* block */ NULL, /* block */
NULL, /* unblock */ NULL, /* unblock */