Bug 1031553 - Create GrallocTextureSourceOGL only when GrallocTextureHostOGL has a gralloc buffer r=nical

This commit is contained in:
Sotaro Ikeda 2014-07-04 06:16:13 -07:00
parent b3fdf22d45
commit e5768ec626
2 changed files with 22 additions and 7 deletions

View File

@ -205,6 +205,9 @@ CompositableClient::CreateTextureClientForDrawing(SurfaceFormat aFormat,
bool
CompositableClient::AddTextureClient(TextureClient* aClient)
{
if(!aClient || !aClient->IsAllocated()) {
return false;
}
return aClient->InitIPDLActor(mForwarder);
}

View File

@ -305,13 +305,13 @@ GrallocTextureHostOGL::GrallocTextureHostOGL(TextureFlags aFlags,
format =
SurfaceFormatForAndroidPixelFormat(graphicBuffer->getPixelFormat(),
aFlags & TextureFlags::RB_SWAPPED);
mTextureSource = new GrallocTextureSourceOGL(nullptr,
this,
graphicBuffer,
format);
} else {
NS_WARNING("gralloc buffer is nullptr");
printf_stderr("gralloc buffer is nullptr");
}
mTextureSource = new GrallocTextureSourceOGL(nullptr,
this,
graphicBuffer,
format);
}
GrallocTextureHostOGL::~GrallocTextureHostOGL()
@ -322,7 +322,9 @@ GrallocTextureHostOGL::~GrallocTextureHostOGL()
void
GrallocTextureHostOGL::SetCompositor(Compositor* aCompositor)
{
mTextureSource->SetCompositor(static_cast<CompositorOGL*>(aCompositor));
if (mTextureSource) {
mTextureSource->SetCompositor(static_cast<CompositorOGL*>(aCompositor));
}
}
bool
@ -344,12 +346,18 @@ GrallocTextureHostOGL::Unlock()
bool
GrallocTextureHostOGL::IsValid() const
{
if (!mTextureSource) {
return false;
}
return mTextureSource->IsValid();
}
gfx::SurfaceFormat
GrallocTextureHostOGL::GetFormat() const
{
if (!mTextureSource) {
return gfx::SurfaceFormat::UNKNOWN;
}
return mTextureSource->GetFormat();
}
@ -358,6 +366,7 @@ GrallocTextureHostOGL::DeallocateSharedData()
{
if (mTextureSource) {
mTextureSource->ForgetBuffer();
mTextureSource = nullptr;
}
if (mGrallocHandle.buffer().type() != SurfaceDescriptor::Tnull_t) {
MaybeMagicGrallocBufferHandle handle = mGrallocHandle.buffer();
@ -378,13 +387,16 @@ GrallocTextureHostOGL::ForgetSharedData()
{
if (mTextureSource) {
mTextureSource->ForgetBuffer();
mTextureSource = nullptr;
}
}
void
GrallocTextureHostOGL::DeallocateDeviceData()
{
mTextureSource->DeallocateDeviceData();
if (mTextureSource) {
mTextureSource->DeallocateDeviceData();
}
}
LayerRenderState