unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Fringe icon color is wrong on OSX
@ 2015-07-15  3:16 Feng Li
  2015-07-15  5:53 ` Bozhidar Batsov
  0 siblings, 1 reply; 4+ messages in thread
From: Feng Li @ 2015-07-15  3:16 UTC (permalink / raw)
  To: emacs-devel

Fringe icons have incorrect background and foreground colors in the git
master version of Emacs.

There are 2 issues:

1. The icon is drawn with background color instead of foreground color.

2. The icon background is opaque (and is in foreground color) instead of
being transparent.

I tracked it down to this commit:

67a878f * Honor :fore/background for XBM on NS (Bug#14969).

The attached patch fixes the fringe icon issue for me.  I haven't tested it
extensively with other XBM image use case though.


diff --git a/src/nsimage.m b/src/nsimage.m
index 9302cd2..33c355a 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -250,18 +250,19 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
           c = *s++;
           for (k = 0; i < w && k < 8; ++k, ++i)
             {
-              *alpha++ = 0xff;
-              if (c & 1)
+              if ((c & 1) == 0)
                 {
                   *rr++ = fgr;
                   *gg++ = fgg;
                   *bb++ = fgb;
+                  *alpha++ = 0xff;
                 }
               else
                 {
                   *rr++ = bgr;
                   *gg++ = bgg;
                   *bb++ = bgb;
+                  *alpha++ = 0;
                 }
               idx++;
               c >>= 1;

--
Feng Li






^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Fringe icon color is wrong on OSX
  2015-07-15  3:16 Fringe icon color is wrong on OSX Feng Li
@ 2015-07-15  5:53 ` Bozhidar Batsov
  2015-08-07  1:55   ` Feng Li
  0 siblings, 1 reply; 4+ messages in thread
From: Bozhidar Batsov @ 2015-07-15  5:53 UTC (permalink / raw)
  To: Feng Li; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1578 bytes --]

I wondered why the fringe icons were looking so terrible for me on master.
Thanks for the patch! I hope it will be merged soon.

On 15 July 2015 at 06:16, Feng Li <fengli@gmail.com> wrote:

> Fringe icons have incorrect background and foreground colors in the git
> master version of Emacs.
>
> There are 2 issues:
>
> 1. The icon is drawn with background color instead of foreground color.
>
> 2. The icon background is opaque (and is in foreground color) instead of
> being transparent.
>
> I tracked it down to this commit:
>
> 67a878f * Honor :fore/background for XBM on NS (Bug#14969).
>
> The attached patch fixes the fringe icon issue for me.  I haven't tested it
> extensively with other XBM image use case though.
>
>
> diff --git a/src/nsimage.m b/src/nsimage.m
> index 9302cd2..33c355a 100644
> --- a/src/nsimage.m
> +++ b/src/nsimage.m
> @@ -250,18 +250,19 @@ ns_set_alpha (void *img, int x, int y, unsigned char
> a)
>            c = *s++;
>            for (k = 0; i < w && k < 8; ++k, ++i)
>              {
> -              *alpha++ = 0xff;
> -              if (c & 1)
> +              if ((c & 1) == 0)
>                  {
>                    *rr++ = fgr;
>                    *gg++ = fgg;
>                    *bb++ = fgb;
> +                  *alpha++ = 0xff;
>                  }
>                else
>                  {
>                    *rr++ = bgr;
>                    *gg++ = bgg;
>                    *bb++ = bgb;
> +                  *alpha++ = 0;
>                  }
>                idx++;
>                c >>= 1;
>
> --
> Feng Li
>
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 2242 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fringe icon color is wrong on OSX
  2015-07-15  5:53 ` Bozhidar Batsov
@ 2015-08-07  1:55   ` Feng Li
  2015-08-07  7:08     ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Feng Li @ 2015-08-07  1:55 UTC (permalink / raw)
  To: Bozhidar Batsov; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 3862 bytes --]

The previous patch fixes the background color but there's another problem:
the fringe bitmaps are left/right flipped.
I don't have time to track down to the root cause of these bugs but this
new patch fixes both color and flipping for me.

  0 git … diff
diff --git a/src/nsimage.m b/src/nsimage.m
index 9302cd2..33c355a 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -250,18 +250,19 @@ ns_set_alpha (void *img, int x, int y, unsigned char
a)
           c = *s++;
           for (k = 0; i < w && k < 8; ++k, ++i)
             {
-              *alpha++ = 0xff;
-              if (c & 1)
+              if ((c & 1) == 0)
                 {
                   *rr++ = fgr;
                   *gg++ = fgg;
                   *bb++ = fgb;
+                  *alpha++ = 0xff;
                 }
               else
                 {
                   *rr++ = bgr;
                   *gg++ = bgg;
                   *bb++ = bgb;
+                  *alpha++ = 0;
                 }
               idx++;
               c >>= 1;
diff --git a/src/nsterm.m b/src/nsterm.m
index 2806f31..b7b7f93 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2321,7 +2321,15 @@ ns_draw_fringe_bitmap (struct window *w, struct
glyph_row *row,
           unsigned char *cbits = xmalloc (len);

           for (i = 0; i < len; i++)
-            cbits[i] = ~(bits[i] & 0xff);
+            {
+              const static unsigned char lut[] = {
+                (~0x0)&0xf, (~0x8)&0xf, (~0x4)&0xf, (~0xc)&0xf,
+                (~0x2)&0xf, (~0xa)&0xf, (~0x6)&0xf, (~0xe)&0xf,
+                (~0x1)&0xf, (~0x9)&0xf, (~0x5)&0xf, (~0xd)&0xf,
+                (~0x3)&0xf, (~0xb)&0xf, (~0x7)&0xf, (~0xf)&0xf };
+              cbits[i] = (lut[bits[i]&0xf]<<4)|(lut[(bits[i]>>4)&0xf]);
+              // cbits[i] = ~(bits[i] & 0xff);
+            }
           img = [[EmacsImage alloc] initFromXBM: cbits width: 8 height:
p->h
                                              fg: 0 bg: 0];
           bimgs[p->which - 1] = img;




On Wed, Jul 15, 2015 at 3:53 PM, Bozhidar Batsov <bozhidar@batsov.com>
wrote:

> I wondered why the fringe icons were looking so terrible for me on master.
> Thanks for the patch! I hope it will be merged soon.
>
> On 15 July 2015 at 06:16, Feng Li <fengli@gmail.com> wrote:
>
>> Fringe icons have incorrect background and foreground colors in the git
>> master version of Emacs.
>>
>> There are 2 issues:
>>
>> 1. The icon is drawn with background color instead of foreground color.
>>
>> 2. The icon background is opaque (and is in foreground color) instead of
>> being transparent.
>>
>> I tracked it down to this commit:
>>
>> 67a878f * Honor :fore/background for XBM on NS (Bug#14969).
>>
>> The attached patch fixes the fringe icon issue for me.  I haven't tested
>> it
>> extensively with other XBM image use case though.
>>
>>
>> diff --git a/src/nsimage.m b/src/nsimage.m
>> index 9302cd2..33c355a 100644
>> --- a/src/nsimage.m
>> +++ b/src/nsimage.m
>> @@ -250,18 +250,19 @@ ns_set_alpha (void *img, int x, int y, unsigned
>> char a)
>>            c = *s++;
>>            for (k = 0; i < w && k < 8; ++k, ++i)
>>              {
>> -              *alpha++ = 0xff;
>> -              if (c & 1)
>> +              if ((c & 1) == 0)
>>                  {
>>                    *rr++ = fgr;
>>                    *gg++ = fgg;
>>                    *bb++ = fgb;
>> +                  *alpha++ = 0xff;
>>                  }
>>                else
>>                  {
>>                    *rr++ = bgr;
>>                    *gg++ = bgg;
>>                    *bb++ = bgb;
>> +                  *alpha++ = 0;
>>                  }
>>                idx++;
>>                c >>= 1;
>>
>> --
>> Feng Li
>>
>>
>>
>>
>>
>


-- 
Feng Li

[-- Attachment #2: Type: text/html, Size: 5591 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Fringe icon color is wrong on OSX
  2015-08-07  1:55   ` Feng Li
@ 2015-08-07  7:08     ` Andreas Schwab
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2015-08-07  7:08 UTC (permalink / raw)
  To: Feng Li; +Cc: Bozhidar Batsov, emacs-devel

Feng Li <fengli@gmail.com> writes:

> +                (~0x0)&0xf, (~0x8)&0xf, (~0x4)&0xf, (~0xc)&0xf,
                   0x0^0xf, 0x8^0xf, 0x4^0xf, 0xc^0xf,

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-07  7:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-15  3:16 Fringe icon color is wrong on OSX Feng Li
2015-07-15  5:53 ` Bozhidar Batsov
2015-08-07  1:55   ` Feng Li
2015-08-07  7:08     ` Andreas Schwab

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).