зеркало из 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,
|
||||
nsIntSize(aWidth, aHeight),
|
||||
gfxASurface::ImageFormatRGB16_565);
|
||||
if (!rgbImage) {
|
||||
NS_WARNING("Could not create rgb image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mImage = rgbImage;
|
||||
return rgbImage->AsSharedImage()->GetBuffer();
|
||||
case MPAPI::YCbCr:
|
||||
|
|
|
@ -119,7 +119,7 @@ void
|
|||
CanvasLayerComposite::CleanupResources()
|
||||
{
|
||||
if (mImageHost) {
|
||||
mImageHost->Detach();
|
||||
mImageHost->Detach(this);
|
||||
}
|
||||
mImageHost = nullptr;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ CompositableHost::CompositableHost(const TextureInfo& aTextureInfo)
|
|||
, mCompositor(nullptr)
|
||||
, mLayer(nullptr)
|
||||
, mAttached(false)
|
||||
, mKeepAttached(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CompositableHost);
|
||||
}
|
||||
|
|
|
@ -210,19 +210,39 @@ public:
|
|||
|
||||
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(!IsAttached());
|
||||
NS_ASSERTION(aFlags & ALLOW_REATTACH || !mAttached,
|
||||
"Re-attaching compositables must be explicitly authorised");
|
||||
SetCompositor(aCompositor);
|
||||
SetLayer(aLayer);
|
||||
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);
|
||||
SetCompositor(nullptr);
|
||||
mAttached = false;
|
||||
if (!mKeepAttached ||
|
||||
aLayer == mLayer) {
|
||||
SetLayer(nullptr);
|
||||
SetCompositor(nullptr);
|
||||
mAttached = false;
|
||||
mKeepAttached = false;
|
||||
}
|
||||
}
|
||||
bool IsAttached() { return mAttached; }
|
||||
|
||||
|
@ -251,6 +271,7 @@ protected:
|
|||
Layer* mLayer;
|
||||
RefPtr<TextureHost> mFirstTexture;
|
||||
bool mAttached;
|
||||
bool mKeepAttached;
|
||||
};
|
||||
|
||||
class CompositableParentManager;
|
||||
|
|
|
@ -169,7 +169,7 @@ void
|
|||
ThebesLayerComposite::CleanupResources()
|
||||
{
|
||||
if (mBuffer) {
|
||||
mBuffer->Detach();
|
||||
mBuffer->Detach(this);
|
||||
}
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
|
|
|
@ -67,9 +67,11 @@ TiledLayerBufferComposite::ValidateTile(TiledTexture aTile,
|
|||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,9 @@ public:
|
|||
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
|
||||
virtual void Dump(FILE* aFile=nullptr,
|
||||
|
|
|
@ -405,7 +405,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
|||
}
|
||||
case Edit::TOpAttachCompositable: {
|
||||
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(
|
||||
mLayerManager->GetCompositor()->GetCompositorID());
|
||||
break;
|
||||
|
@ -414,7 +414,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
|||
const OpAttachAsyncCompositable& op = edit.get_OpAttachAsyncCompositable();
|
||||
CompositableParent* compositableParent = CompositableMap::Get(op.containerID());
|
||||
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());
|
||||
break;
|
||||
}
|
||||
|
@ -501,7 +501,9 @@ LayerTransactionParent::RecvGetTransform(PLayerParent* aParent,
|
|||
}
|
||||
|
||||
void
|
||||
LayerTransactionParent::Attach(ShadowLayerParent* aLayerParent, CompositableParent* aCompositable)
|
||||
LayerTransactionParent::Attach(ShadowLayerParent* aLayerParent,
|
||||
CompositableParent* aCompositable,
|
||||
bool aIsAsyncVideo)
|
||||
{
|
||||
LayerComposite* layer = aLayerParent->AsLayer()->AsLayerComposite();
|
||||
MOZ_ASSERT(layer);
|
||||
|
@ -512,7 +514,12 @@ LayerTransactionParent::Attach(ShadowLayerParent* aLayerParent, CompositablePare
|
|||
CompositableHost* compositable = aCompositable->GetCompositableHost();
|
||||
MOZ_ASSERT(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
|
||||
|
|
|
@ -106,7 +106,9 @@ protected:
|
|||
virtual PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo) MOZ_OVERRIDE;
|
||||
virtual bool DeallocPCompositableParent(PCompositableParent* actor) MOZ_OVERRIDE;
|
||||
|
||||
void Attach(ShadowLayerParent* aLayerParent, CompositableParent* aCompositable);
|
||||
void Attach(ShadowLayerParent* aLayerParent,
|
||||
CompositableParent* aCompositable,
|
||||
bool aIsAsyncVideo);
|
||||
|
||||
private:
|
||||
nsRefPtr<LayerManagerComposite> mLayerManager;
|
||||
|
|
Загрузка…
Ссылка в новой задаче