0

I have a custom TextureView that all the rendering is handled using OpenGL ES through JNI/C++.

Pretty much everything is working, aside the startDragAndDrop method. Which gives me an empty drag view...

Looking at the source code of the View.DragShadowBuilder class I found out that all the rendering logic for the creation of the drag view is inside the method public void onDrawShadow(Canvas canvas); which basically it passes the canvas to the onDraw(Canvas canvas) method of the view.

Now the problem is that TextureView doesn't implement the onDraw(Canvas canvas) method. And I'm unable to override it since it's final...

Is there any way that I can render the content of my TextureView in this canvas...

Right now I'm able to create a bitmap using a ByteBuffer and copying the buffer from OpenGL. But again I don't know how to pass this bitmap to the canvas...

vicmns
  • 724
  • 1
  • 8
  • 20

1 Answers1

1

It should be a simple matter of calling canvas.drawBitmap(bitmap, 0, 0, null); inside onDrawShadow. If that doesn't work you may need to check the data format in the ByteBuffer that you pass to the Bitmap when you call bitmap.copyPixelsFromBuffer to ensure that it matches the Bitmap.Config.

atomirex
  • 86
  • 3
  • Mmmmm I don't know why I didn't think about it, but yeah it worked... The drawback is that if my custom `TextureView` is inside a `ViewGroup` such as `CardView`. We can only render the Parent view (which will contained an empty area since it doesn't implement `onDrawCanvas`); or we can only render our `TextureView`... – vicmns Dec 21 '18 at 03:49