Revert "Make starting window hw-accelerated"
Bug: 17516789
This change corresponds to a sudden influx of bad surface crashes.
Reverting to see if stability returns as this was an optimization
CL
This reverts commit 29ff1bc57ac2c995c56f15ed6e56e5fb247b2a44.
Change-Id: I7835e89017161d94ad05fe46d81bd437c3dae3a7
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index d23e115..edb3798 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -339,8 +339,7 @@
* @param attachInfo AttachInfo tied to the specified view.
* @param callbacks Callbacks invoked when drawing happens.
*/
- abstract void draw(View view, View.AttachInfo attachInfo, HardwareDrawCallbacks callbacks,
- boolean isStartingWindow);
+ abstract void draw(View view, View.AttachInfo attachInfo, HardwareDrawCallbacks callbacks);
/**
* Creates a new hardware layer. A hardware layer built by calling this
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index 3d1332c..5d2822d 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -16,7 +16,6 @@
package android.view;
-import android.graphics.Color;
import com.android.internal.R;
import android.content.Context;
@@ -268,8 +267,7 @@
view.mRecreateDisplayList = false;
}
- private void updateRootDisplayList(View view, HardwareDrawCallbacks callbacks,
- boolean isStartingWindow) {
+ private void updateRootDisplayList(View view, HardwareDrawCallbacks callbacks) {
Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList");
updateViewTreeDisplayList(view);
@@ -281,12 +279,6 @@
callbacks.onHardwarePreDraw(canvas);
canvas.insertReorderBarrier();
- if (isStartingWindow) {
- // Compensate for some situations in which a hw-accelerated surface
- // will not be filled with anything by default; this is equivalent
- // to the old behavior when the system process was not hw-accelerated
- canvas.drawColor(Color.BLACK);
- }
canvas.drawRenderNode(view.getDisplayList());
canvas.insertInorderBarrier();
@@ -306,8 +298,7 @@
}
@Override
- void draw(View view, AttachInfo attachInfo, HardwareDrawCallbacks callbacks,
- boolean isStartingWindow) {
+ void draw(View view, AttachInfo attachInfo, HardwareDrawCallbacks callbacks) {
attachInfo.mIgnoreDirtyState = true;
long frameTimeNanos = mChoreographer.getFrameTimeNanos();
attachInfo.mDrawingTime = frameTimeNanos / TimeUtils.NANOS_PER_MS;
@@ -317,7 +308,7 @@
recordDuration = System.nanoTime();
}
- updateRootDisplayList(view, callbacks, isStartingWindow);
+ updateRootDisplayList(view, callbacks);
if (mProfilingEnabled) {
recordDuration = System.nanoTime() - recordDuration;
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index ae6e4e7..43ab4ef 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -711,10 +711,17 @@
// can be used by code on the system process to escape that and enable
// HW accelerated drawing. (This is basically for the lock screen.)
+ final boolean fakeHwAccelerated = (attrs.privateFlags &
+ WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED) != 0;
final boolean forceHwAccelerated = (attrs.privateFlags &
WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED) != 0;
- if (!HardwareRenderer.sRendererDisabled
+ if (fakeHwAccelerated) {
+ // This is exclusively for the preview windows the window manager
+ // shows for launching applications, so they will look more like
+ // the app being launched.
+ mAttachInfo.mHardwareAccelerationRequested = true;
+ } else if (!HardwareRenderer.sRendererDisabled
|| (HardwareRenderer.sSystemRendererDisabled && forceHwAccelerated)) {
if (mAttachInfo.mHardwareRenderer != null) {
mAttachInfo.mHardwareRenderer.destroy();
@@ -2479,8 +2486,7 @@
dirty.setEmpty();
mBlockResizeBuffer = false;
- mAttachInfo.mHardwareRenderer.draw(mView, mAttachInfo, this,
- params.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
+ mAttachInfo.mHardwareRenderer.draw(mView, mAttachInfo, this);
} else {
// If we get here with a disabled & requested hardware renderer, something went
// wrong (an invalidate posted right before we destroyed the hardware surface
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 273ec9d..47ee52e 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -1024,6 +1024,26 @@
public int flags;
/**
+ * If the window has requested hardware acceleration, but this is not
+ * allowed in the process it is in, then still render it as if it is
+ * hardware accelerated. This is used for the starting preview windows
+ * in the system process, which don't need to have the overhead of
+ * hardware acceleration (they are just a static rendering), but should
+ * be rendered as such to match the actual window of the app even if it
+ * is hardware accelerated.
+ * Even if the window isn't hardware accelerated, still do its rendering
+ * as if it was.
+ * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
+ * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
+ * is generally disabled. This flag must be specified in addition to
+ * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
+ * windows.
+ *
+ * @hide
+ */
+ public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
+
+ /**
* In the system process, we globally do not use hardware acceleration
* because there are many threads doing UI there and they conflict.
* If certain parts of the UI that really do want to use hardware