/**
  * Discard all resources held by this class, notably the EGL context.
  */
 public void Release()
 {
     if (mEGL != null)
     {
         if (mEGL.EglGetCurrentContext().Equals(mEGLContext))
         {
             // Clear the current context and surface to ensure they are discarded immediately.
             mEGL.EglMakeCurrent(mEGLDisplay, EGL10.EglNoSurface, EGL10.EglNoSurface,
                                 EGL10.EglNoContext);
         }
         mEGL.EglDestroySurface(mEGLDisplay, mEGLSurface);
         mEGL.EglDestroyContext(mEGLDisplay, mEGLContext);
         //mEGL.eglTerminate(mEGLDisplay);
     }
     _surface.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();
     // null everything out so future attempts to use this object will cause an NPE
     mEGLDisplay     = null;
     mEGLContext     = null;
     mEGLSurface     = null;
     mEGL            = null;
     _textureRender  = null;
     _surface        = null;
     _surfaceTexture = null;
 }
        /**
         * Creates instances of TextureRender and SurfaceTexture, and a Surface associated
         * with the SurfaceTexture.
         */
        private void setup()
        {
            _textureRender = new TextureRender();
            _textureRender.SurfaceCreated();
            // Even if we don't access the SurfaceTexture after the constructor returns, we
            // still need to keep a reference to it. The Surface doesn't retain a reference
            // at the Java level, so if we don't either then the object can get GCed, which
            // causes the native finalizer to run.

            _surfaceTexture = new SurfaceTexture(_textureRender.TextureId);
            // This doesn't work if OutputSurface 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, OutputSurface 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.
            //_surfaceTexture.SetOnFrameAvailableListener(this);
            _surfaceTexture.FrameAvailable += FrameAvailable;
            _surface = new Surface(_surfaceTexture);
        }
Exemplo n.º 3
0
 /**
  * Creates instances of TextureRender and SurfaceTexture, and a Surface associated
  * with the SurfaceTexture.
  */
 private void setup()
 {
     _textureRender = new TextureRender();
     _textureRender.SurfaceCreated();
     _surfaceTexture = new SurfaceTexture(_textureRender.TextureId);
     Parent.WeakSurfaceTexture.FrameAvailable += FrameAvailable;
     _surface = new Surface(Parent.WeakSurfaceTexture);
 }