當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。