This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OpenVG Masking Problem

Other Parts Discussed in Thread: OMAP3530

Hi, not sure if this is the correct place to ask this so apologies if it is not. I have problem with an OpenVG application (on OMAP3530) whereby whenever masking is used everything slows up and eventually hangs.  Masking works on a one-off basis but repetitive masking operations causes the failure. The following code causes the problem...

#include <VG/openvg.h>
#include <EGL/egl.h>
#include <stdio.h>

int main()
{
    VGPath m_avgPath[2];
    VGPaint m_avgColourPaint[2];
    EGLDisplay            eglDisplay    = 0;
    EGLConfig            eglConfig    = 0;
    EGLSurface            eglSurface    = 0;
    EGLContext            eglContext    = 0;
    EGLint i32NumConfigs, i32MajorVersion, i32MinorVersion;

    EGLNativeWindowType sWindow = (EGLNativeWindowType)0;
    eglDisplay = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY);
    if(!eglInitialize(eglDisplay, &i32MajorVersion, &i32MinorVersion))
    {
        printf("Error: eglInitialize() failed.\n");
        goto cleanup;
    }

    eglBindAPI(EGL_OPENVG_API);

    static const EGLint ai32ConfigAttribs[] =
    {
        EGL_LEVEL,          0,
        EGL_BUFFER_SIZE,         16,
        EGL_SURFACE_TYPE,   EGL_WINDOW_BIT,
        EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
        EGL_NONE
    };

    if(!eglChooseConfig(eglDisplay, ai32ConfigAttribs, &eglConfig, 1, &i32NumConfigs) || (i32NumConfigs != 1))
    {
        printf("Error: eglChooseConfig() failed.\n");
        goto cleanup;
    }

    eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, sWindow, NULL);
    if((eglGetError() != EGL_SUCCESS) || (eglSurface == EGL_NO_SURFACE))
    {
        printf("Error: eglCreateWindowSurface() failed.\n");
        goto cleanup;
    }

    eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, NULL);
    if((eglGetError() != EGL_SUCCESS) || (eglContext == EGL_NO_CONTEXT))
    {
        printf("Error: eglCreateContext() failed.\n");
        goto cleanup;
    }

    eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
    if(eglGetError() != EGL_SUCCESS)
    {
        printf("Error: eglMakeCurrent() failed.\n");
        goto cleanup;
    }

    EGLint i32WindowWidth, i32WindowHeight;
    eglQuerySurface(eglDisplay, eglSurface, EGL_WIDTH, &i32WindowWidth);
    eglQuerySurface(eglDisplay, eglSurface, EGL_HEIGHT, &i32WindowHeight);

    vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
    vgLoadIdentity();

    VGfloat afClearColor[4];
    afClearColor[0] = 0.0f;
    afClearColor[1] = 0.0f;
    afClearColor[2] = 0.0f;
    afClearColor[3] = 1.0f;

    vgSetfv(VG_CLEAR_COLOR, 4, afClearColor);
    vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER);
    vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);

    float fWidth = i32WindowWidth * 0.5f;
    float fHeight= i32WindowHeight * 0.5f;

    m_avgPath[0] = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 4, 3, (unsigned int)VG_PATH_CAPABILITY_ALL);
    VGubyte aui8PathSegments[4] = {
        VG_MOVE_TO,
        VG_LINE_TO,
        VG_LINE_TO,
        VG_CLOSE_PATH,
    };
    VGfloat afPoints[6] = {
            fWidth - 80.0f, fHeight - 50.0f,
            fWidth + 80.0f, fHeight - 50.0f,
            fWidth, fHeight + 80.0f
    };
    vgAppendPathData(m_avgPath[0], 4, aui8PathSegments, afPoints);

    m_avgPath[1] = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 5, 4, (unsigned int)VG_PATH_CAPABILITY_ALL);
    VGubyte aui8PathSegments2[5] = {
        VG_MOVE_TO,
        VG_LINE_TO,
        VG_LINE_TO,
        VG_LINE_TO,
        VG_CLOSE_PATH
    };
    VGfloat afPoints2[8] = {
            fWidth - 20.0f, fHeight - 20.0f,
            fWidth + 20.0f, fHeight - 20.0f,
            fWidth + 20.0f, fHeight + 20.0f,
            fWidth - 20.0f, fHeight + 20.0f
    };

    vgAppendPathData(m_avgPath[1], 5, aui8PathSegments2, afPoints2);

    m_avgColourPaint[0] = vgCreatePaint();
    vgSetParameteri(m_avgColourPaint[0], VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
    vgSetColor(m_avgColourPaint[0], 0xFFFFAAFF);

    int i;
    for(i = 0; i < 100; ++i)
    {
        VGfloat afClearColour[] = { 0.6f, 0.8f, 1.0f, 1.0f };
        vgSetfv(VG_CLEAR_COLOR, 4, afClearColour);
        vgClear(0, 0, i32WindowWidth, i32WindowHeight);
        vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK, 0, 0, i32WindowWidth, i32WindowHeight);
        vgRenderToMask(m_avgPath[1], VG_FILL_PATH, VG_SET_MASK);
        vgSeti(VG_MASKING, VG_TRUE);
        vgSetPaint(m_avgColourPaint[0], VG_FILL_PATH);
        vgDrawPath(m_avgPath[0], VG_STROKE_PATH | VG_FILL_PATH);
        vgSeti(VG_MASKING, VG_FALSE);

        eglSwapBuffers(eglDisplay, eglSurface);
        if (eglGetError() != EGL_SUCCESS)
        {
            printf("Error!\n");
        }
    }

    eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
    eglTerminate(eglDisplay);

    return 0;
}

 

The code simply draws a triangle through a small square mask. It draws successfully and takes approx one second for each repetition until it finally freezes.  Maybe im not doing it right but any help would be much appreciated.

Thanx in advance