DO NOT MERGE ANYWHERE Revert "DO NOT MERGE ANYWHERE libhwui: make setSurface asynchronous"

This reverts commit 80e6d8873b.

Bug: 32771832

Change-Id: Ia2f2ffd08dfd87cbce1ec750d6b61277799b536f
This commit is contained in:
Andriy Naborskyy
2016-11-10 01:51:24 +00:00
parent 80e6d8873b
commit c5bf8bc74d
6 changed files with 13 additions and 14 deletions

View File

@@ -145,10 +145,9 @@ public class ThreadedRenderer extends HardwareRenderer {
@Override @Override
boolean initialize(Surface surface) throws OutOfResourcesException { boolean initialize(Surface surface) throws OutOfResourcesException {
boolean status = !mInitialized;
mInitialized = true; mInitialized = true;
updateEnabledState(surface); updateEnabledState(surface);
nInitialize(mNativeProxy, surface); boolean status = nInitialize(mNativeProxy, surface);
return status; return status;
} }
@@ -504,7 +503,7 @@ public class ThreadedRenderer extends HardwareRenderer {
private static native boolean nLoadSystemProperties(long nativeProxy); private static native boolean nLoadSystemProperties(long nativeProxy);
private static native void nSetName(long nativeProxy, String name); private static native void nSetName(long nativeProxy, String name);
private static native void nInitialize(long nativeProxy, Surface window); private static native boolean nInitialize(long nativeProxy, Surface window);
private static native void nUpdateSurface(long nativeProxy, Surface window); private static native void nUpdateSurface(long nativeProxy, Surface window);
private static native boolean nPauseSurface(long nativeProxy, Surface window); private static native boolean nPauseSurface(long nativeProxy, Surface window);
private static native void nSetup(long nativeProxy, int width, int height, private static native void nSetup(long nativeProxy, int width, int height,

View File

@@ -262,11 +262,11 @@ static void android_view_ThreadedRenderer_setName(JNIEnv* env, jobject clazz,
env->ReleaseStringUTFChars(jname, name); env->ReleaseStringUTFChars(jname, name);
} }
static void android_view_ThreadedRenderer_initialize(JNIEnv* env, jobject clazz, static jboolean android_view_ThreadedRenderer_initialize(JNIEnv* env, jobject clazz,
jlong proxyPtr, jobject jsurface) { jlong proxyPtr, jobject jsurface) {
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
sp<ANativeWindow> window = android_view_Surface_getNativeWindow(env, jsurface); sp<ANativeWindow> window = android_view_Surface_getNativeWindow(env, jsurface);
proxy->initialize(window); return proxy->initialize(window);
} }
static void android_view_ThreadedRenderer_updateSurface(JNIEnv* env, jobject clazz, static void android_view_ThreadedRenderer_updateSurface(JNIEnv* env, jobject clazz,
@@ -461,7 +461,7 @@ static JNINativeMethod gMethods[] = {
{ "nDeleteProxy", "(J)V", (void*) android_view_ThreadedRenderer_deleteProxy }, { "nDeleteProxy", "(J)V", (void*) android_view_ThreadedRenderer_deleteProxy },
{ "nLoadSystemProperties", "(J)Z", (void*) android_view_ThreadedRenderer_loadSystemProperties }, { "nLoadSystemProperties", "(J)Z", (void*) android_view_ThreadedRenderer_loadSystemProperties },
{ "nSetName", "(JLjava/lang/String;)V", (void*) android_view_ThreadedRenderer_setName }, { "nSetName", "(JLjava/lang/String;)V", (void*) android_view_ThreadedRenderer_setName },
{ "nInitialize", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_initialize }, { "nInitialize", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_initialize },
{ "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface }, { "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface },
{ "nPauseSurface", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_pauseSurface }, { "nPauseSurface", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_pauseSurface },
{ "nSetup", "(JIIFII)V", (void*) android_view_ThreadedRenderer_setup }, { "nSetup", "(JIIFII)V", (void*) android_view_ThreadedRenderer_setup },

View File

@@ -110,11 +110,12 @@ void CanvasContext::setSwapBehavior(SwapBehavior swapBehavior) {
mSwapBehavior = swapBehavior; mSwapBehavior = swapBehavior;
} }
void CanvasContext::initialize(ANativeWindow* window) { bool CanvasContext::initialize(ANativeWindow* window) {
setSurface(window); setSurface(window);
if (mCanvas) return; if (mCanvas) return false;
mCanvas = new OpenGLRenderer(mRenderThread.renderState()); mCanvas = new OpenGLRenderer(mRenderThread.renderState());
mCanvas->initProperties(); mCanvas->initProperties();
return true;
} }
void CanvasContext::updateSurface(ANativeWindow* window) { void CanvasContext::updateSurface(ANativeWindow* window) {

View File

@@ -67,7 +67,7 @@ public:
// Won't take effect until next EGLSurface creation // Won't take effect until next EGLSurface creation
void setSwapBehavior(SwapBehavior swapBehavior); void setSwapBehavior(SwapBehavior swapBehavior);
void initialize(ANativeWindow* window); bool initialize(ANativeWindow* window);
void updateSurface(ANativeWindow* window); void updateSurface(ANativeWindow* window);
bool pauseSurface(ANativeWindow* window); bool pauseSurface(ANativeWindow* window);
bool hasSurface() { return mNativeWindow.get(); } bool hasSurface() { return mNativeWindow.get(); }

View File

@@ -140,15 +140,14 @@ void RenderProxy::setName(const char* name) {
} }
CREATE_BRIDGE2(initialize, CanvasContext* context, ANativeWindow* window) { CREATE_BRIDGE2(initialize, CanvasContext* context, ANativeWindow* window) {
args->context->initialize(args->window); return (void*) args->context->initialize(args->window);
return nullptr;
} }
void RenderProxy::initialize(const sp<ANativeWindow>& window) { bool RenderProxy::initialize(const sp<ANativeWindow>& window) {
SETUP_TASK(initialize); SETUP_TASK(initialize);
args->context = mContext; args->context = mContext;
args->window = window.get(); args->window = window.get();
post(task); return (bool) postAndWait(task);
} }
CREATE_BRIDGE2(updateSurface, CanvasContext* context, ANativeWindow* window) { CREATE_BRIDGE2(updateSurface, CanvasContext* context, ANativeWindow* window) {

View File

@@ -67,7 +67,7 @@ public:
ANDROID_API bool loadSystemProperties(); ANDROID_API bool loadSystemProperties();
ANDROID_API void setName(const char* name); ANDROID_API void setName(const char* name);
ANDROID_API void initialize(const sp<ANativeWindow>& window); ANDROID_API bool initialize(const sp<ANativeWindow>& window);
ANDROID_API void updateSurface(const sp<ANativeWindow>& window); ANDROID_API void updateSurface(const sp<ANativeWindow>& window);
ANDROID_API bool pauseSurface(const sp<ANativeWindow>& window); ANDROID_API bool pauseSurface(const sp<ANativeWindow>& window);
ANDROID_API void setup(int width, int height, float lightRadius, ANDROID_API void setup(int width, int height, float lightRadius,