Reputation: 339
I have a set of highly optimized graphic routines for real-time effects (for a camera app)
The routine that uses them works in a layered mode in the following way:
Each time the process is executed (on each preview frame)
> We have a bitmap (after YUV2RGB conversion) to start working with. Will call it B(0)
> We have N independent sets of "layered lenses" with its properties: window (subset
of the bitmap to be processed), color conversion, lighting, distortion, transparency...
For each lens (L=1...N), and sequentially, do the following:
1) Take B(L-1) and, according to layer properties: process a subset of it.
2) Draw the results onto the same bitmap. It will be called bitmap(L)
In 2) the drawing is made with a canvas, and it takes quite a long time if I need to scale it. I would like to speed-up this part.
I have heard of hardware-accelerated canvas and they are faster, but I am a little confused on its usage. I need something which draws faster but still gives me access to the results for further processing.
So, my question is:
Do hardware-accelerated canvas only work with a view, or also with bitmaps? I.e., if I do, let's say N loops, but for each one I need the result of the previous, will it be of use?
If not, any way to speed canvas drawing?
Thanks a lot.
Upvotes: 1
Views: 1094
Reputation: 13548
Because we are not talking about overdraw and multiple view rendering on the screen, there's not so much to do with canvas drawing performance (yes, assuming the view is hardware accelerated). Anyway, drawing bitmap data in a SurfaceTexture should be the faster way to "write" image data on the screen (as suggested by documentation).
Can you tell us more about the implementation? Looking at your composed task, I suppose that you can try to get more performance from the image-processing steps. How are they implemented? Usually fast image elaborations are made at native layer (JNI/C++) and using Renderscript where possible. A good solution could be obtained moving all the elaboration at JNI level, processing the image as an Opengl ES texture which can be drawn very quickly inside a SurfaceTexture.
Upvotes: 1