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


Java Surface.release方法代码示例

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


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

示例1: testSetPresentationTime

import android.view.Surface; //导入方法依赖的package包/类
/**
 * Test for {@link GLTools#setPresentationTime(EGLDisplay, EGLSurface, long)} .
 * @throws Exception by some fails
 */
@Test
public final void testSetPresentationTime() throws Exception {
    final EGLDisplay eglDisplay = GLTools.newDisplay();
    final EGLConfig eglConfig = GLTools.newConfig(eglDisplay, true);
    final EGLContext eglContext = GLTools.newContext(eglDisplay, eglConfig);
    final EGLSurface eglSurface =
            GLTools.newSurface(eglDisplay, eglConfig, FRAME_SIZE, FRAME_SIZE);
    GLTools.makeCurrent(eglDisplay, eglSurface, eglContext);

    final int txt = GLTools.newTexture(TEXTURE_LEVEL);
    final SurfaceTexture surfaceTexture = new SurfaceTexture(txt, true);
    final Surface surface = new Surface(surfaceTexture);
    final EGLSurface window = GLTools.newSurface(eglDisplay, eglConfig, surface);

    GLTools.setPresentationTime(eglDisplay, window, PRESENTATION_TIME);

    GLTools.closeSurface(eglDisplay, window);
    surface.release();
    surfaceTexture.release();
    GLTools.closeTexture(txt, TEXTURE_LEVEL);

    GLTools.closeSurface(eglDisplay, eglSurface);
    GLTools.closeContext(eglDisplay, eglContext);
    GLTools.closeDisplay(eglDisplay);
}
 
开发者ID:Nik-Gleb,项目名称:mpeg-encoder,代码行数:30,代码来源:GLToolsAndroidTest.java

示例2: testSwapBuffers

import android.view.Surface; //导入方法依赖的package包/类
/**
 * Test for {@link GLTools#swapBuffers(EGLDisplay, EGLSurface)}.
 * @throws Exception by some fails
 */
@Test
public final void testSwapBuffers() throws Exception {
    final EGLDisplay eglDisplay = GLTools.newDisplay();
    final EGLConfig eglConfig = GLTools.newConfig(eglDisplay, true);
    final EGLContext eglContext = GLTools.newContext(eglDisplay, eglConfig);
    final EGLSurface eglSurface =
            GLTools.newSurface(eglDisplay, eglConfig, FRAME_SIZE, FRAME_SIZE);
    GLTools.makeCurrent(eglDisplay, eglSurface, eglContext);
    try {
        GLTools.swapBuffers(eglDisplay, eglSurface);
    } catch (RuntimeException exception) {

        final int txt = GLTools.newTexture(TEXTURE_LEVEL);
        final SurfaceTexture surfaceTexture = new SurfaceTexture(txt, true);
        final Surface surface = new Surface(surfaceTexture);
        final EGLSurface window = GLTools.newSurface(eglDisplay, eglConfig, surface);

        GLTools.makeCurrent(eglDisplay, window, eglContext);
        GLTools.swapBuffers(eglDisplay, window);

        GLTools.closeSurface(eglDisplay, window);
        surface.release();
        surfaceTexture.release();
        GLTools.closeTexture(txt, TEXTURE_LEVEL);
    }

    GLTools.closeSurface(eglDisplay, eglSurface);
    GLTools.closeContext(eglDisplay, eglContext);
    GLTools.closeDisplay(eglDisplay);
}
 
开发者ID:Nik-Gleb,项目名称:mpeg-encoder,代码行数:35,代码来源:GLToolsAndroidTest.java

示例3: clickPlayStop

import android.view.Surface; //导入方法依赖的package包/类
/**
 * onClick handler for "play"/"stop" button.
 */
public void clickPlayStop(@SuppressWarnings("unused") View unused) {
    if (mShowStopLabel) {
        Log.d(TAG, "stopping movie");
        stopPlayback();
        // Don't update the controls here -- let the task thread do it after the movie has
        // actually stopped.
        //mShowStopLabel = false;
        //updateControls();
    } else {
        if (mPlayTask != null) {
            Log.w(TAG, "movie already playing");
            return;
        }
        Log.d(TAG, "starting movie");
        SpeedControlCallback callback = new SpeedControlCallback();
        if (((CheckBox) findViewById(R.id.locked60fps_checkbox)).isChecked()) {
            // TODO: consider changing this to be "free running" mode
            callback.setFixedPlaybackRate(60);
        }
        SurfaceTexture st = mTextureView.getSurfaceTexture();
        Surface surface = new Surface(st);
        MoviePlayer player = null;
        try {
             player = new MoviePlayer(
                    new File(getFilesDir(), mMovieFiles[mSelectedMovie]), surface, callback);
        } catch (IOException ioe) {
            Log.e(TAG, "Unable to play movie", ioe);
            surface.release();
            return;
        }
        adjustAspectRatio(player.getVideoWidth(), player.getVideoHeight());

        mPlayTask = new MoviePlayer.PlayTask(player, this);
        if (((CheckBox) findViewById(R.id.loopPlayback_checkbox)).isChecked()) {
            mPlayTask.setLoopMode(true);
        }

        mShowStopLabel = true;
        updateControls();
        mPlayTask.execute();
    }
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:46,代码来源:PlayMovieActivity.java

示例4: clickPlayStop

import android.view.Surface; //导入方法依赖的package包/类
/**
 * onClick handler for "play"/"stop" button.
 */
public void clickPlayStop(@SuppressWarnings("unused") View unused) {
    if (mShowStopLabel) {
        Log.d(TAG, "stopping movie");
        stopPlayback();
        // Don't update the controls here -- let the task thread do it after the movie has
        // actually stopped.
        //mShowStopLabel = false;
        //updateControls();
    } else {
        if (mPlayTask != null) {
            Log.w(TAG, "movie already playing");
            return;
        }

        Log.d(TAG, "starting movie");
        SpeedControlCallback callback = new SpeedControlCallback();
        SurfaceHolder holder = mSurfaceView.getHolder();
        Surface surface = holder.getSurface();

        // Don't leave the last frame of the previous video hanging on the screen.
        // Looks weird if the aspect ratio changes.
        clearSurface(surface);

        MoviePlayer player = null;
        try {
             player = new MoviePlayer(
                    new File(getFilesDir(), mMovieFiles[mSelectedMovie]), surface, callback);
        } catch (IOException ioe) {
            Log.e(TAG, "Unable to play movie", ioe);
            surface.release();
            return;
        }

        AspectFrameLayout layout = (AspectFrameLayout) findViewById(R.id.playMovie_afl);
        int width = player.getVideoWidth();
        int height = player.getVideoHeight();
        layout.setAspectRatio((double) width / height);
        //holder.setFixedSize(width, height);

        mPlayTask = new MoviePlayer.PlayTask(player, this);

        mShowStopLabel = true;
        updateControls();
        mPlayTask.execute();
    }
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:50,代码来源:PlayMovieSurfaceActivity.java

示例5: run

import android.view.Surface; //导入方法依赖的package包/类
@Override
public void run() {
	try {
		mGifInfoHandle = mInputSource.open();
	} catch (IOException ex) {
		mIOException = ex;
		return;
	}

	GifTextureView.super.setSurfaceTextureListener(this);
	final boolean isSurfaceAvailable = isAvailable();
	isSurfaceValid.set(isSurfaceAvailable);
	if (isSurfaceAvailable) {
		post(new Runnable() {
			@Override
			public void run() {
				updateTextureViewSize(mGifInfoHandle);
			}
		});
	}
	mGifInfoHandle.setSpeedFactor(mSpeedFactor);

	while (!isInterrupted()) {
		try {
			isSurfaceValid.block();
		} catch (InterruptedException e) {
			break;
		}
		final SurfaceTexture surfaceTexture = getSurfaceTexture();
		if (surfaceTexture == null) {
			continue;
		}
		final Surface surface = new Surface(surfaceTexture);
		try {
			mGifInfoHandle
					.bindSurface(surface, mSavedState, isOpaque());
		} finally {
			surface.release();
		}
	}
	mGifInfoHandle.recycle();
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:43,代码来源:GifTextureView.java


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