Bug 980647 - Part 2 - Use the PerFrame pool with all layer types on b2g. r=Cwiiis
This commit is contained in:
@@ -93,7 +93,6 @@ GrallocTextureSourceOGL::GrallocTextureSourceOGL(CompositorOGL* aCompositor,
|
||||
, mGraphicBuffer(aGraphicBuffer)
|
||||
, mEGLImage(0)
|
||||
, mFormat(aFormat)
|
||||
, mNeedsReset(true)
|
||||
{
|
||||
MOZ_ASSERT(mGraphicBuffer.get());
|
||||
}
|
||||
@@ -107,14 +106,6 @@ GrallocTextureSourceOGL::~GrallocTextureSourceOGL()
|
||||
void
|
||||
GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit)
|
||||
{
|
||||
/*
|
||||
* The job of this function is to ensure that the texture is tied to the
|
||||
* android::GraphicBuffer, so that texturing will source the GraphicBuffer.
|
||||
*
|
||||
* To this effect we create an EGLImage wrapping this GraphicBuffer,
|
||||
* using EGLImageCreateFromNativeBuffer, and then we tie this EGLImage to our
|
||||
* texture using fEGLImageTargetTexture2D.
|
||||
*/
|
||||
MOZ_ASSERT(gl());
|
||||
if (!IsValid()) {
|
||||
return;
|
||||
@@ -127,24 +118,19 @@ GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit)
|
||||
gl()->fActiveTexture(aTextureUnit);
|
||||
gl()->fBindTexture(textureTarget, tex);
|
||||
|
||||
if (mCompositableBackendData) {
|
||||
// There are two paths for locking/unlocking - if mCompositableBackendData is
|
||||
// set, we use the texture on there, otherwise we use
|
||||
// CompositorBackendSpecificData from the compositor and bind the EGLImage
|
||||
// only in Lock().
|
||||
if (!mEGLImage) {
|
||||
mEGLImage = EGLImageCreateFromNativeBuffer(gl(), mGraphicBuffer->getNativeBuffer());
|
||||
}
|
||||
gl()->fEGLImageTargetTexture2D(textureTarget, mEGLImage);
|
||||
}
|
||||
|
||||
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
}
|
||||
|
||||
void GrallocTextureSourceOGL::Lock()
|
||||
{
|
||||
if (mCompositableBackendData) return;
|
||||
|
||||
/*
|
||||
* The job of this function is to ensure that the texture is tied to the
|
||||
* android::GraphicBuffer, so that texturing will source the GraphicBuffer.
|
||||
*
|
||||
* To this effect we create an EGLImage wrapping this GraphicBuffer,
|
||||
* using EGLImageCreateFromNativeBuffer, and then we tie this EGLImage to our
|
||||
* texture using fEGLImageTargetTexture2D.
|
||||
*/
|
||||
MOZ_ASSERT(IsValid());
|
||||
|
||||
mTexture = mCompositor->GetTemporaryTexture(LOCAL_GL_TEXTURE0);
|
||||
@@ -163,7 +149,7 @@ void GrallocTextureSourceOGL::Lock()
|
||||
bool
|
||||
GrallocTextureSourceOGL::IsValid() const
|
||||
{
|
||||
return !!gl() && !!mGraphicBuffer.get() && (!!mCompositor || !!mCompositableBackendData);
|
||||
return !!gl() && !!mGraphicBuffer.get();
|
||||
}
|
||||
|
||||
gl::GLContext*
|
||||
@@ -203,51 +189,6 @@ GrallocTextureSourceOGL::GetFormat() const {
|
||||
return mFormat;
|
||||
}
|
||||
|
||||
void
|
||||
GrallocTextureSourceOGL::SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData)
|
||||
{
|
||||
if (!aBackendData) {
|
||||
mCompositableBackendData = nullptr;
|
||||
DeallocateDeviceData();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mCompositableBackendData != aBackendData) {
|
||||
mNeedsReset = true;
|
||||
}
|
||||
|
||||
if (!mNeedsReset) {
|
||||
// Update binding to the EGLImage
|
||||
gl()->MakeCurrent();
|
||||
GLuint tex = GetGLTexture();
|
||||
GLuint textureTarget = GetTextureTarget();
|
||||
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
gl()->fBindTexture(textureTarget, tex);
|
||||
gl()->fEGLImageTargetTexture2D(textureTarget, mEGLImage);
|
||||
return;
|
||||
}
|
||||
|
||||
mCompositableBackendData = aBackendData;
|
||||
|
||||
if (!mCompositor) {
|
||||
return;
|
||||
}
|
||||
|
||||
// delete old EGLImage
|
||||
DeallocateDeviceData();
|
||||
|
||||
gl()->MakeCurrent();
|
||||
GLuint tex = GetGLTexture();
|
||||
GLuint textureTarget = GetTextureTarget();
|
||||
|
||||
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
gl()->fBindTexture(textureTarget, tex);
|
||||
// create new EGLImage
|
||||
mEGLImage = EGLImageCreateFromNativeBuffer(gl(), mGraphicBuffer->getNativeBuffer());
|
||||
gl()->fEGLImageTargetTexture2D(textureTarget, mEGLImage);
|
||||
mNeedsReset = false;
|
||||
}
|
||||
|
||||
gfx::IntSize
|
||||
GrallocTextureSourceOGL::GetSize() const
|
||||
{
|
||||
@@ -416,11 +357,6 @@ GrallocTextureSourceOGL::GetAsSurface() {
|
||||
GLuint
|
||||
GrallocTextureSourceOGL::GetGLTexture()
|
||||
{
|
||||
if (mCompositableBackendData) {
|
||||
mCompositableBackendData->SetCompositor(mCompositor);
|
||||
return static_cast<CompositableDataGonkOGL*>(mCompositableBackendData.get())->GetTexture();
|
||||
}
|
||||
|
||||
return mTexture;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user