void TilesManager::updateTilesIfContextVerified()
{
    EGLContext ctx = eglGetCurrentContext();
    GLUtils::checkEglError("contextChanged");
    if (ctx != m_eglContext) {
        if (m_eglContext != EGL_NO_CONTEXT) {
            // A change in EGL context is an unexpected error, but we don't want to
            // crash or ANR. Therefore, abandon the Surface Texture and GL resources;
            // they'll be recreated later in setupDrawing. (We can't delete them
            // since the context is gone)
            ALOGE("Unexpected : EGLContext changed! current %x , expected %x",
                  ctx, m_eglContext);
            transferQueue()->resetQueue();
            shader()->forceNeedsInit();
            videoLayerManager()->forceNeedsInit();
            markAllGLTexturesZero();
        } else {
            // This is the first time we went into this new EGL context.
            // We will have the GL resources to be re-inited and we can't update
            // dirty tiles yet.
            ALOGD("new EGLContext from framework: %x ", ctx);
        }
    } else {
        // Here before we draw, update the Tile which has updated content.
        // Inside this function, just do GPU blits from the transfer queue into
        // the Tiles' texture.
        transferQueue()->updateDirtyTiles();
        // Clean up GL textures for video layer.
        videoLayerManager()->deleteUnusedTextures();
    }
    m_eglContext = ctx;
    return;
}
// When GL context changed or we get a low memory signal, we want to cleanup all
// the GPU memory webview is using.
// The recreation will be on the next incoming draw call at the drawGL of
// GLWebViewState or the VideoLayerAndroid
void TilesManager::cleanupGLResources()
{
    transferQueue()->cleanupGLResourcesAndQueue();
    shader()->cleanupGLResources();
    videoLayerManager()->cleanupGLResources();
    m_eglContext = EGL_NO_CONTEXT;
    GLUtils::checkGlError("TilesManager::cleanupGLResources");
}
Exemplo n.º 3
0
void TilesManager::unregisterGLWebViewState(GLWebViewState* state)
{
    // Discard the whole queue b/c we lost GL context already.
    // Note the real updateTexImage will still wait for the next draw.
    transferQueue()->discardQueue();
}