From: Po Lu Date: Fri, 20 May 2022 02:27:06 +0000 (+0000) Subject: Implement `cross-disabled-images' on Haiku X-Git-Tag: emacs-29.0.90~1910^2~570 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8a7d8bb04b38ba9849b60d63c9fcfd36856eb424;p=emacs.git Implement `cross-disabled-images' on Haiku * src/haiku_draw_support.cc (be_draw_cross_on_pixmap_1) (be_draw_cross_on_pixmap): New functions. * src/haiku_support.h: Update prototypes. * src/image.c (image_pixmap_draw_cross, image_disable_image): Implement drawing cross on Haiku. --- diff --git a/src/haiku_draw_support.cc b/src/haiku_draw_support.cc index 551af51d7c1..f0cc084bb37 100644 --- a/src/haiku_draw_support.cc +++ b/src/haiku_draw_support.cc @@ -503,3 +503,40 @@ BView_InvertRect (void *view, int x, int y, int width, int height) vw->InvertRect (BRect (x, y, x + width - 1, y + height - 1)); } + +static void +be_draw_cross_on_pixmap_1 (BBitmap *bitmap, int x, int y, int width, + int height, uint32_t color) +{ + BBitmap dest (bitmap->Bounds (), + bitmap->ColorSpace (), + true, false); + BView view (bitmap->Bounds (), NULL, B_FOLLOW_NONE, 0); + rgb_color high_color; + + rgb32_to_rgb_color (color, &high_color); + dest.ImportBits (bitmap); + + if (!dest.Lock ()) + return; + + dest.AddChild (&view); + + view.SetHighColor (high_color); + view.StrokeLine (BPoint (x, y), + BPoint (x + width - 1, y + height - 1)); + view.StrokeLine (BPoint (x, y + height - 1), + BPoint (x + width - 1, y)); + view.RemoveSelf (); + bitmap->ImportBits (&dest); +} + +void +be_draw_cross_on_pixmap (void *bitmap, int x, int y, int width, + int height, uint32_t color) +{ + BBitmap *target = (BBitmap *) bitmap; + + be_draw_cross_on_pixmap_1 (target, x, y, width, height, + color); +} diff --git a/src/haiku_support.h b/src/haiku_support.h index 0bfd027c0d3..b66486b1dce 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -484,6 +484,8 @@ extern void hsl_color_rgb (double, double, double, uint32_t *); extern void *BBitmap_new (int, int, int); extern void *BBitmap_data (void *); extern int BBitmap_convert (void *, void **); +extern void be_draw_cross_on_pixmap (void *, int, int, int, int, + uint32_t); extern void BBitmap_free (void *); diff --git a/src/image.c b/src/image.c index 18e9e72d83c..058c1755704 100644 --- a/src/image.c +++ b/src/image.c @@ -6307,7 +6307,7 @@ image_edge_detection (struct frame *f, struct image *img, } -#if defined HAVE_X_WINDOWS || defined USE_CAIRO +#if defined HAVE_X_WINDOWS || defined USE_CAIRO || defined HAVE_HAIKU static void image_pixmap_draw_cross (struct frame *f, Emacs_Pixmap pixmap, int x, int y, unsigned int width, unsigned int height, @@ -6341,9 +6341,11 @@ image_pixmap_draw_cross (struct frame *f, Emacs_Pixmap pixmap, XDrawLine (dpy, pixmap, gc, x, y, x + width - 1, y + height - 1); XDrawLine (dpy, pixmap, gc, x, y + height - 1, x + width - 1, y); XFreeGC (dpy, gc); -#endif /* HAVE_X_WINDOWS */ +#elif HAVE_HAIKU + be_draw_cross_on_pixmap (pixmap, x, y, width, height, color); +#endif } -#endif /* HAVE_X_WINDOWS || USE_CAIRO */ +#endif /* HAVE_X_WINDOWS || USE_CAIRO || HAVE_HAIKU */ /* Transform image IMG on frame F so that it looks disabled. */ @@ -6385,25 +6387,23 @@ image_disable_image (struct frame *f, struct image *img) { #ifndef HAVE_NTGUI #ifndef HAVE_NS /* TODO: NS support, however this not needed for toolbars */ -#ifndef HAVE_HAIKU -#ifndef USE_CAIRO +#if !defined USE_CAIRO && !defined HAVE_HAIKU #define CrossForeground(f) BLACK_PIX_DEFAULT (f) #define MaskForeground(f) WHITE_PIX_DEFAULT (f) -#else /* USE_CAIRO */ +#else /* USE_CAIRO || HAVE_HAIKU */ #define CrossForeground(f) 0 #define MaskForeground(f) PIX_MASK_DRAW -#endif /* USE_CAIRO */ +#endif /* USE_CAIRO || HAVE_HAIKU */ -#ifndef USE_CAIRO +#if !defined USE_CAIRO && !defined HAVE_HAIKU image_sync_to_pixmaps (f, img); -#endif /* !USE_CAIRO */ +#endif /* !USE_CAIRO && !HAVE_HAIKU */ image_pixmap_draw_cross (f, img->pixmap, 0, 0, img->width, img->height, CrossForeground (f)); if (img->mask) image_pixmap_draw_cross (f, img->mask, 0, 0, img->width, img->height, MaskForeground (f)); -#endif /* !HAVE_HAIKU */ #endif /* !HAVE_NS */ #else HDC hdc, bmpdc;