예제 #1
0
            /**
             * Creates interconnected instances of TextureRender, SurfaceTexture, and Surface.
             */
            private void setup()
            {
                try
                {
                    mTextureRender = new STextureRender();
                    mTextureRender.surfaceCreated();

                    //if (VERBOSE) Log.d(TAG, "textureID=" + mTextureRender.getTextureId());
                    mSurfaceTexture = new SurfaceTexture(mTextureRender.getTextureId());

                    // This doesn't work if this object is created on the thread that CTS started for
                    // these test cases.
                    //
                    // The CTS-created thread has a Looper, and the SurfaceTexture constructor will
                    // create a Handler that uses it.  The "frame available" message is delivered
                    // there, but since we're not a Looper-based thread we'll never see it.  For
                    // this to do anything useful, CodecOutputSurface must be created on a thread without
                    // a Looper, so that SurfaceTexture uses the main application Looper instead.
                    //
                    // Java language note: passing "this" out of a constructor is generally unwise,
                    // but we should be able to get away with it here.

                    //removed because could not get callback to work and even so do not want to wait 2.5 seconds for each frame, might need to revist
                    //mSurfaceTexture.SetOnFrameAvailableListener(this);

                    mSurface = new Surface(mSurfaceTexture);

                    mPixelBuf = ByteBuffer.AllocateDirect(mWidth * mHeight * 4);
                    mPixelBuf.Order(ByteOrder.LittleEndian);
                }
                catch (System.Exception e)
                {
                    var x = e;
                }
            }
예제 #2
0
            /**
             * Discard all resources held by this class, notably the EGL context.
             */
            public void release()
            {
                if (mEGLDisplay != EGL14.EglNoDisplay)
                {
                    EGL14.EglDestroySurface(mEGLDisplay, mEGLSurface);
                    EGL14.EglDestroyContext(mEGLDisplay, mEGLContext);
                    EGL14.EglReleaseThread();
                    EGL14.EglTerminate(mEGLDisplay);
                }
                mEGLDisplay = EGL14.EglNoDisplay;
                mEGLContext = EGL14.EglNoContext;
                mEGLSurface = EGL14.EglNoSurface;

                mSurface.Release();

                // this causes a bunch of warnings that appear harmless but might confuse someone:
                //  W BufferQueue: [unnamed-3997-2] cancelBuffer: BufferQueue has been abandoned!
                //mSurfaceTexture.release();

                mTextureRender  = null;
                mSurface        = null;
                mSurfaceTexture = null;
            }