зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1143575. Extend IPDL OpUseTexture to support multiple timestamped images. r=nical
--HG-- extra : commitid : 2GX3DAQCBjp extra : rebase_source : 1cfae59b0e042e4b0295bc4382021e523d69ec70
This commit is contained in:
Родитель
15642eb711
Коммит
faeb0b0fba
|
@ -107,14 +107,12 @@ CompositableHost::FromIPDLActor(PCompositableParent* aActor)
|
|||
}
|
||||
|
||||
void
|
||||
CompositableHost::UseTextureHost(TextureHost* aTexture,
|
||||
const IntRect& aPictureRect)
|
||||
CompositableHost::UseTextureHost(const nsTArray<TimedTexture>& aTextures)
|
||||
{
|
||||
if (!aTexture) {
|
||||
return;
|
||||
}
|
||||
if (GetCompositor()) {
|
||||
aTexture->SetCompositor(GetCompositor());
|
||||
for (auto& texture : aTextures) {
|
||||
texture.mTexture->SetCompositor(GetCompositor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -150,13 +150,6 @@ public:
|
|||
SetLayer(aLayer);
|
||||
mAttached = true;
|
||||
mKeepAttached = aFlags & KEEP_ATTACHED;
|
||||
|
||||
// If we already have a textureHost before, use that in this moment.
|
||||
gfx::IntRect pictureRect;
|
||||
RefPtr<TextureHost> frontBuffer = GetAsTextureHost(&pictureRect);
|
||||
if (frontBuffer) {
|
||||
UseTextureHost(frontBuffer, pictureRect);
|
||||
}
|
||||
}
|
||||
// Detach this compositable host from its layer.
|
||||
// If we are used for async video, then it is not safe to blindly detach since
|
||||
|
@ -187,8 +180,12 @@ public:
|
|||
|
||||
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) = 0;
|
||||
|
||||
virtual void UseTextureHost(TextureHost* aTexture,
|
||||
const gfx::IntRect& aPictureRect);
|
||||
struct TimedTexture {
|
||||
RefPtr<TextureHost> mTexture;
|
||||
TimeStamp mTimeStamp;
|
||||
gfx::IntRect mPictureRect;
|
||||
};
|
||||
virtual void UseTextureHost(const nsTArray<TimedTexture>& aTextures);
|
||||
virtual void UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
|
||||
TextureHost* aTextureOnWhite);
|
||||
virtual void UseOverlaySource(OverlaySource aOverlay,
|
||||
|
|
|
@ -218,14 +218,15 @@ ContentHostTexture::Composite(EffectChain& aEffectChain,
|
|||
}
|
||||
|
||||
void
|
||||
ContentHostTexture::UseTextureHost(TextureHost* aTexture,
|
||||
const nsIntRect& aPictureRect)
|
||||
ContentHostTexture::UseTextureHost(const nsTArray<TimedTexture>& aTextures)
|
||||
{
|
||||
ContentHostBase::UseTextureHost(aTexture, aPictureRect);
|
||||
MOZ_ASSERT(aPictureRect.IsEqualInterior(
|
||||
nsIntRect(nsIntPoint(0, 0), nsIntSize(aTexture->GetSize()))),
|
||||
ContentHostBase::UseTextureHost(aTextures);
|
||||
MOZ_ASSERT(aTextures.Length() == 1);
|
||||
const TimedTexture& t = aTextures[0];
|
||||
MOZ_ASSERT(t.mPictureRect.IsEqualInterior(
|
||||
nsIntRect(nsIntPoint(0, 0), nsIntSize(t.mTexture->GetSize()))),
|
||||
"Only default picture rect supported");
|
||||
mTextureHost = aTexture;
|
||||
mTextureHost = t.mTexture;
|
||||
mTextureHostOnWhite = nullptr;
|
||||
mTextureSourceOnWhite = nullptr;
|
||||
if (mTextureHost) {
|
||||
|
|
|
@ -131,8 +131,7 @@ public:
|
|||
|
||||
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
||||
|
||||
virtual void UseTextureHost(TextureHost* aTexture,
|
||||
const nsIntRect& aPictureRect) override;
|
||||
virtual void UseTextureHost(const nsTArray<TimedTexture>& aTextures) override;
|
||||
virtual void UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
|
||||
TextureHost* aTextureOnWhite) override;
|
||||
|
||||
|
|
|
@ -36,16 +36,17 @@ ImageHost::~ImageHost()
|
|||
{}
|
||||
|
||||
void
|
||||
ImageHost::UseTextureHost(TextureHost* aTexture,
|
||||
const nsIntRect& aPictureRect)
|
||||
ImageHost::UseTextureHost(const nsTArray<TimedTexture>& aTextures)
|
||||
{
|
||||
CompositableHost::UseTextureHost(aTexture, aPictureRect);
|
||||
mFrontBuffer = aTexture;
|
||||
CompositableHost::UseTextureHost(aTextures);
|
||||
MOZ_ASSERT(aTextures.Length() >= 1);
|
||||
const TimedTexture& t = aTextures[0];
|
||||
mFrontBuffer = t.mTexture;
|
||||
if (mFrontBuffer) {
|
||||
mFrontBuffer->Updated();
|
||||
mFrontBuffer->PrepareTextureSource(mTextureSource);
|
||||
}
|
||||
mPictureRect = aPictureRect;
|
||||
mPictureRect = t.mPictureRect;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -68,6 +69,20 @@ ImageHost::GetAsTextureHost(IntRect* aPictureRect)
|
|||
return mFrontBuffer;
|
||||
}
|
||||
|
||||
void ImageHost::Attach(Layer* aLayer,
|
||||
Compositor* aCompositor,
|
||||
AttachFlags aFlags)
|
||||
{
|
||||
CompositableHost::Attach(aLayer, aCompositor, aFlags);
|
||||
if (mFrontBuffer) {
|
||||
if (GetCompositor()) {
|
||||
mFrontBuffer->SetCompositor(GetCompositor());
|
||||
}
|
||||
mFrontBuffer->Updated();
|
||||
mFrontBuffer->PrepareTextureSource(mTextureSource);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImageHost::Composite(EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
|
|
|
@ -51,13 +51,16 @@ public:
|
|||
const gfx::Rect& aClipRect,
|
||||
const nsIntRegion* aVisibleRegion = nullptr) override;
|
||||
|
||||
virtual void UseTextureHost(TextureHost* aTexture,
|
||||
const nsIntRect& aPictureRect) override;
|
||||
virtual void UseTextureHost(const nsTArray<TimedTexture>& aTextures) override;
|
||||
|
||||
virtual void RemoveTextureHost(TextureHost* aTexture) override;
|
||||
|
||||
virtual TextureHost* GetAsTextureHost(gfx::IntRect* aPictureRect = nullptr) override;
|
||||
|
||||
virtual void Attach(Layer* aLayer,
|
||||
Compositor* aCompositor,
|
||||
AttachFlags aFlags = NO_FLAGS) override;
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
gfx::IntSize GetImageSize() const override;
|
||||
|
|
|
@ -171,21 +171,26 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
|
|||
case CompositableOperation::TOpUseTexture: {
|
||||
const OpUseTexture& op = aEdit.get_OpUseTexture();
|
||||
CompositableHost* compositable = AsCompositable(op);
|
||||
RefPtr<TextureHost> tex = TextureHost::AsTextureHost(op.textureParent());
|
||||
|
||||
MOZ_ASSERT(tex.get());
|
||||
if (!ValidatePictureRect(tex->GetSize(), op.picture())) {
|
||||
return false;
|
||||
}
|
||||
compositable->UseTextureHost(tex, op.picture());
|
||||
nsAutoTArray<CompositableHost::TimedTexture,4> textures;
|
||||
for (auto& timedTexture : op.textures()) {
|
||||
CompositableHost::TimedTexture* t = textures.AppendElement();
|
||||
t->mTexture =
|
||||
TextureHost::AsTextureHost(timedTexture.textureParent());
|
||||
MOZ_ASSERT(t->mTexture);
|
||||
t->mTimeStamp = timedTexture.timeStamp();
|
||||
t->mPictureRect = timedTexture.picture();
|
||||
MOZ_ASSERT(ValidatePictureRect(t->mTexture->GetSize(), t->mPictureRect));
|
||||
|
||||
MaybeFence maybeFence = op.fence();
|
||||
if (maybeFence.type() == MaybeFence::TFenceHandle) {
|
||||
FenceHandle fence = maybeFence.get_FenceHandle();
|
||||
if (fence.IsValid() && tex) {
|
||||
tex->SetAcquireFenceHandle(fence);
|
||||
MaybeFence maybeFence = timedTexture.fence();
|
||||
if (maybeFence.type() == MaybeFence::TFenceHandle) {
|
||||
FenceHandle fence = maybeFence.get_FenceHandle();
|
||||
if (fence.IsValid()) {
|
||||
t->mTexture->SetAcquireFenceHandle(fence);
|
||||
}
|
||||
}
|
||||
}
|
||||
compositable->UseTextureHost(textures);
|
||||
|
||||
if (IsAsync() && compositable->GetLayer()) {
|
||||
ScheduleComposition(op);
|
||||
|
|
|
@ -119,10 +119,12 @@ ImageBridgeChild::UseTexture(CompositableClient* aCompositable,
|
|||
FenceHandle fence = aTexture->GetAcquireFenceHandle();
|
||||
IntRect pictureRect = aPictureRect ? *aPictureRect :
|
||||
IntRect(IntPoint(0, 0), IntSize(aTexture->GetSize()));
|
||||
nsAutoTArray<TimedTexture,1> textures;
|
||||
textures.AppendElement(TimedTexture(nullptr, aTexture->GetIPDLActor(),
|
||||
fence.IsValid() ? MaybeFence(fence) : MaybeFence(null_t()),
|
||||
TimeStamp(), pictureRect));
|
||||
mTxn->AddNoSwapEdit(OpUseTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
nullptr, aTexture->GetIPDLActor(),
|
||||
fence.IsValid() ? MaybeFence(fence) : MaybeFence(null_t()),
|
||||
pictureRect));
|
||||
textures));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -383,15 +383,26 @@ union MaybeFence {
|
|||
null_t;
|
||||
};
|
||||
|
||||
struct TimedTexture {
|
||||
PTexture texture;
|
||||
MaybeFence fence;
|
||||
TimeStamp timeStamp;
|
||||
IntRect picture;
|
||||
};
|
||||
|
||||
/**
|
||||
* Tells the compositor-side which texture to use (for example, as front buffer
|
||||
* if there is several textures for double buffering)
|
||||
* Tells the compositor-side which textures to use (for example, as front buffer
|
||||
* if there are several textures for double buffering).
|
||||
* This provides a list of textures with timestamps, ordered by timestamp.
|
||||
* The newest texture whose timestamp is <= the current time is rendered
|
||||
* (where null is considered less than every other timestamp). If there is no
|
||||
* such texture, the first texture is rendered.
|
||||
* The first timestamp value can be null, but the others must not be.
|
||||
* The list must not be empty.
|
||||
*/
|
||||
struct OpUseTexture {
|
||||
PCompositable compositable;
|
||||
PTexture texture;
|
||||
MaybeFence fence;
|
||||
IntRect picture;
|
||||
TimedTexture[] textures;
|
||||
};
|
||||
|
||||
struct OpUseComponentAlphaTextures {
|
||||
|
|
|
@ -362,10 +362,12 @@ ShadowLayerForwarder::UseTexture(CompositableClient* aCompositable,
|
|||
FenceHandle fence = aTexture->GetAcquireFenceHandle();
|
||||
IntRect pictureRect = aPictureRect ? *aPictureRect :
|
||||
IntRect(nsIntPoint(0, 0), IntSize(aTexture->GetSize()));
|
||||
nsAutoTArray<TimedTexture,1> textures;
|
||||
textures.AppendElement(TimedTexture(nullptr, aTexture->GetIPDLActor(),
|
||||
fence.IsValid() ? MaybeFence(fence) : MaybeFence(null_t()),
|
||||
TimeStamp(), pictureRect));
|
||||
mTxn->AddEdit(OpUseTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
nullptr, aTexture->GetIPDLActor(),
|
||||
fence.IsValid() ? MaybeFence(fence) : MaybeFence(null_t()),
|
||||
pictureRect));
|
||||
textures));
|
||||
if (aTexture->GetFlags() & TextureFlags::IMMEDIATE_UPLOAD
|
||||
&& aTexture->HasInternalBuffer()) {
|
||||
// We use IMMEDIATE_UPLOAD when we want to be sure that the upload cannot
|
||||
|
|
Загрузка…
Ссылка в новой задаче