summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Brown <jeffbrown@google.com> 2012-10-10 18:27:44 -0700
committer Jeff Brown <jeffbrown@google.com> 2012-10-10 21:46:55 -0700
commit78eb122450f127d66d4e8cf7f65cad80ea85d3ac (patch)
tree03e699d07837e6e833d09ba37bf782483137294b
parent9cf36b7a77bb8e821f9e593fdbb200f8a1742ff0 (diff)
Dejank electron beam.
On some devices it can take hundreds of milliseconds to get a brand new EGL surface performing in tip-top shape. To get it ready make it do a few pushups before the show begins. Bug: 7318962 Change-Id: I7ae92ce100c368327042a29ffa65faee9b567c8d
-rw-r--r--services/java/com/android/server/power/ElectronBeam.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/services/java/com/android/server/power/ElectronBeam.java b/services/java/com/android/server/power/ElectronBeam.java
index 2abdceb5de41..9a536485ae1b 100644
--- a/services/java/com/android/server/power/ElectronBeam.java
+++ b/services/java/com/android/server/power/ElectronBeam.java
@@ -63,6 +63,11 @@ final class ElectronBeam {
private static final float HSTRETCH_DURATION = 0.5f;
private static final float VSTRETCH_DURATION = 1.0f - HSTRETCH_DURATION;
+ // The number of frames to draw when preparing the animation so that it will
+ // be ready to run smoothly. We use 3 frames because we are triple-buffered.
+ // See code for details.
+ private static final int DEJANK_FRAMES = 3;
+
// Set to true when the animation context has been fully prepared.
private boolean mPrepared;
private int mMode;
@@ -145,6 +150,19 @@ final class ElectronBeam {
// Done.
mPrepared = true;
+
+ // Dejanking optimization.
+ // Some GL drivers can introduce a lot of lag in the first few frames as they
+ // initialize their state and allocate graphics buffers for rendering.
+ // Work around this problem by rendering the first frame of the animation a few
+ // times. The rest of the animation should run smoothly thereafter.
+ // The frames we draw here aren't visible because we are essentially just
+ // painting the screenshot as-is.
+ if (mode == MODE_COOL_DOWN) {
+ for (int i = 0; i < DEJANK_FRAMES; i++) {
+ draw(1.0f);
+ }
+ }
return true;
}