fastest way to draw a screen buffer on the iphone

后端 未结 5 1921
终归单人心
终归单人心 2020-12-12 21:35

I have a \"software renderer\" that I am porting from PC to the iPhone. what is the fastest way to manually update the screen with a buffer of pixels on the iphone? for in

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 21:58

    The fastest App Store approved way to do CPU-only 2D graphics is to create a CGImage backed by a buffer using CGDataProviderCreateDirect and assign that to a CALayer's contents property.

    For best results use the kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little or kCGImageAlphaNone | kCGBitmapByteOrder32Little bitmap types and double buffer so that the display is never in an inconsistent state.

    edit: this should be faster than drawing to an OpenGL texture in theory, but as always, profile to be sure.

    edit2: CADisplayLink is a useful class no matter which compositing method you use.

提交回复
热议问题