Bug 1000640 - Crash if we try to use the Gralloc path in TextureHost. - r=mattwoodrow

This commit is contained in:
Jeff Gilbert 2014-06-18 17:04:06 -07:00
parent bde621b73d
commit f50b8dc737
2 changed files with 36 additions and 45 deletions

View File

@ -155,52 +155,51 @@ CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
stream = screen->Stream();
}
bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
bool bufferCreated = false;
if (isCrossProcess) {
#ifdef MOZ_WIDGET_GONK
SharedSurface* surf = stream->SwapConsumer();
if (!surf) {
printf_stderr("surf is null post-SwapConsumer!\n");
return;
}
SharedSurface* surf = stream->SwapConsumer();
if (!surf) {
printf_stderr("surf is null post-SwapConsumer!\n");
return;
}
if (surf->Type() != SharedSurfaceType::Gralloc) {
printf_stderr("Unexpected non-Gralloc SharedSurface in IPC path!");
MOZ_ASSERT(false);
return;
}
if (surf->Type() != SharedSurfaceType::Gralloc) {
printf_stderr("Unexpected non-Gralloc SharedSurface in IPC path!");
MOZ_ASSERT(false);
return;
}
SharedSurface_Gralloc* grallocSurf = SharedSurface_Gralloc::Cast(surf);
SharedSurface_Gralloc* grallocSurf = SharedSurface_Gralloc::Cast(surf);
RefPtr<GrallocTextureClientOGL> grallocTextureClient =
static_cast<GrallocTextureClientOGL*>(grallocSurf->GetTextureClient());
RefPtr<GrallocTextureClientOGL> grallocTextureClient =
static_cast<GrallocTextureClientOGL*>(grallocSurf->GetTextureClient());
// If IPDLActor is null means this TextureClient didn't AddTextureClient yet
if (!grallocTextureClient->GetIPDLActor()) {
grallocTextureClient->SetTextureFlags(mTextureInfo.mTextureFlags);
AddTextureClient(grallocTextureClient);
}
// If IPDLActor is null means this TextureClient didn't AddTextureClient yet
if (!grallocTextureClient->GetIPDLActor()) {
grallocTextureClient->SetTextureFlags(mTextureInfo.mTextureFlags);
AddTextureClient(grallocTextureClient);
}
if (grallocTextureClient->GetIPDLActor()) {
UseTexture(grallocTextureClient);
}
if (grallocTextureClient->GetIPDLActor()) {
UseTexture(grallocTextureClient);
}
if (mBuffer) {
// remove old buffer from CompositableHost
RefPtr<AsyncTransactionTracker> tracker = new RemoveTextureFromCompositableTracker();
// Hold TextureClient until transaction complete.
tracker->SetTextureClient(mBuffer);
mBuffer->SetRemoveFromCompositableTracker(tracker);
// RemoveTextureFromCompositableAsync() expects CompositorChild's presence.
GetForwarder()->RemoveTextureFromCompositableAsync(tracker, this, mBuffer);
}
mBuffer = grallocTextureClient;
if (mBuffer) {
// remove old buffer from CompositableHost
RefPtr<AsyncTransactionTracker> tracker = new RemoveTextureFromCompositableTracker();
// Hold TextureClient until transaction complete.
tracker->SetTextureClient(mBuffer);
mBuffer->SetRemoveFromCompositableTracker(tracker);
// RemoveTextureFromCompositableAsync() expects CompositorChild's presence.
GetForwarder()->RemoveTextureFromCompositableAsync(tracker, this, mBuffer);
}
mBuffer = grallocTextureClient;
#else
bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
if (isCrossProcess) {
printf_stderr("isCrossProcess, but not MOZ_WIDGET_GONK! Someone needs to write some code!");
MOZ_ASSERT(false);
#endif
} else {
bool bufferCreated = false;
if (!mBuffer) {
StreamTextureClient* textureClient =
new StreamTextureClient(mTextureInfo.mTextureFlags);
@ -218,6 +217,7 @@ CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
GetForwarder()->UseTexture(this, mBuffer);
}
}
#endif
aLayer->Painted();
}

View File

@ -947,19 +947,10 @@ StreamTextureHost::Lock()
surf->Size());
break;
}
#ifdef MOZ_WIDGET_GONK
case gfx::SharedSurfaceType::Gralloc: {
gl::SharedSurface_Gralloc* surf = gl::SharedSurface_Gralloc::Cast(abstractSurf);
GrallocTextureClientOGL* client = surf->GetTextureClient();
android::GraphicBuffer* graphicBuffer = client->GetGraphicBuffer().get();
MOZ_ASSERT(mCompositor->GetBackendType() == LayersBackend::LAYERS_OPENGL);
CompositorOGL* compositorOGL = static_cast<CompositorOGL*>(mCompositor);
newTexSource = new GrallocTextureSourceOGL(compositorOGL, nullptr, graphicBuffer, format);
MOZ_ASSERT(false, "WebGL in the Host process? Gralloc without E10S? Not yet supported.");
break;
}
#endif
#ifdef XP_MACOSX
case gfx::SharedSurfaceType::IOSurface: {
gl::SharedSurface_IOSurface* surf = gl::SharedSurface_IOSurface::Cast(abstractSurf);