EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { EGLWrapperContext *wctx = (EGLWrapperContext *)ctx; EGLContext aglContext = (ctx == EGL_NO_CONTEXT ? EGL_NO_CONTEXT : wctx->aglContext); EGLThreadInfo *ti = getEGLThreadInfo(); EGLBoolean res = getDispatch()->eglMakeCurrent(dpy, draw, read, aglContext); if (res ) { // NOTE - we do get a pointer to the server connection, (rather then using ti->serverConn) // for cases that this is the first egl call of the current thread. ServerConnection *server; if (s_needEncode && (server = ServerConnection::s_getServerConnection())) { server->utEnc()->makeCurrentContext(server->utEnc(), getpid(), (uint32_t) (draw == EGL_NO_SURFACE ? 0 : draw), (uint32_t) (read == EGL_NO_SURFACE ? 0 : read), (uint32_t) (ctx == EGL_NO_CONTEXT ? 0 : ctx)); server->glEncoder()->setClientState( wctx ? wctx->clientState : NULL ); server->gl2Encoder()->setClientState( wctx ? wctx->clientState : NULL ); } // set current context in our thread info ti->currentContext = wctx; } return res; }
Atom MSIDispatchConsumer::getAtomProperty(Atom name) const { AXTam *axcore = (AXTam *)core(); IDispatch *disp = (IDispatch *)getDispatch(); if (!axcore->isString(name)) axcore->toplevel->throwTypeError(kCheckTypeFailedError); DISPID id; OLECHAR *olename = (OLECHAR *)axcore->atomToString(name)->c_str(); HRESULT hr = disp->GetIDsOfNames(IID_NULL, &olename, 1, 0, &id); if (hr == DISP_E_UNKNOWNNAME) { // not a name this object has - do we need to see if its builtin? // If we call ScriptObject::getAtomProperty() with an unknown name, // it throws an exception, where we just want undefinedAtom. // XXX - but we must call the base for now to resolve 'Object' etc //return ScriptObject::getAtomProperty(name); return undefinedAtom; } if (FAILED(hr)) axcore->throwCOMConsumerError(hr); EXCEPINFO ei; DISPPARAMS params = {NULL, NULL, 0, 0}; CComVariant ret; hr = disp->Invoke(id, IID_NULL, 0, DISPATCH_PROPERTYGET, ¶ms, &ret, &ei, NULL); if (FAILED(hr)) axcore->throwCOMConsumerError(hr, &ei); return axcore->toAtom(ret); }
// Ditto hasMultinameProperty - needsHashtable is checked. bool MSIDispatchConsumer::hasMultinameProperty(Multiname* name) const { DISPID id; OLECHAR *olename = (OLECHAR *)name->getName()->c_str(); IDispatch *disp = (IDispatch *)getDispatch(); HRESULT hr = disp->GetIDsOfNames(IID_NULL, &olename, 1, 0, &id); return SUCCEEDED(hr); }
EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) { EGLBoolean res = getDispatch()->eglQuerySurface(dpy, surface, attribute, value); if (res && attribute == EGL_RENDERABLE_TYPE) { *value |= EGL_OPENGL_ES2_BIT; } return res; }
EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) { if (s_needEncode && attribute == EGL_RENDERABLE_TYPE) { *value = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT; return EGL_TRUE; } else { return getDispatch()->eglGetConfigAttrib(dpy, config, attribute, value); } }
__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) { for (int i=0; i<egl_num_funcs; i++) { if (!strcmp(egl_funcs_by_name[i].name, procname)) { return (__eglMustCastToProperFunctionPointerType)egl_funcs_by_name[i].proc; } } return getDispatch()->eglGetProcAddress(procname); }
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) { ServerConnection *server; if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) { server->utEnc()->swapBuffers(server->utEnc(), getpid(), (uint32_t)surface); server->glEncoder()->flush(); server->gl2Encoder()->flush(); return 1; } return getDispatch()->eglSwapBuffers(dpy, surface); }
EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) { EGLBoolean res = getDispatch()->eglDestroySurface(dpy, surface); if (res && surface != EGL_NO_SURFACE) { ServerConnection *server; if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) { server->utEnc()->destroySurface(server->utEnc(), getpid(), (uint32_t)surface); } } return res; }
EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) { EGLSurface surface = getDispatch()->eglCreatePixmapSurface(dpy, config, pixmap, attrib_list); if (surface != EGL_NO_SURFACE) { ServerConnection *server; if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) { server->utEnc()->createSurface(server->utEnc(), getpid(), (uint32_t)surface); } } return surface; }
EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) { EGLWrapperContext *wctx = (EGLWrapperContext *)ctx; if (wctx) { if (attribute == EGL_CONTEXT_CLIENT_VERSION) { *value = wctx->version; return EGL_TRUE; } else { return getDispatch()->eglQueryContext(dpy, wctx->aglContext, attribute, value); } } else { return EGL_BAD_CONTEXT; } }
EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) { EGLBoolean res; if (s_needEncode) { EGLint *attribs = filter_es2_bit(attrib_list, NULL); res = getDispatch()->eglChooseConfig(dpy, attribs, configs, config_size, num_config); ALOGD("eglChooseConfig: %d configs found\n", *num_config); if (*num_config == 0 && attribs != NULL) { ALOGD("requested attributes:\n"); for (int i = 0; attribs[i] != EGL_NONE; i++) { ALOGD("%d: 0x%x\n", i, attribs[i]); } } delete attribs; } else { res = getDispatch()->eglChooseConfig(dpy, attrib_list, configs, config_size, num_config); } return res; }
EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) { EGLContext share = share_context; if (share) share = ((EGLWrapperContext *)share_context)->aglContext; // check if are ES2, and convert it to ES1. int nAttribs = 0; if (attrib_list != NULL) { while(attrib_list[nAttribs] != EGL_NONE) { nAttribs++; } nAttribs++; } EGLint *attrib = NULL; if (nAttribs > 0) { attrib = new EGLint[nAttribs]; memcpy(attrib, attrib_list, nAttribs * sizeof(EGLint)); } int version = 1; for (int i = 0; i < nAttribs; i++) { if (attrib[i] == EGL_CONTEXT_CLIENT_VERSION && attrib[i + 1] == 2) { version = 2; attrib[i + 1] = 1; // replace to version 1 } } EGLContext ctx = getDispatch()->eglCreateContext(dpy, config, share, attrib); delete attrib; EGLWrapperContext *wctx = new EGLWrapperContext(ctx, version); if (ctx != EGL_NO_CONTEXT) { ServerConnection *server; if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) { wctx->clientState = new GLClientState(); server->utEnc()->createContext(server->utEnc(), getpid(), (uint32_t)wctx, (uint32_t)(share_context == EGL_NO_CONTEXT ? 0 : share_context), wctx->version); } } return (EGLContext)wctx; }
EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { EGLWrapperContext *wctx = (EGLWrapperContext *)ctx; EGLBoolean res = EGL_FALSE; if (ctx && ctx != EGL_NO_CONTEXT) { res = getDispatch()->eglDestroyContext(dpy, wctx->aglContext); if (res) { EGLThreadInfo *ti = getEGLThreadInfo(); ServerConnection *server; if (s_needEncode && (server = ServerConnection::s_getServerConnection())) { server->utEnc()->destroyContext(ti->serverConn->utEnc(), getpid(), (uint32_t)ctx); } if (ti->currentContext == wctx) ti->currentContext = NULL; delete wctx; } } return res; }
// ScriptObject::setMultinameProperty checks if our traits have 'needsHashtable' - // but we don't. Its possible 'needsHashtable' is misnamed and means more like 'isDynamic' // so we should revisit this... void MSIDispatchConsumer::setMultinameProperty(Multiname* name, Atom value) { // its possible we should just call setStringProperty(), which calls // setAtomProperty(), and we should add our impl there - but let's see // if we can get away without that for now... DISPID id; AXTam *axcore = (AXTam *)core(); OLECHAR *olename = (OLECHAR *)name->getName()->c_str(); IDispatch *disp = (IDispatch *)getDispatch(); HRESULT hr = disp->GetIDsOfNames(IID_NULL, &olename, 1, 0, &id); // ScriptObject::setMultinameProperty just throws an exception, so // no point trying it... if (FAILED(hr)) axcore->throwCOMConsumerError(hr); // Now create args for the call. EXCEPINFO ei; CComVariant arg; axcore->atomToVARIANT(value, &arg); DISPPARAMS params = {&arg, NULL, 1, 0}; hr = disp->Invoke(id, IID_NULL, 0, DISPATCH_PROPERTYPUT, ¶ms, NULL, &ei, NULL); if (FAILED(hr)) axcore->throwCOMConsumerError(hr, &ei); }
Atom MSIDispatchConsumer::callProperty(avmplus::Multiname *name, int argc, avmplus::Atom *argv) { // Not sure how to best handle this re 'builtin' names, such as toString() // XXX - need a map of DISPIDs to speed things up, and/or optimizations // using the typelib. DISPID id; AXTam *axcore = (AXTam *)core(); IDispatch *disp = (IDispatch *)getDispatch(); OLECHAR *olename = (OLECHAR *)name->getName()->c_str(); HRESULT hr = disp->GetIDsOfNames(IID_NULL, &olename, 1, 0, &id); if (hr == DISP_E_UNKNOWNNAME) { // not a name this object has - see if its builtin. return ScriptObject::callProperty(name, argc, argv); } if (FAILED(hr)) axcore->throwCOMConsumerError(hr); // Now create args for the call. EXCEPINFO ei; CComVariant *pArgs = new CComVariant[argc]; //memset(pArgs, 0, sizeof(VARIANT) * argc); // Take care to not early exit without cleaning up variants int i; for (i=0; i<argc; i++) { //VariantInit(pArgs+i); axcore->atomToVARIANT(argv[i+1], pArgs+i); } DISPPARAMS params = {pArgs, NULL, argc, 0}; CComVariant ret; hr = disp->Invoke(id, IID_NULL, 0, DISPATCH_METHOD, ¶ms, &ret, &ei, NULL); //for (i=0;i<argc;i++) // VariantClear(pArg+i); delete [] pArgs; if (FAILED(hr)) axcore->throwCOMConsumerError(hr, &ei); return axcore->toAtom(ret); }
EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value) { return getDispatch()->eglGetSyncAttribKHR(dpy, sync, attribute, value); }
EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) { return getDispatch()->eglDestroyImageKHR(dpy, image); }
EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) { return getDispatch()->eglGetConfigAttrib(dpy, config, attribute, value); }
EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) { return getDispatch()->eglCreateSyncKHR(dpy, type, attrib_list); }
EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) { return getDispatch()->eglGetConfigs(dpy, configs, config_size, num_config); }
EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) { return getDispatch()->eglChooseConfig(dpy, attrib_list, configs, config_size, num_config); }
EGLBoolean eglTerminate(EGLDisplay dpy) { return getDispatch()->eglTerminate(dpy); }
const char* eglQueryString(EGLDisplay dpy, EGLint name) { return getDispatch()->eglQueryString(dpy, name); }
EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id) { return getDispatch()->eglGetDisplay(display_id); }
EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { return getDispatch()->eglInitialize(dpy, major, minor); }
EGLint eglGetError() { return getDispatch()->eglGetError(); }
EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) { return getDispatch()->eglDestroySyncKHR(dpy, sync); }
EGLBoolean eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height) { return getDispatch()->eglSetSwapRectangleANDROID(dpy, draw, left, top, width, height); }
EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) { return getDispatch()->eglClientWaitSyncKHR(dpy, sync, flags, timeout); }
EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) { return getDispatch()->eglSignalSyncKHR(dpy, sync, mode); }