コード例 #1
0
/*
 * Class:     sun_java2d_loops_FillRect
 * Method:    FillRect
 * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;IIII)V
 */
JNIEXPORT void JNICALL
Java_sun_java2d_loops_FillRect_FillRect
(JNIEnv *env, jobject self,
 jobject sg2d, jobject sData,
 jint x, jint y, jint w, jint h)
{
    SurfaceDataOps *sdOps;
    SurfaceDataRasInfo rasInfo;
    NativePrimitive *pPrim;
    CompositeInfo compInfo;
    jint pixel = GrPrim_Sg2dGetPixel(env, sg2d);

    if (w <= 0 || h <= 0) {
        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);
    SurfaceData_IntersectBoundsXYWH(&rasInfo.bounds, x, y, w, h);
    if (rasInfo.bounds.y2 <= rasInfo.bounds.y1 ||
            rasInfo.bounds.x2 <= rasInfo.bounds.x1)
    {
        return;
    }

    if (sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags) != SD_SUCCESS) {
        return;
    }

    if (rasInfo.bounds.x2 > rasInfo.bounds.x1 &&
            rasInfo.bounds.y2 > rasInfo.bounds.y1)
    {
        sdOps->GetRasInfo(env, sdOps, &rasInfo);
        if (rasInfo.rasBase) {
            (*pPrim->funcs.fillrect)(&rasInfo,
                                     rasInfo.bounds.x1, rasInfo.bounds.y1,
                                     rasInfo.bounds.x2, rasInfo.bounds.y2,
                                     pixel, pPrim, &compInfo);
        }
        SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
    }
    SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
}
コード例 #2
0
ファイル: FillPath.c プロジェクト: AllenWeb/openjdk-1
/*
 * Class:     sun_java2d_loops_FillPath
 * Method:    FillPath
 * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;IILjava/awt/geom/Path2D.Float;)V
 */
JNIEXPORT void JNICALL Java_sun_java2d_loops_FillPath_FillPath
    (JNIEnv *env, jobject self,
     jobject sg2d, jobject sData,
     jint transX, jint transY, jobject p2df)
{
    jarray typesArray;
    jarray coordsArray;
    jint numTypes;
    jint fillRule;
    jboolean ok = JNI_TRUE;
    jint pixel = GrPrim_Sg2dGetPixel(env, sg2d);
    jint maxCoords;
    jfloat *coords;
    SurfaceDataOps *sdOps;
    SurfaceDataRasInfo rasInfo;
    CompositeInfo compInfo;
    jint ret;
    NativePrimitive *pPrim = GetNativePrim(env, self);
    jint stroke = (*env)->GetIntField(env, sg2d, sg2dStrokeHintID);

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

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

    typesArray = (jarray)(*env)->GetObjectField(env, p2df, path2DTypesID);
    coordsArray = (jarray)(*env)->GetObjectField(env, p2df,
                                                 path2DFloatCoordsID);
    if (coordsArray == NULL) {
        JNU_ThrowNullPointerException(env, "coordinates array");
        return;
    }
    numTypes = (*env)->GetIntField(env, p2df, path2DNumTypesID);
    fillRule = (*env)->GetIntField(env, p2df, path2DWindingRuleID);
    if ((*env)->GetArrayLength(env, typesArray) < numTypes) {
        JNU_ThrowArrayIndexOutOfBoundsException(env, "types array");
        return;
    }

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

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

    maxCoords = (*env)->GetArrayLength(env, coordsArray);
    coords = (jfloat*)(*env)->GetPrimitiveArrayCritical(
            env, coordsArray, NULL);

    if (ret == SD_SLOWLOCK) {
        GrPrim_RefineBounds(&rasInfo.bounds, transX, transY,
                     coords, maxCoords);
        ok = (rasInfo.bounds.x2 > rasInfo.bounds.x1 &&
              rasInfo.bounds.y2 > rasInfo.bounds.y1);
    }

    if (ok) {
        sdOps->GetRasInfo(env, sdOps, &rasInfo);
        if (rasInfo.rasBase) {
            if (rasInfo.bounds.x2 > rasInfo.bounds.x1 &&
                rasInfo.bounds.y2 > rasInfo.bounds.y1)
            {
                DrawHandlerData dHData;
                DrawHandler drawHandler = {
                    NULL,
                    NULL,
                    &drawScanline,
                    0, 0, 0, 0,
                    0, 0, 0, 0,
                    NULL
                };

                jbyte *types = (jbyte*)(*env)->GetPrimitiveArrayCritical(
                    env, typesArray, NULL);

                /* Initialization of the following fields in the declaration of
                 * the dHData and drawHandler above causes warnings on sun
                 * studio compiler with
                 * -xc99=%none option applied (this option means compliance
                 *  with C90 standard instead of C99)
                 */
                dHData.pRasInfo = &rasInfo;
                dHData.pixel = pixel;
                dHData.pPrim = pPrim;
                dHData.pCompInfo = &compInfo;

                drawHandler.xMin = rasInfo.bounds.x1;
                drawHandler.yMin = rasInfo.bounds.y1;
                drawHandler.xMax = rasInfo.bounds.x2;
                drawHandler.yMax = rasInfo.bounds.y2;
                drawHandler.pData = &dHData;

                if (!doFillPath(&drawHandler,
                                transX, transY, coords,
                                maxCoords, types, numTypes,
                                (stroke == sunHints_INTVAL_STROKE_PURE)?
                                     PH_STROKE_PURE : PH_STROKE_DEFAULT,
                                fillRule))
                {
                    JNU_ThrowArrayIndexOutOfBoundsException(env,
                                                            "coords array");
                }

                (*env)->ReleasePrimitiveArrayCritical(env, typesArray, types,
                                                      JNI_ABORT);
            }
        }
        SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
    }
    (*env)->ReleasePrimitiveArrayCritical(env, coordsArray, coords,
                                          JNI_ABORT);
    SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
}
コード例 #3
0
/*
 * Class:     sun_java2d_loops_DrawRect
 * Method:    DrawRect
 * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;IIII)V
 */
JNIEXPORT void JNICALL
Java_sun_java2d_loops_DrawRect_DrawRect
    (JNIEnv *env, jobject self,
     jobject sg2d, jobject sData,
     jint x, jint y, jint w, jint h)
{
    SurfaceDataOps *sdOps;
    SurfaceDataRasInfo rasInfo;
    NativePrimitive *pPrim;
    CompositeInfo compInfo;
    jint lox, loy, hix, hiy;
    jint pixel = GrPrim_Sg2dGetPixel(env, sg2d);

    if (w < 0 || h < 0) {
	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;
    }

    lox = x;
    loy = y;
    hix = x + w + 1;
    hiy = y + h + 1;
    if (hix < lox) {
	hix = 0x7fffffff;
    }
    if (hiy < loy) {
	hiy = 0x7fffffff;
    }

    GrPrim_Sg2dGetClip(env, sg2d, &rasInfo.bounds);
    if (rasInfo.bounds.x1 < lox) rasInfo.bounds.x1 = lox;
    if (rasInfo.bounds.y1 < loy) rasInfo.bounds.y1 = loy;
    if (rasInfo.bounds.x2 > hix) rasInfo.bounds.x2 = hix;
    if (rasInfo.bounds.y2 > hiy) rasInfo.bounds.y2 = hiy;
    if (sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags) != SD_SUCCESS) {
	return;
    }

    if (rasInfo.bounds.x2 > rasInfo.bounds.x1 &&
	rasInfo.bounds.y2 > rasInfo.bounds.y1)
    {
	sdOps->GetRasInfo(env, sdOps, &rasInfo);
	if (rasInfo.rasBase) {
	    DrawLineFunc *pLine = pPrim->funcs.drawline;
	    int loyin = (loy == rasInfo.bounds.y1);
	    int hiyin = (hiy == rasInfo.bounds.y2);
	    int xsize = (rasInfo.bounds.x2 - rasInfo.bounds.x1);
	    int ysize = (rasInfo.bounds.y2 - rasInfo.bounds.y1 - loyin - hiyin);
	    /*
	     * To avoid drawing the corners twice (both for performance
	     * and because XOR erases them otherwise) and to maximize the
	     * number of pixels we draw in the horizontal portions
	     * which are more cache-friendly, we include the corner
	     * pixels only in the top and bottom segments.
	     * We also protect against degenerate rectangles where we
	     * would draw the same line for top & bottom or left & right.
	     */
	    if (loyin) {
		/* Line across the top */
		(*pLine)(&rasInfo,
			 rasInfo.bounds.x1, rasInfo.bounds.y1,
			 pixel, xsize, 0,
			 BUMP_POS_PIXEL, 0, BUMP_NOOP, 0, pPrim, &compInfo);
	    }
	    if (lox == rasInfo.bounds.x1 && ysize > 0) {
		/* Line down the left side */
		(*pLine)(&rasInfo,
			 rasInfo.bounds.x1, rasInfo.bounds.y1 + loyin,
			 pixel, ysize, 0,
			 BUMP_POS_SCAN, 0, BUMP_NOOP, 0, pPrim, &compInfo);
	    }
	    if (hix == rasInfo.bounds.x2 && ysize > 0 && lox != hix - 1) {
		/* Line down the right side */
		(*pLine)(&rasInfo,
			 rasInfo.bounds.x2 - 1, rasInfo.bounds.y1 + loyin,
			 pixel, ysize, 0,
			 BUMP_POS_SCAN, 0, BUMP_NOOP, 0, pPrim, &compInfo);
	    }
	    if (hiyin && loy != hiy - 1) {
		/* Line across the bottom */
		(*pLine)(&rasInfo,
			 rasInfo.bounds.x1, rasInfo.bounds.y2 - 1,
			 pixel, xsize, 0,
			 BUMP_POS_PIXEL, 0, BUMP_NOOP, 0, pPrim, &compInfo);
	    }
	}
	SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
    }
    SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
}
コード例 #4
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);
}
コード例 #5
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);
}