0

I want to use TextureView for draw Math curves(a lot), which data source is external device.

Here, every zone i draw, must add lines to previous.

Down to TextureView render using 3 buffers, i would like the buffer i draw in each moment, has like source the buffer i´ve just to release.

That is, i want the contain from buffer i release, fill the next buffer before i draw on it.

Other posibility, will be, force to use only one buffer.

I see, is possible get bitmap and setbitmap, but i would like do it without charge this in memory.

Anyone know if is this possible.

titgar
  • 27
  • 4

2 Answers2

0

I would recommend two things:

  1. Assuming you're rendering with Canvas, don't use TextureView. Use a custom View instead. TextureView doesn't really give you an advantage, and you lose hardware-accelerated rendering.
  2. Render to an off-screen Bitmap, then blit the Bitmap to the View. Offscreen rendering is not hardware-accelerated, but you avoid re-drawing the entire scene. You will have to experiment to determine which is most efficient.

If you're drawing with OpenGL ES, just draw everything to the TextureView on every frame (unless you want to play with FBOs).

fadden
  • 51,356
  • 5
  • 116
  • 166
  • Ok, thanks. I understand there´s no way to clone in gpu one buffer contain to the next buffer. But if i draw in off-screen bitmap, what is the point to use a customview instead of Textureview. Textureview with three buffers will be smother i guess... – titgar May 17 '16 at 20:20
  • The custom View should be uploading the Bitmap as a texture and using GLES to render it (assuming hardware acceleration is enabled, which it pretty much always is). IIRC the code is smart enough to not re-upload the Bitmap if it hasn't changed, though in your case that won't usually matter. Drawing on a TextureView with Canvas will always involve a software blit, followed by a texture upload... it should be faster to just upload the Bitmap directly, rather than rendering it in software and then uploading the rendered output. – fadden May 17 '16 at 22:20
  • Excuseme Fadden, i thought i answer you. I check the answer. Thank you. – titgar Jun 20 '16 at 11:32
0

You can try lockCanvas(null) of Surface.

  1. use TextureView.getSurfaceTexture to get a surfaceTexture
  2. use new Surface(surfaceTexture) to create a surface
  3. use Surface.lockCanvas or Canvas.lockHardwareCanvas to get a canvas.

Then you can do a lot of drawings on textureView with this canvas.

dragonfly
  • 1,151
  • 14
  • 35