зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1363123 - Queue compositor messages that are sent before UiCompositorControllerParent has been initialized r=botond
MozReview-Commit-ID: LNmCv9D6bS6
This commit is contained in:
Родитель
69acf9044e
Коммит
5c26b07626
|
@ -73,10 +73,17 @@ AndroidDynamicToolbarAnimator::AndroidDynamicToolbarAnimator()
|
|||
void
|
||||
AndroidDynamicToolbarAnimator::Initialize(uint64_t aRootLayerTreeId)
|
||||
{
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
mRootLayerTreeId = aRootLayerTreeId;
|
||||
RefPtr<UiCompositorControllerParent> uiController = UiCompositorControllerParent::GetFromRootLayerTreeId(mRootLayerTreeId);
|
||||
MOZ_ASSERT(uiController);
|
||||
uiController->RegisterAndroidDynamicToolbarAnimator(this);
|
||||
|
||||
// Send queued messages that were posted before Initialize() was called.
|
||||
for (QueuedMessage* message = mCompositorQueuedMessages.getFirst(); message != nullptr; message = message->getNext()) {
|
||||
uiController->ToolbarAnimatorMessageFromCompositor(message->mMessage);
|
||||
}
|
||||
mCompositorQueuedMessages.clear();
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -461,6 +468,7 @@ AndroidDynamicToolbarAnimator::Shutdown()
|
|||
mCompositorShutdown = true;
|
||||
mCompositorToolbarEffect = nullptr;
|
||||
mCompositorToolbarTexture = nullptr;
|
||||
mCompositorQueuedMessages.clear();
|
||||
if (mCompositorToolbarPixels) {
|
||||
RefPtr<UiCompositorControllerParent> uiController = UiCompositorControllerParent::GetFromRootLayerTreeId(mRootLayerTreeId);
|
||||
uiController->DeallocShmem(mCompositorToolbarPixels.ref());
|
||||
|
@ -620,11 +628,19 @@ AndroidDynamicToolbarAnimator::HandleTouchEnd(StaticToolbarState aCurrentToolbar
|
|||
|
||||
void
|
||||
AndroidDynamicToolbarAnimator::PostMessage(int32_t aMessage) {
|
||||
// if the root layer tree id is zero then Initialize() has not been called yet
|
||||
// so queue the message until Initialize() is called.
|
||||
if (mRootLayerTreeId == 0) {
|
||||
QueueMessage(aMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<UiCompositorControllerParent> uiController = UiCompositorControllerParent::GetFromRootLayerTreeId(mRootLayerTreeId);
|
||||
if (!uiController) {
|
||||
// Looks like IPC may be shutdown.
|
||||
return;
|
||||
}
|
||||
|
||||
// ToolbarAnimatorMessageFromCompositor may be called from any thread.
|
||||
uiController->ToolbarAnimatorMessageFromCompositor(aMessage);
|
||||
}
|
||||
|
@ -958,5 +974,23 @@ AndroidDynamicToolbarAnimator::CheckForResetOnNextMove(ScreenIntCoord aCurrentTo
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
AndroidDynamicToolbarAnimator::QueueMessage(int32_t aMessage)
|
||||
{
|
||||
if (!CompositorThreadHolder::IsInCompositorThread()) {
|
||||
CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod<int32_t>(this, &AndroidDynamicToolbarAnimator::QueueMessage, aMessage));
|
||||
return;
|
||||
}
|
||||
|
||||
// If the root layer tree id is no longer zero, Initialize() was called before QueueMessage was processed
|
||||
// so just post the message now.
|
||||
if (mRootLayerTreeId != 0) {
|
||||
PostMessage(aMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
mCompositorQueuedMessages.insertBack(new QueuedMessage(aMessage));
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/ipc/Shmem.h"
|
||||
#include "mozilla/layers/Effects.h"
|
||||
#include "mozilla/layers/TextureHost.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "nsISupports.h"
|
||||
|
@ -151,6 +152,7 @@ protected:
|
|||
ScreenIntCoord GetFixedLayerMarginsBottom();
|
||||
void NotifyControllerSnapshotFailed();
|
||||
void CheckForResetOnNextMove(ScreenIntCoord aCurrentTouch);
|
||||
void QueueMessage(int32_t aMessage);
|
||||
|
||||
// Read only Compositor and Controller threads after Initialize()
|
||||
uint64_t mRootLayerTreeId;
|
||||
|
@ -195,6 +197,17 @@ protected:
|
|||
// Controller thread only
|
||||
FrameMetricsState mControllerFrameMetrics;
|
||||
|
||||
class QueuedMessage : public LinkedListElement<QueuedMessage> {
|
||||
public:
|
||||
explicit QueuedMessage(int32_t aMessage) :
|
||||
mMessage(aMessage) {}
|
||||
int32_t mMessage;
|
||||
private:
|
||||
QueuedMessage() = delete;
|
||||
QueuedMessage(const QueuedMessage&) = delete;
|
||||
QueuedMessage& operator=(const QueuedMessage&) = delete;
|
||||
};
|
||||
|
||||
// Compositor thread only
|
||||
bool mCompositorShutdown;
|
||||
bool mCompositorAnimationDeferred; // An animation has been deferred until the toolbar is unlocked
|
||||
|
@ -211,6 +224,7 @@ protected:
|
|||
RefPtr<DataTextureSource> mCompositorToolbarTexture; // The OGL texture used to render the snapshot in the compositor
|
||||
RefPtr<EffectRGB> mCompositorToolbarEffect; // Effect used to render the snapshot in the compositor
|
||||
TimeStamp mCompositorAnimationStartTimeStamp; // Time stamp when the current animation started
|
||||
AutoCleanLinkedList<QueuedMessage> mCompositorQueuedMessages; // Queue to contain messages sent before Initialize() called
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
|
|
Загрузка…
Ссылка в новой задаче