зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1146214 - Implement fence delivery. Combine ipc messages and remove reply fence delivery message. r=nical
This commit is contained in:
Родитель
ffe96d98c7
Коммит
a837628695
|
@ -149,18 +149,6 @@ TextureHost::GetIPDLActor()
|
|||
FenceHandle
|
||||
TextureHost::GetAndResetReleaseFenceHandle()
|
||||
{
|
||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||
TextureHostOGL* hostOGL = this->AsHostOGL();
|
||||
if (!hostOGL) {
|
||||
return FenceHandle();
|
||||
}
|
||||
|
||||
android::sp<android::Fence> fence = hostOGL->GetAndResetReleaseFence();
|
||||
if (fence.get() && fence->isValid()) {
|
||||
FenceHandle handle = FenceHandle(fence);
|
||||
return handle;
|
||||
}
|
||||
#endif
|
||||
return FenceHandle();
|
||||
}
|
||||
|
||||
|
|
|
@ -473,7 +473,7 @@ public:
|
|||
*/
|
||||
PTextureParent* GetIPDLActor();
|
||||
|
||||
FenceHandle GetAndResetReleaseFenceHandle();
|
||||
virtual FenceHandle GetAndResetReleaseFenceHandle();
|
||||
|
||||
/**
|
||||
* Specific to B2G's Composer2D
|
||||
|
|
|
@ -156,15 +156,13 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
|
|||
// Send message back via PImageBridge.
|
||||
ImageBridgeParent::ReplyRemoveTexture(
|
||||
GetChildProcessId(),
|
||||
OpReplyRemoveTexture(true, // isMain
|
||||
op.holderId(),
|
||||
OpReplyRemoveTexture(op.holderId(),
|
||||
op.transactionId()));
|
||||
} else {
|
||||
// send FenceHandle if present.
|
||||
SendFenceHandleIfPresent(op.textureParent(), compositable);
|
||||
|
||||
ReplyRemoveTexture(OpReplyRemoveTexture(false, // isMain
|
||||
op.holderId(),
|
||||
ReplyRemoveTexture(OpReplyRemoveTexture(op.holderId(),
|
||||
op.transactionId()));
|
||||
}
|
||||
break;
|
||||
|
@ -177,6 +175,19 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
|
|||
MOZ_ASSERT(tex.get());
|
||||
compositable->UseTextureHost(tex);
|
||||
|
||||
MaybeFence maybeFence = op.fence();
|
||||
if (maybeFence.type() == MaybeFence::TFenceHandle) {
|
||||
FenceHandle fence = maybeFence.get_FenceHandle();
|
||||
if (fence.IsValid() && tex) {
|
||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||
TextureHostOGL* hostOGL = tex->AsHostOGL();
|
||||
if (hostOGL) {
|
||||
hostOGL->SetAcquireFence(fence.mFence);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (IsAsync() && compositable->GetLayer()) {
|
||||
ScheduleComposition(op);
|
||||
// Async layer updates don't trigger invalidation, manually tell the layer
|
||||
|
|
|
@ -113,15 +113,11 @@ ImageBridgeChild::UseTexture(CompositableClient* aCompositable,
|
|||
MOZ_ASSERT(aTexture);
|
||||
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
||||
MOZ_ASSERT(aTexture->GetIPDLActor());
|
||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||
FenceHandle handle = aTexture->GetAcquireFenceHandle();
|
||||
if (handle.IsValid()) {
|
||||
RefPtr<FenceDeliveryTracker> tracker = new FenceDeliveryTracker(handle);
|
||||
SendFenceHandle(tracker, aTexture->GetIPDLActor(), handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
FenceHandle fence = aTexture->GetAcquireFenceHandle();
|
||||
mTxn->AddNoSwapEdit(OpUseTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
nullptr, aTexture->GetIPDLActor()));
|
||||
nullptr, aTexture->GetIPDLActor(),
|
||||
fence.IsValid() ? MaybeFence(fence) : MaybeFence(null_t())));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -156,10 +152,8 @@ ImageBridgeChild::SendFenceHandle(AsyncTransactionTracker* aTracker,
|
|||
PTextureChild* aTexture,
|
||||
const FenceHandle& aFence)
|
||||
{
|
||||
HoldUntilComplete(aTracker);
|
||||
InfallibleTArray<AsyncChildMessageData> messages;
|
||||
messages.AppendElement(OpDeliverFenceFromChild(aTracker->GetId(),
|
||||
nullptr, aTexture,
|
||||
messages.AppendElement(OpDeliverFenceFromChild(nullptr, aTexture,
|
||||
aFence));
|
||||
SendChildAsyncMessages(messages);
|
||||
}
|
||||
|
@ -835,7 +829,6 @@ ImageBridgeChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessageDat
|
|||
if (texture) {
|
||||
texture->SetReleaseFenceHandle(fence);
|
||||
}
|
||||
HoldTransactionsToRespond(op.transactionId());
|
||||
break;
|
||||
}
|
||||
case AsyncParentMessageData::TOpDeliverFenceToTracker: {
|
||||
|
@ -845,15 +838,6 @@ ImageBridgeChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessageDat
|
|||
AsyncTransactionTrackersHolder::SetReleaseFenceHandle(fence,
|
||||
op.destHolderId(),
|
||||
op.destTransactionId());
|
||||
// Send back a response.
|
||||
InfallibleTArray<AsyncChildMessageData> replies;
|
||||
replies.AppendElement(OpReplyDeliverFence(op.transactionId()));
|
||||
SendChildAsyncMessages(replies);
|
||||
break;
|
||||
}
|
||||
case AsyncParentMessageData::TOpReplyDeliverFence: {
|
||||
const OpReplyDeliverFence& op = message.get_OpReplyDeliverFence();
|
||||
TransactionCompleteted(op.transactionId());
|
||||
break;
|
||||
}
|
||||
case AsyncParentMessageData::TOpReplyRemoveTexture: {
|
||||
|
@ -948,18 +932,6 @@ bool ImageBridgeChild::IsSameProcess() const
|
|||
|
||||
void ImageBridgeChild::SendPendingAsyncMessges()
|
||||
{
|
||||
if (!IsCreated() ||
|
||||
mTransactionsToRespond.empty()) {
|
||||
return;
|
||||
}
|
||||
// Send OpReplyDeliverFence messages
|
||||
InfallibleTArray<AsyncChildMessageData> replies;
|
||||
replies.SetCapacity(mTransactionsToRespond.size());
|
||||
for (size_t i = 0; i < mTransactionsToRespond.size(); i++) {
|
||||
replies.AppendElement(OpReplyDeliverFence(mTransactionsToRespond[i]));
|
||||
}
|
||||
mTransactionsToRespond.clear();
|
||||
SendChildAsyncMessages(replies);
|
||||
}
|
||||
|
||||
} // layers
|
||||
|
|
|
@ -247,10 +247,8 @@ ImageBridgeParent::SendFenceHandle(AsyncTransactionTracker* aTracker,
|
|||
PTextureParent* aTexture,
|
||||
const FenceHandle& aFence)
|
||||
{
|
||||
HoldUntilComplete(aTracker);
|
||||
InfallibleTArray<AsyncParentMessageData> messages;
|
||||
messages.AppendElement(OpDeliverFence(aTracker->GetId(),
|
||||
aTexture, nullptr,
|
||||
messages.AppendElement(OpDeliverFence(aTexture, nullptr,
|
||||
aFence));
|
||||
mozilla::unused << SendParentAsyncMessages(messages);
|
||||
}
|
||||
|
@ -283,15 +281,6 @@ ImageBridgeParent::RecvChildAsyncMessages(InfallibleTArray<AsyncChildMessageData
|
|||
hostOGL->SetAcquireFence(fence.mFence);
|
||||
}
|
||||
#endif
|
||||
// Send back a response.
|
||||
InfallibleTArray<AsyncParentMessageData> replies;
|
||||
replies.AppendElement(OpReplyDeliverFence(op.transactionId()));
|
||||
mozilla::unused << SendParentAsyncMessages(replies);
|
||||
break;
|
||||
}
|
||||
case AsyncChildMessageData::TOpReplyDeliverFence: {
|
||||
const OpReplyDeliverFence& op = message.get_OpReplyDeliverFence();
|
||||
TransactionCompleteted(op.transactionId());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -373,10 +362,7 @@ ImageBridgeParent::SendFenceHandleIfPresent(PTextureParent* aTexture,
|
|||
if (aCompositableHost && aCompositableHost->GetCompositor()) {
|
||||
FenceHandle fence = aCompositableHost->GetCompositor()->GetReleaseFence();
|
||||
if (fence.IsValid()) {
|
||||
RefPtr<FenceDeliveryTracker> tracker = new FenceDeliveryTracker(fence);
|
||||
HoldUntilComplete(tracker);
|
||||
mPendingAsyncMessage.push_back(OpDeliverFence(tracker->GetId(),
|
||||
aTexture, nullptr,
|
||||
mPendingAsyncMessage.push_back(OpDeliverFence(aTexture, nullptr,
|
||||
fence));
|
||||
}
|
||||
}
|
||||
|
@ -384,10 +370,7 @@ ImageBridgeParent::SendFenceHandleIfPresent(PTextureParent* aTexture,
|
|||
// Send a ReleaseFence that is set by HwcComposer2D.
|
||||
FenceHandle fence = texture->GetAndResetReleaseFenceHandle();
|
||||
if (fence.IsValid()) {
|
||||
RefPtr<FenceDeliveryTracker> tracker = new FenceDeliveryTracker(fence);
|
||||
HoldUntilComplete(tracker);
|
||||
mPendingAsyncMessage.push_back(OpDeliverFence(tracker->GetId(),
|
||||
aTexture, nullptr,
|
||||
mPendingAsyncMessage.push_back(OpDeliverFence(aTexture, nullptr,
|
||||
fence));
|
||||
}
|
||||
}
|
||||
|
@ -407,10 +390,7 @@ ImageBridgeParent::SendFenceHandleToTrackerIfPresent(uint64_t aDestHolderId,
|
|||
if (aCompositableHost && aCompositableHost->GetCompositor()) {
|
||||
FenceHandle fence = aCompositableHost->GetCompositor()->GetReleaseFence();
|
||||
if (fence.IsValid()) {
|
||||
RefPtr<FenceDeliveryTracker> tracker = new FenceDeliveryTracker(fence);
|
||||
HoldUntilComplete(tracker);
|
||||
mPendingAsyncMessage.push_back(OpDeliverFenceToTracker(tracker->GetId(),
|
||||
aDestHolderId,
|
||||
mPendingAsyncMessage.push_back(OpDeliverFenceToTracker(aDestHolderId,
|
||||
aTransactionId,
|
||||
fence));
|
||||
}
|
||||
|
@ -419,10 +399,7 @@ ImageBridgeParent::SendFenceHandleToTrackerIfPresent(uint64_t aDestHolderId,
|
|||
// Send a ReleaseFence that is set by HwcComposer2D.
|
||||
FenceHandle fence = texture->GetAndResetReleaseFenceHandle();
|
||||
if (fence.IsValid()) {
|
||||
RefPtr<FenceDeliveryTracker> tracker = new FenceDeliveryTracker(fence);
|
||||
HoldUntilComplete(tracker);
|
||||
mPendingAsyncMessage.push_back(OpDeliverFenceToTracker(tracker->GetId(),
|
||||
aDestHolderId,
|
||||
mPendingAsyncMessage.push_back(OpDeliverFenceToTracker(aDestHolderId,
|
||||
aTransactionId,
|
||||
fence));
|
||||
}
|
||||
|
|
|
@ -90,19 +90,6 @@ LayerTransactionChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessa
|
|||
if (texture) {
|
||||
texture->SetReleaseFenceHandle(fence);
|
||||
}
|
||||
if (mForwarder) {
|
||||
mForwarder->HoldTransactionsToRespond(op.transactionId());
|
||||
} else {
|
||||
// Send back a response.
|
||||
InfallibleTArray<AsyncChildMessageData> replies;
|
||||
replies.AppendElement(OpReplyDeliverFence(op.transactionId()));
|
||||
SendChildAsyncMessages(replies);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AsyncParentMessageData::TOpReplyDeliverFence: {
|
||||
const OpReplyDeliverFence& op = message.get_OpReplyDeliverFence();
|
||||
TransactionCompleteted(op.transactionId());
|
||||
break;
|
||||
}
|
||||
case AsyncParentMessageData::TOpReplyRemoveTexture: {
|
||||
|
@ -125,10 +112,8 @@ LayerTransactionChild::SendFenceHandle(AsyncTransactionTracker* aTracker,
|
|||
PTextureChild* aTexture,
|
||||
const FenceHandle& aFence)
|
||||
{
|
||||
HoldUntilComplete(aTracker);
|
||||
InfallibleTArray<AsyncChildMessageData> messages;
|
||||
messages.AppendElement(OpDeliverFenceFromChild(aTracker->GetId(),
|
||||
nullptr, aTexture,
|
||||
messages.AppendElement(OpDeliverFenceFromChild(nullptr, aTexture,
|
||||
aFence));
|
||||
SendChildAsyncMessages(messages);
|
||||
}
|
||||
|
|
|
@ -929,15 +929,6 @@ LayerTransactionParent::RecvChildAsyncMessages(InfallibleTArray<AsyncChildMessag
|
|||
hostOGL->SetAcquireFence(fence.mFence);
|
||||
}
|
||||
#endif
|
||||
// Send back a response.
|
||||
InfallibleTArray<AsyncParentMessageData> replies;
|
||||
replies.AppendElement(OpReplyDeliverFence(op.transactionId()));
|
||||
mozilla::unused << SendParentAsyncMessages(replies);
|
||||
break;
|
||||
}
|
||||
case AsyncChildMessageData::TOpReplyDeliverFence: {
|
||||
const OpReplyDeliverFence& op = message.get_OpReplyDeliverFence();
|
||||
TransactionCompleteted(op.transactionId());
|
||||
break;
|
||||
}
|
||||
case AsyncChildMessageData::TOpRemoveTextureAsync: {
|
||||
|
@ -960,9 +951,8 @@ LayerTransactionParent::RecvChildAsyncMessages(InfallibleTArray<AsyncChildMessag
|
|||
// Send message back via PImageBridge.
|
||||
ImageBridgeParent::ReplyRemoveTexture(
|
||||
GetChildProcessId(),
|
||||
OpReplyRemoveTexture(true, // isMain
|
||||
op.holderId(),
|
||||
op.transactionId()));
|
||||
OpReplyRemoveTexture(op.holderId(),
|
||||
op.transactionId()));
|
||||
} else {
|
||||
NS_ERROR("ImageBridgeParent should exist");
|
||||
}
|
||||
|
@ -1000,10 +990,7 @@ LayerTransactionParent::SendFenceHandleIfPresent(PTextureParent* aTexture,
|
|||
if (aCompositableHost && aCompositableHost->GetCompositor()) {
|
||||
FenceHandle fence = aCompositableHost->GetCompositor()->GetReleaseFence();
|
||||
if (fence.IsValid()) {
|
||||
RefPtr<FenceDeliveryTracker> tracker = new FenceDeliveryTracker(fence);
|
||||
HoldUntilComplete(tracker);
|
||||
mPendingAsyncMessage.push_back(OpDeliverFence(tracker->GetId(),
|
||||
aTexture, nullptr,
|
||||
mPendingAsyncMessage.push_back(OpDeliverFence(aTexture, nullptr,
|
||||
fence));
|
||||
}
|
||||
}
|
||||
|
@ -1011,10 +998,7 @@ LayerTransactionParent::SendFenceHandleIfPresent(PTextureParent* aTexture,
|
|||
// Send a ReleaseFence that is set by HwcComposer2D.
|
||||
FenceHandle fence = texture->GetAndResetReleaseFenceHandle();
|
||||
if (fence.IsValid()) {
|
||||
RefPtr<FenceDeliveryTracker> tracker = new FenceDeliveryTracker(fence);
|
||||
HoldUntilComplete(tracker);
|
||||
mPendingAsyncMessage.push_back(OpDeliverFence(tracker->GetId(),
|
||||
aTexture, nullptr,
|
||||
mPendingAsyncMessage.push_back(OpDeliverFence(aTexture, nullptr,
|
||||
fence));
|
||||
}
|
||||
}
|
||||
|
@ -1024,10 +1008,8 @@ LayerTransactionParent::SendFenceHandle(AsyncTransactionTracker* aTracker,
|
|||
PTextureParent* aTexture,
|
||||
const FenceHandle& aFence)
|
||||
{
|
||||
HoldUntilComplete(aTracker);
|
||||
InfallibleTArray<AsyncParentMessageData> messages;
|
||||
messages.AppendElement(OpDeliverFence(aTracker->GetId(),
|
||||
aTexture, nullptr,
|
||||
messages.AppendElement(OpDeliverFence(aTexture, nullptr,
|
||||
aFence));
|
||||
mozilla::unused << SendParentAsyncMessages(messages);
|
||||
}
|
||||
|
|
|
@ -367,11 +367,15 @@ struct OpRemoveTextureAsync {
|
|||
};
|
||||
|
||||
struct OpReplyRemoveTexture {
|
||||
bool isMain;
|
||||
uint64_t holderId;
|
||||
uint64_t transactionId;
|
||||
};
|
||||
|
||||
union MaybeFence {
|
||||
FenceHandle;
|
||||
null_t;
|
||||
};
|
||||
|
||||
/**
|
||||
* Tells the compositor-side which texture to use (for example, as front buffer
|
||||
* if there is several textures for double buffering)
|
||||
|
@ -379,6 +383,7 @@ struct OpReplyRemoveTexture {
|
|||
struct OpUseTexture {
|
||||
PCompositable compositable;
|
||||
PTexture texture;
|
||||
MaybeFence fence;
|
||||
};
|
||||
|
||||
struct OpUseComponentAlphaTextures {
|
||||
|
@ -393,28 +398,21 @@ union MaybeRegion {
|
|||
};
|
||||
|
||||
struct OpDeliverFence {
|
||||
uint64_t transactionId;
|
||||
PTexture texture;
|
||||
FenceHandle fence;
|
||||
};
|
||||
|
||||
struct OpDeliverFenceToTracker {
|
||||
uint64_t transactionId;
|
||||
uint64_t destHolderId;
|
||||
uint64_t destTransactionId;
|
||||
FenceHandle fence;
|
||||
};
|
||||
|
||||
struct OpDeliverFenceFromChild {
|
||||
uint64_t transactionId;
|
||||
PTexture texture;
|
||||
FenceHandle fence;
|
||||
};
|
||||
|
||||
struct OpReplyDeliverFence {
|
||||
uint64_t transactionId;
|
||||
};
|
||||
|
||||
union CompositableOperation {
|
||||
OpUpdatePictureRect;
|
||||
|
||||
|
@ -480,13 +478,11 @@ union EditReply {
|
|||
union AsyncParentMessageData {
|
||||
OpDeliverFence;
|
||||
OpDeliverFenceToTracker;
|
||||
OpReplyDeliverFence;
|
||||
OpReplyRemoveTexture;
|
||||
};
|
||||
|
||||
union AsyncChildMessageData {
|
||||
OpDeliverFenceFromChild;
|
||||
OpReplyDeliverFence;
|
||||
OpRemoveTextureAsync;
|
||||
};
|
||||
|
||||
|
|
|
@ -369,15 +369,11 @@ ShadowLayerForwarder::UseTexture(CompositableClient* aCompositable,
|
|||
MOZ_ASSERT(aTexture);
|
||||
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
||||
MOZ_ASSERT(aTexture->GetIPDLActor());
|
||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||
FenceHandle handle = aTexture->GetAcquireFenceHandle();
|
||||
if (handle.IsValid()) {
|
||||
RefPtr<FenceDeliveryTracker> tracker = new FenceDeliveryTracker(handle);
|
||||
SendFenceHandle(tracker, aTexture->GetIPDLActor(), handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
FenceHandle fence = aTexture->GetAcquireFenceHandle();
|
||||
mTxn->AddEdit(OpUseTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
nullptr, aTexture->GetIPDLActor()));
|
||||
nullptr, aTexture->GetIPDLActor(),
|
||||
fence.IsValid() ? MaybeFence(fence) : MaybeFence(null_t())));
|
||||
if (aTexture->GetFlags() & TextureFlags::IMMEDIATE_UPLOAD
|
||||
&& aTexture->HasInternalBuffer()) {
|
||||
// We use IMMEDIATE_UPLOAD when we want to be sure that the upload cannot
|
||||
|
@ -855,22 +851,15 @@ void ShadowLayerForwarder::SendPendingAsyncMessges()
|
|||
{
|
||||
if (!HasShadowManager() ||
|
||||
!mShadowManager->IPCOpen()) {
|
||||
mTransactionsToRespond.clear();
|
||||
mPendingAsyncMessages.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mTransactionsToRespond.empty() && mPendingAsyncMessages.empty()) {
|
||||
if (mPendingAsyncMessages.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
InfallibleTArray<AsyncChildMessageData> replies;
|
||||
replies.SetCapacity(mTransactionsToRespond.size());
|
||||
// Prepare OpReplyDeliverFence messages.
|
||||
for (size_t i = 0; i < mTransactionsToRespond.size(); i++) {
|
||||
replies.AppendElement(OpReplyDeliverFence(mTransactionsToRespond[i]));
|
||||
}
|
||||
mTransactionsToRespond.clear();
|
||||
// Prepare pending messages.
|
||||
for (size_t i = 0; i < mPendingAsyncMessages.size(); i++) {
|
||||
replies.AppendElement(mPendingAsyncMessages[i]);
|
||||
|
|
|
@ -260,6 +260,19 @@ GrallocTextureHostOGL::UnbindTextureSource()
|
|||
mGLTextureSource = nullptr;
|
||||
}
|
||||
|
||||
FenceHandle
|
||||
GrallocTextureHostOGL::GetAndResetReleaseFenceHandle()
|
||||
{
|
||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||
android::sp<android::Fence> fence = GetAndResetReleaseFence();
|
||||
if (fence.get() && fence->isValid()) {
|
||||
FenceHandle handle = FenceHandle(fence);
|
||||
return handle;
|
||||
}
|
||||
#endif
|
||||
return FenceHandle();
|
||||
}
|
||||
|
||||
GLenum GetTextureTarget(gl::GLContext* aGL, android::PixelFormat aFormat) {
|
||||
MOZ_ASSERT(aGL);
|
||||
if (aGL->Renderer() == gl::GLRenderer::SGX530 ||
|
||||
|
|
|
@ -53,6 +53,8 @@ public:
|
|||
|
||||
virtual void UnbindTextureSource() override;
|
||||
|
||||
virtual FenceHandle GetAndResetReleaseFenceHandle() override;
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||
virtual TextureHostOGL* AsHostOGL() override
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче