Exemple #1
0
JNIEXPORT void JNICALL
Java_sun_java2d_opengl_GLXGraphicsConfig_initConfig(JNIEnv *env,
                                                    jobject glxgc,
                                                    jlong configInfo)
{
#ifndef HEADLESS
    GLXGraphicsConfigInfo *glxinfo;
    AwtGraphicsConfigDataPtr configData = (AwtGraphicsConfigDataPtr)
	JNU_GetLongFieldAsPtr(env, glxgc, x11GraphicsConfigIDs.aData);

    J2dTraceLn(J2D_TRACE_INFO, "in GLXGraphicsConfig_initConfig");

    if (configData == NULL) {
	JNU_ThrowNullPointerException(env, "Native GraphicsConfig missing");
	return;
    }

    glxinfo = (GLXGraphicsConfigInfo *)jlong_to_ptr(configInfo);
    if (glxinfo == NULL) {
	JNU_ThrowNullPointerException(env,
                                      "GLXGraphicsConfigInfo data missing");
	return;
    }

    configData->glxInfo = glxinfo;
#endif /* !HEADLESS */
}
/*
 * Class:     java_io_ObjectInputStream
 * Method:    bytesToFloats
 * Signature: ([BI[FII)V
 * 
 * Reconstitutes nfloats float values from their byte representations.  Byte
 * values are read from array src starting at offset srcpos; the resulting
 * float values are written to array dst starting at dstpos.
 */
JNIEXPORT void JNICALL 
Java_java_io_ObjectInputStream_bytesToFloats(JNIEnv *env, 
					     jclass thisObj, 
					     jbyteArray src, 
					     jint srcpos, 
					     jfloatArray dst, 
					     jint dstpos, 
					     jint nfloats)
{
    union {
	int i;
	float f;
    } u;
    jfloat *floats;
    jbyte *bytes;
    jsize dstend;
    jint ival;

    if (nfloats == 0)
	return;
    
    /* fetch source array */
    if (src == NULL) {
	JNU_ThrowNullPointerException(env, NULL);
	return;
    }
    bytes = (jbyte *)(*env)->GetPrimitiveArrayCritical(env, src, NULL);
    if (bytes == NULL)		/* exception thrown */
	return;
    
    /* fetch dest array */
    if (dst == NULL) {
	(*env)->ReleasePrimitiveArrayCritical(env, src, bytes, JNI_ABORT);
	JNU_ThrowNullPointerException(env, NULL);
	return;
    }
    floats = (jfloat *)(*env)->GetPrimitiveArrayCritical(env, dst, NULL);
    if (floats == NULL) {	/* exception thrown */
	(*env)->ReleasePrimitiveArrayCritical(env, src, bytes, JNI_ABORT);
	return;
    }
    
    /* do conversion */
    dstend = dstpos + nfloats;
    for ( ; dstpos < dstend; dstpos++) {
	ival = ((bytes[srcpos + 0] & 0xFF) << 24) +
	       ((bytes[srcpos + 1] & 0xFF) << 16) +
	       ((bytes[srcpos + 2] & 0xFF) << 8) +
	       ((bytes[srcpos + 3] & 0xFF) << 0);
	u.i = (long) ival;
	floats[dstpos] = (jfloat) u.f;
	srcpos += 4;
    }
    
    (*env)->ReleasePrimitiveArrayCritical(env, src, bytes, JNI_ABORT);
    (*env)->ReleasePrimitiveArrayCritical(env, dst, floats, 0);
}
/*
 * Class:     java_io_ObjectInputStream
 * Method:    bytesToDoubles
 * Signature: ([BI[DII)V
 * 
 * Reconstitutes ndoubles double values from their byte representations.
 * Byte values are read from array src starting at offset srcpos; the
 * resulting double values are written to array dst starting at dstpos.
 */
JNIEXPORT void JNICALL 
Java_java_io_ObjectInputStream_bytesToDoubles(JNIEnv *env, 
					      jclass thisObj, 
					      jbyteArray src, 
					      jint srcpos, 
					      jdoubleArray dst, 
					      jint dstpos, 
					      jint ndoubles)

{
    union {
	jlong l;
	double d;
    } u;
    jdouble *doubles;
    jbyte *bytes;
    jsize dstend;
    jlong lval;

    if (ndoubles == 0)
	return;
    
    /* fetch source array */
    if (src == NULL) {
	JNU_ThrowNullPointerException(env, NULL);
	return;
    }
    bytes = (jbyte *)(*env)->GetPrimitiveArrayCritical(env, src, NULL);
    if (bytes == NULL)		/* exception thrown */
	return;
    
    /* fetch dest array */
    if (dst == NULL) {
	(*env)->ReleasePrimitiveArrayCritical(env, src, bytes, JNI_ABORT);
	JNU_ThrowNullPointerException(env, NULL);
	return;
    }
    doubles = (jdouble *)(*env)->GetPrimitiveArrayCritical(env, dst, NULL);
    if (doubles == NULL) {	/* exception thrown */
	(*env)->ReleasePrimitiveArrayCritical(env, src, bytes, JNI_ABORT);
	return;
    }
    
    /* do conversion */
    dstend = dstpos + ndoubles;
    for ( ; dstpos < dstend; dstpos++) {
	lval = READ_JLONG_FROM_BUF(bytes, srcpos);
	jlong_to_jdouble_bits(&lval);
	u.l = lval;
	doubles[dstpos] = (jdouble) u.d;
	srcpos += 8;
    }
    
    (*env)->ReleasePrimitiveArrayCritical(env, src, bytes, JNI_ABORT);
    (*env)->ReleasePrimitiveArrayCritical(env, dst, doubles, 0);
}
Exemple #4
0
JNIEXPORT void JNICALL
Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
                                              jobject peer, jlong aData)
{
#ifndef HEADLESS
    GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps));

    if (glxsdo == NULL) {
        JNU_ThrowOutOfMemoryError(env, "creating native GLX ops");
        return;
    }

    OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd,
                                                       sizeof(OGLSDOps));
    if (oglsdo == NULL) {
        free(glxsdo);
        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
        return;
    }

    J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps");

    oglsdo->privOps = glxsdo;

    oglsdo->sdOps.Lock       = OGLSD_Lock;
    oglsdo->sdOps.GetRasInfo = OGLSD_GetRasInfo;
    oglsdo->sdOps.Unlock     = OGLSD_Unlock;
    oglsdo->sdOps.Dispose    = OGLSD_Dispose;

    oglsdo->drawableType = OGLSD_UNDEFINED;
    oglsdo->activeBuffer = GL_FRONT;
    oglsdo->needsInit = JNI_TRUE;

    if (peer != NULL) {
        glxsdo->window = JNU_CallMethodByName(env, NULL, peer,
                                              "getContentWindow", "()J").j;
    } else {
        glxsdo->window = 0;
    }
    glxsdo->configData = (AwtGraphicsConfigDataPtr)jlong_to_ptr(aData);
    if (glxsdo->configData == NULL) {
        free(glxsdo);
        JNU_ThrowNullPointerException(env,
                                 "Native GraphicsConfig data block missing");
        return;
    }

    if (glxsdo->configData->glxInfo == NULL) {
        free(glxsdo);
        JNU_ThrowNullPointerException(env, "GLXGraphicsConfigInfo missing");
        return;
    }
#endif /* HEADLESS */
}
JNIEXPORT void JNICALL
Java_java_awt_AWTEvent_nativeSetSource(JNIEnv *env, jobject self,
				       jobject newSource)
{
    jbyteArray bdata;

    AWT_LOCK();

    bdata = (jbyteArray)(*env)->GetObjectField(env, self, awtEventIDs.bdata);

    if (bdata != NULL) {
	XEvent *xev;
	Window w;
	jboolean dummy;

	/* get the widget out of the peer newSource */
	struct ComponentData *cdata = (struct ComponentData *)
	    JNU_GetLongFieldAsPtr(env, newSource, mComponentPeerIDs.pData);
	if (JNU_IsNull(env, cdata) || (cdata == NULL) ||
	    ((cdata->widget != NULL) && (XtIsObject(cdata->widget)) &&
	     (cdata->widget->core.being_destroyed))) {
	    JNU_ThrowNullPointerException(env, "null widget");
	    AWT_UNLOCK();
	    return;
	}
	
	/* get the Window out of the widget */
	w = XtWindow(cdata->widget);

	if (w == None) {
	    JNU_ThrowNullPointerException(env, "null window");
	    AWT_UNLOCK();
	    return;
	}

	/* reset the filed in the event */
	xev = (XEvent *)(*env)->GetPrimitiveArrayCritical(env, bdata, &dummy);
	if (xev == NULL) {
	    JNU_ThrowNullPointerException(env, "null data");
	    AWT_UNLOCK();
	    return;
	}
	xev->xany.window = w;
	(*env)->ReleasePrimitiveArrayCritical(env, bdata, (void *)xev, 0);
    }

    AWT_UNLOCK();
}
JNIEXPORT jobject JNICALL
    awt_GetComponent(JNIEnv* env, void* platformInfo)
{
    Window window = (Window)platformInfo;
    jobject peer = NULL;
    jobject target = NULL;

    AWT_LOCK();

    if (window != None) {
        peer = JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit",
            "windowToXWindow", "(J)Lsun/awt/X11/XBaseWindow;", (jlong)window).l;
    }
    if ((peer != NULL) &&
        (JNU_IsInstanceOfByName(env, peer, "sun/awt/X11/XWindow") == 1)) {
        target = (*env)->GetObjectField(env, peer, targetID);
    }

    if (target == NULL) {
        JNU_ThrowNullPointerException(env, "NullPointerException");
        AWT_UNLOCK();
        return (jobject)NULL;
    }

    AWT_UNLOCK();

    return target;
}
JNIEXPORT void JNICALL
Java_java_awt_image_ColorModel_initIDs(JNIEnv *env, jclass cls) {
    g_CMpDataID = (*env)->GetFieldID (env, cls, "pData", "J");
    g_CMnBitsID  = (*env)->GetFieldID(env, cls, "nBits", "[I");
    g_CMcspaceID = (*env)->GetFieldID(env, cls, "colorSpace",
                                    "Ljava/awt/color/ColorSpace;");
    g_CMnumComponentsID = (*env)->GetFieldID(env, cls, "numComponents", "I");
    g_CMsuppAlphaID  = (*env)->GetFieldID(env, cls, "supportsAlpha", "Z");
    g_CMisAlphaPreID = (*env)->GetFieldID(env, cls, "isAlphaPremultiplied",
                                          "Z");
    g_CMtransparencyID = (*env)->GetFieldID(env, cls, "transparency", "I");
    g_CMgetRGBMID      = (*env)->GetMethodID(env, cls, "getRGB",
                                             "(Ljava/lang/Object;)I");
    g_CMcsTypeID       = (*env)->GetFieldID(env, cls, "colorSpaceType", "I");
    g_CMis_sRGBID      = (*env)->GetFieldID(env, cls, "is_sRGB", "Z");
    g_CMgetRGBdefaultMID   = (*env)->GetStaticMethodID(env, cls,
                                                       "getRGBdefault",
                                             "()Ljava/awt/image/ColorModel;");
    if (g_CMnBitsID == NULL || g_CMcspaceID == NULL 
        || g_CMnumComponentsID == NULL || g_CMsuppAlphaID == NULL
        || g_CMisAlphaPreID == NULL || g_CMtransparencyID == NULL
        || g_CMgetRGBMID == NULL || g_CMgetRGBMID == NULL
        || g_CMis_sRGBID == NULL || g_CMgetRGBdefaultMID == NULL
	|| g_CMpDataID == NULL)
    {
        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
    }
}
JNIEXPORT void JNICALL
Java_java_awt_image_Raster_initIDs(JNIEnv *env, jclass cls) {
    g_RasterWidthID    = (*env)->GetFieldID(env, cls, "width", "I");
    g_RasterHeightID   = (*env)->GetFieldID(env, cls, "height", "I");
    g_RasterNumBandsID = (*env)->GetFieldID(env, cls, "numBands", "I");
    g_RasterGetDataMID = (*env)->GetMethodID(env, cls, "getDataElements",
                              "(IIIILjava/lang/Object;)Ljava/lang/Object;");
    g_RasterMinXID  = (*env)->GetFieldID(env, cls, "minX", "I");
    g_RasterMinYID  = (*env)->GetFieldID(env, cls, "minY", "I");
    g_RasterBaseOriginXID  = (*env)->GetFieldID(env, cls,
                                 "sampleModelTranslateX", "I");
    g_RasterBaseOriginYID  = (*env)->GetFieldID(env, cls, 
                                 "sampleModelTranslateY", "I");
    g_RasterSampleModelID = (*env)->GetFieldID(env, cls,
                                 "sampleModel","Ljava/awt/image/SampleModel;");
    g_RasterNumDataElementsID = (*env)->GetFieldID(env, cls, "numDataElements",
                                                   "I");
    g_RasterNumBandsID = (*env)->GetFieldID(env, cls, "numBands", "I");
    g_RasterDataBufferID = (*env)->GetFieldID(env, cls, "dataBuffer",
                                              "Ljava/awt/image/DataBuffer;");
    if (g_RasterWidthID == NULL || g_RasterHeightID == NULL
        || g_RasterNumBandsID == NULL || g_RasterGetDataMID == NULL
        || g_RasterMinXID == NULL || g_RasterMinYID == NULL
        || g_RasterBaseOriginXID == NULL || g_RasterBaseOriginYID == NULL
        || g_RasterSampleModelID == NULL || g_RasterNumDataElementsID == NULL
        || g_RasterNumBandsID == NULL || g_RasterDataBufferID == NULL)
    {
        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
    }
}
Exemple #9
0
/*
 * Class:     sun_java2d_x11_X11Renderer
 * Method:    XDrawPoly
 * Signature: (IJII[I[IIZ)V
 */
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XDrawPoly
    (JNIEnv *env, jobject xr,
     jlong pXSData, jlong xgc,
     jint transx, jint transy,
     jintArray xcoordsArray, jintArray ycoordsArray, jint npoints,
     jboolean isclosed)
{
#ifndef HEADLESS
    XPoint pTmp[POLYTEMPSIZE], *points;
    X11SDOps *xsdo = (X11SDOps *) pXSData;

    if (xsdo == NULL) {
        return;
    }

    if (JNU_IsNull(env, xcoordsArray) || JNU_IsNull(env, ycoordsArray)) {
        JNU_ThrowNullPointerException(env, "coordinate array");
        return;
    }
    if ((*env)->GetArrayLength(env, ycoordsArray) < npoints ||
        (*env)->GetArrayLength(env, xcoordsArray) < npoints)
    {
        JNU_ThrowArrayIndexOutOfBoundsException(env, "coordinate array");
        return;
    }

    if (npoints < 2) {
        return;
    }

    points = transformPoints(env, xcoordsArray, ycoordsArray, transx, transy,
                             pTmp, (int *)&npoints, isclosed);
    if (points == 0) {
        JNU_ThrowOutOfMemoryError(env, "translated coordinate array");
    } else {
        if (npoints == 2) {
            /*
             * Some X11 implementations fail to draw anything for
             * simple 2 point polygons where the vertices are the
             * same point even though this violates the X11
             * specification.  For simplicity we will dispatch all
             * 2 point polygons through XDrawLine even if they are
             * non-degenerate as this may invoke less processing
             * down the line than a Poly primitive anyway.
             */
            XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
                      points[0].x, points[0].y,
                      points[1].x, points[1].y);
        } else {
            XDrawLines(awt_display, xsdo->drawable, (GC) xgc,
                       points, npoints, CoordModeOrigin);
        }
        if (points != pTmp) {
            free(points);
        }
        X11SD_DirectRenderNotify(env, xsdo);
    }
#endif /* !HEADLESS */
}
Exemple #10
0
/*
 * Class:     sun_java2d_windows_GDIRenderer
 * Method:    doFillPoly
 * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;III[I[II)V
 */
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doFillPoly
    (JNIEnv *env, jobject wr,
     jobject sData,
     jobject clip, jobject comp, jint color,
     jint transx, jint transy,
     jintArray xpointsarray, jintArray ypointsarray,
     jint npoints)
{
    J2dTraceLn(J2D_TRACE_INFO, "GDIRenderer_doFillPoly");
    J2dTraceLn4(J2D_TRACE_VERBOSE,
                "  color=0x%x transx=%-4d transy=%-4d npoints=%-4d",
                color, transx, transy, npoints);
    if (JNU_IsNull(env, xpointsarray) || JNU_IsNull(env, ypointsarray)) {
        JNU_ThrowNullPointerException(env, "coordinate array");
        return;
    }
    if (env->GetArrayLength(xpointsarray) < npoints ||
        env->GetArrayLength(ypointsarray) < npoints)
    {
        JNU_ThrowArrayIndexOutOfBoundsException(env, "coordinate array");
        return;
    }
    if (npoints < 3) {
        // Fix for 4067534 - assertion failure in 1.3.1 for degenerate polys
        // Not enough points for a triangle.
        // Note that this would be ignored later anyway, but returning
        // here saves us from mistakes in TransformPoly and seeing bad
        // return values from the Windows Polyline function.
        return;
    }

    GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOps(env, sData);
    if (wsdo == NULL) {
        return;
    }

    POINT tmpPts[POLYTEMPSIZE], *pPoints;
    jint *xpoints = (jint *) env->GetPrimitiveArrayCritical(xpointsarray, NULL);
    jint *ypoints = (jint *) env->GetPrimitiveArrayCritical(ypointsarray, NULL);
    pPoints = TransformPoly(xpoints, ypoints, transx, transy,
                            tmpPts, &npoints, FALSE, FALSE);
    env->ReleasePrimitiveArrayCritical(xpointsarray, xpoints, JNI_ABORT);
    env->ReleasePrimitiveArrayCritical(ypointsarray, ypoints, JNI_ABORT);
    if (pPoints == NULL) {
        return;
    }

    HDC hdc = wsdo->GetDC(env, wsdo, BRUSHONLY, NULL, clip, comp, color);
    if (hdc == NULL) {
        return;
    }
    ::SetPolyFillMode(hdc, ALTERNATE);
    ::Polygon(hdc, pPoints, npoints);
    wsdo->ReleaseDC(env, wsdo, hdc);
    if (pPoints != tmpPts) {
        free(pPoints);
    }
}
JNIEXPORT void JNICALL
Java_java_awt_image_DataBufferInt_initIDs(JNIEnv *env, jclass cls) {
    g_DataBufferIntPdataID = (*env)->GetFieldID(env, cls, "pData", "J");
    if (g_DataBufferIntPdataID == NULL) {
        JNU_ThrowNullPointerException(env, "Unable to grab DataBufferInt.pData");
        return;
    }
}
Exemple #12
0
JNIEXPORT void JNICALL
Java_java_awt_Color_initIDs
  (JNIEnv *env, jclass clazz)
{
    colorValueID = (*env)->GetFieldID(env, clazz, "value", "I");

    if(colorValueID == NULL)
        JNU_ThrowNullPointerException (env, "Can't get java/awt/Color.value fieldID");
}
JNIEXPORT void JNICALL
Java_java_awt_image_IndexColorModel_initIDs(JNIEnv *env, jclass cls) {
    g_ICMtransIdxID = (*env)->GetFieldID(env, cls, "transparent_index", "I");
    g_ICMmapSizeID  = (*env)->GetFieldID(env, cls, "map_size", "I");
    g_ICMrgbID      = (*env)->GetFieldID(env, cls, "rgb", "[I");
    if (g_ICMtransIdxID == NULL || g_ICMmapSizeID == NULL
        || g_ICMrgbID == NULL) {
        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
    }
}
JNIEXPORT void JNICALL
Java_java_awt_image_ComponentSampleModel_initIDs(JNIEnv *env, jclass cls) {
    g_CSMPixStrideID = (*env)->GetFieldID(env, cls, "pixelStride", "I");
    g_CSMScanStrideID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
    g_CSMBandOffsetsID = (*env)->GetFieldID(env, cls, "bandOffsets", "[I");
    if (g_CSMPixStrideID == NULL || g_CSMScanStrideID == NULL ||
        g_CSMBandOffsetsID == NULL) {
        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
    }
}
Exemple #15
0
void
awt_util_hide(Widget w)
{
    if (w == NULL) {
        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
        JNU_ThrowNullPointerException(env,"NullPointerException");
        return;
    }
    XtSetMappedWhenManaged(w, False);
}
Exemple #16
0
void *findFunction(JNIEnv *env, void *hModule, char *functionName) {
    void *fAddress = dlsym(hModule, functionName);
    if (fAddress == NULL) {
        char errorMessage[256];
        snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
        JNU_ThrowNullPointerException(env, errorMessage);
        return NULL;
    }
    return fAddress;
}
JNIEXPORT void JNICALL
Java_java_awt_image_Kernel_initIDs(JNIEnv *env, jclass cls) {
    g_KernelWidthID   = (*env)->GetFieldID(env, cls, "width", "I");
    g_KernelHeightID  = (*env)->GetFieldID(env, cls, "height", "I");
    g_KernelDataID    = (*env)->GetFieldID(env, cls, "data", "[F");
    if (g_KernelWidthID == NULL || g_KernelHeightID == NULL
        || g_KernelDataID == NULL)
    {
        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
    }
}
void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
    HINSTANCE hModule = (HINSTANCE)jHandle;
    void *fAddress = GetProcAddress(hModule, functionName);
    if (fAddress == NULL) {
        char errorMessage[256];
        _snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
        JNU_ThrowNullPointerException(env, errorMessage);
        return NULL;
    }
    return fAddress;
}
Exemple #19
0
JNIEXPORT jint JNICALL Java_com_sun_management_internal_GcInfoBuilder_getNumGcExtAttributes
  (JNIEnv *env, jobject dummy, jobject gc) {
    jlong value;

    if (gc == NULL) {
        JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMBean");
        return 0;
    }
    value = jmm_interface->GetLongAttribute(env, gc,
                                            JMM_GC_EXT_ATTRIBUTE_INFO_SIZE);
    return (jint) value;
}
Exemple #20
0
JNIEXPORT Win32SDOps * JNICALL
Win32OffScreenSurfaceData_GetOps(JNIEnv *env, jobject sData)
{
    SurfaceDataOps *ops = SurfaceData_GetOps(env, sData);
    if (ops == NULL) {
	JNU_ThrowNullPointerException(env, "SurfaceData native ops");
    } else if (ops->Lock != Win32OSSD_Lock) {
	SurfaceData_ThrowInvalidPipeException(env, "not a Win32 SurfaceData");
	ops = NULL;
    }
    return (Win32SDOps *) ops;
}
Exemple #21
0
/*
 * Class:     sun_java2d_x11_X11Renderer
 * Method:    XFillSpans
 * Signature: (IJLsun/java2d/pipe/SpanIterator;JII)V
 */
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XFillSpans
    (JNIEnv *env, jobject xr,
     jlong pXSData, jlong xgc,
     jobject si, jlong pIterator,
     jint transx, jint transy)
{
#ifndef HEADLESS
    SpanIteratorFuncs *pFuncs = (SpanIteratorFuncs *) jlong_to_ptr(pIterator);
    void *srData;
    jint x, y, w, h;
    jint spanbox[4];
    X11SDOps *xsdo = (X11SDOps *) pXSData;

    if (xsdo == NULL) {
        return;
    }

    if (JNU_IsNull(env, si)) {
        JNU_ThrowNullPointerException(env, "span iterator");
        return;
    }
    if (pFuncs == NULL) {
        JNU_ThrowNullPointerException(env, "native iterator not supplied");
        return;
    }

    srData = (*pFuncs->open)(env, si);
    while ((*pFuncs->nextSpan)(srData, spanbox)) {
        x = spanbox[0] + transx;
        y = spanbox[1] + transy;
        w = spanbox[2] - spanbox[0];
        h = spanbox[3] - spanbox[1];
        XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
                       CLAMP_TO_SHORT(x),  CLAMP_TO_SHORT(y),
                       CLAMP_TO_USHORT(w), CLAMP_TO_USHORT(h));
    }
    (*pFuncs->close)(env, srData);
    X11SD_DirectRenderNotify(env, xsdo);
#endif /* !HEADLESS */
}
JNIEXPORT void JNICALL
Java_java_awt_image_SampleModel_initIDs(JNIEnv *env, jclass cls) {
    g_SMWidthID = (*env)->GetFieldID(env, cls, "width","I");
    g_SMHeightID = (*env)->GetFieldID(env, cls, "height","I");
    g_SMGetPixelsMID = (*env)->GetMethodID(env, cls, "getPixels",
                                      "(IIII[ILjava/awt/image/DataBuffer;)[I");
    g_SMSetPixelsMID = (*env)->GetMethodID(env, cls, "setPixels",
                                      "(IIII[ILjava/awt/image/DataBuffer;)V");
    if (g_SMWidthID == NULL || g_SMHeightID == NULL || g_SMGetPixelsMID == NULL
        || g_SMSetPixelsMID == NULL) {
        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
    }
}
JNIEXPORT void JNICALL
Java_sun_awt_image_BytePackedRaster_initIDs(JNIEnv *env, jclass cls) {
    g_BPRdataID = (*env)->GetFieldID(env, cls, "data", "[B");
    g_BPRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
    g_BPRpixstrID = (*env)->GetFieldID(env, cls, "pixelBitStride", "I");
    g_BPRtypeID = (*env)->GetFieldID(env, cls, "type", "I");
    g_BPRdataBitOffsetID = (*env)->GetFieldID(env, cls, "dataBitOffset", "I");
    if (g_BPRdataID == NULL || g_BPRscanstrID == NULL ||
        g_BPRpixstrID == NULL ||  g_BPRtypeID == NULL)
    {
        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
    }
}
JNIEXPORT void JNICALL
Java_java_awt_image_SinglePixelPackedSampleModel_initIDs(JNIEnv *env,
                                                         jclass cls) {
    g_SPPSMmaskArrID = (*env)->GetFieldID(env, cls, "bitMasks", "[I");
    g_SPPSMmaskOffID = (*env)->GetFieldID(env, cls, "bitOffsets", "[I");
    g_SPPSMnBitsID   = (*env)->GetFieldID(env, cls, "bitSizes", "[I");
    g_SPPSMmaxBitID  = (*env)->GetFieldID(env, cls, "maxBitSize", "I");

    if (g_SPPSMmaskArrID == NULL || g_SPPSMmaskOffID == NULL ||
        g_SPPSMnBitsID == NULL || g_SPPSMmaxBitID == NULL) {
        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
    }
}
Exemple #25
0
static pathData *
GetSpanData(JNIEnv *env, jobject sr, int minState, int maxState)
{
    pathData *pd = (pathData *) JNU_GetLongFieldAsPtr(env, sr, pSpanDataID);

    if (pd == NULL) {
	JNU_ThrowNullPointerException(env, "private data");
    } else if (pd->state < minState || pd->state > maxState) {
	JNU_ThrowInternalError(env, "bad path delivery sequence");
	pd = NULL;
    }

    return pd;
}
JNIEXPORT void JNICALL
Java_sun_awt_image_ShortComponentRaster_initIDs(JNIEnv *env, jclass cls) {
    g_SCRdataID = (*env)->GetFieldID(env, cls, "data", "[S");
    g_SCRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
    g_SCRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I");
    g_SCRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I");
    g_SCRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I");
    g_SCRtypeID = (*env)->GetFieldID(env, cls, "type", "I");
    if (g_SCRdataID == NULL || g_SCRscanstrID == NULL ||
        g_SCRpixstrID == NULL || g_SCRbandoffsID == NULL ||
        g_SCRdataOffsetsID == NULL || g_SCRtypeID == NULL)
    {        
        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
    }
}
Exemple #27
0
static SurfaceDataOps *
GetSDOps(JNIEnv *env, jobject sData, jboolean callSetup)
{
    SurfaceDataOps *ops;
    if (JNU_IsNull(env, sData)) {
        JNU_ThrowNullPointerException(env, "surfaceData");
        return NULL;
    }
    ops = (SurfaceDataOps *)JNU_GetLongFieldAsPtr(env, sData, pDataID);
    if (ops == NULL) {
        if (!(*env)->ExceptionOccurred(env) &&
            !(*env)->IsInstanceOf(env, sData, pNullSurfaceDataClass))
        {
            if (!(*env)->GetBooleanField(env, sData, validID)) {
                SurfaceData_ThrowInvalidPipeException(env, "invalid data");
            } else {
                JNU_ThrowNullPointerException(env, "native ops missing");
            }
        }
    } else if (callSetup) {
        SurfaceData_InvokeSetup(env, ops);
    }
    return ops;
}
JNIEXPORT void JNICALL
Java_sun_java2d_opengl_WGLSurfaceData_initOps(JNIEnv *env, jobject wglsd,
                                              jlong pConfigInfo,
                                              jobject peer, jlong hwnd)
{
    OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, wglsd,
                                                       sizeof(OGLSDOps));
    WGLSDOps *wglsdo = (WGLSDOps *)malloc(sizeof(WGLSDOps));

    J2dTraceLn(J2D_TRACE_INFO, "WGLSurfaceData_initOps");

    if (wglsdo == NULL) {
        JNU_ThrowOutOfMemoryError(env, "creating native wgl ops");
        return;
    }
    if (oglsdo == NULL) {
        free(wglsdo);
        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
        return;
    }

    oglsdo->privOps = wglsdo;

    oglsdo->sdOps.Lock               = OGLSD_Lock;
    oglsdo->sdOps.GetRasInfo         = OGLSD_GetRasInfo;
    oglsdo->sdOps.Unlock             = OGLSD_Unlock;
    oglsdo->sdOps.Dispose            = OGLSD_Dispose;

    oglsdo->drawableType = OGLSD_UNDEFINED;
    oglsdo->activeBuffer = GL_FRONT;
    oglsdo->needsInit = JNI_TRUE;
    if (peer != NULL) {
        RECT insets;
        AwtComponent_GetInsets(env, peer, &insets);
        oglsdo->xOffset = -insets.left;
        oglsdo->yOffset = -insets.bottom;
    } else {
        oglsdo->xOffset = 0;
        oglsdo->yOffset = 0;
    }

    wglsdo->window = (HWND)jlong_to_ptr(hwnd);
    wglsdo->configInfo = (WGLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
    if (wglsdo->configInfo == NULL) {
        free(wglsdo);
        JNU_ThrowNullPointerException(env, "Config info is null in initOps");
    }
}
JNIEXPORT void JNICALL
Java_java_awt_image_BufferedImage_initIDs(JNIEnv *env, jclass cls) {
    g_BImgRasterID     = (*env)->GetFieldID(env, cls, "raster",
                                            "Ljava/awt/image/WritableRaster;");
    g_BImgTypeID = (*env)->GetFieldID(env, cls, "imageType", "I");
    g_BImgCMID = (*env)->GetFieldID(env, cls, "colorModel",
                                    "Ljava/awt/image/ColorModel;");
    g_BImgGetRGBMID = (*env)->GetMethodID(env, cls, "getRGB",
                                          "(IIII[III)[I");
    g_BImgSetRGBMID = (*env)->GetMethodID(env, cls, "setRGB",
                                          "(IIII[III)V");
    if (g_BImgRasterID == NULL || g_BImgTypeID == NULL || g_BImgCMID == NULL
        || g_BImgGetRGBMID == NULL) {
        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
    }
}
JNIEXPORT void JNICALL
Java_sun_awt_image_IntegerComponentRaster_initIDs(JNIEnv *env, jclass cls) {
    g_ICRdataID = (*env)->GetFieldID(env, cls, "data", "[I");
    g_ICRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
    g_ICRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I");
    g_ICRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I");
    g_ICRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I");
    g_ICRputDataMID  = (*env)->GetMethodID(env, cls, "setDataElements", 
                                     "(IIIILjava/lang/Object;)V");
    g_ICRtypeID = (*env)->GetFieldID(env, cls, "type", "I");
    if (g_ICRdataID == NULL || g_ICRscanstrID == NULL
        || g_ICRpixstrID == NULL || g_ICRbandoffsID == NULL 
        || g_ICRputDataMID == NULL || g_ICRdataOffsetsID == NULL || g_ICRtypeID == NULL)
    {
        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
    }
}