OSDN Git Service

libhwui: make surface buffer allocation asynchronous
authorThomas Buhot <thomas.buhot@intel.com>
Fri, 2 Oct 2015 12:12:12 +0000 (14:12 +0200)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 20 Jul 2016 09:53:18 +0000 (17:53 +0800)
On the critical path of the cold launch of applications
the main thread of the started application allocates
the surface buffer. The allocation is synchronous and blocks
the main thread of the application.
As a consequence the launch time of the application is delayed
by the time spent doing the allocation.

With this optimization the allocation is performed
asynchronously in the RenderThread. This optimization
will benefit to the launch of all applications.

Change-Id: I4bc145cfc3ba6fe1efbca519bcee2e4ea6617ae7
Signed-off-by: Thomas Buhot <thomas.buhot@intel.com>
Tracked-On: https://jira01.devtools.intel.com/browse/OAM-3601
FeatureID: https://jira01.devtools.intel.com/browse/AREQ-13987
Reviewed-on: https://android.intel.com:443/420527

core/java/android/view/ViewRootImpl.java
libs/hwui/renderthread/CanvasContext.cpp

index 42402eb..97476f2 100644 (file)
@@ -1721,12 +1721,6 @@ public final class ViewRootImpl implements ViewParent,
                             try {
                                 hwInitialized = mAttachInfo.mHardwareRenderer.initialize(
                                         mSurface);
-                                if (hwInitialized && (host.mPrivateFlags
-                                        & View.PFLAG_REQUEST_TRANSPARENT_REGIONS) == 0) {
-                                    // Don't pre-allocate if transparent regions
-                                    // are requested as they may not be needed
-                                    mSurface.allocateBuffers();
-                                }
                             } catch (OutOfResourcesException e) {
                                 handleOutOfResourcesException(e);
                                 return;
index 6dfb6e8..33eb3f1 100644 (file)
@@ -31,6 +31,7 @@
 #include <strings.h>
 #include <cutils/properties.h>
 #include <private/hwui/DrawGlInfo.h>
+#include <gui/Surface.h>
 
 #define TRIM_MEMORY_COMPLETE 80
 #define TRIM_MEMORY_UI_HIDDEN 20
@@ -115,6 +116,10 @@ bool CanvasContext::initialize(ANativeWindow* window) {
     if (mCanvas) return false;
     mCanvas = new OpenGLRenderer(mRenderThread.renderState());
     mCanvas->initProperties();
+    if (window) {
+        Surface *s = static_cast<Surface*>(window);
+        s->allocateBuffers();
+    }
     return true;
 }