Merge "Implement missing safelyRun() on ThreadedRenderer"
This commit is contained in:
@@ -113,8 +113,8 @@ public class ThreadedRenderer extends HardwareRenderer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean safelyRun(Runnable action) {
|
boolean safelyRun(Runnable action) {
|
||||||
// TODO:
|
nRunWithGlContext(mNativeProxy, action);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -256,6 +256,7 @@ public class ThreadedRenderer extends HardwareRenderer {
|
|||||||
private static native void nSetup(long nativeProxy, int width, int height);
|
private static native void nSetup(long nativeProxy, int width, int height);
|
||||||
private static native void nDrawDisplayList(long nativeProxy, long displayList,
|
private static native void nDrawDisplayList(long nativeProxy, long displayList,
|
||||||
int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom);
|
int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom);
|
||||||
|
private static native void nRunWithGlContext(long nativeProxy, Runnable runnable);
|
||||||
private static native void nDestroyCanvas(long nativeProxy);
|
private static native void nDestroyCanvas(long nativeProxy);
|
||||||
|
|
||||||
private static native void nAttachFunctor(long nativeProxy, long functor);
|
private static native void nAttachFunctor(long nativeProxy, long functor);
|
||||||
|
|||||||
@@ -131,6 +131,13 @@ static void android_view_ThreadedRenderer_detachFunctor(JNIEnv* env, jobject cla
|
|||||||
proxy->detachFunctor(functor);
|
proxy->detachFunctor(functor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void android_view_ThreadedRenderer_runWithGlContext(JNIEnv* env, jobject clazz,
|
||||||
|
jlong proxyPtr, jobject jrunnable) {
|
||||||
|
RenderProxy* proxy = reinterpret_cast<RenderProxy*>( proxyPtr);
|
||||||
|
RenderTask* task = new JavaTask(env, jrunnable);
|
||||||
|
proxy->runWithGlContext(task);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -151,6 +158,7 @@ static JNINativeMethod gMethods[] = {
|
|||||||
{ "nDestroyCanvas", "(J)V", (void*) android_view_ThreadedRenderer_destroyCanvas},
|
{ "nDestroyCanvas", "(J)V", (void*) android_view_ThreadedRenderer_destroyCanvas},
|
||||||
{ "nAttachFunctor", "(JJ)V", (void*) android_view_ThreadedRenderer_attachFunctor},
|
{ "nAttachFunctor", "(JJ)V", (void*) android_view_ThreadedRenderer_attachFunctor},
|
||||||
{ "nDetachFunctor", "(JJ)V", (void*) android_view_ThreadedRenderer_detachFunctor},
|
{ "nDetachFunctor", "(JJ)V", (void*) android_view_ThreadedRenderer_detachFunctor},
|
||||||
|
{ "nRunWithGlContext", "(JLjava/lang/Runnable;)V", (void*) android_view_ThreadedRenderer_runWithGlContext },
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -462,6 +462,16 @@ void CanvasContext::queueFunctorsTask(int delayMs) {
|
|||||||
mRenderThread.queueDelayed(&mInvokeFunctorsTask, delayMs);
|
mRenderThread.queueDelayed(&mInvokeFunctorsTask, delayMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CanvasContext::runWithGlContext(RenderTask* task) {
|
||||||
|
if (mEglSurface != EGL_NO_SURFACE) {
|
||||||
|
mGlobalContext->makeCurrent(mEglSurface);
|
||||||
|
} else {
|
||||||
|
mGlobalContext->usePBufferSurface();
|
||||||
|
}
|
||||||
|
|
||||||
|
task->run();
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace renderthread */
|
} /* namespace renderthread */
|
||||||
} /* namespace uirenderer */
|
} /* namespace uirenderer */
|
||||||
} /* namespace android */
|
} /* namespace android */
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ public:
|
|||||||
void attachFunctor(Functor* functor);
|
void attachFunctor(Functor* functor);
|
||||||
void detachFunctor(Functor* functor);
|
void detachFunctor(Functor* functor);
|
||||||
|
|
||||||
|
void runWithGlContext(RenderTask* task);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setSurface(EGLNativeWindowType window);
|
void setSurface(EGLNativeWindowType window);
|
||||||
void swapBuffers();
|
void swapBuffers();
|
||||||
|
|||||||
@@ -170,6 +170,18 @@ void RenderProxy::detachFunctor(Functor* functor) {
|
|||||||
post(task);
|
post(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CREATE_BRIDGE2(runWithGlContext, CanvasContext* context, RenderTask* task) {
|
||||||
|
args->context->runWithGlContext(args->task);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderProxy::runWithGlContext(RenderTask* gltask) {
|
||||||
|
SETUP_TASK(runWithGlContext);
|
||||||
|
args->context = mContext;
|
||||||
|
args->task = gltask;
|
||||||
|
postAndWait(task);
|
||||||
|
}
|
||||||
|
|
||||||
MethodInvokeRenderTask* RenderProxy::createTask(RunnableMethod method) {
|
MethodInvokeRenderTask* RenderProxy::createTask(RunnableMethod method) {
|
||||||
// TODO: Consider having a small pool of these to avoid alloc churn
|
// TODO: Consider having a small pool of these to avoid alloc churn
|
||||||
return new MethodInvokeRenderTask(method);
|
return new MethodInvokeRenderTask(method);
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ public:
|
|||||||
ANDROID_API void attachFunctor(Functor* functor);
|
ANDROID_API void attachFunctor(Functor* functor);
|
||||||
ANDROID_API void detachFunctor(Functor* functor);
|
ANDROID_API void detachFunctor(Functor* functor);
|
||||||
|
|
||||||
|
ANDROID_API void runWithGlContext(RenderTask* task);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RenderThread& mRenderThread;
|
RenderThread& mRenderThread;
|
||||||
CanvasContext* mContext;
|
CanvasContext* mContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user