diff options
author | Tom Gall <tom.gall@linaro.org> | 2014-10-06 17:08:43 -0500 |
---|---|---|
committer | Tom Gall <tom.gall@linaro.org> | 2014-10-06 17:08:43 -0500 |
commit | 3e7ba806a23dfd3d75f9cc156df9229f237f5d04 (patch) | |
tree | 13023fe356a41d6e807c8195a37e990a7827e9ec | |
parent | ffbf61c267a162c3e5d41c9ff310e2c8dae1c3bd (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.
-rw-r--r-- | include/esUtil.h | 3 | ||||
-rw-r--r-- | src/vg/Api.cpp | 9 | ||||
-rw-r--r-- | src/vg/EGLAddOn.cpp | 39 | ||||
-rw-r--r-- | tests/font/main.c | 34 |
4 files changed, 80 insertions, 5 deletions
diff --git a/include/esUtil.h b/include/esUtil.h index c41a599..faa87fd 100644 --- a/include/esUtil.h +++ b/include/esUtil.h @@ -90,6 +90,9 @@ typedef struct _escontext EGLConfig eglConfig;
void *vgContext;
+ void *rieglSurface;
+ void *rieglDisplay;
+ void *rieglContext;
/// Callbacks
void (ESCALLBACK *drawFunc) ( struct _escontext * );
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;
}
diff --git a/tests/font/main.c b/tests/font/main.c index d65cc09..10abf9a 100644 --- a/tests/font/main.c +++ b/tests/font/main.c @@ -476,6 +476,39 @@ GLuint CreateSimpleTexture2D( ) } +GLuint CreateVGTexture2D(ESContext *esContext) +{ + // Texture object handle + GLuint textureId; + + // 2x2 Image, 3 bytes per pixel (R, G, B) + // Use tightly packed data + glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 ); + + // Generate a texture object + glGenTextures ( 1, &textureId ); + + // Bind the texture object + glBindTexture ( GL_TEXTURE_2D, textureId ); + + // Load the texture + glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, esContext->width, esContext->height, 0, GL_RGB, GL_UNSIGNED_BYTE, tgTextureBuffer); + + // Set the filtering mode + glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + + return textureId; + +} + +void Update(ESContext *esContext, float deltaTime) { + UserData *userData = esContext ->userData; + + glDeleteTextures ( 1, &userData->textureId ); + userData->textureId = CreateVGTexture2D (esContext); +} + /// // Initialize the shader and program object // @@ -597,6 +630,7 @@ int main ( int argc, char *argv[] ) initFont(); esRegisterDrawFunc ( &esContext, Draw ); + esRegisterUpdateFunc ( &esContext, Update); esMainLoop ( &esContext ); |