aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-02-09 15:01:36 +0800
committerPo Lu2022-02-09 15:04:12 +0800
commit5627693ce3f6ff7ef928a902bfab59731a63fbd4 (patch)
tree7da7e30b2b2a209359ed7f9bfc1138f96ef7c965 /src
parent34772455261fc1508c3623ba549381976dcba258 (diff)
downloademacs-5627693ce3f6ff7ef928a902bfab59731a63fbd4.tar.gz
emacs-5627693ce3f6ff7ef928a902bfab59731a63fbd4.zip
Explictly specify whether or not to respect alpha-background on Cairo
* src/ftcrfont.c (ftcrfont_draw): Don't respect `alpha-background' if drawing cursor. (bug#53890) * src/xterm.c (x_set_cr_source_with_gc_foreground): (x_set_cr_source_with_gc_background): New parameters `respect_alpha_background'. All callers changed. * src/xterm.h: Update protoypes.
Diffstat (limited to 'src')
-rw-r--r--src/ftcrfont.c4
-rw-r--r--src/xterm.c52
-rw-r--r--src/xterm.h4
3 files changed, 38 insertions, 22 deletions
diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index a0a3490c494..4d1ecee3788 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -566,7 +566,7 @@ ftcrfont_draw (struct glyph_string *s,
566 { 566 {
567#ifndef USE_BE_CAIRO 567#ifndef USE_BE_CAIRO
568#ifdef HAVE_X_WINDOWS 568#ifdef HAVE_X_WINDOWS
569 x_set_cr_source_with_gc_background (f, s->gc); 569 x_set_cr_source_with_gc_background (f, s->gc, s->hl != DRAW_CURSOR);
570#else 570#else
571 pgtk_set_cr_source_with_color (f, s->xgcv.background, true); 571 pgtk_set_cr_source_with_color (f, s->xgcv.background, true);
572#endif 572#endif
@@ -595,7 +595,7 @@ ftcrfont_draw (struct glyph_string *s,
595 } 595 }
596#ifndef USE_BE_CAIRO 596#ifndef USE_BE_CAIRO
597#ifdef HAVE_X_WINDOWS 597#ifdef HAVE_X_WINDOWS
598 x_set_cr_source_with_gc_foreground (f, s->gc); 598 x_set_cr_source_with_gc_foreground (f, s->gc, false);
599#else 599#else
600 pgtk_set_cr_source_with_color (f, s->xgcv.foreground, false); 600 pgtk_set_cr_source_with_color (f, s->xgcv.foreground, false);
601#endif 601#endif
diff --git a/src/xterm.c b/src/xterm.c
index 9b480069275..aed97fb37e9 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -875,20 +875,35 @@ x_end_cr_clip (struct frame *f)
875} 875}
876 876
877void 877void
878x_set_cr_source_with_gc_foreground (struct frame *f, GC gc) 878x_set_cr_source_with_gc_foreground (struct frame *f, GC gc,
879 bool respect_alpha_background)
879{ 880{
880 XGCValues xgcv; 881 XGCValues xgcv;
881 XColor color; 882 XColor color;
883 unsigned int depth;
882 884
883 XGetGCValues (FRAME_X_DISPLAY (f), gc, GCForeground, &xgcv); 885 XGetGCValues (FRAME_X_DISPLAY (f), gc, GCForeground, &xgcv);
884 color.pixel = xgcv.foreground; 886 color.pixel = xgcv.foreground;
885 x_query_colors (f, &color, 1); 887 x_query_colors (f, &color, 1);
886 cairo_set_source_rgb (FRAME_CR_CONTEXT (f), color.red / 65535.0, 888 depth = FRAME_DISPLAY_INFO (f)->n_planes;
887 color.green / 65535.0, color.blue / 65535.0); 889
890 if (f->alpha_background < 1.0 && depth == 32
891 && respect_alpha_background)
892 {
893 cairo_set_source_rgba (FRAME_CR_CONTEXT (f), color.red / 65535.0,
894 color.green / 65535.0, color.blue / 65535.0,
895 f->alpha_background);
896
897 cairo_set_operator (FRAME_CR_CONTEXT (f), CAIRO_OPERATOR_SOURCE);
898 }
899 else
900 cairo_set_source_rgb (FRAME_CR_CONTEXT (f), color.red / 65535.0,
901 color.green / 65535.0, color.blue / 65535.0);
888} 902}
889 903
890void 904void
891x_set_cr_source_with_gc_background (struct frame *f, GC gc) 905x_set_cr_source_with_gc_background (struct frame *f, GC gc,
906 bool respect_alpha_background)
892{ 907{
893 XGCValues xgcv; 908 XGCValues xgcv;
894 XColor color; 909 XColor color;
@@ -901,7 +916,8 @@ x_set_cr_source_with_gc_background (struct frame *f, GC gc)
901 916
902 depth = FRAME_DISPLAY_INFO (f)->n_planes; 917 depth = FRAME_DISPLAY_INFO (f)->n_planes;
903 918
904 if (f->alpha_background < 1.0 && depth == 32) 919 if (f->alpha_background < 1.0 && depth == 32
920 && respect_alpha_background)
905 { 921 {
906 cairo_set_source_rgba (FRAME_CR_CONTEXT (f), color.red / 65535.0, 922 cairo_set_source_rgba (FRAME_CR_CONTEXT (f), color.red / 65535.0,
907 color.green / 65535.0, color.blue / 65535.0, 923 color.green / 65535.0, color.blue / 65535.0,
@@ -912,7 +928,6 @@ x_set_cr_source_with_gc_background (struct frame *f, GC gc)
912 else 928 else
913 cairo_set_source_rgb (FRAME_CR_CONTEXT (f), color.red / 65535.0, 929 cairo_set_source_rgb (FRAME_CR_CONTEXT (f), color.red / 65535.0,
914 color.green / 65535.0, color.blue / 65535.0); 930 color.green / 65535.0, color.blue / 65535.0);
915
916} 931}
917 932
918static const cairo_user_data_key_t xlib_surface_key, saved_drawable_key; 933static const cairo_user_data_key_t xlib_surface_key, saved_drawable_key;
@@ -1097,7 +1112,7 @@ x_cr_draw_image (struct frame *f, GC gc, cairo_pattern_t *image,
1097 cairo_rectangle (cr, dest_x, dest_y, width, height); 1112 cairo_rectangle (cr, dest_x, dest_y, width, height);
1098 else 1113 else
1099 { 1114 {
1100 x_set_cr_source_with_gc_background (f, gc); 1115 x_set_cr_source_with_gc_background (f, gc, false);
1101 cairo_rectangle (cr, dest_x, dest_y, width, height); 1116 cairo_rectangle (cr, dest_x, dest_y, width, height);
1102 cairo_fill_preserve (cr); 1117 cairo_fill_preserve (cr);
1103 } 1118 }
@@ -1114,7 +1129,7 @@ x_cr_draw_image (struct frame *f, GC gc, cairo_pattern_t *image,
1114 } 1129 }
1115 else 1130 else
1116 { 1131 {
1117 x_set_cr_source_with_gc_foreground (f, gc); 1132 x_set_cr_source_with_gc_foreground (f, gc, false);
1118 cairo_clip (cr); 1133 cairo_clip (cr);
1119 cairo_mask (cr, image); 1134 cairo_mask (cr, image);
1120 } 1135 }
@@ -1325,7 +1340,7 @@ x_fill_rectangle (struct frame *f, GC gc, int x, int y, int width, int height,
1325 regarded as Pixmap of unspecified size filled with ones. */ 1340 regarded as Pixmap of unspecified size filled with ones. */
1326 || (xgcv.stipple & ((Pixmap) 7 << (sizeof (Pixmap) * CHAR_BIT - 3)))) 1341 || (xgcv.stipple & ((Pixmap) 7 << (sizeof (Pixmap) * CHAR_BIT - 3))))
1327 { 1342 {
1328 x_set_cr_source_with_gc_foreground (f, gc); 1343 x_set_cr_source_with_gc_foreground (f, gc, respect_alpha_background);
1329 cairo_rectangle (cr, x, y, width, height); 1344 cairo_rectangle (cr, x, y, width, height);
1330 cairo_fill (cr); 1345 cairo_fill (cr);
1331 } 1346 }
@@ -1333,14 +1348,14 @@ x_fill_rectangle (struct frame *f, GC gc, int x, int y, int width, int height,
1333 { 1348 {
1334 eassert (xgcv.fill_style == FillOpaqueStippled); 1349 eassert (xgcv.fill_style == FillOpaqueStippled);
1335 eassert (xgcv.stipple != None); 1350 eassert (xgcv.stipple != None);
1336 x_set_cr_source_with_gc_background (f, gc); 1351 x_set_cr_source_with_gc_background (f, gc, respect_alpha_background);
1337 cairo_rectangle (cr, x, y, width, height); 1352 cairo_rectangle (cr, x, y, width, height);
1338 cairo_fill_preserve (cr); 1353 cairo_fill_preserve (cr);
1339 1354
1340 cairo_pattern_t *pattern = x_bitmap_stipple (f, xgcv.stipple); 1355 cairo_pattern_t *pattern = x_bitmap_stipple (f, xgcv.stipple);
1341 if (pattern) 1356 if (pattern)
1342 { 1357 {
1343 x_set_cr_source_with_gc_foreground (f, gc); 1358 x_set_cr_source_with_gc_foreground (f, gc, respect_alpha_background);
1344 cairo_clip (cr); 1359 cairo_clip (cr);
1345 cairo_mask (cr, pattern); 1360 cairo_mask (cr, pattern);
1346 } 1361 }
@@ -1384,7 +1399,7 @@ x_clear_rectangle (struct frame *f, GC gc, int x, int y, int width, int height,
1384 cairo_t *cr; 1399 cairo_t *cr;
1385 1400
1386 cr = x_begin_cr_clip (f, gc); 1401 cr = x_begin_cr_clip (f, gc);
1387 x_set_cr_source_with_gc_background (f, gc); 1402 x_set_cr_source_with_gc_background (f, gc, respect_alpha_background);
1388 cairo_rectangle (cr, x, y, width, height); 1403 cairo_rectangle (cr, x, y, width, height);
1389 cairo_fill (cr); 1404 cairo_fill (cr);
1390 x_end_cr_clip (f); 1405 x_end_cr_clip (f);
@@ -1430,7 +1445,7 @@ x_draw_rectangle (struct frame *f, GC gc, int x, int y, int width, int height)
1430 cairo_t *cr; 1445 cairo_t *cr;
1431 1446
1432 cr = x_begin_cr_clip (f, gc); 1447 cr = x_begin_cr_clip (f, gc);
1433 x_set_cr_source_with_gc_foreground (f, gc); 1448 x_set_cr_source_with_gc_foreground (f, gc, false);
1434 cairo_rectangle (cr, x + 0.5, y + 0.5, width, height); 1449 cairo_rectangle (cr, x + 0.5, y + 0.5, width, height);
1435 cairo_set_line_width (cr, 1); 1450 cairo_set_line_width (cr, 1);
1436 cairo_stroke (cr); 1451 cairo_stroke (cr);
@@ -1448,7 +1463,7 @@ x_clear_window (struct frame *f)
1448 cairo_t *cr; 1463 cairo_t *cr;
1449 1464
1450 cr = x_begin_cr_clip (f, NULL); 1465 cr = x_begin_cr_clip (f, NULL);
1451 x_set_cr_source_with_gc_background (f, f->output_data.x->normal_gc); 1466 x_set_cr_source_with_gc_background (f, f->output_data.x->normal_gc, true);
1452 cairo_paint (cr); 1467 cairo_paint (cr);
1453 x_end_cr_clip (f); 1468 x_end_cr_clip (f);
1454#else 1469#else
@@ -1471,7 +1486,7 @@ x_fill_trapezoid_for_relief (struct frame *f, GC gc, int x, int y,
1471 cairo_t *cr; 1486 cairo_t *cr;
1472 1487
1473 cr = x_begin_cr_clip (f, gc); 1488 cr = x_begin_cr_clip (f, gc);
1474 x_set_cr_source_with_gc_foreground (f, gc); 1489 x_set_cr_source_with_gc_foreground (f, gc, false);
1475 cairo_move_to (cr, top_p ? x : x + height, y); 1490 cairo_move_to (cr, top_p ? x : x + height, y);
1476 cairo_line_to (cr, x, y + height); 1491 cairo_line_to (cr, x, y + height);
1477 cairo_line_to (cr, top_p ? x + width - height : x + width, y + height); 1492 cairo_line_to (cr, top_p ? x + width - height : x + width, y + height);
@@ -1498,7 +1513,7 @@ x_erase_corners_for_relief (struct frame *f, GC gc, int x, int y,
1498 int i; 1513 int i;
1499 1514
1500 cr = x_begin_cr_clip (f, gc); 1515 cr = x_begin_cr_clip (f, gc);
1501 x_set_cr_source_with_gc_background (f, gc); 1516 x_set_cr_source_with_gc_background (f, gc, false);
1502 for (i = 0; i < CORNER_LAST; i++) 1517 for (i = 0; i < CORNER_LAST; i++)
1503 if (corners & (1 << i)) 1518 if (corners & (1 << i))
1504 { 1519 {
@@ -1531,7 +1546,7 @@ x_draw_horizontal_wave (struct frame *f, GC gc, int x, int y,
1531 int xoffset, n; 1546 int xoffset, n;
1532 1547
1533 cr = x_begin_cr_clip (f, gc); 1548 cr = x_begin_cr_clip (f, gc);
1534 x_set_cr_source_with_gc_foreground (f, gc); 1549 x_set_cr_source_with_gc_foreground (f, gc, false);
1535 cairo_rectangle (cr, x, y, width, height); 1550 cairo_rectangle (cr, x, y, width, height);
1536 cairo_clip (cr); 1551 cairo_clip (cr);
1537 1552
@@ -4840,7 +4855,8 @@ x_clear_area (struct frame *f, int x, int y, int width, int height)
4840 eassert (width > 0 && height > 0); 4855 eassert (width > 0 && height > 0);
4841 4856
4842 cr = x_begin_cr_clip (f, NULL); 4857 cr = x_begin_cr_clip (f, NULL);
4843 x_set_cr_source_with_gc_background (f, f->output_data.x->normal_gc); 4858 x_set_cr_source_with_gc_background (f, f->output_data.x->normal_gc,
4859 true);
4844 cairo_rectangle (cr, x, y, width, height); 4860 cairo_rectangle (cr, x, y, width, height);
4845 cairo_fill (cr); 4861 cairo_fill (cr);
4846 x_end_cr_clip (f); 4862 x_end_cr_clip (f);
diff --git a/src/xterm.h b/src/xterm.h
index 1ce3e7a6cf8..435569943c4 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1267,8 +1267,8 @@ extern void x_cr_destroy_frame_context (struct frame *);
1267extern void x_cr_update_surface_desired_size (struct frame *, int, int); 1267extern void x_cr_update_surface_desired_size (struct frame *, int, int);
1268extern cairo_t *x_begin_cr_clip (struct frame *, GC); 1268extern cairo_t *x_begin_cr_clip (struct frame *, GC);
1269extern void x_end_cr_clip (struct frame *); 1269extern void x_end_cr_clip (struct frame *);
1270extern void x_set_cr_source_with_gc_foreground (struct frame *, GC); 1270extern void x_set_cr_source_with_gc_foreground (struct frame *, GC, bool);
1271extern void x_set_cr_source_with_gc_background (struct frame *, GC); 1271extern void x_set_cr_source_with_gc_background (struct frame *, GC, bool);
1272extern void x_cr_draw_frame (cairo_t *, struct frame *); 1272extern void x_cr_draw_frame (cairo_t *, struct frame *);
1273extern Lisp_Object x_cr_export_frames (Lisp_Object, cairo_surface_type_t); 1273extern Lisp_Object x_cr_export_frames (Lisp_Object, cairo_surface_type_t);
1274#endif 1274#endif