[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    [OpenJDK 2D-Dev] Marlin 0.9.5 with experimental pure-java alpha blending
From:       Laurent_Bourgès <bourges.laurent () gmail ! com>
Date:       2020-07-28 8:24:21
Message-ID: CAKjRUT5dQ9qxEoYou+O7icMkynSmUV250e7AhDEnJ7pkKtOWKw () mail ! gmail ! com
[Download RAW message or body]

Hi,

For 3 months I worked on an improved alpha blending method in the Marlin
renderer project (on github):
https://github.com/bourgesl/marlin-renderer/tree/unsafe-dev

It is implemented as a pure-java  experimental code that rewrite alpha
compositing operations (SRC_OVER) to perform gamma-correction (sRGB
profile) before/after any pixel operation to properly mix colors in RGB
linear space.

As dark shades looks then lighter, in particular for font or thin shapes
(black over white), I implemented several correction algorithms based on
luminance & contrast correction that adjusts alpha values.

It is tricky as the ideal correction would require enlarging stroke width
or polygon fills... but it would change coverage algebra= overlaps... that
may need API enhancements at least. I forgave this direction as no simple &
automatic solution exists.
Finally I have 3 compositor modes: linear / hybrid / perceptual.

See the latest Marlin renderer 0.9.5 EA release notes:
https://github.com/bourgesl/marlin-renderer/releases/tag/v0_9_5_0_EA_b2

Visual comparison:
https://bourgesl.github.io/gamma-correction/GRID_FONT.final/index.html

It is only working up to now on buffered images (off-screen INT_ARGB) but
the performance (java + unsafe) is now as good as the former C software
loops.

I wonder if:
- there is any interest in improving java2d color handling in 2020 ? it is
a behaviour change that must be discussed first.
- how to proceed for a possible OpenJDK integration? Use java code like my
hack or fix C macros / loops to use this new approach / maths ?
- How to fix accelerated pipelines (opengl, directx, metal) too ?
- who would help me ?

Any comment or feedback on this topic ?

Thanks,
Laurent

[Attachment #3 (text/html)]

<div dir="auto"><span style="font-family:sans-serif;font-size:12.8px">Hi,</span><div \
dir="auto" style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">For 3 months I worked on an improved \
alpha blending method in the Marlin renderer project (on github):  </div><div \
dir="auto" style="font-family:sans-serif;font-size:12.8px"><a \
href="https://github.com/bourgesl/marlin-renderer/tree/unsafe-dev" \
style="text-decoration-line:none;color:rgb(66,133,244)">https://github.com/bourgesl/marlin-renderer/tree/unsafe-dev</a><br></div><div \
dir="auto" style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">It is implemented as a pure-java   \
experimental code that rewrite alpha compositing operations (SRC_OVER) to perform \
gamma-correction (sRGB profile) before/after any pixel operation to properly mix \
colors in RGB linear space.</div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">As dark shades looks then lighter, in \
particular for font or thin shapes (black over white), I implemented several \
correction algorithms based on luminance &amp; contrast correction that adjusts alpha \
values.  </div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">It is tricky as the ideal correction \
would require enlarging stroke width or polygon fills... but it would change coverage \
algebra= overlaps... that may need API enhancements at least. I forgave this \
direction as no simple &amp; automatic solution exists.</div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">Finally I have 3 compositor modes: \
linear / hybrid / perceptual.</div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">See the latest Marlin renderer 0.9.5 \
EA release notes:</div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px"><a \
href="https://github.com/bourgesl/marlin-renderer/releases/tag/v0_9_5_0_EA_b2" \
style="text-decoration-line:none;color:rgb(66,133,244)">https://github.com/bourgesl/marlin-renderer/releases/tag/v0_9_5_0_EA_b2</a><br></div><div \
dir="auto" style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">Visual comparison:</div><div \
dir="auto" style="font-family:sans-serif;font-size:12.8px"><a \
href="https://bourgesl.github.io/gamma-correction/GRID_FONT.final/index.html" \
style="text-decoration-line:none;color:rgb(66,133,244)">https://bourgesl.github.io/gamma-correction/GRID_FONT.final/index.html</a></div><div \
dir="auto" style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">It is only working up to now on \
buffered images (off-screen INT_ARGB) but the performance (java + unsafe) is now as \
good as the former C software loops.</div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">I wonder if:</div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">- there is any interest in improving \
java2d color handling in 2020 ? it is a behaviour change that must be discussed \
first.</div><div dir="auto" style="font-family:sans-serif;font-size:12.8px">- how to \
proceed for a possible OpenJDK integration? Use java code like my hack or fix C \
macros / loops to use this new approach / maths ?</div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">- How to fix accelerated pipelines \
(opengl, directx, metal) too ?</div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">- who would help me ?</div><div \
dir="auto" style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" \
style="font-family:sans-serif;font-size:12.8px">Any comment or feedback on this topic \
?</div><div dir="auto" style="font-family:sans-serif;font-size:12.8px"><br></div><div \
dir="auto" style="font-family:sans-serif;font-size:12.8px">Thanks,</div><div \
dir="auto" style="font-family:sans-serif;font-size:12.8px">Laurent</div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic