Bug 980647 - Part 2 - Use the PerFrame pool with all layer types on b2g. r=Cwiiis

This commit is contained in:
Nicolas Silva 2014-04-02 10:37:49 +08:00
Родитель 686f6935cf
Коммит 039348f258
3 изменённых файлов: 9 добавлений и 102 удалений

Просмотреть файл

@ -108,14 +108,6 @@ GrallocTextureSourceOGL::~GrallocTextureSourceOGL()
void
GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit, gfx::Filter aFilter)
{
/*
* 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;
@ -128,24 +120,19 @@ GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit, gfx::Filter aFilter)
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);
}
ApplyFilterToBoundTexture(gl(), aFilter, textureTarget);
}
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(GetTextureTarget(), LOCAL_GL_TEXTURE0);
@ -164,7 +151,7 @@ void GrallocTextureSourceOGL::Lock()
bool
GrallocTextureSourceOGL::IsValid() const
{
return !!gl() && !!mGraphicBuffer.get() && (!!mCompositor || !!mCompositableBackendData);
return !!gl() && !!mGraphicBuffer.get();
}
gl::GLContext*
@ -210,45 +197,10 @@ 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
@ -419,11 +371,6 @@ GrallocTextureSourceOGL::GetAsSurface() {
GLuint
GrallocTextureSourceOGL::GetGLTexture()
{
if (mCompositableBackendData) {
mCompositableBackendData->SetCompositor(mCompositor);
return static_cast<CompositableDataGonkOGL*>(mCompositableBackendData.get())->GetTexture();
}
return mTexture;
}

Просмотреть файл

@ -145,12 +145,10 @@ WrapMode(gl::GLContext *aGl, bool aAllowRepeat)
}
CompositableDataGonkOGL::CompositableDataGonkOGL()
: mTexture(0)
{
}
CompositableDataGonkOGL::~CompositableDataGonkOGL()
{
DeleteTextureIfPresent();
}
gl::GLContext*
@ -167,28 +165,6 @@ void CompositableDataGonkOGL::SetCompositor(Compositor* aCompositor)
void CompositableDataGonkOGL::ClearData()
{
CompositableBackendSpecificData::ClearData();
DeleteTextureIfPresent();
}
GLuint CompositableDataGonkOGL::GetTexture()
{
if (!mTexture) {
if (gl()->MakeCurrent()) {
gl()->fGenTextures(1, &mTexture);
}
}
return mTexture;
}
void
CompositableDataGonkOGL::DeleteTextureIfPresent()
{
if (mTexture) {
if (gl()->MakeCurrent()) {
gl()->fDeleteTextures(1, &mTexture);
}
mTexture = 0;
}
}
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
@ -730,19 +706,6 @@ TextureImageDeprecatedTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage
return;
}
#ifdef MOZ_WIDGET_GONK
if (mCompositableBackendData) {
// on gonk, this class is used as a fallback from gralloc buffer.
// There is a case this class is used with GrallocDeprecatedTextureHostOGL
// under same CompositableHost. if it happens, a gralloc buffer of
// GrallocDeprecatedTextureHostOGL needs to be unbounded from a texture,
// when the gralloc buffer is not rendered.
// Establish the unbound by deleting the texture.
// See Bug 916264.
static_cast<CompositableDataGonkOGL*>(mCompositableBackendData.get())->DeleteTextureIfPresent();
}
#endif
AutoOpenSurface surf(OPEN_READ_ONLY, aImage);
gfx::IntSize size = surf.Size();
TextureImage::ImageFormat format = surf.ImageFormat();

Просмотреть файл

@ -72,12 +72,9 @@ public:
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
virtual void ClearData() MOZ_OVERRIDE;
GLuint GetTexture();
void DeleteTextureIfPresent();
gl::GLContext* gl() const;
protected:
RefPtr<CompositorOGL> mCompositor;
GLuint mTexture;
};
inline void ApplyFilterToBoundTexture(gl::GLContext* aGL,