[haiku-bugs] Re: [Haiku] #10007: OP_INVERT and anti-aliasing don't play together

  • From: "Pete" <trac@xxxxxxxxxxxx>
  • Date: Thu, 08 Dec 2016 01:05:45 -0000

#10007: OP_INVERT and anti-aliasing don't play together
----------------------------------+----------------------------
   Reporter:  Pete                |      Owner:  stippi
       Type:  bug                 |     Status:  assigned
   Priority:  normal              |  Milestone:  R1
  Component:  Kits/Interface Kit  |    Version:  R1/Development
 Resolution:                      |   Keywords:
 Blocked By:                      |   Blocking:
Has a Patch:  0                   |   Platform:  All
----------------------------------+----------------------------

Comment (by Pete):

 Replying to [comment:5 pulkomandy]:

It looks like removing the calls to BLEND_INVERT could work.
 Alternatively, we could tweak that function so that its operation is
 reversible, so we can get antialiasing without leaving artifacts on the
 background.

 Looking more closely, I don't think just removing BLEND_INVERT would do
 the job.  If you examine the pixels of an anti-aliased, slightly-slanted,
 line, you can see fairly large sections where there is no 100% (a=255)
 coverage of any written pixel.  You'd get gaps in the drawing.  As
 OP_INVERT is being fed the anti-aliased data, there's not much can be done
 about that.

 I think letting BLEND_INVERT draw pixels above a certain threshold
 coverage would work. It seems reasonable that 50% (>127) is probably the
 right threshold.

 (Thinking more about some kind of "scaled invertible blend", I think
 you're right and that it's not possible.  Trying to invert less than all
 the bits leads to crazy values.)

 Also, I don't think that setting alpha to 255, as the current code does,
 is correct.  This is not reversible.  I'd prefer that alpha was just left
 alone.

 So here's a suggested minimal rewrite of thos macros.  (I've switched to
 exclusive-or because I can't see any problem.)



 {{{
 // BLEND_INVERT
 // (threshold may be arbitrary.  leave alpha unchanged)
 #define BLEND_INVERT(d, a) \
  if (a > 127) { \
         d[0] = 255 ^ d[0]; \
         d[1] = 255 ^ d[1]; \
         d[2] = 255 ^ d[2]; \
 }

 // ASSIGN_INVERT
 // (leave alpha unchanged)
 #define ASSIGN_INVERT(d) \
 { \
         d[0] = 255 ^ d[0]; \
         d[1] = 255 ^ d[1]; \
         d[2] = 255 ^ d[2]; \
 }

 }}}

 Obviously the threshold check could be done in the invoking code rather
 than the macro, and the two could probably be merged a bit, but I don't
 have the ability to build a test ATM, so I'll leave it there.

--
Ticket URL: <https://dev.haiku-os.org/ticket/10007#comment:8>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: