summaryrefslogtreecommitdiff
path: root/src/vg/EGLAddOn.cpp
diff options
context:
space:
mode:
authorTom Gall <tom.gall@linaro.org>2014-10-06 17:08:43 -0500
committerTom Gall <tom.gall@linaro.org>2014-10-06 17:08:43 -0500
commit3e7ba806a23dfd3d75f9cc156df9229f237f5d04 (patch)
tree13023fe356a41d6e807c8195a37e990a7827e9ec /src/vg/EGLAddOn.cpp
parentffbf61c267a162c3e5d41c9ff310e2c8dae1c3bd (diff)
to esContext, hold references for RIEGL objects such as
Display, Surface and Context to EGLAddOn.cpp, sort out and add init routine to setup and string together various background objects that the reference implementation needs in order to render to a buffer space. to tests/font/main.c, add an Update function and change to use the drawn into OpenVG buffer that we've read back. font renders to the screen now but the pixels aren't interpreted quite right. On the right track tho.
Diffstat (limited to 'src/vg/EGLAddOn.cpp')
-rw-r--r--src/vg/EGLAddOn.cpp39
1 files changed, 35 insertions, 4 deletions
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;
}