예제 #1
0
EGLDisplaySurface::~EGLDisplaySurface()
{
    magic = 0;
    copybit_close(mBlitEngine);
    mBlitEngine = 0;
    close(egl_native_window_t::fd);
    munmap(mFb[0].data, mSize);
    if (!(mFlags & PAGE_FLIP))
        free((void*)mFb[1].data);
}
예제 #2
0
void ogles_uninit(ogles_context_t* c)
{
    ogles_uninit_array(c);
    ogles_uninit_matrix(c);
    ogles_uninit_vertex(c);
    ogles_uninit_light(c);
    ogles_uninit_texture(c);
    c->surfaceManager->decStrong(c);
    c->bufferObjectManager->decStrong(c);
    ggl_uninit_context(&(c->rasterizer));
    free(c->rasterizer.base);
#ifdef LIBAGL_USE_GRALLOC_COPYBITS
    if (c->copybits.blitEngine != NULL) {
        copybit_close((struct copybit_device_t*) c->copybits.blitEngine);
    }
#endif // LIBAGL_USE_GRALLOC_COPYBITS
}
status_t SurfaceTexture::detachFromContext() {
    ATRACE_CALL();
    ST_LOGV("detachFromContext");
    Mutex::Autolock lock(mMutex);

    if (mAbandoned) {
        ST_LOGE("detachFromContext: abandoned SurfaceTexture");
        return NO_INIT;
    }

    if (!mAttached) {
        ST_LOGE("detachFromContext: SurfaceTexture is not attached to a "
                "context");
        return INVALID_OPERATION;
    }

    EGLDisplay dpy = eglGetCurrentDisplay();
    EGLContext ctx = eglGetCurrentContext();

    if (mEglDisplay != dpy && mEglDisplay != EGL_NO_DISPLAY) {
        ST_LOGE("detachFromContext: invalid current EGLDisplay");
        return INVALID_OPERATION;
    }

    if (mEglContext != ctx && mEglContext != EGL_NO_CONTEXT) {
        ST_LOGE("detachFromContext: invalid current EGLContext");
        return INVALID_OPERATION;
    }

    if (dpy != EGL_NO_DISPLAY && ctx != EGL_NO_CONTEXT) {
        status_t err = syncForReleaseLocked(dpy);
        if (err != OK) {
            return err;
        }

        glDeleteTextures(1, &mTexName);
    }

    // Because we're giving up the EGLDisplay we need to free all the EGLImages
    // that are associated with it.  They'll be recreated when the
    // SurfaceTexture gets attached to a new OpenGL ES context (and thus gets a
    // new EGLDisplay).
    for (int i =0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
        EGLImageKHR img = mEglSlots[i].mEglImage;
        if (img != EGL_NO_IMAGE_KHR) {
            eglDestroyImageKHR(mEglDisplay, img);
            mEglSlots[i].mEglImage = EGL_NO_IMAGE_KHR;
        }
    }

#ifdef STE_HARDWARE
    if (mBlitEngine) {
        copybit_close(mBlitEngine);
    }
#endif

    mEglDisplay = EGL_NO_DISPLAY;
    mEglContext = EGL_NO_CONTEXT;
    mAttached = false;

    return OK;
}