flowkey / UIKit-cross-platform

Cross-platform Swift implementation of UIKit, mostly for Android
MIT License
600 stars 40 forks source link

Only render when layer tree dirty #183

Closed ephemer closed 6 years ago

ephemer commented 6 years ago

Type of change: performance improvement, bugfix

Motivation

Sometimes when things changed on the screen we wouldn't update the view until you pressed the screen / moved the mouse etc. This was confusing for users. Also we would often re-render even if nothing had changed in the layer tree.

This change fixes both of those issues, simultaneously improving performance (on mac we use 1/10th of the CPU we used to in the normal case) and improving rendering correctness.

michaelknoch commented 6 years ago

I wondered if it would make sense to implement layerTreeIsDirty as instance variable on CALayer. If a layer gets dirty it would set layerTreeIsDirty of all parent layers to true. That would allow us to partially render parts of the layer hierarchy @ephemer