0

When i have tried to render texture and transformation matrix to the EGLSurface, no display is seen in the view.

As a follow up of this issue , slightly i have modified slightly the code by following grafika/fadden sample code continuous capture

Here is my code:

Here is a draw method which runs on RenderThread.

This draw method is getting invoked properly whevener the data is produced at the producer end from Native Code.

 public void drawFrame() {

        mOffScreenSurface.makeCurrent();
        mCameraTexture.updateTexImage();
        mCameraTexture.getTransformMatrix(mTmpMatrix);

        mSurfaceWindowUser.makeCurrent();
        mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
        mSurfaceWindowUser.swapBuffers();


    }

run method of RenderThread ->

     public void run() {
            Looper.prepare();

            mHandler = new RenderHandler(this);

            mEglCore = new EglCore(null, EglCore.FLAG_RECORDABLE);

            mOffScreenSurface = new OffscreenSurface(mEglCore, 640, 480);

            mOffScreenSurface.makeCurrent();

            mFullFrameBlit = new FullFrameRect(
                    new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
            mTextureId = mFullFrameBlit.createTextureObject();

            mCameraTexture = new SurfaceTexture(mTextureId);
            mCameraSurface = new Surface (mCameraTexture);   // This surface i am sending to Native Code where i use ANativeWindow reference and copy the data using post method. {producer}

            mCameraTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
                @Override
                public void onFrameAvailable(SurfaceTexture surfaceTexture) {
                    Log.d (TAG, "Long breath.. data is pumbed by Native Layer producer..");
                    mHandler.frameReceivedFromProducer();
                }
            });

            mSurfaceWindowUser = new WindowSurface(mEglCore, mSurfaceUser, false);   // this mSurfaceUser is a surface received from MainActivity TextureView.
    }

To confirm if the produce at the native side producing the data, if i pass directly the user surface Without any EGL configurations, the frames are rendered into the screen.

At the native Level,

geometryResult = ANativeWindow_setBuffersGeometry(userNaiveWindow,640, 480, WINDOW_FORMAT_RGBA_8888);

To Render the frame i use

  ANativeWindow_lock  and ANativeWindow_unlockAndPost() to render directly frame into buffer. 

I could not able to think what could be wrong and where i have to dig more ?

Thanks fadden for your help.

Community
  • 1
  • 1
DrunkenMaster
  • 1,218
  • 3
  • 14
  • 28
  • You're not actually drawing anything on your OffscreenSurface -- there should be two calls to `drawFrame()`. – fadden Nov 22 '15 at 06:35
  • Hi fadden, do you mean surfaceTexture callback should be invoked two times? kindly provide input. i am afraid, i could not understand where to make drawFrame() twice. Thanks – DrunkenMaster Nov 24 '15 at 07:03
  • Sorry for the confusion, there are two methods with the same name. Your `drawFrame()` method calls `mFullFrameBlit.drawFrame()` for `mSurfaceWindowUser`, drawing the image on the TextureView, but does not call it for `mOffscreenSurface`. Your offscreen surface will never hold anything but transparent black, because you're not drawing anything on it. I'm assuming your native code is using that as the source for pixels. I don't fully understand what you're doing here though, or where things are breaking down. – fadden Nov 24 '15 at 16:32
  • Thanks fadden. Between, I see the preview in the user surface. Very bad of me. I was keeping another Surfaceview on top of TextureView. :(. – DrunkenMaster Nov 24 '15 at 16:43

0 Answers0