< prev index next >
src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m
Print this page
rev 54094 : 8257853: Remove dependencies on JNF's JNI utility functions in AWT and 2D code
rev 54096 : 8259651: [macOS] Replace JNF_COCOA_ENTER/EXIT macros
rev 54098 : 8260616: Removing remaining JNF dependencies in the java.desktop module
8259729: Missed JNFInstanceOf -> IsInstanceOf conversion
@@ -21,17 +21,17 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import "java_awt_geom_PathIterator.h"
#import "sun_font_CStrike.h"
#import "sun_font_CStrikeDisposer.h"
#import "CGGlyphImages.h"
#import "CGGlyphOutlines.h"
#import "CoreTextSupport.h"
+#import "JNIUtilities.h"
#include "fontscalerdefs.h"
@implementation AWTStrike
static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
@@ -101,11 +101,11 @@
#define AWT_FONT_CLEANUP_FINISH \
if (_fontThrowJavaException == YES) { \
char s[512]; \
sprintf(s, "%s-%s:%d", __FILE__, __FUNCTION__, __LINE__); \
- [JNFException raise:env as:kRuntimeException reason:s]; \
+ JNU_ThrowByName(env, "java/lang/RuntimeException", s); \
}
/*
* Creates an affine transform from the corresponding doubles sent
@@ -141,11 +141,11 @@
JNIEXPORT jfloat JNICALL
Java_sun_font_CStrike_getNativeGlyphAdvance
(JNIEnv *env, jclass clazz, jlong awtStrikePtr, jint glyphCode)
{
CGSize advance;
-JNF_COCOA_ENTER(env);
+JNI_COCOA_ENTER(env);
AWTStrike *awtStrike = (AWTStrike *)jlong_to_ptr(awtStrikePtr);
AWTFont *awtFont = awtStrike->fAWTFont;
// negative glyph codes are really unicodes, which were placed there by the mapper
// to indicate we should use CoreText to substitute the character
@@ -156,11 +156,11 @@
advance = CGSizeApplyAffineTransform(advance, awtStrike->fFontTx);
if (!JRSFontStyleUsesFractionalMetrics(awtStrike->fStyle)) {
advance.width = round(advance.width);
}
-JNF_COCOA_EXIT(env);
+JNI_COCOA_EXIT(env);
return advance.width;
}
/*
* Class: sun_font_CStrike
@@ -171,11 +171,11 @@
Java_sun_font_CStrike_getNativeGlyphImageBounds
(JNIEnv *env, jclass clazz,
jlong awtStrikePtr, jint glyphCode,
jobject result /*Rectangle*/, jdouble x, jdouble y)
{
-JNF_COCOA_ENTER(env);
+JNI_COCOA_ENTER(env);
AWTStrike *awtStrike = (AWTStrike *)jlong_to_ptr(awtStrikePtr);
AWTFont *awtFont = awtStrike->fAWTFont;
CGAffineTransform tx = awtStrike->fAltTx;
@@ -194,15 +194,17 @@
// the origin of this bounding box is relative to the bottom-left corner baseline
CGFloat decender = -bbox.origin.y;
bbox.origin.y = -bbox.size.height + decender;
// Rectangle2D.Float.setRect(float x, float y, float width, float height);
- static JNF_CLASS_CACHE(sjc_Rectangle2D_Float, "java/awt/geom/Rectangle2D$Float"); // cache class id for Rectangle
- static JNF_MEMBER_CACHE(sjr_Rectangle2DFloat_setRect, sjc_Rectangle2D_Float, "setRect", "(FFFF)V");
- JNFCallVoidMethod(env, result, sjr_Rectangle2DFloat_setRect, (jfloat)bbox.origin.x, (jfloat)bbox.origin.y, (jfloat)bbox.size.width, (jfloat)bbox.size.height);
+ DECLARE_CLASS(sjc_Rectangle2D_Float, "java/awt/geom/Rectangle2D$Float"); // cache class id for Rectangle
+ DECLARE_METHOD(sjr_Rectangle2DFloat_setRect, sjc_Rectangle2D_Float, "setRect", "(FFFF)V");
+ (*env)->CallVoidMethod(env, result, sjr_Rectangle2DFloat_setRect,
+ (jfloat)bbox.origin.x, (jfloat)bbox.origin.y, (jfloat)bbox.size.width, (jfloat)bbox.size.height);
+ CHECK_EXCEPTION();
-JNF_COCOA_EXIT(env);
+JNI_COCOA_EXIT(env);
}
/*
* Class: sun_font_CStrike
* Method: getNativeGlyphOutline
@@ -213,16 +215,19 @@
(JNIEnv *env, jclass clazz,
jlong awtStrikePtr, jint glyphCode, jdouble xPos, jdouble yPos)
{
jobject generalPath = NULL;
-JNF_COCOA_ENTER(env);
+JNI_COCOA_ENTER(env);
AWTPathRef path = NULL;
jfloatArray pointCoords = NULL;
jbyteArray pointTypes = NULL;
+ DECLARE_CLASS_RETURN(jc_GeneralPath, "java/awt/geom/GeneralPath", NULL);
+ DECLARE_METHOD_RETURN(jc_GeneralPath_ctor, jc_GeneralPath, "<init>", "(I[BI[FI)V", NULL);
+
AWT_FONT_CLEANUP_SETUP;
AWTStrike *awtStrike = (AWTStrike *)jlong_to_ptr(awtStrikePtr);
AWTFont *awtfont = awtStrike->fAWTFont;
@@ -261,13 +266,12 @@
pointTypes = (*env)->NewByteArray(env, path->fNumberOfSegments);
AWT_FONT_CLEANUP_CHECK(pointTypes);
(*env)->SetByteArrayRegion(env, pointTypes, 0, path->fNumberOfSegments, (jbyte*)path->fSegmentType);
- static JNF_CLASS_CACHE(jc_GeneralPath, "java/awt/geom/GeneralPath");
- static JNF_CTOR_CACHE(jc_GeneralPath_ctor, jc_GeneralPath, "(I[BI[FI)V");
- generalPath = JNFNewObject(env, jc_GeneralPath_ctor, java_awt_geom_PathIterator_WIND_NON_ZERO, pointTypes, path->fNumberOfSegments, pointCoords, path->fNumberOfDataElements); // AWT_THREADING Safe (known object)
+ generalPath = (*env)->NewObject(env, jc_GeneralPath, jc_GeneralPath_ctor, java_awt_geom_PathIterator_WIND_NON_ZERO, pointTypes,
+ path->fNumberOfSegments, pointCoords, path->fNumberOfDataElements); // AWT_THREADING Safe (known object)
// Cleanup
cleanup:
if (path != NULL) {
AWTPathFree(path);
@@ -283,11 +287,11 @@
(*env)->DeleteLocalRef(env, pointTypes);
pointTypes = NULL;
}
AWT_FONT_CLEANUP_FINISH;
-JNF_COCOA_EXIT(env);
+JNI_COCOA_EXIT(env);
return generalPath;
}
/*
* Class: sun_font_CStrike
@@ -298,11 +302,11 @@
Java_sun_font_CStrike_getGlyphImagePtrsNative
(JNIEnv *env, jclass clazz,
jlong awtStrikePtr, jlongArray glyphInfoLongArray,
jintArray glyphCodes, jint len)
{
-JNF_COCOA_ENTER(env);
+JNI_COCOA_ENTER(env);
AWTStrike *awtStrike = (AWTStrike *)jlong_to_ptr(awtStrikePtr);
jlong *glyphInfos =
(*env)->GetPrimitiveArrayCritical(env, glyphInfoLongArray, NULL);
@@ -326,11 +330,11 @@
(*env)->ReleasePrimitiveArrayCritical(env, glyphInfoLongArray,
glyphInfos, 0);
}
}
-JNF_COCOA_EXIT(env);
+JNI_COCOA_EXIT(env);
}
/*
* Class: sun_font_CStrike
* Method: createNativeStrikePtr
@@ -338,11 +342,11 @@
*/
JNIEXPORT jlong JNICALL Java_sun_font_CStrike_createNativeStrikePtr
(JNIEnv *env, jclass clazz, jlong nativeFontPtr, jdoubleArray glyphTxArray, jdoubleArray invDevTxArray, jint aaStyle, jint fmHint)
{
AWTStrike *awtStrike = nil;
-JNF_COCOA_ENTER(env);
+JNI_COCOA_ENTER(env);
AWTFont *awtFont = (AWTFont *)jlong_to_ptr(nativeFontPtr);
JRSFontRenderingStyle style = JRSFontGetRenderingStyleForHints(fmHint, aaStyle);
CGAffineTransform glyphTx = GetTxFromDoubles(env, glyphTxArray);
@@ -353,11 +357,11 @@
if (awtStrike)
{
CFRetain(awtStrike); // GC
}
-JNF_COCOA_EXIT(env);
+JNI_COCOA_EXIT(env);
return ptr_to_jlong(awtStrike);
}
/*
* Class: sun_font_CStrike
@@ -366,17 +370,17 @@
*/
JNIEXPORT void JNICALL
Java_sun_font_CStrike_disposeNativeStrikePtr
(JNIEnv *env, jclass clazz, jlong awtStrike)
{
-JNF_COCOA_ENTER(env);
+JNI_COCOA_ENTER(env);
if (awtStrike) {
CFRelease((AWTStrike *)jlong_to_ptr(awtStrike)); // GC
}
-JNF_COCOA_EXIT(env);
+JNI_COCOA_EXIT(env);
}
/*
* Class: sun_font_CStrike
* Method: getFontMetrics
@@ -386,11 +390,11 @@
Java_sun_font_CStrike_getFontMetrics
(JNIEnv *env, jclass clazz, jlong awtStrikePtr)
{
jobject metrics = NULL;
-JNF_COCOA_ENTER(env);
+JNI_COCOA_ENTER(env);
AWT_FONT_CLEANUP_SETUP;
AWTFont *awtfont = ((AWTStrike *)jlong_to_ptr(awtStrikePtr))->fAWTFont;
AWT_FONT_CLEANUP_CHECK(awtfont);
@@ -421,19 +425,19 @@
* leadingX: no need to set leadingX - it will be zero.
* leadingY: made-up number, but being compatible with what 1.4.x did.
* advance: no need to set yMaxLinearAdvanceWidth - it will be zero.
*/
- JNF_CLASS_CACHE(sjc_StrikeMetrics, "sun/font/StrikeMetrics");
- JNF_CTOR_CACHE(strikeMetricsCtr, sjc_StrikeMetrics, "(FFFFFFFFFF)V");
- metrics = JNFNewObject(env, strikeMetricsCtr,
+ DECLARE_CLASS_RETURN(sjc_StrikeMetrics, "sun/font/StrikeMetrics", NULL);
+ DECLARE_METHOD_RETURN(strikeMetricsCtr, sjc_StrikeMetrics, "<init>", "(FFFFFFFFFF)V", NULL);
+ metrics = (*env)->NewObject(env, sjc_StrikeMetrics, strikeMetricsCtr,
0.0, ay, 0.0, dy, 1.0,
0.0, 0.0, ly, mx, 0.0);
cleanup:
AWT_FONT_CLEANUP_FINISH;
-JNF_COCOA_EXIT(env);
+JNI_COCOA_EXIT(env);
return metrics;
}
extern void AccelGlyphCache_RemoveAllInfos(GlyphInfo* glyph);
@@ -443,11 +447,11 @@
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_sun_font_CStrikeDisposer_removeGlyphInfoFromCache
(JNIEnv *env, jclass cls, jlong glyphInfo)
{
- JNF_COCOA_ENTER(env);
+ JNI_COCOA_ENTER(env);
AccelGlyphCache_RemoveAllCellInfos((GlyphInfo*)jlong_to_ptr(glyphInfo));
- JNF_COCOA_EXIT(env);
+ JNI_COCOA_EXIT(env);
}
< prev index next >