8296905: Replace the native LCMS#getProfileID() method with the accessor
Reviewed-by: prr
This commit is contained in:
parent
e10778acce
commit
defe0607e3
@ -52,6 +52,7 @@ import java.security.AccessController;
|
|||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import sun.awt.AWTAccessor;
|
||||||
import sun.java2d.cmm.CMSManager;
|
import sun.java2d.cmm.CMSManager;
|
||||||
import sun.java2d.cmm.PCMM;
|
import sun.java2d.cmm.PCMM;
|
||||||
import sun.java2d.cmm.Profile;
|
import sun.java2d.cmm.Profile;
|
||||||
@ -134,6 +135,10 @@ public sealed class ICC_Profile implements Serializable
|
|||||||
"GRAY.pf", ColorSpace.TYPE_GRAY, 1, CLASS_DISPLAY));
|
"GRAY.pf", ColorSpace.TYPE_GRAY, 1, CLASS_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
AWTAccessor.setICC_ProfileAccessor(ICC_Profile::cmmProfile);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Profile class is input.
|
* Profile class is input.
|
||||||
*/
|
*/
|
||||||
|
@ -27,6 +27,7 @@ package sun.awt;
|
|||||||
|
|
||||||
import javax.accessibility.AccessibleContext;
|
import javax.accessibility.AccessibleContext;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.color.ICC_Profile;
|
||||||
import java.awt.event.FocusEvent.Cause;
|
import java.awt.event.FocusEvent.Cause;
|
||||||
import java.awt.dnd.DragSourceContext;
|
import java.awt.dnd.DragSourceContext;
|
||||||
import java.awt.dnd.DropTargetContext;
|
import java.awt.dnd.DropTargetContext;
|
||||||
@ -50,6 +51,8 @@ import java.util.ResourceBundle;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import javax.accessibility.AccessibleBundle;
|
import javax.accessibility.AccessibleBundle;
|
||||||
|
|
||||||
|
import sun.java2d.cmm.Profile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AWTAccessor utility class.
|
* The AWTAccessor utility class.
|
||||||
* The main purpose of this class is to enable accessing
|
* The main purpose of this class is to enable accessing
|
||||||
@ -67,6 +70,16 @@ public final class AWTAccessor {
|
|||||||
private AWTAccessor() {
|
private AWTAccessor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An interface of accessor for the java.awt.color.ICC_Profile class.
|
||||||
|
*/
|
||||||
|
public interface ICC_ProfileAccessor {
|
||||||
|
/*
|
||||||
|
* Activates and returns the deferred standard profiles.
|
||||||
|
*/
|
||||||
|
Profile cmmProfile(ICC_Profile profile);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* An interface of accessor for the java.awt.Component class.
|
* An interface of accessor for the java.awt.Component class.
|
||||||
*/
|
*/
|
||||||
@ -831,6 +844,7 @@ public final class AWTAccessor {
|
|||||||
* Accessor instances are initialized in the static initializers of
|
* Accessor instances are initialized in the static initializers of
|
||||||
* corresponding AWT classes by using setters defined below.
|
* corresponding AWT classes by using setters defined below.
|
||||||
*/
|
*/
|
||||||
|
private static ICC_ProfileAccessor iccProfileAccessor;
|
||||||
private static ComponentAccessor componentAccessor;
|
private static ComponentAccessor componentAccessor;
|
||||||
private static ContainerAccessor containerAccessor;
|
private static ContainerAccessor containerAccessor;
|
||||||
private static WindowAccessor windowAccessor;
|
private static WindowAccessor windowAccessor;
|
||||||
@ -863,6 +877,25 @@ public final class AWTAccessor {
|
|||||||
private static DragSourceContextAccessor dragSourceContextAccessor;
|
private static DragSourceContextAccessor dragSourceContextAccessor;
|
||||||
private static DropTargetContextAccessor dropTargetContextAccessor;
|
private static DropTargetContextAccessor dropTargetContextAccessor;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set an accessor object for the java.awt.color.ICC_Profile class.
|
||||||
|
*/
|
||||||
|
public static void setICC_ProfileAccessor(ICC_ProfileAccessor ipa) {
|
||||||
|
iccProfileAccessor = ipa;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve the accessor object for the java.awt.color.ICC_Profile class.
|
||||||
|
*/
|
||||||
|
public static ICC_ProfileAccessor getICC_ProfileAccessor() {
|
||||||
|
var access = iccProfileAccessor;
|
||||||
|
if (access == null) {
|
||||||
|
ensureClassInitialized(ICC_Profile.class);
|
||||||
|
access = iccProfileAccessor;
|
||||||
|
}
|
||||||
|
return access;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set an accessor object for the java.awt.Component class.
|
* Set an accessor object for the java.awt.Component class.
|
||||||
*/
|
*/
|
||||||
|
@ -53,7 +53,7 @@ final class LCMS implements PCMM {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LCMSProfile getLcmsProfile(Profile p) {
|
static LCMSProfile getLcmsProfile(Profile p) {
|
||||||
if (p instanceof LCMSProfile) {
|
if (p instanceof LCMSProfile) {
|
||||||
return (LCMSProfile)p;
|
return (LCMSProfile)p;
|
||||||
}
|
}
|
||||||
@ -95,8 +95,6 @@ final class LCMS implements PCMM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static synchronized native LCMSProfile getProfileID(ICC_Profile profile);
|
|
||||||
|
|
||||||
/* Helper method used from LCMSColorTransfrom */
|
/* Helper method used from LCMSColorTransfrom */
|
||||||
static long createTransform(
|
static long createTransform(
|
||||||
LCMSProfile[] profiles, int renderingIntent,
|
LCMSProfile[] profiles, int renderingIntent,
|
||||||
|
@ -46,6 +46,7 @@ import java.awt.image.SampleModel;
|
|||||||
import java.awt.image.WritableRaster;
|
import java.awt.image.WritableRaster;
|
||||||
import java.lang.ref.Reference;
|
import java.lang.ref.Reference;
|
||||||
|
|
||||||
|
import sun.awt.AWTAccessor;
|
||||||
import sun.java2d.cmm.ColorTransform;
|
import sun.java2d.cmm.ColorTransform;
|
||||||
|
|
||||||
import static sun.java2d.cmm.lcms.LCMSImageLayout.ImageLayoutException;
|
import static sun.java2d.cmm.lcms.LCMSImageLayout.ImageLayoutException;
|
||||||
@ -85,9 +86,10 @@ final class LCMSTransform implements ColorTransform {
|
|||||||
* @param profiles the list of color profiles
|
* @param profiles the list of color profiles
|
||||||
*/
|
*/
|
||||||
LCMSTransform(int renderingIntent, ICC_Profile... profiles) {
|
LCMSTransform(int renderingIntent, ICC_Profile... profiles) {
|
||||||
|
var acc = AWTAccessor.getICC_ProfileAccessor();
|
||||||
lcmsProfiles = new LCMSProfile[profiles.length];
|
lcmsProfiles = new LCMSProfile[profiles.length];
|
||||||
for (int i = 0; i < profiles.length; i++) {
|
for (int i = 0; i < profiles.length; i++) {
|
||||||
lcmsProfiles[i] = LCMS.getProfileID(profiles[i]);
|
lcmsProfiles[i] = LCMS.getLcmsProfile(acc.cmmProfile(profiles[i]));
|
||||||
profiles[i].getNumComponents(); // force header initialization
|
profiles[i].getNumComponents(); // force header initialization
|
||||||
}
|
}
|
||||||
this.renderingIntent = (renderingIntent == ColorTransform.Any) ?
|
this.renderingIntent = (renderingIntent == ColorTransform.Any) ?
|
||||||
|
@ -557,40 +557,6 @@ JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_colorConvert
|
|||||||
releaseILData(env, outputBuffer, dstDType, dstData, 0);
|
releaseILData(env, outputBuffer, dstDType, dstData, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: sun_java2d_cmm_lcms_LCMS
|
|
||||||
* Method: getProfileID
|
|
||||||
* Signature: (Ljava/awt/color/ICC_Profile;)Lsun/java2d/cmm/lcms/LCMSProfile;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jobject JNICALL Java_sun_java2d_cmm_lcms_LCMS_getProfileID
|
|
||||||
(JNIEnv *env, jclass cls, jobject pf)
|
|
||||||
{
|
|
||||||
if (pf == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
jclass pcls = (*env)->GetObjectClass(env, pf);
|
|
||||||
if (pcls == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
jmethodID mid = (*env)->GetMethodID(env, pcls, "cmmProfile",
|
|
||||||
"()Lsun/java2d/cmm/Profile;");
|
|
||||||
if (mid == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
jobject cmmProfile = (*env)->CallObjectMethod(env, pf, mid);
|
|
||||||
if ((*env)->ExceptionCheck(env)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
jclass lcmsPCls = (*env)->FindClass(env, "sun/java2d/cmm/lcms/LCMSProfile");
|
|
||||||
if (lcmsPCls == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if ((*env)->IsInstanceOf(env, cmmProfile, lcmsPCls)) {
|
|
||||||
return cmmProfile;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static cmsBool _getHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize)
|
static cmsBool _getHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize)
|
||||||
{
|
{
|
||||||
cmsUInt32Number pfSize = 0;
|
cmsUInt32Number pfSize = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user