summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2014-11-07 11:02:07 -0800
committerJohn Reck <jreck@google.com>2014-11-07 11:02:07 -0800
commitaa95a88327d9a3ac8a4a00b065b78ac0f28b3a19 (patch)
tree1e2e65ec4a7d28ea3b0a253be0d31eaf397dd005 /core/java/android
parentb9744c1c1f5e8cc936da7f1832665f77ad5bb18f (diff)
downloadframeworks_base-aa95a88327d9a3ac8a4a00b065b78ac0f28b3a19.zip
frameworks_base-aa95a88327d9a3ac8a4a00b065b78ac0f28b3a19.tar.gz
frameworks_base-aa95a88327d9a3ac8a4a00b065b78ac0f28b3a19.tar.bz2
Have an actual fallback if the surface is lost
Bug: 17516789 This will force a relayout/reinitialize pass if the Surface is lost mid-render instead of crashing on the next frame Change-Id: If08bfa16f740728fa7c05904fa11e26f07b81e2e
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/ThreadedRenderer.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index 00a8884..5579c13 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -66,6 +66,8 @@ public class ThreadedRenderer extends HardwareRenderer {
private static final int SYNC_OK = 0;
// Needs a ViewRoot invalidate
private static final int SYNC_INVALIDATE_REQUIRED = 1 << 0;
+ // Spoiler: the reward is GPU-accelerated drawing, better find that Surface!
+ private static final int SYNC_LOST_SURFACE_REWARD_IF_FOUND = 1 << 1;
private static final String[] VISUALIZERS = {
PROFILE_PROPERTY_VISUALIZE_BARS,
@@ -336,6 +338,12 @@ public class ThreadedRenderer extends HardwareRenderer {
int syncResult = nSyncAndDrawFrame(mNativeProxy, frameTimeNanos,
recordDuration, view.getResources().getDisplayMetrics().density);
+ if ((syncResult & SYNC_LOST_SURFACE_REWARD_IF_FOUND) != 0) {
+ setEnabled(false);
+ // Invalidate since we failed to draw. This should fetch a Surface
+ // if it is still needed or do nothing if we are no longer drawing
+ attachInfo.mViewRootImpl.invalidate();
+ }
if ((syncResult & SYNC_INVALIDATE_REQUIRED) != 0) {
attachInfo.mViewRootImpl.invalidate();
}