RFR: 8297681: Unnecessary color conversion during 4BYTE_ABGR_PRE to INT_ARGB_PRE blit

Laurent Bourgès lbourges at openjdk.org
Mon Nov 28 11:00:07 UTC 2022


On Sun, 27 Nov 2022 06:26:48 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> I have found that drawing the BufferedImage.4BYTE_ABGR_PRE to the INT_ARGB_PRE image caused java2d to do an additional conversion from/to ARGB format. That conversion is done via a native [loop](https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/java.desktop/share/native/libawt/java2d/loops/AlphaMath.c#L32) which tries to approximate the math,  it is better to skip such conversion.
> 
> An additional benefit is ~x2 performance improvements of this blit, so it will have the same performance as the opposite INT_ARGB_PRE to 4BYTE_ABGR_PRE blit. 
> 
> 
> global.dest=BufImg(IntArgbPre),graphics.imaging.src=4ByteAbgrPre
> translucent,graphics.opts.alpharule=Src,graphics.opts.sizes=100:
> fix: 286439.77665 (var=3.42%) (100.0%)
> ***********************************************************|
> ***********************************************************|
> ********************************************************** |
> base: 167280.80808 (var=1.8%) (58.4%)
> ********************************** |
> ********************************** |
> ********************************** | 
> 
> global.dest=BufImg(IntArgbPre),graphics.imaging.src=4ByteAbgrPre
> translucent,graphics.opts.alpharule=SrcOver,graphics.opts.sizes=100:
> fix: 325989.80002 (var=1.58%) (100.0%)
> *********************************************************** |
> ************************************************************|
> ************************************************************|
> base: 200830.44521 (var=1.58%) (61.61%)
> ************************************* |
> ************************************* |
> ************************************* | 
> 
> 
> To implement direct 4BYTE_ABGR_PRE to INT_ARGB_PRE blit it is necessary to "declare" and "register" blit only, all other macros are already in place.

Excellent finding !
LGTM, not an official reviewer.

-------------

PR: https://git.openjdk.org/jdk/pull/11376



More information about the client-libs-dev mailing list