/* * Get the module data of the entry for the given pkcs11Implementation. Returns * NULL, if the pkcs11Implementation is not in the list. */ ModuleData * getModuleEntry(JNIEnv *env, jobject pkcs11Implementation) { jlong jData; if (pkcs11Implementation == NULL) { return NULL; } jData = (*env)->GetLongField(env, pkcs11Implementation, pNativeDataID); return (ModuleData*)jlong_to_ptr(jData); }
/* * Class: com_sun_media_jfxmediaimpl_NativeVideoBuffer * Method: nativeDisposeBuffer * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeDisposeBuffer (JNIEnv *env, jclass klass, jlong nativeHandle) { CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle); if (frame) { delete frame; } }
/* * Class: com_sun_media_jfxmediaimpl_NativeVideoBuffer * Method: nativeSetDirty * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeSetDirty (JNIEnv *env, jobject obj, jlong nativeHandle) { CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle); if (frame) { frame->SetFrameDirty(true); } }
JNIEXPORT void JNICALL Java_sun_nio_fs_LinuxNativeDispatcher_fsetxattr0(JNIEnv* env, jclass clazz, jint fd, jlong nameAddress, jlong valueAddress, jint valueLen) { int res = -1; const char* name = jlong_to_ptr(nameAddress); void* value = jlong_to_ptr(valueAddress); if (my_fsetxattr_func == NULL) { errno = ENOTSUP; } else { /* EINTR not documented */ res = (*my_fsetxattr_func)(fd, name, value, valueLen, 0); } if (res == -1) throwUnixException(env, errno); }
/* * Class: com_sun_media_jfxmediaimpl_NativeVideoBuffer * Method: nativeGetFrameNumber * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeGetFrameNumber (JNIEnv *env, jobject obj, jlong nativeHandle) { CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle); if (frame) { return (jlong)frame->GetFrameNumber(); } return 0; }
/* * Class: com_sun_media_jfxmediaimpl_NativeVideoBuffer * Method: nativeGetTimestamp * Signature: (J)D */ JNIEXPORT jdouble JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeGetTimestamp (JNIEnv *env, jobject obj, jlong nativeHandle) { CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle); if (frame) { return frame->GetTime(); } return 0.0; }
/* * Class: com_sun_media_jfxmediaimpl_NativeVideoBuffer * Method: nativeConvertToFormat * Signature: (JI)J */ JNIEXPORT jlong JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeConvertToFormat (JNIEnv *env, jobject obj, jlong nativeHandle, jint newFormat) { CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle); if (frame) { return ptr_to_jlong(frame->ConvertToFormat((CVideoFrame::FrameType)newFormat)); } return 0; }
/* * Class: com_sun_media_jfxmediaimpl_NativeVideoBuffer * Method: nativeGetPlaneCount * Signature: (J)I */ JNIEXPORT jint JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeGetPlaneCount (JNIEnv *env, jobject obj, jlong nativeHandle) { CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle); if (frame) { return frame->GetPlaneCount(); } return 0; }
/* * Class: sun_dc_pr_PathDasher * Method: cInitialize * Signature: (Lsun/dc/path/PathConsumer;)V */ JNIEXPORT void JNICALL Java_sun_dc_pr_PathDasher_cInitialize (JNIEnv *env, jobject obj, jobject out) { jclass cls; jfieldID fid; jmethodID mid; PathDasher cdata; doeE cenv = doeE_make(); doeE_setPCtxt(cenv, env); cdata = (PathDasher)doeMem_malloc(cenv, sizeof(PathDasherData)); if (doeError_occurred(cenv)) { CJError_throw(cenv); return; } (*env)->SetLongField(env, obj, fidCData, ptr_to_jlong(cdata)); /* __________________________ * the c environment variable */ cdata->env = cenv; /* __________________________________ * the corresponding CJ path consumer * (always created so as to be able to deal with any type of * incoming out path consumers) */ cdata->cjout = CJPathConsumer_create(cenv, out); if (doeError_occurred(cenv)) { CJError_throw(cenv); return; } /* ________________________________________________ * determines if "out" has a native implementation. */ cls = (*env)->GetObjectClass(env, out); mid = (*env)->GetMethodID(env, cls, "getCPathConsumer", "()J"); cdata->cout = (dcPathConsumer) jlong_to_ptr((*env)->CallLongMethod(env, out, mid)); /* _______________________ * the actual c PathDasher */ if (cdata->cout) { cdata->dasher = dcPathDasher_create(cenv, cdata->cout); } else { cdata->dasher = dcPathDasher_create(cenv, (dcPathConsumer)cdata->cjout); } if (doeError_occurred(cenv)) { CJError_throw(cenv); return; } }
JNIEXPORT jint JNICALL Java_sun_nio_ch_FileDispatcher_pwrite0(JNIEnv *env, jclass clazz, jobject fdo, jlong address, jint len, jlong offset) { jint fd = fdval(env, fdo); void *buf = (void *)jlong_to_ptr(address); return convertReturnVal(env, pwrite64(fd, buf, len, offset), JNI_FALSE); }
/* * Class: com_sun_media_jfxmediaimpl_NativeVideoBuffer * Method: nativeHasAlpha * Signature: (J)Z */ JNIEXPORT jboolean JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeHasAlpha (JNIEnv *env, jobject obj, jlong nativeHandle) { CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle); if (frame) { return frame->HasAlpha(); } return JNI_FALSE; }
JNIEXPORT jint JNICALL Java_sun_nio_ch_FileDispatcher_read0(JNIEnv *env, jclass clazz, jobject fdo, jlong address, jint len) { jint fd = fdval(env, fdo); void *buf = (void *)jlong_to_ptr(address); return convertReturnVal(env, read(fd, buf, len), JNI_TRUE); }
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; } oglsdo->privOps = wglsdo; oglsdo->sdOps.Lock = OGLSD_Lock; oglsdo->sdOps.GetRasInfo = OGLSD_GetRasInfo; oglsdo->sdOps.Unlock = OGLSD_Unlock; oglsdo->sdOps.Dispose = OGLSD_Dispose; oglsdo->sdOps.dirty = JNI_FALSE; 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"); } }
/* * Class: sun_java2d_d3d_D3DSurfaceData * Method: dbGetPixelNative * Signature: (JII)I */ JNIEXPORT jint JNICALL Java_sun_java2d_d3d_D3DSurfaceData_dbGetPixelNative (JNIEnv *env, jclass clazz, jlong pData, jint x, jint y) { HRESULT res; D3DSDOps *d3dsdo; D3DContext *pCtx; D3DPipelineManager *pMgr; D3DResource *pLockableRes; jint pixel = 0; J2dTraceLn(J2D_TRACE_INFO, "D3DSurfaceData_dbGetPixelNative"); RETURN_STATUS_IF_NULL(d3dsdo = (D3DSDOps *)jlong_to_ptr(pData), pixel); RETURN_STATUS_IF_NULL(d3dsdo->pResource, pixel); RETURN_STATUS_IF_NULL(pMgr = D3DPipelineManager::GetInstance(), pixel); if (FAILED(res = pMgr->GetD3DContext(d3dsdo->adapter, &pCtx))) { D3DRQ_MarkLostIfNeeded(res, d3dsdo); return pixel; } RETURN_STATUS_IF_NULL(pCtx->GetResourceManager(), 0); IDirect3DDevice9 *pd3dDevice = pCtx->Get3DDevice(); IDirect3DSurface9 *pSrc = d3dsdo->pResource->GetSurface(); D3DFORMAT srcFmt = d3dsdo->pResource->GetDesc()->Format; pCtx->UpdateState(STATE_OTHEROP); res = pCtx->GetResourceManager()-> GetLockableRTSurface(1, 1, srcFmt, &pLockableRes); if (SUCCEEDED(res)) { IDirect3DSurface9 *pTmpSurface; RECT srcRect = { x, y, x+1, y+1}; RECT dstRect = { 0l, 0l, 1, 1 }; pTmpSurface = pLockableRes->GetSurface(); res = pd3dDevice->StretchRect(pSrc, &srcRect, pTmpSurface, &dstRect, D3DTEXF_NONE); if (SUCCEEDED(res)) { D3DLOCKED_RECT lRect; res = pTmpSurface->LockRect(&lRect, &dstRect, D3DLOCK_NOSYSLOCK); if (SUCCEEDED(res)) { if (srcFmt == D3DFMT_X8R8G8B8) { pixel = *(jint*)lRect.pBits; } else { pixel = *(unsigned short*)lRect.pBits; } pTmpSurface->UnlockRect(); } } } D3DRQ_MarkLostIfNeeded(res, d3dsdo); return pixel; }
JNIEXPORT jint JNICALL Java_java_util_zip_CRC32_updateByteBuffer0(JNIEnv *env, jclass cls, jint crc, jlong address, jint off, jint len) { Bytef *buf = (Bytef *)jlong_to_ptr(address); if (buf) { crc = crc32(crc, buf + off, len); } return crc; }
JNIEXPORT jstring JNICALL Java_java_util_zip_ZipFile_getZipMessage(JNIEnv *env, jclass cls, jlong zfile) { jzfile *zip = jlong_to_ptr(zfile); char *msg = zip->msg; if (msg == NULL) { return NULL; } return JNU_NewStringPlatform(env, msg); }
void SurfaceData_DisposeOps(JNIEnv *env, jlong ops) { if (ops != 0) { SurfaceDataOps *sdops = (SurfaceDataOps*)jlong_to_ptr(ops); /* Invoke the ops-specific disposal function */ SurfaceData_InvokeDispose(env, sdops); (*env)->DeleteWeakGlobalRef(env, sdops->sdObject); free(sdops); } }
JNIEXPORT void JNICALL Java_java_nio_MappedByteBuffer_force0(JNIEnv *env, jobject obj, jlong address, jlong len) { void *a = (void *) jlong_to_ptr(address); int result = FlushViewOfFile(a, (DWORD)len); if (result == 0) { JNU_ThrowByName(env, "java/io/IOException", 0); } }
/* * Class: com_sun_media_jfxmediaimpl_NativeVideoBuffer * Method: nativeGetFormat * Signature: (J)I */ JNIEXPORT jint JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeGetFormat (JNIEnv *env, jobject obj, jlong nativeHandle) { CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle); if (frame) { // CVideoFrame types now match Java VideoFormat native types, so just pass it along return (jint)frame->GetType(); } return 0; }
/** * Initializes a framebuffer object, using the given width and height as * a guide. See OGLSD_InitTextureObject() and OGLSD_InitFBObject() * for more information. */ JNIEXPORT jboolean JNICALL Java_sun_java2d_opengl_OGLSurfaceData_initFBObject (JNIEnv *env, jobject oglsd, jlong pData, jboolean isOpaque, jboolean texNonPow2, jboolean texRect, jint width, jint height) { OGLSDOps *oglsdo = (OGLSDOps *)jlong_to_ptr(pData); GLuint fbobjectID, depthID; J2dTraceLn2(J2D_TRACE_INFO, "OGLSurfaceData_initFBObject: w=%d h=%d", width, height); if (oglsdo == NULL) { J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSurfaceData_initFBObject: ops are null"); return JNI_FALSE; } // initialize color texture object if (!OGLSD_InitTextureObject(oglsdo, isOpaque, texNonPow2, texRect, width, height)) { J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSurfaceData_initFBObject: could not init texture object"); return JNI_FALSE; } // initialize framebuffer object using color texture created above if (!OGLSD_InitFBObject(&fbobjectID, &depthID, oglsdo->textureID, oglsdo->textureTarget, oglsdo->textureWidth, oglsdo->textureHeight)) { J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSurfaceData_initFBObject: could not init fbobject"); j2d_glDeleteTextures(1, &oglsdo->textureID); return JNI_FALSE; } oglsdo->drawableType = OGLSD_FBOBJECT; // other fields (e.g. width, height) are set in OGLSD_InitTextureObject() oglsdo->fbobjectID = fbobjectID; oglsdo->depthID = depthID; OGLSD_SetNativeDimensions(env, oglsdo, oglsdo->textureWidth, oglsdo->textureHeight); // framebuffer objects differ from other OpenGL surfaces in that the // value passed to glRead/DrawBuffer() must be GL_COLOR_ATTACHMENTn_EXT, // rather than GL_FRONT (or GL_BACK) oglsdo->activeBuffer = GL_COLOR_ATTACHMENT0_EXT; return JNI_TRUE; }
/* * Class: sun_font_FreetypeFontScaler * Method: getGlyphOutlineBoundsNative * Signature: (Lsun/font/Font2D;JI)Ljava/awt/geom/Rectangle2D/Float; */ JNIEXPORT jobject JNICALL Java_sun_font_FreetypeFontScaler_getGlyphOutlineBoundsNative( JNIEnv *env, jobject scaler, jobject font2D, jlong pScalerContext, jlong pScaler, jint glyphCode) { FT_Outline *outline; FT_BBox bbox; int error; jobject bounds; FTScalerContext *context = (FTScalerContext*) jlong_to_ptr(pScalerContext); FTScalerInfo* scalerInfo = (FTScalerInfo *) jlong_to_ptr(pScaler); outline = getFTOutline(env, font2D, context, scalerInfo, glyphCode, 0, 0); if (outline == NULL || outline->n_points == 0) { /* it is legal case, e.g. invisible glyph */ bounds = (*env)->NewObject(env, sunFontIDs.rect2DFloatClass, sunFontIDs.rect2DFloatCtr); return bounds; } error = FT_Outline_Get_BBox(outline, &bbox); //convert bbox if (error || bbox.xMin >= bbox.xMax || bbox.yMin >= bbox.yMax) { bounds = (*env)->NewObject(env, sunFontIDs.rect2DFloatClass, sunFontIDs.rect2DFloatCtr); } else { bounds = (*env)->NewObject(env, sunFontIDs.rect2DFloatClass, sunFontIDs.rect2DFloatCtr4, F26Dot6ToFloat(bbox.xMin), F26Dot6ToFloat(-bbox.yMax), F26Dot6ToFloat(bbox.xMax-bbox.xMin), F26Dot6ToFloat(bbox.yMax-bbox.yMin)); } return bounds; }
/* * Class: java_awt_SplashScreen * Method: _isVisible * Signature: (J)Z */ JNIEXPORT jboolean JNICALL Java_java_awt_SplashScreen__1isVisible(JNIEnv * env, jclass thisClass, jlong jsplash) { Splash *splash = (Splash *) jlong_to_ptr(jsplash); if (!splash) { return JNI_FALSE; } return splash->isVisible>0 ? JNI_TRUE : JNI_FALSE; }
/** * This is the native dispose method that gets invoked when the Java-level * thread associated with this context is about to go away. This method * invokes the AWT_LOCK mechanism for thread safety, then destroys the * OGLContext kept in thread-local storage. */ static void WGLGC_DisposeOGLContext(JNIEnv *env, jlong pData) { OGLContext *oglc = (OGLContext *)jlong_to_ptr(pData); J2dTraceLn(J2D_TRACE_INFO, "in WGLGC_DisposeOGLContext"); OGLSD_LockImpl(env); WGLGC_DestroyOGLContext(env, oglc); OGLSD_UnlockImpl(env, OGLSD_NO_FLUSH); }
void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) { void *hModule = (void*)jlong_to_ptr(jHandle); void *fAddress = dlsym(hModule, functionName); if (fAddress == NULL) { char errorMessage[256]; snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName); throwNullPointerException(env, errorMessage); return NULL; } return fAddress; }
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 */ }
/** * This is the native dispose method that gets invoked when the Java-level * thread associated with this context is about to go away. This method * invokes the AWT_LOCK mechanism for thread safety, then destroys the * OGLContext kept in thread-local storage. */ static void GLXGC_DisposeOGLContext(JNIEnv *env, jlong pData) { OGLContext *oglc = (OGLContext *)jlong_to_ptr(pData); J2dTraceLn(J2D_TRACE_INFO, "in GLXGC_DisposeOGLContext"); AWT_LOCK(); GLXGC_DestroyOGLContext(env, oglc); AWT_FLUSH_UNLOCK(); }
/* * Class: com_sun_media_jfxmediaimpl_NativeVideoBuffer * Method: nativeGetBuffer * Signature: (J)Ljava/nio/ByteBuffer; * * WARNING: This method will create a new ByteBuffer object, you should cache this object to avoid multiple allocations. */ JNIEXPORT jobject JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeGetBuffer (JNIEnv *env, jobject obj, jlong nativeHandle) { CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle); if (frame) { void *dataPtr = frame->GetData(); jlong capacity = (jlong)frame->GetSize(); return env->NewDirectByteBuffer(dataPtr, capacity); } return NULL; }
JNIEXPORT jlong JNICALL Java_sun_nio_ch_FileDispatcher_writev0(JNIEnv *env, jclass clazz, jobject fdo, jlong address, jint len) { jint fd = fdval(env, fdo); struct iovec *iov = (struct iovec *)jlong_to_ptr(address); if (len > 16) { len = 16; } return convertLongReturnVal(env, writev(fd, iov, len), JNI_FALSE); }
JNIEXPORT void JNICALL Java_sun_nio_fs_LinuxNativeDispatcher_fremovexattr0(JNIEnv* env, jclass clazz, jint fd, jlong nameAddress) { int res = -1; const char* name = jlong_to_ptr(nameAddress); res = fremovexattr (fd, name); if (res == -1) throwUnixException(env, errno); }
/* * Class: sun_font_StrikeCache * Method: freeLongPointer * Signature: (J)V */ JNIEXPORT void JNICALL Java_sun_font_StrikeCache_freeLongPointer (JNIEnv *env, jclass cacheClass, jlong ptr) { /* Note this is used for freeing a glyph which was allocated * but never placed into the glyph cache. The caller holds the * only reference, therefore it is unnecessary to invalidate any * accelerated glyph cache cells as we do in freeInt/LongMemory(). */ if (ptr != 0L) { free(jlong_to_ptr(ptr)); } }