8381039: Enhance AWT ImagingLib

Reviewed-by: mschoene, rhalade, azvegint, prr
This commit is contained in:
Jayathirth D V 2026-04-10 12:14:14 +00:00 committed by bchristi
parent 404a4dd177
commit 33e220059b

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -2218,7 +2218,11 @@ allocateArray(JNIEnv *env, BufImageS_t *imageP,
/* Means we need to fill in alpha */
if (!cvtToDefault && addAlpha) {
*mlibImagePP = (*sMlibSysFns.createFP)(MLIB_BYTE, 4, width, height);
if (*mlibImagePP != NULL) {
if (*mlibImagePP == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, rasterP->jdata, dataP,
JNI_ABORT);
return -1;
} else {
unsigned int *dstP = (unsigned int *)
mlib_ImageGetData(*mlibImagePP);
int dstride = (*mlibImagePP)->stride>>2;
@ -2234,10 +2238,10 @@ allocateArray(JNIEnv *env, BufImageS_t *imageP,
dP[x] = sP[x] | 0xff000000;
}
}
(*env)->ReleasePrimitiveArrayCritical(env, rasterP->jdata, dataP,
JNI_ABORT);
return 0;
}
(*env)->ReleasePrimitiveArrayCritical(env, rasterP->jdata, dataP,
JNI_ABORT);
return 0;
}
else if ((hintP->packing & BYTE_INTERLEAVED) == BYTE_INTERLEAVED) {
int nChans = (cmP->isDefaultCompatCM ? 4 : hintP->numChans);
@ -2252,6 +2256,11 @@ allocateArray(JNIEnv *env, BufImageS_t *imageP,
hintP->sStride,
(unsigned char *)dataP
+ hintP->dataOffset);
if (*mlibImagePP == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, rasterP->jdata, dataP,
JNI_ABORT);
return -1;
}
}
else if ((hintP->packing & SHORT_INTERLEAVED) == SHORT_INTERLEAVED) {
*mlibImagePP = (*sMlibSysFns.createStructFP)(MLIB_SHORT,
@ -2261,6 +2270,11 @@ allocateArray(JNIEnv *env, BufImageS_t *imageP,
imageP->raster.scanlineStride*2,
(unsigned short *)dataP
+ hintP->channelOffset);
if (*mlibImagePP == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, rasterP->jdata, dataP,
JNI_ABORT);
return -1;
}
}
else {
/* Release the data array */
@ -2360,6 +2374,11 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP,
width, height,
rasterP->scanlineStride*4,
(unsigned char *)dataP + offset);
if (*mlibImagePP == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, rasterP->jdata, dataP,
JNI_ABORT);
return -1;
}
*dataPP = dataP;
return 0;
case sun_awt_image_IntegerComponentRaster_TYPE_BYTE_SAMPLES:
@ -2388,6 +2407,11 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP,
width, height,
rasterP->scanlineStride,
(unsigned char *)dataP + offset);
if (*mlibImagePP == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, rasterP->jdata, dataP,
JNI_ABORT);
return -1;
}
*dataPP = dataP;
return 0;
case sun_awt_image_IntegerComponentRaster_TYPE_USHORT_SAMPLES:
@ -2418,6 +2442,11 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP,
width, height,
rasterP->scanlineStride*2,
(unsigned char *)dataP + offset);
if (*mlibImagePP == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, rasterP->jdata, dataP,
JNI_ABORT);
return -1;
}
*dataPP = dataP;
return 0;