當前位置: 首頁>>代碼示例>>C++>>正文


C++ ANativeWindow_fromSurface函數代碼示例

本文整理匯總了C++中ANativeWindow_fromSurface函數的典型用法代碼示例。如果您正苦於以下問題:C++ ANativeWindow_fromSurface函數的具體用法?C++ ANativeWindow_fromSurface怎麽用?C++ ANativeWindow_fromSurface使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ANativeWindow_fromSurface函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: onSurfaceCreated

static void onSurfaceCreated(JNIEnv *env, jobject /*object*/, jobject surface)
{
    s_currentNativeWindowMutex.lock();
    s_currentNativeWindow = AndroidWindow(ANativeWindow_fromSurface(env, surface), [](ANativeWindow *w) { ANativeWindow_release(w); });
    ++s_currentNativeWindowId;
    s_currentNativeWindowMutex.unlock();
}
開發者ID:goneflash,項目名稱:apitrace,代碼行數:7,代碼來源:glws_egl_android.cpp

示例2: ANativeWindow_fromSurface

//rendering
JNIEXPORT void JNICALL Java_me_lake_librestreaming_core_ColorHelper_renderingSurface
(JNIEnv * env, jobject thiz,jobject javaSurface,jbyteArray pixelsArray,jint w,jint h,jint size) {
	ANativeWindow* window = ANativeWindow_fromSurface(env, javaSurface);
	if(window!=NULL)
	{
		ANativeWindow_setBuffersGeometry(window,w,h,COLOR_FORMAT_NV21);
		ANativeWindow_Buffer buffer;
		if (ANativeWindow_lock(window, &buffer, NULL) == 0) {
			unsigned char *pixels = (unsigned char*)(*env)->GetByteArrayElements(env,pixelsArray, 0);
			if(buffer.width==buffer.stride){
				memcpy(buffer.bits, pixels,  size);
			}else{
				int height = h*3/2;
				int width = w;
				int i=0;
				for(;i<height;++i)
					memcpy(buffer.bits +  buffer.stride * i
						, pixels + width * i
						, width);
			}
			(*env)->ReleaseByteArrayElements(env,pixelsArray,pixels,JNI_ABORT);
			ANativeWindow_unlockAndPost(window);
		}
		ANativeWindow_release(window);
	}
	return;
}
開發者ID:fly518420,項目名稱:librestreaming,代碼行數:28,代碼來源:restreaming.c

示例3: Java_org_skia_viewer_ViewerActivity_onSurfaceChanged

extern "C" JNIEXPORT void JNICALL Java_org_skia_viewer_ViewerActivity_onSurfaceChanged(
    JNIEnv* env, jobject activity, jlong handle, jobject surface) {
    auto skiaAndroidApp = (SkiaAndroidApp*)handle;
    Message message(kSurfaceChanged);
    message.fNativeWindow = ANativeWindow_fromSurface(env, surface);
    skiaAndroidApp->postMessage(message);
}
開發者ID:VarcoDevs,項目名稱:skia,代碼行數:7,代碼來源:surface_glue_android.cpp

示例4: com_stainberg_MediaPlayer_MediaPlayer_setSurface

static void
com_stainberg_MediaPlayer_MediaPlayer_setSurface(JNIEnv* env, jobject thiz, jobject surface) {
//	if(surface != NULL) {
//		if(spWindow != NULL) {
//			ANativeWindow_release(spWindow);
//			spWindow = NULL;
//		}
//		spWindow = ANativeWindow_fromSurface(env, surface);
//		if(spMediaPlayer != NULL) {
//			spMediaPlayer->initSurface(spWindow);
//		}
//	}
	if(spWindow != NULL) {
		ANativeWindow_release(spWindow);
		spWindow = NULL;
	}
	if(spMediaPlayer != NULL) {
		spMediaPlayer->initSurface(NULL);
	}
	if(surface != NULL) {
		spWindow = ANativeWindow_fromSurface(env, surface);
		if(spMediaPlayer != NULL) {
			spMediaPlayer->initSurface(spWindow);
		}
	}
}
開發者ID:stainberg,項目名稱:android_FFMPEG,代碼行數:26,代碼來源:com_stainberg_MediaPlayer_MediaPlayer.cpp

示例5: ANativeWindow_fromSurface

/*
 * Class:     com_mcxiaoke_ndk_Native
 * Method:    initNW
 * Signature: (JLandroid/view/Surface;)V
 */
JNIEXPORT void JNICALL Java_com_mcxiaoke_ndk_Native_initNW
(JNIEnv *env, jclass clazz, jlong avi, jobject surface)
{
    // Get the native window from the surface
    ANativeWindow* nativeWindow = ANativeWindow_fromSurface(
                                      env, surface);
    if (0 == nativeWindow)
    {
        ThrowException(env, "java/lang/RuntimeException",
                       "Unable to get native window from surface.");
        goto exit;
    }

    // Set the buffers geometry to AVI movie frame dimensions
    // If these are different than the window's physical size
    // then the buffer will be scaled to match that size.
    if (0 > ANativeWindow_setBuffersGeometry(nativeWindow,
            AVI_video_width((avi_t*) avi),
            AVI_video_height((avi_t*) avi),
            WINDOW_FORMAT_RGB_565))
    {
        ThrowException(env, "java/lang/RuntimeException",
                       "Unable to set buffers geometry.");
    }

    // Release the native window
    ANativeWindow_release(nativeWindow);
    nativeWindow = 0;

exit:
    return;
}
開發者ID:GoghVin,項目名稱:android-ndk-notes,代碼行數:37,代碼來源:player.cpp

示例6: onSurfaceChanged

static void onSurfaceChanged(JNIEnv *env, jobject /*object*/, jobject surface, int /*format*/, int /*width*/, int /*height*/)
{
    s_currentNativeWindowMutex.lock();
    s_currentNativeWindow = AndroidWindow(ANativeWindow_fromSurface(env, surface), [](ANativeWindow *w) { ANativeWindow_release(w); });
    ++s_currentNativeWindowId;
    s_currentNativeWindowMutex.unlock();
}
開發者ID:goneflash,項目名稱:apitrace,代碼行數:7,代碼來源:glws_egl_android.cpp

示例7: GetPlatformWindowDimensions

extern void GetPlatformWindowDimensions(void* nativeHandle, int* width, int* height)
{
    ANativeWindow* w = ANativeWindow_fromSurface(Jni, (jobject)nativeHandle);
    VERBOSE("Got native window for measurements %p", w);
    *width = ANativeWindow_getWidth(w);
    *height = ANativeWindow_getHeight(w);
    ANativeWindow_release(w);
}
開發者ID:AvaloniaUI,項目名稱:libperspesk,代碼行數:8,代碼來源:droid.cpp

示例8: Java_com_gaulois94_samples_ZombieRenderer_createZombieRenderer

JNIEXPORT jlong JNICALL Java_com_gaulois94_samples_ZombieRenderer_createZombieRenderer(JNIEnv* jenv, jclass jcls, jlong parent, jobject surface)
{
	ZombieRenderer* renderer = new ZombieRenderer((Updatable*)parent);
	ANativeWindow* window = ANativeWindow_fromSurface(jenv, surface);
	renderer->initializeContext(window);

	return (jlong)renderer;
}
開發者ID:MickaelSERENO,項目名稱:ZombieAttack,代碼行數:8,代碼來源:nativeZombieRenderer.cpp

示例9: nativeSetSurface

	JNIEXPORT void JNICALL nativeSetSurface(JNIEnv* jenv, jobject obj, jobject surface) {
		if(surface != 0) {
			nativeWindow = ANativeWindow_fromSurface(jenv, surface);
		} else {
			ANativeWindow_release(nativeWindow);
		}
		return;
	}
開發者ID:yaakuro,項目名稱:XdevLSDK,代碼行數:8,代碼來源:XdevLWindowAndroid.cpp

示例10: Java_info_sodapanda_sodaplayer_FFmpegVideoView_setupsurface

//當Android係統中對應播放窗口的Surfaceview創建的時候,在native層得到這個surface的引用地址
int Java_info_sodapanda_sodaplayer_FFmpegVideoView_setupsurface(JNIEnv* env,jobject thiz,jobject pSurface,int pwidth,int pheight,jlong ptr){
	playInstance *instance = (playInstance *)ptr;
	instance->window = ANativeWindow_fromSurface(env,pSurface);
	if(instance->display_width !=0){
		setAndroidWindowPix(instance->display_width,instance->display_height,instance);
	}
	instance->disable_video=0;
	return 0;
}
開發者ID:PlayOrion,項目名稱:sodaplayer,代碼行數:10,代碼來源:main.c

示例11: Java_com_android_cts_opengl_primitive_GLPrimitiveActivity_setupContextSwitchBenchmark

extern "C" JNIEXPORT void JNICALL
Java_com_android_cts_opengl_primitive_GLPrimitiveActivity_setupContextSwitchBenchmark(
        JNIEnv* env, jclass clazz, jobject surface, jboolean offscreen, jint workload) {
    if (workload <= 8) {
        // This test uses 8 iterations, so workload can't be more than 8.
        gRenderer = new ContextSwitchRenderer(
                ANativeWindow_fromSurface(env, surface), offscreen, workload);
    }
}
開發者ID:10114395,項目名稱:android-5.0.0_r5,代碼行數:9,代碼來源:GLPrimitive.cpp

示例12: Java_com_huazhen_barcode_MainActivity_JNIinitDecoder

extern "C" JNIEXPORT void JNICALL
Java_com_huazhen_barcode_MainActivity_JNIinitDecoder(JNIEnv *env, jclass cls, jint w, jint h, jobject surface) {
    ANativeWindow* window = 0;
    if (surface) {
        window = ANativeWindow_fromSurface(env, surface); // ANativeWindow_release
        ERR_EXIT_IF(!window, "ANativeWindow_fromSurface: %p %p", env, surface);
    }
    hgs_init( w,h, window);
}
開發者ID:hyz,項目名稱:cpp-snippets,代碼行數:9,代碼來源:hgs-jni.cpp

示例13: Android_JNI_GetEnv

ANativeWindow *Android_JNI_GetNativeWindow(void) {
	ANativeWindow *anw;
	jobject s;
	JNIEnv *env = Android_JNI_GetEnv();

	s = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetNativeSurface);
	anw = ANativeWindow_fromSurface(env, s);
	(*env)->DeleteLocalRef(env, s);

	return anw;
}
開發者ID:angjminer,項目名稱:godot,代碼行數:11,代碼來源:power_android.cpp

示例14: Java_com_example_nativecodec_NativeCodec_setSurface

// set the surface
void Java_com_example_nativecodec_NativeCodec_setSurface(JNIEnv *env, jclass clazz, jobject surface)
{
   // obtain a native window from a Java surface
   if (data.window)
   {
      ANativeWindow_release(data.window);
      data.window = NULL;
   }
   data.window = ANativeWindow_fromSurface(env, surface);
   LOGV("@@@ setsurface %p", data.window);
}
開發者ID:mrkcass,項目名稱:MammothPlayer4K,代碼行數:12,代碼來源:native-codec-jni.cpp

示例15: naSetSurface

void naSetSurface(JNIEnv *pEnv, jobject pObj, jobject pSurface) {
	if (0 != pSurface) {
		// get the native window reference
		window = ANativeWindow_fromSurface(pEnv, pSurface);
		// set format and size of window buffer
		ANativeWindow_setBuffersGeometry(window, 0, 0, WINDOW_FORMAT_RGBA_8888);
	} else {
		// release the native window
		ANativeWindow_release(window);
	}
}
開發者ID:alexandruc,項目名稱:android-ffmpeg-player,代碼行數:11,代碼來源:ffmpeg-player.c


注:本文中的ANativeWindow_fromSurface函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。