зеркало из https://github.com/mozilla/gecko-dev.git
Bug 902929. Be explicit about re-attaching async video compositable hosts. r=nical
This commit is contained in:
Родитель
dc0aaf9d43
Коммит
01348ed72b
|
@ -366,6 +366,11 @@ MediaPluginReader::ImageBufferCallback::operator()(size_t aWidth, size_t aHeight
|
||||||
rgbImage = mozilla::layers::CreateSharedRGBImage(mImageContainer,
|
rgbImage = mozilla::layers::CreateSharedRGBImage(mImageContainer,
|
||||||
nsIntSize(aWidth, aHeight),
|
nsIntSize(aWidth, aHeight),
|
||||||
gfxASurface::ImageFormatRGB16_565);
|
gfxASurface::ImageFormatRGB16_565);
|
||||||
|
if (!rgbImage) {
|
||||||
|
NS_WARNING("Could not create rgb image");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
mImage = rgbImage;
|
mImage = rgbImage;
|
||||||
return rgbImage->AsSharedImage()->GetBuffer();
|
return rgbImage->AsSharedImage()->GetBuffer();
|
||||||
case MPAPI::YCbCr:
|
case MPAPI::YCbCr:
|
||||||
|
|
|
@ -119,7 +119,7 @@ void
|
||||||
CanvasLayerComposite::CleanupResources()
|
CanvasLayerComposite::CleanupResources()
|
||||||
{
|
{
|
||||||
if (mImageHost) {
|
if (mImageHost) {
|
||||||
mImageHost->Detach();
|
mImageHost->Detach(this);
|
||||||
}
|
}
|
||||||
mImageHost = nullptr;
|
mImageHost = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ CompositableHost::CompositableHost(const TextureInfo& aTextureInfo)
|
||||||
, mCompositor(nullptr)
|
, mCompositor(nullptr)
|
||||||
, mLayer(nullptr)
|
, mLayer(nullptr)
|
||||||
, mAttached(false)
|
, mAttached(false)
|
||||||
|
, mKeepAttached(false)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(CompositableHost);
|
MOZ_COUNT_CTOR(CompositableHost);
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,19 +210,39 @@ public:
|
||||||
|
|
||||||
virtual TiledLayerComposer* AsTiledLayerComposer() { return nullptr; }
|
virtual TiledLayerComposer* AsTiledLayerComposer() { return nullptr; }
|
||||||
|
|
||||||
virtual void Attach(Layer* aLayer, Compositor* aCompositor)
|
typedef uint32_t AttachFlags;
|
||||||
|
static const AttachFlags NO_FLAGS = 0;
|
||||||
|
static const AttachFlags ALLOW_REATTACH = 1;
|
||||||
|
static const AttachFlags KEEP_ATTACHED = 2;
|
||||||
|
|
||||||
|
virtual void Attach(Layer* aLayer,
|
||||||
|
Compositor* aCompositor,
|
||||||
|
AttachFlags aFlags = NO_FLAGS)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aCompositor, "Compositor is required");
|
MOZ_ASSERT(aCompositor, "Compositor is required");
|
||||||
MOZ_ASSERT(!IsAttached());
|
NS_ASSERTION(aFlags & ALLOW_REATTACH || !mAttached,
|
||||||
|
"Re-attaching compositables must be explicitly authorised");
|
||||||
SetCompositor(aCompositor);
|
SetCompositor(aCompositor);
|
||||||
SetLayer(aLayer);
|
SetLayer(aLayer);
|
||||||
mAttached = true;
|
mAttached = true;
|
||||||
|
mKeepAttached = aFlags & KEEP_ATTACHED;
|
||||||
}
|
}
|
||||||
void Detach()
|
// Detach this compositable host from its layer.
|
||||||
|
// If we are used for async video, then it is not safe to blindly detach since
|
||||||
|
// we might be re-attached to a different layer. aLayer is the layer which the
|
||||||
|
// caller expects us to be attached to, we will only detach if we are in fact
|
||||||
|
// attached to that layer. If we are part of a normal layer, then we will be
|
||||||
|
// detached in any case. if aLayer is null, then we will only detach if we are
|
||||||
|
// not async.
|
||||||
|
void Detach(Layer* aLayer = nullptr)
|
||||||
{
|
{
|
||||||
SetLayer(nullptr);
|
if (!mKeepAttached ||
|
||||||
SetCompositor(nullptr);
|
aLayer == mLayer) {
|
||||||
mAttached = false;
|
SetLayer(nullptr);
|
||||||
|
SetCompositor(nullptr);
|
||||||
|
mAttached = false;
|
||||||
|
mKeepAttached = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool IsAttached() { return mAttached; }
|
bool IsAttached() { return mAttached; }
|
||||||
|
|
||||||
|
@ -251,6 +271,7 @@ protected:
|
||||||
Layer* mLayer;
|
Layer* mLayer;
|
||||||
RefPtr<TextureHost> mFirstTexture;
|
RefPtr<TextureHost> mFirstTexture;
|
||||||
bool mAttached;
|
bool mAttached;
|
||||||
|
bool mKeepAttached;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CompositableParentManager;
|
class CompositableParentManager;
|
||||||
|
|
|
@ -169,7 +169,7 @@ void
|
||||||
ThebesLayerComposite::CleanupResources()
|
ThebesLayerComposite::CleanupResources()
|
||||||
{
|
{
|
||||||
if (mBuffer) {
|
if (mBuffer) {
|
||||||
mBuffer->Detach();
|
mBuffer->Detach(this);
|
||||||
}
|
}
|
||||||
mBuffer = nullptr;
|
mBuffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,9 +67,11 @@ TiledLayerBufferComposite::ValidateTile(TiledTexture aTile,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TiledContentHost::Attach(Layer* aLayer, Compositor* aCompositor)
|
TiledContentHost::Attach(Layer* aLayer,
|
||||||
|
Compositor* aCompositor,
|
||||||
|
AttachFlags aFlags /* = NO_FLAGS */)
|
||||||
{
|
{
|
||||||
CompositableHost::Attach(aLayer, aCompositor);
|
CompositableHost::Attach(aLayer, aCompositor, aFlags);
|
||||||
static_cast<ThebesLayerComposite*>(aLayer)->EnsureTiled();
|
static_cast<ThebesLayerComposite*>(aLayer)->EnsureTiled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,9 @@ public:
|
||||||
mLowPrecisionVideoMemoryTiledBuffer.SetCompositor(aCompositor);
|
mLowPrecisionVideoMemoryTiledBuffer.SetCompositor(aCompositor);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Attach(Layer* aLayer, Compositor* aCompositor) MOZ_OVERRIDE;
|
virtual void Attach(Layer* aLayer,
|
||||||
|
Compositor* aCompositor,
|
||||||
|
AttachFlags aFlags = NO_FLAGS) MOZ_OVERRIDE;
|
||||||
|
|
||||||
#ifdef MOZ_DUMP_PAINTING
|
#ifdef MOZ_DUMP_PAINTING
|
||||||
virtual void Dump(FILE* aFile=nullptr,
|
virtual void Dump(FILE* aFile=nullptr,
|
||||||
|
|
|
@ -405,7 +405,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||||
}
|
}
|
||||||
case Edit::TOpAttachCompositable: {
|
case Edit::TOpAttachCompositable: {
|
||||||
const OpAttachCompositable& op = edit.get_OpAttachCompositable();
|
const OpAttachCompositable& op = edit.get_OpAttachCompositable();
|
||||||
Attach(cast(op.layerParent()), cast(op.compositableParent()));
|
Attach(cast(op.layerParent()), cast(op.compositableParent()), false);
|
||||||
cast(op.compositableParent())->SetCompositorID(
|
cast(op.compositableParent())->SetCompositorID(
|
||||||
mLayerManager->GetCompositor()->GetCompositorID());
|
mLayerManager->GetCompositor()->GetCompositorID());
|
||||||
break;
|
break;
|
||||||
|
@ -414,7 +414,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||||
const OpAttachAsyncCompositable& op = edit.get_OpAttachAsyncCompositable();
|
const OpAttachAsyncCompositable& op = edit.get_OpAttachAsyncCompositable();
|
||||||
CompositableParent* compositableParent = CompositableMap::Get(op.containerID());
|
CompositableParent* compositableParent = CompositableMap::Get(op.containerID());
|
||||||
MOZ_ASSERT(compositableParent, "CompositableParent not found in the map");
|
MOZ_ASSERT(compositableParent, "CompositableParent not found in the map");
|
||||||
Attach(cast(op.layerParent()), compositableParent);
|
Attach(cast(op.layerParent()), compositableParent, true);
|
||||||
compositableParent->SetCompositorID(mLayerManager->GetCompositor()->GetCompositorID());
|
compositableParent->SetCompositorID(mLayerManager->GetCompositor()->GetCompositorID());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -501,7 +501,9 @@ LayerTransactionParent::RecvGetTransform(PLayerParent* aParent,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LayerTransactionParent::Attach(ShadowLayerParent* aLayerParent, CompositableParent* aCompositable)
|
LayerTransactionParent::Attach(ShadowLayerParent* aLayerParent,
|
||||||
|
CompositableParent* aCompositable,
|
||||||
|
bool aIsAsyncVideo)
|
||||||
{
|
{
|
||||||
LayerComposite* layer = aLayerParent->AsLayer()->AsLayerComposite();
|
LayerComposite* layer = aLayerParent->AsLayer()->AsLayerComposite();
|
||||||
MOZ_ASSERT(layer);
|
MOZ_ASSERT(layer);
|
||||||
|
@ -512,7 +514,12 @@ LayerTransactionParent::Attach(ShadowLayerParent* aLayerParent, CompositablePare
|
||||||
CompositableHost* compositable = aCompositable->GetCompositableHost();
|
CompositableHost* compositable = aCompositable->GetCompositableHost();
|
||||||
MOZ_ASSERT(compositable);
|
MOZ_ASSERT(compositable);
|
||||||
layer->SetCompositableHost(compositable);
|
layer->SetCompositableHost(compositable);
|
||||||
compositable->Attach(aLayerParent->AsLayer(), compositor);
|
compositable->Attach(aLayerParent->AsLayer(),
|
||||||
|
compositor,
|
||||||
|
aIsAsyncVideo
|
||||||
|
? CompositableHost::ALLOW_REATTACH
|
||||||
|
| CompositableHost::KEEP_ATTACHED
|
||||||
|
: CompositableHost::NO_FLAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -106,7 +106,9 @@ protected:
|
||||||
virtual PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo) MOZ_OVERRIDE;
|
virtual PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo) MOZ_OVERRIDE;
|
||||||
virtual bool DeallocPCompositableParent(PCompositableParent* actor) MOZ_OVERRIDE;
|
virtual bool DeallocPCompositableParent(PCompositableParent* actor) MOZ_OVERRIDE;
|
||||||
|
|
||||||
void Attach(ShadowLayerParent* aLayerParent, CompositableParent* aCompositable);
|
void Attach(ShadowLayerParent* aLayerParent,
|
||||||
|
CompositableParent* aCompositable,
|
||||||
|
bool aIsAsyncVideo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsRefPtr<LayerManagerComposite> mLayerManager;
|
nsRefPtr<LayerManagerComposite> mLayerManager;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче