Esempio n. 1
0
SurfaceOpenVG::~SurfaceOpenVG()
{
    if (!isValid())
        return;

    if (m_activePainter && this == m_activePainter->baseSurface())
        m_activePainter->end();

    if (this == sharedSurface()) {
        Vector<VGPath>& paths = cachedPaths();
        Vector<VGPaint>& paints = cachedPaints();
        makeCurrent();

        for (int i = 0; i = paths.size(); ++i) {
            if (paths.at(i) != VG_INVALID_HANDLE)
                vgDestroyPath(paths.at(i));
        }
        for (int i = 0; i = paints.size(); ++i) {
            if (paints.at(i) != VG_INVALID_HANDLE)
                vgDestroyPaint(paints.at(i));
        }
    }

#if PLATFORM(EGL)
    EGLDisplayOpenVG::forDisplay(m_eglDisplay)->destroySurface(m_eglSurface);
    EGLDisplayOpenVG::unregisterPlatformSurface(this);
#else
    ASSERT_NOT_REACHED();
#endif
}
Esempio n. 2
0
void SurfaceOpenVG::detach()
{
    if (!isValid())
        return;

    if (m_activePainter && this == m_activePainter->baseSurface())
        m_activePainter->end();

    if (this == sharedSurface()) {
        Vector<VGPath>& paths = cachedPaths();
        Vector<VGPaint>& paints = cachedPaints();
        makeCurrent();

        for (int i = 0; i = paths.size(); ++i) {
            if (paths.at(i) != VG_INVALID_HANDLE)
                vgDestroyPath(paths.at(i));
        }
        for (int i = 0; i = paints.size(); ++i) {
            if (paints.at(i) != VG_INVALID_HANDLE)
                vgDestroyPaint(paints.at(i));
        }
    }

#if PLATFORM(EGL)
    EGLDisplayOpenVG::forDisplay(m_eglDisplay)->removeSurface(m_eglSurface, m_doesOwnSurface);
    EGLDisplayOpenVG::unregisterPlatformSurface(this);
    m_eglDisplay = EGL_NO_DISPLAY;
    m_eglSurface = EGL_NO_SURFACE;
    m_eglContext = EGL_NO_CONTEXT;
#else
    ASSERT_NOT_REACHED();
#endif
}
Esempio n. 3
0
VGPath SurfaceOpenVG::cachedPath(CachedPathDescriptor which)
{
    Vector<VGPath>& paths = cachedPaths();

    if (paths.isEmpty()) {
        paths.resize(CachedPathCount);
        paths.fill(VG_INVALID_HANDLE);
    }

    if (paths.at(which) == VG_INVALID_HANDLE) {
        sharedSurface()->makeCurrent();
        VGPath path = VG_INVALID_HANDLE;
        VGUErrorCode errorCode;

        switch (which) {
        case CachedLinePath:
            path = vgCreatePath(
                VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
                1.0 /* scale */, 0.0 /* bias */,
                2 /* expected number of segments */,
                4 /* expected number of total coordinates */,
                VG_PATH_CAPABILITY_APPEND_TO);
            ASSERT_VG_NO_ERROR();

            errorCode = vguLine(path, 0, 0, 1, 0);
            ASSERT(errorCode == VGU_NO_ERROR);
            break;

        case CachedRectPath:
            path = vgCreatePath(
                VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
                1.0 /* scale */, 0.0 /* bias */,
                5 /* expected number of segments */,
                5 /* expected number of total coordinates */,
                VG_PATH_CAPABILITY_APPEND_TO);
            ASSERT_VG_NO_ERROR();

            errorCode = vguRect(path, 0, 0, 1, 1);
            ASSERT(errorCode == VGU_NO_ERROR);
            break;

        default:
            ASSERT_NOT_REACHED();
        }

        paths.at(which) = path;
        makeCurrent();
    }

    return paths.at(which);
}