aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-05-20 02:27:06 +0000
committerPo Lu2022-05-20 02:28:29 +0000
commit8a7d8bb04b38ba9849b60d63c9fcfd36856eb424 (patch)
treeb105fcf9b03deeae53d07fcbd14ec9d0609bd6ca /src
parent9d557d4d4adf68ca15ca9aaa48470133544ede26 (diff)
downloademacs-8a7d8bb04b38ba9849b60d63c9fcfd36856eb424.tar.gz
emacs-8a7d8bb04b38ba9849b60d63c9fcfd36856eb424.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/haiku_draw_support.cc37
-rw-r--r--src/haiku_support.h2
-rw-r--r--src/image.c20
3 files changed, 49 insertions, 10 deletions
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)
503 503
504 vw->InvertRect (BRect (x, y, x + width - 1, y + height - 1)); 504 vw->InvertRect (BRect (x, y, x + width - 1, y + height - 1));
505} 505}
506
507static void
508be_draw_cross_on_pixmap_1 (BBitmap *bitmap, int x, int y, int width,
509 int height, uint32_t color)
510{
511 BBitmap dest (bitmap->Bounds (),
512 bitmap->ColorSpace (),
513 true, false);
514 BView view (bitmap->Bounds (), NULL, B_FOLLOW_NONE, 0);
515 rgb_color high_color;
516
517 rgb32_to_rgb_color (color, &high_color);
518 dest.ImportBits (bitmap);
519
520 if (!dest.Lock ())
521 return;
522
523 dest.AddChild (&view);
524
525 view.SetHighColor (high_color);
526 view.StrokeLine (BPoint (x, y),
527 BPoint (x + width - 1, y + height - 1));
528 view.StrokeLine (BPoint (x, y + height - 1),
529 BPoint (x + width - 1, y));
530 view.RemoveSelf ();
531 bitmap->ImportBits (&dest);
532}
533
534void
535be_draw_cross_on_pixmap (void *bitmap, int x, int y, int width,
536 int height, uint32_t color)
537{
538 BBitmap *target = (BBitmap *) bitmap;
539
540 be_draw_cross_on_pixmap_1 (target, x, y, width, height,
541 color);
542}
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 *);
484extern void *BBitmap_new (int, int, int); 484extern void *BBitmap_new (int, int, int);
485extern void *BBitmap_data (void *); 485extern void *BBitmap_data (void *);
486extern int BBitmap_convert (void *, void **); 486extern int BBitmap_convert (void *, void **);
487extern void be_draw_cross_on_pixmap (void *, int, int, int, int,
488 uint32_t);
487 489
488extern void BBitmap_free (void *); 490extern void BBitmap_free (void *);
489 491
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,
6307} 6307}
6308 6308
6309 6309
6310#if defined HAVE_X_WINDOWS || defined USE_CAIRO 6310#if defined HAVE_X_WINDOWS || defined USE_CAIRO || defined HAVE_HAIKU
6311static void 6311static void
6312image_pixmap_draw_cross (struct frame *f, Emacs_Pixmap pixmap, 6312image_pixmap_draw_cross (struct frame *f, Emacs_Pixmap pixmap,
6313 int x, int y, unsigned int width, unsigned int height, 6313 int x, int y, unsigned int width, unsigned int height,
@@ -6341,9 +6341,11 @@ image_pixmap_draw_cross (struct frame *f, Emacs_Pixmap pixmap,
6341 XDrawLine (dpy, pixmap, gc, x, y, x + width - 1, y + height - 1); 6341 XDrawLine (dpy, pixmap, gc, x, y, x + width - 1, y + height - 1);
6342 XDrawLine (dpy, pixmap, gc, x, y + height - 1, x + width - 1, y); 6342 XDrawLine (dpy, pixmap, gc, x, y + height - 1, x + width - 1, y);
6343 XFreeGC (dpy, gc); 6343 XFreeGC (dpy, gc);
6344#endif /* HAVE_X_WINDOWS */ 6344#elif HAVE_HAIKU
6345 be_draw_cross_on_pixmap (pixmap, x, y, width, height, color);
6346#endif
6345} 6347}
6346#endif /* HAVE_X_WINDOWS || USE_CAIRO */ 6348#endif /* HAVE_X_WINDOWS || USE_CAIRO || HAVE_HAIKU */
6347 6349
6348/* Transform image IMG on frame F so that it looks disabled. */ 6350/* Transform image IMG on frame F so that it looks disabled. */
6349 6351
@@ -6385,25 +6387,23 @@ image_disable_image (struct frame *f, struct image *img)
6385 { 6387 {
6386#ifndef HAVE_NTGUI 6388#ifndef HAVE_NTGUI
6387#ifndef HAVE_NS /* TODO: NS support, however this not needed for toolbars */ 6389#ifndef HAVE_NS /* TODO: NS support, however this not needed for toolbars */
6388#ifndef HAVE_HAIKU
6389 6390
6390#ifndef USE_CAIRO 6391#if !defined USE_CAIRO && !defined HAVE_HAIKU
6391#define CrossForeground(f) BLACK_PIX_DEFAULT (f) 6392#define CrossForeground(f) BLACK_PIX_DEFAULT (f)
6392#define MaskForeground(f) WHITE_PIX_DEFAULT (f) 6393#define MaskForeground(f) WHITE_PIX_DEFAULT (f)
6393#else /* USE_CAIRO */ 6394#else /* USE_CAIRO || HAVE_HAIKU */
6394#define CrossForeground(f) 0 6395#define CrossForeground(f) 0
6395#define MaskForeground(f) PIX_MASK_DRAW 6396#define MaskForeground(f) PIX_MASK_DRAW
6396#endif /* USE_CAIRO */ 6397#endif /* USE_CAIRO || HAVE_HAIKU */
6397 6398
6398#ifndef USE_CAIRO 6399#if !defined USE_CAIRO && !defined HAVE_HAIKU
6399 image_sync_to_pixmaps (f, img); 6400 image_sync_to_pixmaps (f, img);
6400#endif /* !USE_CAIRO */ 6401#endif /* !USE_CAIRO && !HAVE_HAIKU */
6401 image_pixmap_draw_cross (f, img->pixmap, 0, 0, img->width, img->height, 6402 image_pixmap_draw_cross (f, img->pixmap, 0, 0, img->width, img->height,
6402 CrossForeground (f)); 6403 CrossForeground (f));
6403 if (img->mask) 6404 if (img->mask)
6404 image_pixmap_draw_cross (f, img->mask, 0, 0, img->width, img->height, 6405 image_pixmap_draw_cross (f, img->mask, 0, 0, img->width, img->height,
6405 MaskForeground (f)); 6406 MaskForeground (f));
6406#endif /* !HAVE_HAIKU */
6407#endif /* !HAVE_NS */ 6407#endif /* !HAVE_NS */
6408#else 6408#else
6409 HDC hdc, bmpdc; 6409 HDC hdc, bmpdc;