How to synchronize OpenGL drawing with UIKit updates

前端 未结 6 548
深忆病人
深忆病人 2020-12-24 02:24

In our app we have UIScrollView above CAEAGLLayer. UIScrollView contains some UIViews (red rectangles). In CAEAGLLayer we draw white rectangles. Centers of white rectangles

6条回答
  •  孤城傲影
    2020-12-24 03:12

    I am trying to solve exactly same issue. I tried all method described above but nothing was acceptable.

    Ideally, this can be solved by accessing Core Animation's final compositing GL context. But we can't access the private API.

    One another way is transferring GL result to CA. I tried this by reading frame-buffer pixels to dispatch to CALayer which was too slow. About over 200MB/sec data should be transferred. Now I am trying to optimize this. Because this is the last way that I can try.

    Update

    Still heavy, but reading frame-buffer and setting it to a CALayer.content is working well and shows acceptable performance on my iPhone 4S. Anyway over 70% of CPU load is used only for this reading and setting operation. Especially glReadPixels I this most of them are just waiting time for reading data from GPU memory.

    Update2

    I gave up last method. It's cost is almost purely pixel transferring and still too slow. I decided to draw every dynamic objects in GL. Only some static popup views will be drawn with CA.

提交回复
热议问题