/*
 * Class:     sun_awt_font_X11TextRenderer
 * Method:    doDrawGlyphList
 * Signature: (Lsun/java2d/SurfaceData;Ljava/awt/Rectangle;ILsun/awt/font/GlyphList;J)V
 */
JNIEXPORT void JNICALL Java_sun_awt_font_X11TextRenderer_doDrawGlyphList
    (JNIEnv *env, jobject xtr,
     jobject sData, jobject clip, jint pixel,
     jobject glist, jlong glpeer)
{
    SurfaceDataBounds bounds;
    SurfaceData_GetBoundsFromRegion(env, clip, &bounds);

    GlyphVector &gv = *(GlyphVector*)jlong_to_ptr(glpeer);
    if (!RefineBounds(gv, &bounds)) {
        return;
    }
    AWTDrawGlyphList(env, xtr, sData, clip, pixel, glist, glpeer,
		     &bounds, gv.getGlyphImages(), gv.getNumGlyphs());
}
Пример #2
0
/*
 * Class:     sun_java2d_loops_DrawPolygons
 * Method:    DrawPolygons
 * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;[I[I[IIIIZ)V
 */
JNIEXPORT void JNICALL
Java_sun_java2d_loops_DrawPolygons_DrawPolygons
    (JNIEnv *env, jobject self,
     jobject sg2d, jobject sData,
     jintArray xPointsArray, jintArray yPointsArray,
     jintArray nPointsArray, jint numPolys,
     jint transX, jint transY, jboolean close)
{
    SurfaceDataOps *sdOps;
    SurfaceDataRasInfo rasInfo;
    NativePrimitive *pPrim;
    CompositeInfo compInfo;
    jsize nPointsLen, xPointsLen, yPointsLen;
    jint *nPointsPtr = NULL;
    jint *xPointsPtr = NULL;
    jint *yPointsPtr = NULL;
    jint pointsNeeded;
    jint i, ret;
    jboolean ok = JNI_TRUE;
    jint pixel = GrPrim_Sg2dGetPixel(env, sg2d);

    if (JNU_IsNull(env, xPointsArray) || JNU_IsNull(env, yPointsArray)) {
	JNU_ThrowNullPointerException(env, "coordinate array");
	return;
    }
    if (JNU_IsNull(env, nPointsArray)) {
	JNU_ThrowNullPointerException(env, "polygon length array");
	return;
    }

    nPointsLen = (*env)->GetArrayLength(env, nPointsArray);
    xPointsLen = (*env)->GetArrayLength(env, xPointsArray);
    yPointsLen = (*env)->GetArrayLength(env, yPointsArray);
    if (nPointsLen < numPolys) {
	JNU_ThrowArrayIndexOutOfBoundsException(env,
						"polygon length array size");
	return;
    }

    pPrim = GetNativePrim(env, self);
    if (pPrim == NULL) {
	return;
    }
    if (pPrim->pCompType->getCompInfo != NULL) { 
        GrPrim_Sg2dGetCompInfo(env, sg2d, pPrim, &compInfo); 
    }

    sdOps = SurfaceData_GetOps(env, sData);
    if (sdOps == 0) {
	return;
    }

    GrPrim_Sg2dGetClip(env, sg2d, &rasInfo.bounds);

    ret = sdOps->Lock(env, sdOps, &rasInfo, SD_LOCK_FASTEST | pPrim->dstflags);
    if (ret == SD_FAILURE) {
	return;
    }

    nPointsPtr = (*env)->GetPrimitiveArrayCritical(env, nPointsArray, NULL);
    if (!nPointsPtr) {
	ok = JNI_FALSE;
    }

    if (ok) {
	pointsNeeded = 0;
	for (i = 0; i < numPolys; i++) {
	    if (nPointsPtr[i] > 0) {
		pointsNeeded += nPointsPtr[i];
	    }
	}

	if (yPointsLen < pointsNeeded || xPointsLen < pointsNeeded) {
	    (*env)->ReleasePrimitiveArrayCritical(env, nPointsArray,
						  nPointsPtr, JNI_ABORT);
	    SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
	    JNU_ThrowArrayIndexOutOfBoundsException(env,
						    "coordinate array length");
	    return;
	}

	xPointsPtr = (*env)->GetPrimitiveArrayCritical(env, xPointsArray, NULL);
	yPointsPtr = (*env)->GetPrimitiveArrayCritical(env, yPointsArray, NULL);
	if (!xPointsPtr || !yPointsPtr) {
	    ok = JNI_FALSE;
	}
    }

    if (ok) {
	if (ret == SD_SLOWLOCK) {
	    RefineBounds(&rasInfo.bounds, transX, transY,
			 xPointsPtr, yPointsPtr, pointsNeeded);
	    ok = (rasInfo.bounds.x2 > rasInfo.bounds.x1 &&
		  rasInfo.bounds.y2 > rasInfo.bounds.y1);
	}
    }

    if (ok) {
	sdOps->GetRasInfo(env, sdOps, &rasInfo);
	if (rasInfo.rasBase &&
	    rasInfo.bounds.x2 > rasInfo.bounds.x1 &&
	    rasInfo.bounds.y2 > rasInfo.bounds.y1)
	{
	    ProcessPoly(&rasInfo, pPrim->funcs.drawline, pPrim, &compInfo, 
                        pixel, transX, transY,
			xPointsPtr, yPointsPtr,
			nPointsPtr, numPolys,
			close);
	}
	SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
    }

    if (nPointsPtr) {
	(*env)->ReleasePrimitiveArrayCritical(env, nPointsArray,
					      nPointsPtr, JNI_ABORT);
    }
    if (xPointsPtr) {
	(*env)->ReleasePrimitiveArrayCritical(env, xPointsArray,
					      xPointsPtr, JNI_ABORT);
    }
    if (yPointsPtr) {
	(*env)->ReleasePrimitiveArrayCritical(env, yPointsArray,
					      yPointsPtr, JNI_ABORT);
    }
    SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
}
Пример #3
0
static void drawGlyphListLCD(JNIEnv *env, jobject self,
                          jobject sg2d, jobject sData,
                          GlyphBlitVector *gbv, jint pixel, jint color,
                          jboolean rgbOrder, int contrast,
                          NativePrimitive *pPrim,
                          DrawGlyphListLCDFunc *func) {

    SurfaceDataOps *sdOps;
    SurfaceDataRasInfo rasInfo;
    CompositeInfo compInfo;
    int clipLeft, clipRight, clipTop, clipBottom;
    int ret;

    sdOps = SurfaceData_GetOps(env, sData);
    if (sdOps == 0) {
        return;
    }

    if (pPrim->pCompType->getCompInfo != NULL) {
        GrPrim_Sg2dGetCompInfo(env, sg2d, pPrim, &compInfo);
    }

    GrPrim_Sg2dGetClip(env, sg2d, &rasInfo.bounds);
    if (rasInfo.bounds.y2 <= rasInfo.bounds.y1 ||
        rasInfo.bounds.x2 <= rasInfo.bounds.x1)
    {
        return;
    }

    ret = sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags);
    if (ret != SD_SUCCESS) {
        if (ret == SD_SLOWLOCK) {
            if (!RefineBounds(gbv, &rasInfo.bounds)) {
                SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
                return;
            }
        } else {
            return;
        }
    }

    sdOps->GetRasInfo(env, sdOps, &rasInfo);
    if (!rasInfo.rasBase) {
        SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
        return;
    }
    clipLeft    = rasInfo.bounds.x1;
    clipRight   = rasInfo.bounds.x2;
    clipTop     = rasInfo.bounds.y1;
    clipBottom  = rasInfo.bounds.y2;

    if (clipRight > clipLeft && clipBottom > clipTop) {

        (*func)(&rasInfo,
                gbv->glyphs, gbv->numGlyphs,
                pixel, color,
                clipLeft, clipTop,
                clipRight, clipBottom, (jint)rgbOrder,
                getLCDGammaLUT(contrast), getInvLCDGammaLUT(contrast),
                pPrim, &compInfo);
        SurfaceData_InvokeRelease(env, sdOps, &rasInfo);

    }
    SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
}