From a9cdd4ff38aed1fb1bac64caec97bfb0b72d0ce9 Mon Sep 17 00:00:00 2001 From: Thomas Buhot Date: Fri, 2 Oct 2015 14:12:12 +0200 Subject: libhwui: make surface buffer allocation asynchronous 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 Signed-off-by: Zhiquan Liu --- libs/hwui/renderthread/CanvasContext.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libs') diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 6dfb6e8..33eb3f1 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #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(window); + s->allocateBuffers(); + } return true; } -- cgit v1.1