DescriptionDynamically set CAOpenGLLAyer to be asynchronous
The supported non-blocking path for drawing content that updates on the
order of 60fps is to create a CAOpenGLLayer and set its asynchronous
property to YES. In practice, just calling setNeedsDisplay about
about 60fps results in noticeable jank.
The downside to setting the CAOpenGLLayer to be asynchronous is that it
will be asked, every vsync, if it has anything new to draw (via the
canDrawInOpenGLContext callback), resulting in high CPU usage, even
when idle.
The solution to this is to dynamically set the isAsynchronous property
to YES when new frames are seen, and leave it at NO when it has been a
while (defined as a quarter second arbitrarily) since a new frame has
been generated.
Note that when a new frame is generated, the gotNewFrame call is made,
while when a re-display is required (say, because the window became
visible), only setNeedsDisplay is called. This is to avoid going in to
asynchronous mode unnecessarily.
Also note that the DelayTimer object is hung off the RWHVMac class
instead of the CompositingIOSurfaceLayer object. This is because
the DelayTimer class requires a C++ class to hang off of, instead of an
Objective C interface.
BUG=340133
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=251323
Patch Set 1 #Patch Set 2 : Unset needsDisplay_ in a more conservative place #
Total comments: 3
Patch Set 3 : Incorporate review feedback #
Messages
Total messages: 6 (0 generated)
|