diff options
author | Chet Haase <chet@google.com> | 2014-09-11 11:07:02 -0700 |
---|---|---|
committer | Chet Haase <chet@google.com> | 2014-09-11 12:28:29 -0700 |
commit | 4f52b3420684e85252a7341d906e47145855b6ec (patch) | |
tree | d6f173b2b326ae5e16e944b80a7ad457a9eadb7c /core/java/android/view | |
parent | a7cbaeb138b280b51f282a371cd11c65c0d05d1b (diff) | |
download | frameworks_base-4f52b3420684e85252a7341d906e47145855b6ec.zip frameworks_base-4f52b3420684e85252a7341d906e47145855b6ec.tar.gz frameworks_base-4f52b3420684e85252a7341d906e47145855b6ec.tar.bz2 |
Make starting window hw-accelerated
An earlier fix in L disabled hw acceleration for the starting window
after the system process became hw accelerated. This was done to preserve
the old behavior of the starting window having some default behavior
(in particular, being filled with a default color). However, this ends up
being a memory and performance problem on some platforms (memory because
some platforms have backing store for software surfaces, performance
because it takes far longer to create a screen-size software surface than
a hardware surface).
The fix is to allow the starting window to inherit the hw acceleration
behavior of its process, and to detect when we are drawing the contents
of that starting window and to fill it with a default color (black).
Issue #17443449 use hardware rendering for app preview window
Change-Id: I8be8111d9e38c51fbbc07185acca065815ce26dc
Diffstat (limited to 'core/java/android/view')
-rw-r--r-- | core/java/android/view/HardwareRenderer.java | 3 | ||||
-rw-r--r-- | core/java/android/view/ThreadedRenderer.java | 15 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 12 | ||||
-rw-r--r-- | core/java/android/view/WindowManager.java | 20 |
4 files changed, 17 insertions, 33 deletions
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index edb3798..d23e115 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -339,7 +339,8 @@ public abstract class HardwareRenderer { * @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); + abstract void draw(View view, View.AttachInfo attachInfo, HardwareDrawCallbacks callbacks, + boolean isStartingWindow); /** * 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 5d2822d..3d1332c 100644 --- a/core/java/android/view/ThreadedRenderer.java +++ b/core/java/android/view/ThreadedRenderer.java @@ -16,6 +16,7 @@ package android.view; +import android.graphics.Color; import com.android.internal.R; import android.content.Context; @@ -267,7 +268,8 @@ public class ThreadedRenderer extends HardwareRenderer { view.mRecreateDisplayList = false; } - private void updateRootDisplayList(View view, HardwareDrawCallbacks callbacks) { + private void updateRootDisplayList(View view, HardwareDrawCallbacks callbacks, + boolean isStartingWindow) { Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList"); updateViewTreeDisplayList(view); @@ -279,6 +281,12 @@ public class ThreadedRenderer extends HardwareRenderer { 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(); @@ -298,7 +306,8 @@ public class ThreadedRenderer extends HardwareRenderer { } @Override - void draw(View view, AttachInfo attachInfo, HardwareDrawCallbacks callbacks) { + void draw(View view, AttachInfo attachInfo, HardwareDrawCallbacks callbacks, + boolean isStartingWindow) { attachInfo.mIgnoreDirtyState = true; long frameTimeNanos = mChoreographer.getFrameTimeNanos(); attachInfo.mDrawingTime = frameTimeNanos / TimeUtils.NANOS_PER_MS; @@ -308,7 +317,7 @@ public class ThreadedRenderer extends HardwareRenderer { recordDuration = System.nanoTime(); } - updateRootDisplayList(view, callbacks); + updateRootDisplayList(view, callbacks, isStartingWindow); if (mProfilingEnabled) { recordDuration = System.nanoTime() - recordDuration; diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 43ab4ef..ae6e4e7 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -711,17 +711,10 @@ public final class ViewRootImpl implements ViewParent, // 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 (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 + if (!HardwareRenderer.sRendererDisabled || (HardwareRenderer.sSystemRendererDisabled && forceHwAccelerated)) { if (mAttachInfo.mHardwareRenderer != null) { mAttachInfo.mHardwareRenderer.destroy(); @@ -2486,7 +2479,8 @@ public final class ViewRootImpl implements ViewParent, dirty.setEmpty(); mBlockResizeBuffer = false; - mAttachInfo.mHardwareRenderer.draw(mView, mAttachInfo, this); + mAttachInfo.mHardwareRenderer.draw(mView, mAttachInfo, this, + params.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); } 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 47ee52e..273ec9d 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -1024,26 +1024,6 @@ public interface WindowManager extends ViewManager { 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 |