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

Sergey Bylokhov serb at openjdk.org
Sun Nov 27 10:04:52 UTC 2022


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.

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

Commit messages:
 - Update SkipConversionIfPossible.java
 - Update SkipConversionIfPossible.java
 - make 4BYTE_ABGR_PRE to TYPE_INT_ARGB_PRE blit direct

Changes: https://git.openjdk.org/jdk/pull/11376/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11376&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8297681
  Stats: 98 lines in 2 files changed: 97 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/11376.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11376/head:pull/11376

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



More information about the client-libs-dev mailing list