本文整理匯總了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();
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}