]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix wide fringe bitmap processing on Haiku
authorPo Lu <luangruo@yahoo.com>
Mon, 14 Feb 2022 01:34:09 +0000 (01:34 +0000)
committerPo Lu <luangruo@yahoo.com>
Mon, 14 Feb 2022 01:36:50 +0000 (01:36 +0000)
* src/haiku_support.cc (BBitmap_import_mono_bits): Rewrite to
use ImportBits.
(BBitmap_import_fringe_bitmap): New function.

* src/haiku_support.h: Update prototypes.

* src/haikuterm.c (haiku_define_fringe_bitmap): Pass entire
short array to BBitmap_import_fringe_bitmap instead.

src/haiku_support.cc
src/haiku_support.h
src/haikuterm.c

index 5feb56b9f97d986511791cd03035f3b706f25fa2..ced680d2e53efef2142c51f6cfcb28d5c85f292e 100644 (file)
@@ -2187,21 +2187,40 @@ BView_mouse_moved (void *view, int x, int y, uint32_t transit)
     }
 }
 
-/* Import BITS into BITMAP using the B_GRAY1 colorspace.  */
+/* Import fringe bitmap (short array, low bit rightmost) BITS into
+   BITMAP using the B_GRAY1 colorspace.  */
 void
-BBitmap_import_mono_bits (void *bitmap, void *bits, int wd, int h)
+BBitmap_import_fringe_bitmap (void *bitmap, unsigned short *bits, int wd, int h)
 {
   BBitmap *bmp = (BBitmap *) bitmap;
   unsigned char *data = (unsigned char *) bmp->Bits ();
-  unsigned short *bts = (unsigned short *) bits;
+  int i;
 
-  for (int i = 0; i < (h * (wd / 8)); i++)
+  for (i = 0; i < h; i++)
     {
-      *((unsigned short *) data) = bts[i];
+      if (wd <= 8)
+       data[0] = bits[i] & 0xff;
+      else
+       {
+         data[1] = bits[i] & 0xff;
+         data[0] = bits[i] >> 8;
+       }
+
       data += bmp->BytesPerRow ();
     }
 }
 
+void
+BBitmap_import_mono_bits (void *bitmap, void *bits, int wd, int h)
+{
+  BBitmap *bmp = (BBitmap *) bitmap;
+
+  if (wd % 8)
+    wd += 8 - (wd % 8);
+
+  bmp->ImportBits (bits, wd / 8 * h, wd / 8, 0, B_GRAY1);
+}
+
 /* Make a scrollbar at X, Y known to the view VIEW.  */
 void
 BView_publish_scroll_bar (void *view, int x, int y, int width, int height)
index e6560f401ac2aeb28214aa9cb9a9a5502a3d8ee2..c9035d3dc0dd9bb5df094a3f357035db14f2c1c0 100644 (file)
@@ -631,6 +631,10 @@ extern "C"
   extern void
   BView_mouse_up (void *view, int x, int y);
 
+  extern void
+  BBitmap_import_fringe_bitmap (void *bitmap, unsigned short *bits,
+                               int wd, int h);
+
   extern void
   BBitmap_import_mono_bits (void *bitmap, void *bits, int wd, int h);
 
index f129eba0ccc25df7a9c0ae9befaaadb6af15bbe1..9d128f6a6a855566ad397d61f1e59d500d16d573 100644 (file)
@@ -2293,7 +2293,7 @@ haiku_define_fringe_bitmap (int which, unsigned short *bits,
     }
 
   fringe_bmps[which] = BBitmap_new (wd, h, 1);
-  BBitmap_import_mono_bits (fringe_bmps[which], bits, wd, h);
+  BBitmap_import_fringe_bitmap (fringe_bmps[which], bits, wd, h);
 }
 
 static void