当前位置: 首页>>代码示例>>C++>>正文


C++ JAWT::Unlock方法代码示例

本文整理汇总了C++中JAWT::Unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ JAWT::Unlock方法的具体用法?C++ JAWT::Unlock怎么用?C++ JAWT::Unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JAWT的用法示例。


在下文中一共展示了JAWT::Unlock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUnlockAWT(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.Unlock(env);
}
开发者ID:edubrunaldi,项目名称:SpaceSample,代码行数:9,代码来源:org_lwjgl_opengl_Display.c

示例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);
}
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:78,代码来源:myfile.c

示例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;
}
开发者ID:JREkiwi,项目名称:sagetv,代码行数:93,代码来源:SageTVWin32DLL.cpp

示例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);
}
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:71,代码来源:myfile.cpp


注:本文中的JAWT::Unlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。