summaryrefslogtreecommitdiff
path: root/src/ftcrfont.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ftcrfont.c')
-rw-r--r--src/ftcrfont.c81
1 files changed, 78 insertions, 3 deletions
diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index db417b3e77d..49b179b0efc 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -22,7 +22,15 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <cairo-ft.h>
#include "lisp.h"
+#ifdef HAVE_X_WINDOWS
#include "xterm.h"
+#elif HAVE_HAIKU
+#include "haikuterm.h"
+#include "haiku_support.h"
+#include "termchar.h"
+#else
+#include "pgtkterm.h"
+#endif
#include "blockinput.h"
#include "charset.h"
#include "composite.h"
@@ -30,6 +38,12 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "ftfont.h"
#include "pdumper.h"
+#ifdef USE_BE_CAIRO
+#define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
+#define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
+#define BLUE_FROM_ULONG(color) ((color) & 0xff)
+#endif
+
#define METRICS_NCOLS_PER_ROW (128)
enum metrics_status
@@ -513,11 +527,52 @@ ftcrfont_draw (struct glyph_string *s,
block_input ();
+#ifndef USE_BE_CAIRO
+#ifdef HAVE_X_WINDOWS
cr = x_begin_cr_clip (f, s->gc);
+#else
+ cr = pgtk_begin_cr_clip (f);
+#endif
+#else
+ BView_draw_lock (FRAME_HAIKU_VIEW (f));
+ EmacsWindow_begin_cr_critical_section (FRAME_HAIKU_WINDOW (f));
+ cr = haiku_begin_cr_clip (f, s);
+ if (!cr)
+ {
+ BView_draw_unlock (FRAME_HAIKU_VIEW (f));
+ EmacsWindow_end_cr_critical_section (FRAME_HAIKU_WINDOW (f));
+ unblock_input ();
+ return 0;
+ }
+ BView_cr_dump_clipping (FRAME_HAIKU_VIEW (f), cr);
+
+ if (s->left_overhang && s->clip_head && !s->for_overlaps)
+ {
+ cairo_rectangle (cr, s->clip_head->x, 0,
+ FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f));
+ cairo_clip (cr);
+ }
+#endif
if (with_background)
{
+#ifndef USE_BE_CAIRO
+#ifdef HAVE_X_WINDOWS
x_set_cr_source_with_gc_background (f, s->gc);
+#else
+ pgtk_set_cr_source_with_color (f, s->xgcv.background);
+#endif
+#else
+ struct face *face = s->face;
+
+ uint32_t col = s->hl == DRAW_CURSOR ?
+ FRAME_CURSOR_COLOR (s->f).pixel : face->background;
+
+ cairo_set_source_rgb (cr, RED_FROM_ULONG (col) / 255.0,
+ GREEN_FROM_ULONG (col) / 255.0,
+ BLUE_FROM_ULONG (col) / 255.0);
+#endif
+ s->background_filled_p = 1;
cairo_rectangle (cr, x, y - FONT_BASE (face->font),
s->width, FONT_HEIGHT (face->font));
cairo_fill (cr);
@@ -533,13 +588,33 @@ ftcrfont_draw (struct glyph_string *s,
glyphs[i].index,
NULL));
}
-
+#ifndef USE_BE_CAIRO
+#ifdef HAVE_X_WINDOWS
x_set_cr_source_with_gc_foreground (f, s->gc);
+#else
+ pgtk_set_cr_source_with_color (f, s->xgcv.foreground);
+#endif
+#else
+ uint32_t col = s->hl == DRAW_CURSOR ?
+ FRAME_OUTPUT_DATA (s->f)->cursor_fg : face->foreground;
+
+ cairo_set_source_rgb (cr, RED_FROM_ULONG (col) / 255.0,
+ GREEN_FROM_ULONG (col) / 255.0,
+ BLUE_FROM_ULONG (col) / 255.0);
+#endif
cairo_set_scaled_font (cr, ftcrfont_info->cr_scaled_font);
cairo_show_glyphs (cr, glyphs, len);
-
+#ifndef USE_BE_CAIRO
+#ifdef HAVE_X_WINDOWS
x_end_cr_clip (f);
-
+#else
+ pgtk_end_cr_clip (f);
+#endif
+#else
+ haiku_end_cr_clip (cr);
+ EmacsWindow_end_cr_critical_section (FRAME_HAIKU_WINDOW (f));
+ BView_draw_unlock (FRAME_HAIKU_VIEW (f));
+#endif
unblock_input ();
return len;