Bug 897452 - Part 0.2 - Make sure the texture host has a compositor - r=mattwoodrow

This commit is contained in:
Nicolas Silva 2013-12-11 13:05:07 -05:00
parent 4f1be1a2e8
commit 7cc0a23243
4 changed files with 23 additions and 1 deletions

View File

@ -46,6 +46,16 @@ CompositableHost::~CompositableHost()
}
}
void
CompositableHost::UseTextureHost(TextureHost* aTexture)
{
if (!aTexture) {
return;
}
aTexture->SetCompositor(GetCompositor());
}
void
CompositableHost::AddTextureHost(TextureHost* aTexture)
{

View File

@ -295,7 +295,7 @@ public:
virtual void PrintInfo(nsACString& aTo, const char* aPrefix) { }
void AddTextureHost(TextureHost* aTexture);
virtual void UseTextureHost(TextureHost* aTexture) {}
virtual void UseTextureHost(TextureHost* aTexture);
// If a texture host is flagged for deferred removal, the compositable will
// get an option to run any cleanup code early, that is when it would have
// been run if the texture host was not marked deferred.

View File

@ -38,6 +38,7 @@ ImageHost::~ImageHost() {}
void
ImageHost::UseTextureHost(TextureHost* aTexture)
{
CompositableHost::UseTextureHost(aTexture);
mFrontBuffer = aTexture;
}
@ -74,6 +75,10 @@ ImageHost::Composite(EffectChain& aEffectChain,
if (!mFrontBuffer) {
return;
}
// Make sure the front buffer has a compositor
mFrontBuffer->SetCompositor(GetCompositor());
if (!mFrontBuffer->Lock()) {
NS_WARNING("failed to lock front buffer");
return;

View File

@ -384,6 +384,13 @@ BufferTextureHost::MaybeUpload(nsIntRegion *aRegion)
bool
BufferTextureHost::Upload(nsIntRegion *aRegion)
{
if (!mCompositor) {
NS_WARNING("Tried to upload without a compositor. Skipping texture upload...");
// If we are in this situation it means we should have called SetCompositor
// earlier. It is conceivable that on certain rare conditions with async-video
// we may end up here for the first frame, but this should not happen repeatedly.
return false;
}
if (mFormat == gfx::FORMAT_UNKNOWN) {
NS_WARNING("BufferTextureHost: unsupported format!");
return false;