summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2018-07-17 15:24:16 +0200
committerJorim Jaggi <jjaggi@google.com>2018-07-17 17:34:49 +0200
commit7823ee73ee504fcb5b0448b0b8f1b4804309df45 (patch)
treef8da6181ceba92bf79e44981bf8305bcb1cd862b
parent0c84996a12ace0a81ecfeb5f3a79e55127a06af0 (diff)
downloadbase-7823ee73ee504fcb5b0448b0b8f1b4804309df45.tar.gz
Move allocateBuffers to RT
Such that it gets executed after setSurface, in order that mReqUsage has the correct flags set. Test: Take trace, ensure that allocateBuffers actually allocates in the right format/usage by ensuring that dequeueBuffer doesn't trash them immediately again. Bug: 111517695 Change-Id: I94b402d7b29d565155a77a2d09106246261712d2
-rw-r--r--core/java/android/view/ThreadedRenderer.java5
-rw-r--r--core/java/android/view/ViewRootImpl.java2
-rw-r--r--core/jni/android_view_ThreadedRenderer.cpp8
-rw-r--r--libs/hwui/renderthread/RenderProxy.cpp5
-rw-r--r--libs/hwui/renderthread/RenderProxy.h1
5 files changed, 20 insertions, 1 deletions
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index 5b61015e9d42..5952d782fa2a 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -961,6 +961,10 @@ public final class ThreadedRenderer {
nSetDebuggingEnabled(enable);
}
+ void allocateBuffers(Surface surface) {
+ nAllocateBuffers(mNativeProxy, surface);
+ }
+
@Override
protected void finalize() throws Throwable {
try {
@@ -1251,4 +1255,5 @@ public final class ThreadedRenderer {
private static native void nSetDebuggingEnabled(boolean enabled);
private static native void nSetIsolatedProcess(boolean enabled);
private static native void nSetContextPriority(int priority);
+ private static native void nAllocateBuffers(long nativeProxy, Surface window);
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 98a1ec38a1b4..6df0173d9684 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -2103,7 +2103,7 @@ public final class ViewRootImpl implements ViewParent,
& View.PFLAG_REQUEST_TRANSPARENT_REGIONS) == 0) {
// Don't pre-allocate if transparent regions
// are requested as they may not be needed
- mSurface.allocateBuffers();
+ mAttachInfo.mThreadedRenderer.allocateBuffers(mSurface);
}
} catch (OutOfResourcesException e) {
handleOutOfResourcesException(e);
diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp
index ee9a123ab674..165316ca7b9c 100644
--- a/core/jni/android_view_ThreadedRenderer.cpp
+++ b/core/jni/android_view_ThreadedRenderer.cpp
@@ -1060,6 +1060,13 @@ static void android_view_ThreadedRenderer_setContextPriority(JNIEnv*, jclass,
Properties::contextPriority = contextPriority;
}
+static void android_view_ThreadedRenderer_allocateBuffers(JNIEnv* env, jobject clazz,
+ jlong proxyPtr, jobject jsurface) {
+ RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
+ sp<Surface> surface = android_view_Surface_getSurface(env, jsurface);
+ proxy->allocateBuffers(surface);
+}
+
// ----------------------------------------------------------------------------
// FrameMetricsObserver
// ----------------------------------------------------------------------------
@@ -1173,6 +1180,7 @@ static const JNINativeMethod gMethods[] = {
{ "nSetDebuggingEnabled", "(Z)V", (void*)android_view_ThreadedRenderer_setDebuggingEnabled },
{ "nSetIsolatedProcess", "(Z)V", (void*)android_view_ThreadedRenderer_setIsolatedProcess },
{ "nSetContextPriority", "(I)V", (void*)android_view_ThreadedRenderer_setContextPriority },
+ { "nAllocateBuffers", "(JLandroid/view/Surface;)V", (void*)android_view_ThreadedRenderer_allocateBuffers },
};
static JavaVM* mJvm = nullptr;
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 59048be768e9..020761110ef0 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -87,6 +87,11 @@ void RenderProxy::initialize(const sp<Surface>& surface) {
[ this, surf = surface ]() mutable { mContext->setSurface(std::move(surf)); });
}
+void RenderProxy::allocateBuffers(const sp<Surface>& surface) {
+ mRenderThread.queue().post(
+ [ surf = surface ]() mutable { surf->allocateBuffers(); });
+}
+
void RenderProxy::updateSurface(const sp<Surface>& surface) {
mRenderThread.queue().post(
[ this, surf = surface ]() mutable { mContext->setSurface(std::move(surf)); });
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index ad534f0d96b5..0d29b4bcc317 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -70,6 +70,7 @@ public:
ANDROID_API void setName(const char* name);
ANDROID_API void initialize(const sp<Surface>& surface);
+ ANDROID_API void allocateBuffers(const sp<Surface>& surface);
ANDROID_API void updateSurface(const sp<Surface>& surface);
ANDROID_API bool pauseSurface(const sp<Surface>& surface);
ANDROID_API void setStopped(bool stopped);