Add invokeFunctor
Change-Id: I09e675d3e02e3e528642175ada00b2b17fab7652
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 017fb56..fa82627 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -82,6 +82,8 @@
// Returns true on success, false on failure
void initialize();
+ bool hasContext();
+
void usePBufferSurface();
EGLSurface createSurface(EGLNativeWindowType window);
void destroySurface(EGLSurface surface);
@@ -138,7 +140,7 @@
}
void GlobalContext::initialize() {
- if (mEglDisplay != EGL_NO_DISPLAY) return;
+ if (hasContext()) return;
mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
LOG_ALWAYS_FATAL_IF(mEglDisplay == EGL_NO_DISPLAY,
@@ -157,6 +159,10 @@
initAtlas();
}
+bool GlobalContext::hasContext() {
+ return mEglDisplay != EGL_NO_DISPLAY;
+}
+
void GlobalContext::loadConfig() {
EGLint swapBehavior = mCanSetDirtyRegions ? EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0;
EGLint attribs[] = {
@@ -440,6 +446,15 @@
mCanvas->detachFunctor(functor);
}
+void CanvasContext::invokeFunctor(Functor* functor) {
+ DrawGlInfo::Mode mode = DrawGlInfo::kModeProcessNoContext;
+ if (mGlobalContext->hasContext()) {
+ requireGlContext();
+ mode = DrawGlInfo::kModeProcess;
+ }
+ (*functor)(mode, NULL);
+}
+
void CanvasContext::invokeFunctors() {
mInvokeFunctorsPending = false;