emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 8a7d8bb04b: Implement `cross-disabled-images' on Haiku


From: Po Lu
Subject: master 8a7d8bb04b: Implement `cross-disabled-images' on Haiku
Date: Thu, 19 May 2022 22:28:47 -0400 (EDT)

branch: master
commit 8a7d8bb04b38ba9849b60d63c9fcfd36856eb424
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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.
---
 src/haiku_draw_support.cc | 37 +++++++++++++++++++++++++++++++++++++
 src/haiku_support.h       |  2 ++
 src/image.c               | 20 ++++++++++----------
 3 files changed, 49 insertions(+), 10 deletions(-)

diff --git a/src/haiku_draw_support.cc b/src/haiku_draw_support.cc
index 551af51d7c..f0cc084bb3 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 0bfd027c0d..b66486b1dc 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 18e9e72d83..058c175570 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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]