Bug 868946 - Make GrallocTextureHostOGL not crash when it doesn't have a GL context. r=bjacob

This commit is contained in:
Nicolas Silva 2013-05-07 16:19:15 -04:00
parent 99dceb7e72
commit f52aecfad5
2 changed files with 9 additions and 5 deletions

View File

@ -200,13 +200,14 @@ public:
const gfx::IntSize& aSize) {}
/**
* Lock the texture host for compositing, returns an effect that should
* be used to composite this texture.
* Lock the texture host for compositing, returns true if the TextureHost is
* valid for composition.
*/
virtual bool Lock() { return true; }
virtual bool Lock() { return IsValid(); }
/**
* Unlock the texture host after compositing
* Unlock the texture host after compositing.
* Should handle the case where Lock failed without crashing.
*/
virtual void Unlock() {}

View File

@ -780,7 +780,7 @@ void GrallocTextureHostOGL::BindTexture(GLenum aTextureUnit)
bool
GrallocTextureHostOGL::IsValid() const
{
return !!mGraphicBuffer.get();
return !!mGL && !!mGraphicBuffer.get();
}
GrallocTextureHostOGL::~GrallocTextureHostOGL()
@ -798,6 +798,9 @@ GrallocTextureHostOGL::~GrallocTextureHostOGL()
bool
GrallocTextureHostOGL::Lock()
{
if (!IsValid()) {
return false;
}
/*
* The job of this function is to ensure that the texture is tied to the
* android::GraphicBuffer, so that texturing will source the GraphicBuffer.