зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1364302 - Fix HoldExternalImage() handling r=nical
This commit is contained in:
Родитель
e853c9b0a6
Коммит
3121f12bfb
|
@ -470,7 +470,6 @@ WebRenderBridgeParent::ProcessWebRenderCommands(const gfx::IntSize &aSize,
|
||||||
mApi->AddExternalImageHandle(key,
|
mApi->AddExternalImageHandle(key,
|
||||||
descriptor,
|
descriptor,
|
||||||
wrTexture->GetExternalImageKey());
|
wrTexture->GetExternalImageKey());
|
||||||
mCompositableHolder->HoldExternalImage(mPipelineId, aEpoch, texture->AsWebRenderTextureHost());
|
|
||||||
} else {
|
} else {
|
||||||
// XXX handling YUV
|
// XXX handling YUV
|
||||||
gfx::SurfaceFormat format =
|
gfx::SurfaceFormat format =
|
||||||
|
@ -479,7 +478,6 @@ WebRenderBridgeParent::ProcessWebRenderCommands(const gfx::IntSize &aSize,
|
||||||
mApi->AddExternalImageBuffer(key,
|
mApi->AddExternalImageBuffer(key,
|
||||||
descriptor,
|
descriptor,
|
||||||
wrTexture->GetExternalImageKey());
|
wrTexture->GetExternalImageKey());
|
||||||
mCompositableHolder->HoldExternalImage(mPipelineId, aEpoch, texture->AsWebRenderTextureHost());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -627,7 +625,7 @@ WebRenderBridgeParent::RecvAddExternalImageId(const ExternalImageId& aImageId,
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
wrHost->SetWrCompositableHolder(mCompositableHolder);
|
wrHost->SetWrBridge(this);
|
||||||
mExternalImageIds.Put(wr::AsUint64(aImageId), wrHost);
|
mExternalImageIds.Put(wr::AsUint64(aImageId), wrHost);
|
||||||
|
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
|
@ -650,7 +648,7 @@ WebRenderBridgeParent::RecvAddExternalImageIdForCompositable(const ExternalImage
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
wrHost->SetWrCompositableHolder(mCompositableHolder);
|
wrHost->SetWrBridge(this);
|
||||||
mExternalImageIds.Put(wr::AsUint64(aImageId), wrHost);
|
mExternalImageIds.Put(wr::AsUint64(aImageId), wrHost);
|
||||||
|
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
|
@ -665,7 +663,7 @@ WebRenderBridgeParent::RecvRemoveExternalImageId(const ExternalImageId& aImageId
|
||||||
MOZ_ASSERT(mExternalImageIds.Get(wr::AsUint64(aImageId)).get());
|
MOZ_ASSERT(mExternalImageIds.Get(wr::AsUint64(aImageId)).get());
|
||||||
WebRenderImageHost* wrHost = mExternalImageIds.Get(wr::AsUint64(aImageId)).get();
|
WebRenderImageHost* wrHost = mExternalImageIds.Get(wr::AsUint64(aImageId)).get();
|
||||||
if (wrHost) {
|
if (wrHost) {
|
||||||
wrHost->SetWrCompositableHolder(nullptr);
|
wrHost->SetWrBridge(nullptr);
|
||||||
}
|
}
|
||||||
mExternalImageIds.Remove(wr::AsUint64(aImageId));
|
mExternalImageIds.Remove(wr::AsUint64(aImageId));
|
||||||
|
|
||||||
|
@ -878,11 +876,11 @@ WebRenderBridgeParent::ClearResources()
|
||||||
DeleteOldImages();
|
DeleteOldImages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mCompositableHolder->RemovePipeline(mPipelineId);
|
|
||||||
for (auto iter = mExternalImageIds.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mExternalImageIds.Iter(); !iter.Done(); iter.Next()) {
|
||||||
iter.Data()->SetWrCompositableHolder(nullptr);
|
iter.Data()->SetWrBridge(nullptr);
|
||||||
}
|
}
|
||||||
mExternalImageIds.Clear();
|
mExternalImageIds.Clear();
|
||||||
|
mCompositableHolder->RemovePipeline(mPipelineId);
|
||||||
|
|
||||||
if (mWidget && mCompositorScheduler) {
|
if (mWidget && mCompositorScheduler) {
|
||||||
mCompositorScheduler->Destroy();
|
mCompositorScheduler->Destroy();
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
|
|
||||||
wr::PipelineId PipelineId() { return mPipelineId; }
|
wr::PipelineId PipelineId() { return mPipelineId; }
|
||||||
wr::WebRenderAPI* GetWebRenderAPI() { return mApi; }
|
wr::WebRenderAPI* GetWebRenderAPI() { return mApi; }
|
||||||
|
wr::Epoch WrEpoch() { return wr::NewEpoch(mWrEpoch); }
|
||||||
WebRenderCompositableHolder* CompositableHolder() { return mCompositableHolder; }
|
WebRenderCompositableHolder* CompositableHolder() { return mCompositableHolder; }
|
||||||
CompositorVsyncScheduler* CompositorScheduler() { return mCompositorScheduler.get(); }
|
CompositorVsyncScheduler* CompositorScheduler() { return mCompositorScheduler.get(); }
|
||||||
|
|
||||||
|
@ -171,9 +172,12 @@ private:
|
||||||
virtual ~WebRenderBridgeParent();
|
virtual ~WebRenderBridgeParent();
|
||||||
|
|
||||||
void DeleteOldImages();
|
void DeleteOldImages();
|
||||||
void ProcessWebRenderCommands(const gfx::IntSize &aSize, InfallibleTArray<WebRenderParentCommand>& commands, const wr::Epoch& aEpoch,
|
void ProcessWebRenderCommands(const gfx::IntSize &aSize,
|
||||||
const WrSize& aContentSize, const ByteBuffer& dl,
|
InfallibleTArray<WebRenderParentCommand>& commands,
|
||||||
const WrBuiltDisplayListDescriptor& dlDesc);
|
const wr::Epoch& aEpoch,
|
||||||
|
const WrSize& aContentSize,
|
||||||
|
const ByteBuffer& dl,
|
||||||
|
const WrBuiltDisplayListDescriptor& dlDesc);
|
||||||
void ScheduleComposition();
|
void ScheduleComposition();
|
||||||
void ClearResources();
|
void ClearResources();
|
||||||
uint64_t GetChildLayerObserverEpoch() const { return mChildLayerObserverEpoch; }
|
uint64_t GetChildLayerObserverEpoch() const { return mChildLayerObserverEpoch; }
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||||
#include "mozilla/layers/Effects.h" // for TexturedEffect, Effect, etc
|
#include "mozilla/layers/Effects.h" // for TexturedEffect, Effect, etc
|
||||||
#include "mozilla/layers/LayerManagerComposite.h" // for TexturedEffect, Effect, etc
|
#include "mozilla/layers/LayerManagerComposite.h" // for TexturedEffect, Effect, etc
|
||||||
|
#include "mozilla/layers/WebRenderBridgeParent.h"
|
||||||
#include "mozilla/layers/WebRenderCompositableHolder.h"
|
#include "mozilla/layers/WebRenderCompositableHolder.h"
|
||||||
#include "nsAString.h"
|
#include "nsAString.h"
|
||||||
#include "nsDebug.h" // for NS_WARNING, NS_ASSERTION
|
#include "nsDebug.h" // for NS_WARNING, NS_ASSERTION
|
||||||
|
@ -26,12 +27,12 @@ class ISurfaceAllocator;
|
||||||
WebRenderImageHost::WebRenderImageHost(const TextureInfo& aTextureInfo)
|
WebRenderImageHost::WebRenderImageHost(const TextureInfo& aTextureInfo)
|
||||||
: CompositableHost(aTextureInfo)
|
: CompositableHost(aTextureInfo)
|
||||||
, ImageComposite()
|
, ImageComposite()
|
||||||
, mWrCompositableHolder(nullptr)
|
, mWrBridge(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
WebRenderImageHost::~WebRenderImageHost()
|
WebRenderImageHost::~WebRenderImageHost()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!mWrCompositableHolder);
|
MOZ_ASSERT(!mWrBridge);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -70,12 +71,13 @@ WebRenderImageHost::UseTextureHost(const nsTArray<TimedTexture>& aTextures)
|
||||||
// slightly different timestamps in order to sync with the audio clock. This
|
// slightly different timestamps in order to sync with the audio clock. This
|
||||||
// means that any CompositeUntil() call we made in Composite() may no longer
|
// means that any CompositeUntil() call we made in Composite() may no longer
|
||||||
// guarantee that we'll composite until the next frame is ready. Fix that here.
|
// guarantee that we'll composite until the next frame is ready. Fix that here.
|
||||||
if (mWrCompositableHolder && mLastFrameID >= 0) {
|
if (mWrBridge && mLastFrameID >= 0) {
|
||||||
|
MOZ_ASSERT(mWrBridge->CompositableHolder());
|
||||||
for (size_t i = 0; i < mImages.Length(); ++i) {
|
for (size_t i = 0; i < mImages.Length(); ++i) {
|
||||||
bool frameComesAfter = mImages[i].mFrameID > mLastFrameID ||
|
bool frameComesAfter = mImages[i].mFrameID > mLastFrameID ||
|
||||||
mImages[i].mProducerID != mLastProducerID;
|
mImages[i].mProducerID != mLastProducerID;
|
||||||
if (frameComesAfter && !mImages[i].mTimeStamp.IsNull()) {
|
if (frameComesAfter && !mImages[i].mTimeStamp.IsNull()) {
|
||||||
mWrCompositableHolder->CompositeUntil(mImages[i].mTimeStamp +
|
mWrBridge->CompositableHolder()->CompositeUntil(mImages[i].mTimeStamp +
|
||||||
TimeDuration::FromMilliseconds(BIAS_TIME_MS));
|
TimeDuration::FromMilliseconds(BIAS_TIME_MS));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -96,6 +98,7 @@ WebRenderImageHost::CleanupResources()
|
||||||
nsTArray<TimedImage> newImages;
|
nsTArray<TimedImage> newImages;
|
||||||
mImages.SwapElements(newImages);
|
mImages.SwapElements(newImages);
|
||||||
newImages.Clear();
|
newImages.Clear();
|
||||||
|
SetCurrentTextureHost(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -115,8 +118,9 @@ TimeStamp
|
||||||
WebRenderImageHost::GetCompositionTime() const
|
WebRenderImageHost::GetCompositionTime() const
|
||||||
{
|
{
|
||||||
TimeStamp time;
|
TimeStamp time;
|
||||||
if (mWrCompositableHolder) {
|
if (mWrBridge) {
|
||||||
time = mWrCompositableHolder->GetCompositionTime();
|
MOZ_ASSERT(mWrBridge->CompositableHolder());
|
||||||
|
time = mWrBridge->CompositableHolder()->GetCompositionTime();
|
||||||
}
|
}
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
@ -136,11 +140,13 @@ WebRenderImageHost::GetAsTextureHostForComposite()
|
||||||
{
|
{
|
||||||
int imageIndex = ChooseImageIndex();
|
int imageIndex = ChooseImageIndex();
|
||||||
if (imageIndex < 0) {
|
if (imageIndex < 0) {
|
||||||
|
SetCurrentTextureHost(nullptr);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mWrCompositableHolder && uint32_t(imageIndex) + 1 < mImages.Length()) {
|
if (mWrBridge && uint32_t(imageIndex) + 1 < mImages.Length()) {
|
||||||
mWrCompositableHolder->CompositeUntil(mImages[imageIndex + 1].mTimeStamp + TimeDuration::FromMilliseconds(BIAS_TIME_MS));
|
MOZ_ASSERT(mWrBridge->CompositableHolder());
|
||||||
|
mWrBridge->CompositableHolder()->CompositeUntil(mImages[imageIndex + 1].mTimeStamp + TimeDuration::FromMilliseconds(BIAS_TIME_MS));
|
||||||
}
|
}
|
||||||
|
|
||||||
TimedImage* img = &mImages[imageIndex];
|
TimedImage* img = &mImages[imageIndex];
|
||||||
|
@ -149,7 +155,31 @@ WebRenderImageHost::GetAsTextureHostForComposite()
|
||||||
mLastFrameID = img->mFrameID;
|
mLastFrameID = img->mFrameID;
|
||||||
mLastProducerID = img->mProducerID;
|
mLastProducerID = img->mProducerID;
|
||||||
}
|
}
|
||||||
return img->mTextureHost;
|
SetCurrentTextureHost(img->mTextureHost);
|
||||||
|
return mCurrentTextureHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WebRenderImageHost::SetCurrentTextureHost(TextureHost* aTexture)
|
||||||
|
{
|
||||||
|
if (aTexture == mCurrentTextureHost.get()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mWrBridge &&
|
||||||
|
!!mCurrentTextureHost &&
|
||||||
|
mCurrentTextureHost != aTexture &&
|
||||||
|
mCurrentTextureHost->AsWebRenderTextureHost()) {
|
||||||
|
MOZ_ASSERT(mWrBridge->CompositableHolder());
|
||||||
|
wr::PipelineId piplineId = mWrBridge->PipelineId();
|
||||||
|
wr::Epoch epoch = mWrBridge->WrEpoch();
|
||||||
|
mWrBridge->CompositableHolder()->HoldExternalImage(
|
||||||
|
piplineId,
|
||||||
|
epoch,
|
||||||
|
mCurrentTextureHost->AsWebRenderTextureHost());
|
||||||
|
}
|
||||||
|
|
||||||
|
mCurrentTextureHost = aTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRenderImageHost::Attach(Layer* aLayer,
|
void WebRenderImageHost::Attach(Layer* aLayer,
|
||||||
|
@ -246,5 +276,12 @@ WebRenderImageHost::GetImageSize() const
|
||||||
return IntSize();
|
return IntSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WebRenderImageHost::SetWrBridge(WebRenderBridgeParent* aWrBridge)
|
||||||
|
{
|
||||||
|
SetCurrentTextureHost(nullptr);
|
||||||
|
mWrBridge = aWrBridge;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace layers
|
} // namespace layers
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace layers {
|
namespace layers {
|
||||||
|
|
||||||
class WebRenderCompositableHolder;
|
class WebRenderBridgeParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ImageHost. Works with ImageClientSingle and ImageClientBuffered
|
* ImageHost. Works with ImageClientSingle and ImageClientBuffered
|
||||||
|
@ -69,16 +69,17 @@ public:
|
||||||
|
|
||||||
TextureHost* GetAsTextureHostForComposite();
|
TextureHost* GetAsTextureHostForComposite();
|
||||||
|
|
||||||
void SetWrCompositableHolder(WebRenderCompositableHolder* aWrCompositableHolder)
|
void SetWrBridge(WebRenderBridgeParent* aWrBridge);
|
||||||
{
|
|
||||||
mWrCompositableHolder = aWrCompositableHolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ImageComposite
|
// ImageComposite
|
||||||
virtual TimeStamp GetCompositionTime() const override;
|
virtual TimeStamp GetCompositionTime() const override;
|
||||||
|
|
||||||
WebRenderCompositableHolder* MOZ_NON_OWNING_REF mWrCompositableHolder;
|
void SetCurrentTextureHost(TextureHost* aTexture);
|
||||||
|
|
||||||
|
WebRenderBridgeParent* MOZ_NON_OWNING_REF mWrBridge;
|
||||||
|
|
||||||
|
CompositableTextureHostRef mCurrentTextureHost;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace layers
|
} // namespace layers
|
||||||
|
|
Загрузка…
Ссылка в новой задаче