From 413baf8a03db180607efaca0bb60c15a153c4322 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Tue, 15 May 2012 19:15:47 -0700 Subject: Don't draw onto a hw surface using the software renderer Bug #6485955 If an invalidate gets scheduled right before the EGL surface is destroyed, the next draw pass is done in software. This causes the software renderer to connect to the surface forever which prevents the hardware renderer from coming back when the screen is turned back on. The fix here is to ignore the draw request when hw acceleration is requested but not yet available. Proper software fallback will still happen when an error is encountered with hardware rendering (in which case hw acceleration will not be marked as requested anymore.) Change-Id: I1edc4a51c8dd38240aa2345092a18a081a756fc1 --- core/java/android/view/ViewRootImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'core/java/android/view/ViewRootImpl.java') diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 41cd8873cdfb..bcd336d42d47 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2183,6 +2183,18 @@ public final class ViewRootImpl implements ViewParent, private boolean drawSoftware(Surface surface, AttachInfo attachInfo, int yoff, boolean scalingRequired, Rect dirty) { + // If we get here with a disabled & requested hardware renderer, something went + // wrong (an invalidate posted right before we destroyed the hardware surface + // for instance) so we should just bail out. Locking the surface with software + // rendering at this point would lock it forever and prevent hardware renderer + // from doing its job when it comes back. + if (attachInfo.mHardwareRenderer != null && !attachInfo.mHardwareRenderer.isEnabled() && + attachInfo.mHardwareRenderer.isRequested()) { + mFullRedrawNeeded = true; + scheduleTraversals(); + return false; + } + // Draw with software renderer. Canvas canvas; try { -- cgit v1.2.3