Ejemplo n.º 1
0
bool
GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage)
{
    AndroidSurfaceTexture* surfaceTexture = stImage->GetSurfaceTexture();

    ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);

    if (NS_FAILED(surfaceTexture->Attach(mGL, PR_MillisecondsToInterval(ATTACH_WAIT_MS))))
        return false;

    // UpdateTexImage() changes the EXTERNAL binding, so save it here
    // so we can restore it after.
    int oldBinding = 0;
    mGL->fGetIntegerv(LOCAL_GL_TEXTURE_BINDING_EXTERNAL, &oldBinding);

    surfaceTexture->UpdateTexImage();

    gfx::Matrix4x4 transform;
    surfaceTexture->GetTransformMatrix(transform);

    mGL->fUniformMatrix4fv(mTextureTransformLoc, 1, false, &transform._11);
    mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);

    surfaceTexture->Detach();

    mGL->fBindTexture(LOCAL_GL_TEXTURE_EXTERNAL, oldBinding);
    return true;
}
Ejemplo n.º 2
0
bool
GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage)
{
    AndroidSurfaceTexture* surfaceTexture = stImage->GetData()->mSurfTex;
    bool yFlip = stImage->GetData()->mInverted;

    ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
    mGL->fClear(LOCAL_GL_COLOR_BUFFER_BIT);

    if (NS_FAILED(surfaceTexture->Attach(mGL))) {
        return false;
    }

    // UpdateTexImage() changes the EXTERNAL binding, so save it here
    // so we can restore it after.
    int oldBinding = 0;
    mGL->fGetIntegerv(LOCAL_GL_TEXTURE_BINDING_EXTERNAL, &oldBinding);

    surfaceTexture->UpdateTexImage();

    gfx::Matrix4x4 transform;
    surfaceTexture->GetTransformMatrix(transform);

    mGL->fUniformMatrix4fv(mTextureTransformLoc, 1, false, &transform._11);
    mGL->fUniform1f(mYFlipLoc, yFlip ? 1.0f : 0.0f);
    mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);

    surfaceTexture->Detach();

    mGL->fBindTexture(LOCAL_GL_TEXTURE_EXTERNAL, oldBinding);
    return true;
}
Ejemplo n.º 3
0
// native method for QtSurfaceTexture.java
static void notifyFrameAvailable(JNIEnv* , jobject, int id)
{
    AndroidSurfaceTexture *obj = g_objectMap.value(id, 0);
    if (obj)
        Q_EMIT obj->frameAvailable();
}