8299425: "LCMSImageLayout.isIntPacked" flag can be deleted

Reviewed-by: prr
This commit is contained in:
Sergey Bylokhov 2023-01-06 20:17:10 +00:00
parent d6d6eb4cba
commit 4a95c74b76
4 changed files with 20 additions and 44 deletions
src/java.desktop/share
classes/sun/java2d/cmm/lcms
native/liblcms

@ -96,11 +96,9 @@ final class LCMS implements PCMM {
}
/* Helper method used from LCMSColorTransfrom */
static long createTransform(
LCMSProfile[] profiles, int renderingIntent,
int inFormatter, boolean isInIntPacked,
int outFormatter, boolean isOutIntPacked,
Object disposerRef)
static long createTransform(LCMSProfile[] profiles, int renderingIntent,
int inFormatter, int outFormatter,
Object disposerRef)
{
long[] ptrs = new long[profiles.length];
long stamp = lock.readLock();
@ -113,17 +111,17 @@ final class LCMS implements PCMM {
}
return createNativeTransform(ptrs, renderingIntent, inFormatter,
isInIntPacked, outFormatter, isOutIntPacked, disposerRef);
outFormatter, disposerRef);
} finally {
lock.unlockRead(stamp);
}
}
private static native long createNativeTransform(
long[] profileIDs, int renderingIntent,
int inFormatter, boolean isInIntPacked,
int outFormatter, boolean isOutIntPacked,
Object disposerRef);
private static native long createNativeTransform(long[] profileIDs,
int renderingIntent,
int inFormatter,
int outFormatter,
Object disposerRef);
/**
* Constructs ColorTransform object corresponding to the ICC_profiles.

@ -31,11 +31,14 @@ import java.awt.image.ColorModel;
import java.awt.image.ComponentColorModel;
import java.awt.image.ComponentSampleModel;
import java.awt.image.Raster;
import java.nio.ByteOrder;
import sun.awt.image.ByteComponentRaster;
import sun.awt.image.IntegerComponentRaster;
import sun.awt.image.ShortComponentRaster;
import static java.nio.ByteOrder.LITTLE_ENDIAN;
final class LCMSImageLayout {
static int BYTES_SH(int x) {
@ -59,12 +62,12 @@ final class LCMSImageLayout {
private static final int PT_BGR_8 = PT_RGB_8 | DOSWAP;
private static final int PT_ABGR_8 = PT_BGR_8 | EXTRA_SH(1);
// private static final int PT_BGRA_8 = PT_ABGR_8 | SWAPFIRST;
private static final int SWAP_ENDIAN =
ByteOrder.nativeOrder() == LITTLE_ENDIAN ? DOSWAP : 0;
private static final int DT_BYTE = 0;
private static final int DT_SHORT = 1;
private static final int DT_INT = 2;
private static final int DT_DOUBLE = 3;
boolean isIntPacked = false;
int pixelType;
int dataType;
int width;
@ -143,16 +146,13 @@ final class LCMSImageLayout {
switch (image.getType()) {
case BufferedImage.TYPE_INT_RGB:
l.pixelType = PT_ARGB_8;
l.isIntPacked = true;
l.pixelType = PT_ARGB_8 ^ SWAP_ENDIAN;
break;
case BufferedImage.TYPE_INT_ARGB:
l.pixelType = PT_ARGB_8;
l.isIntPacked = true;
l.pixelType = PT_ARGB_8 ^ SWAP_ENDIAN;
break;
case BufferedImage.TYPE_INT_BGR:
l.pixelType = PT_ABGR_8;
l.isIntPacked = true;
l.pixelType = PT_ABGR_8 ^ SWAP_ENDIAN;
break;
case BufferedImage.TYPE_3BYTE_BGR:
l.pixelType = PT_BGR_8;

@ -53,15 +53,10 @@ final class LCMSTransform implements ColorTransform {
private static final class NativeTransform {
private long ID;
private int inFormatter;
private boolean isInIntPacked;
private int outFormatter;
private boolean isOutIntPacked;
private boolean match(LCMSImageLayout in, LCMSImageLayout out) {
return inFormatter == in.pixelType
&& isInIntPacked == in.isIntPacked
&& outFormatter == out.pixelType
&& isOutIntPacked == out.isIntPacked;
return inFormatter == in.pixelType && outFormatter == out.pixelType;
}
}
@ -115,16 +110,10 @@ final class LCMSTransform implements ColorTransform {
if (tfm == null || !tfm.match(in, out)) {
tfm = new NativeTransform();
tfm.inFormatter = in.pixelType;
tfm.isInIntPacked = in.isIntPacked;
tfm.outFormatter = out.pixelType;
tfm.isOutIntPacked = out.isIntPacked;
tfm.ID = LCMS.createTransform(lcmsProfiles, renderingIntent,
tfm.inFormatter,
tfm.isInIntPacked,
tfm.outFormatter,
tfm.isOutIntPacked, tfm);
tfm.outFormatter, tfm);
// Disposer will destroy forgotten transform
transform = tfm;
}

@ -142,8 +142,7 @@ static void ThrowIllegalArgumentException(JNIEnv *env, const char *msg) {
*/
JNIEXPORT jlong JNICALL Java_sun_java2d_cmm_lcms_LCMS_createNativeTransform
(JNIEnv *env, jclass cls, jlongArray profileIDs, jint renderingIntent,
jint inFormatter, jboolean isInIntPacked,
jint outFormatter, jboolean isOutIntPacked, jobject disposerRef)
jint inFormatter, jint outFormatter, jobject disposerRef)
{
cmsHPROFILE _iccArray[DF_ICC_BUF_SIZE];
cmsHPROFILE *iccArray = &_iccArray[0];
@ -158,16 +157,6 @@ JNIEXPORT jlong JNICALL Java_sun_java2d_cmm_lcms_LCMS_createNativeTransform
return 0L;
}
#ifdef _LITTLE_ENDIAN
/* Reversing data packed into int for LE archs */
if (isInIntPacked) {
inFormatter ^= DOSWAP_SH(1);
}
if (isOutIntPacked) {
outFormatter ^= DOSWAP_SH(1);
}
#endif
if (DF_ICC_BUF_SIZE < size*2) {
iccArray = (cmsHPROFILE*) malloc(
size*2*sizeof(cmsHPROFILE));