summaryrefslogtreecommitdiff
path: root/src/vg
diff options
context:
space:
mode:
Diffstat (limited to 'src/vg')
-rw-r--r--src/vg/Api.cpp9
-rw-r--r--src/vg/EGLAddOn.cpp39
2 files changed, 43 insertions, 5 deletions
diff --git a/src/vg/Api.cpp b/src/vg/Api.cpp
index 5b97a50..10dcc0d 100644
--- a/src/vg/Api.cpp
+++ b/src/vg/Api.cpp
@@ -511,7 +511,14 @@ void RI_APIENTRY vgSetiv(VGParamType type, VGint count, const VGint * values)
void RI_APIENTRY vgSetfv(VGParamType type, VGint count, const VGfloat * values)
{
- RI_GET_CONTEXT(RI_NO_RETVAL);
+ OSAcquireMutex();
+ VGContext* context = (VGContext*)eglvgGetCurrentVGContext();
+ if(!context)
+ {
+ OSReleaseMutex();
+ return RI_NO_RETVAL;
+ }
+// RI_GET_CONTEXT(RI_NO_RETVAL);
RI_IF_ERROR(count < 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
RI_IF_ERROR((!values && count > 0) || (values && !isAligned(values,4)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
setifv(context, type, count, values, true);
diff --git a/src/vg/EGLAddOn.cpp b/src/vg/EGLAddOn.cpp
index e8da666..f8d25bc 100644
--- a/src/vg/EGLAddOn.cpp
+++ b/src/vg/EGLAddOn.cpp
@@ -306,7 +306,9 @@ public:
int getNumConfigs() const { return EGL_NUMCONFIGS; }
const RIEGLConfig& getConfig(int i) const { RI_ASSERT(i >= 0 && i < EGL_NUMCONFIGS); return m_configs[i]; }
- const RIEGLConfig& getConfig(const EGLConfig config) const { for(int i=0;i<EGL_NUMCONFIGS;i++) { if(m_configs[i].m_config == config) return m_configs[i]; } RI_ASSERT(0); return m_configs[0]; }
+ const RIEGLConfig& getConfig(const EGLConfig config) const { for(int i=0;i<EGL_NUMCONFIGS;i++) { if(m_configs[i].m_config == config) return m_configs[i]; }
+ // RI_ASSERT(0);
+ return m_configs[0]; }
const EGLDisplay getID() const { return m_id; }
@@ -838,19 +840,48 @@ extern "C"
void tgOpenVGCreateContext(ESContext *esContext) {
EGL* egl = getEGL();
+ RIEGLSurface *riSurfaceDraw;
+ RIEGLDisplay *riD;
+ RIEGLContext *riC;
+ Drawable *d;
RIEGLThread* thread = egl->getThread();
- tgOpenVG::VGContext* vgctx = NULL;
- RIEGLContext* c = NULL;
+ if (!thread) {
+ thread = RI_NEW(RIEGLThread, (OSGetCurrentThreadID() ));
+ }
+
+ /* sane defaults */
+ int colorSpace = EGL_VG_COLORSPACE_sRGB;
+ int alphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE;
+ tgOpenVG::VGContext* vgctx = NULL;
try {
vgctx = RI_NEW(tgOpenVG::VGContext, (NULL)); //throws bad_alloc
- c = RI_NEW(RIEGLContext, (vgctx, esContext->eglConfig)); //throws bad_alloc
+ riC = RI_NEW(RIEGLContext, (vgctx, esContext->eglConfig)); //throws bad_alloc
+
esContext->vgContext = vgctx;
+ riD=RI_NEW(RIEGLDisplay, (esContext->eglDisplay));
+ riD->addContext(riC);
+
+ d = RI_NEW(Drawable, (riD->getConfig(esContext->eglConfig).configToDescriptor((colorSpace == EGL_VG_COLORSPACE_LINEAR) ? false : true, (alphaFormat == EGL_VG_ALPHA_FORMAT_PRE) ? true : false), esContext->width, esContext->height, riD->getConfig(esContext->eglConfig).m_samples, riD->getConfig(esContext->eglConfig).m_maskBits));
+
+ riSurfaceDraw=RI_NEW(RIEGLSurface, (esContext->eglContext, esContext->eglConfig, d, false , EGL_BACK_BUFFER));
+ riD->addSurface(riSurfaceDraw);
+
+ thread->makeCurrent(riC, riSurfaceDraw);
+ riC->getVGContext()->setDefaultDrawable(riSurfaceDraw->getDrawable());
+
+ egl->addCurrentThread(thread);
}
catch (std::bad_alloc) {
}
+
+ riC->addReference();
+ riSurfaceDraw->addReference();
+ esContext->rieglSurface=riSurfaceDraw;
+ esContext->rieglDisplay=riD;
+ esContext->rieglContext=riC;
}