本文整理汇总了C++中JAWT::Lock方法的典型用法代码示例。如果您正苦于以下问题:C++ JAWT::Lock方法的具体用法?C++ JAWT::Lock怎么用?C++ JAWT::Lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JAWT
的用法示例。
在下文中一共展示了JAWT::Lock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT(JNIEnv *env, jclass clazz) {
JAWT jawt;
jawt.version = JAWT_VERSION_1_4;
if (JAWT_GetAWT(env, &jawt) != JNI_TRUE) {
throwException(env, "GetAWT failed");
return;
}
jawt.Lock(env);
}
示例2: printf
/*
* Class: MyCanvas
* Method: paint
* Signature: (Ljava/awt/Graphics;)V
*/
JNIEXPORT void JNICALL Java_MyCanvas_paint
(JNIEnv* env, jobject canvas, jobject graphics)
{
JAWT awt;
JAWT_DrawingSurface* ds;
JAWT_DrawingSurfaceInfo* dsi;
JAWT_X11DrawingSurfaceInfo* dsi_x11;
jboolean result;
jint lock;
GC gc;
jobject ref;
/* Get the AWT */
awt.version = JAWT_VERSION_1_4;
if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
printf("AWT Not found\n");
return;
}
/* Lock the AWT */
awt.Lock(env);
/* Unlock the AWT */
awt.Unlock(env);
/* Get the drawing surface */
ds = awt.GetDrawingSurface(env, canvas);
if (ds == NULL) {
printf("NULL drawing surface\n");
return;
}
/* Lock the drawing surface */
lock = ds->Lock(ds);
printf("Lock value %d\n", (int)lock);
if((lock & JAWT_LOCK_ERROR) != 0) {
printf("Error locking surface\n");
awt.FreeDrawingSurface(ds);
return;
}
/* Get the drawing surface info */
dsi = ds->GetDrawingSurfaceInfo(ds);
if (dsi == NULL) {
printf("Error getting surface info\n");
ds->Unlock(ds);
awt.FreeDrawingSurface(ds);
return;
}
/* Get the platform-specific drawing info */
dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
/* Now paint */
gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0);
XSetForeground(dsi_x11->display, gc, 0);
XFillRectangle(dsi_x11->display, dsi_x11->drawable, gc,
5, 5, 90, 90);
XFreeGC(dsi_x11->display, gc);
ref = awt.GetComponent(env, (void*)(dsi_x11->drawable));
if (!(*env)->IsSameObject(env, ref, canvas)) {
printf("Error! Different objects!\n");
}
/* Free the drawing surface info */
ds->FreeDrawingSurfaceInfo(dsi);
/* Unlock the drawing surface */
ds->Unlock(ds);
/* Free the drawing surface */
awt.FreeDrawingSurface(ds);
}
示例3: jboolean
/*
* Class: sage_UIUtils
* Method: getHWND
* Signature: (Ljava/awt/Canvas;)J
*/
JNIEXPORT jlong JNICALL Java_sage_UIUtils_getHWND
(JNIEnv *env, jclass jc, jobject canvas)
{
JAWT awt;
JAWT_DrawingSurface* ds = NULL;
JAWT_DrawingSurfaceInfo* dsi = NULL;
JAWT_Win32DrawingSurfaceInfo* dsi_win = NULL;
jboolean result;
jint lock;
env->MonitorEnter(canvas);
loadAWTLib();
// Get the AWT, we have to explicitly load it otherwise it'll try it load it
// when we execute and the link will fail.
typedef jboolean (JNICALL *AWTPROC)(JNIEnv* env, JAWT* awt);
awt.version = JAWT_VERSION_1_4;
#ifdef _WIN64
AWTPROC lpfnProc = (AWTPROC)GetProcAddress(sageLoadedAwtLib, "JAWT_GetAWT");
#else
AWTPROC lpfnProc = (AWTPROC)GetProcAddress(sageLoadedAwtLib, "[email protected]");
#endif
result = lpfnProc(env, &awt);
if (result == JNI_FALSE)
{
slog((env, "Failed loading JAWT lib\r\n"));
env->MonitorExit(canvas);
return 0;
}
awt.Lock(env);
// Get the drawing surface
ds = awt.GetDrawingSurface(env, canvas);
if (ds == NULL)
{
slog((env, "Failed getting drawing surface for AWT\r\n"));
env->MonitorExit(canvas);
awt.Unlock(env);
return 0;
}
// Lock the drawing surface
lock = ds->Lock(ds);
if ((lock & JAWT_LOCK_ERROR) != 0)
{
slog((env, "Failed locking the drawing surface for AWT\r\n"));
// Free the drawing surface
awt.FreeDrawingSurface(ds);
env->MonitorExit(canvas);
awt.Unlock(env);
return 0;
}
// Get the drawing surface info
dsi = ds->GetDrawingSurfaceInfo(ds);
if (dsi == NULL)
{
slog((env, "Failed getting dsi for AWT\r\n"));
// Unlock the drawing surface
ds->Unlock(ds);
// Free the drawing surface
awt.FreeDrawingSurface(ds);
env->MonitorExit(canvas);
awt.Unlock(env);
return 0;
}
// Get the platform-specific drawing info
dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
jlong rv = (jlong) dsi_win->hwnd;
// Free the drawing surface info
ds->FreeDrawingSurfaceInfo(dsi);
// Unlock the drawing surface
ds->Unlock(ds);
// Free the drawing surface
awt.FreeDrawingSurface(ds);
env->MonitorExit(canvas);
awt.Unlock(env);
return rv;
}
示例4: printf
JNIEXPORT void JNICALL Java_MyCanvas_paint
(JNIEnv* env, jobject canvas, jobject graphics)
{
/* Get the AWT */
JAWT awt;
awt.version = JAWT_VERSION_1_4;
if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
printf("AWT Not found\n");
return;
}
/* Lock the AWT */
awt.Lock(env);
/* Unlock the AWT */
awt.Unlock(env);
/* Get the drawing surface */
JAWT_DrawingSurface* ds = awt.GetDrawingSurface(env, canvas);
if (ds == NULL) {
printf("NULL drawing surface\n");
return;
}
/* Lock the drawing surface */
jint lock = ds->Lock(ds);
printf("Lock value %d\n", (int)lock);
if((lock & JAWT_LOCK_ERROR) != 0) {
printf("Error locking surface\n");
return;
}
/* Get the drawing surface info */
JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds);
if (dsi == NULL) {
printf("Error getting surface info\n");
ds->Unlock(ds);
return;
}
/* Get the platform-specific drawing info */
JAWT_Win32DrawingSurfaceInfo* dsi_win =
(JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
/* Now paint */
PAINTSTRUCT ps;
/* Do not use the HDC returned from BeginPaint()!! */
::BeginPaint(dsi_win->hwnd, &ps);
HBRUSH hbrush = (HBRUSH)::GetStockObject(BLACK_BRUSH);
RECT rect;
rect.left = 5;
rect.top = 5;
rect.right = 95;
rect.bottom = 95;
::FillRect(dsi_win->hdc, &rect, hbrush);
::EndPaint(dsi_win->hwnd, &ps);
jobject ref = awt.GetComponent(env, (void*)(dsi_win->hwnd));
if (!env->IsSameObject(ref, canvas)) {
printf("Error! Different objects!\n");
}
/* Free the drawing surface info */
ds->FreeDrawingSurfaceInfo(dsi);
/* Unlock the drawing surface */
ds->Unlock(ds);
/* Free the drawing surface */
awt.FreeDrawingSurface(ds);
}