Bug 1501442 - Part 1: Add CompositionPayload type and allow submitting it as part of a transaction. r=mstange

--HG--
extra : rebase_source : 20a6ac6929bc99b8ddbf5500e7edbaa514c7ebe2
This commit is contained in:
Bas Schouten 2018-12-13 15:59:22 +01:00
Родитель 718bf761d4
Коммит 93c70bd2f6
10 изменённых файлов: 78 добавлений и 3 удалений

Просмотреть файл

@ -731,6 +731,15 @@ class LayerManager : public FrameRecorder {
virtual CompositorBridgeChild* GetCompositorBridgeChild() { return nullptr; }
void RegisterPayload(const CompositionPayload& aPayload) {
mPayload.AppendElement(aPayload);
MOZ_ASSERT(mPayload.Length() < 10000);
}
void RegisterPayload(const InfallibleTArray<CompositionPayload>& aPayload) {
mPayload.AppendElements(aPayload);
MOZ_ASSERT(mPayload.Length() < 10000);
}
protected:
RefPtr<Layer> mRoot;
gfx::UserData mUserData;
@ -757,6 +766,14 @@ class LayerManager : public FrameRecorder {
TimeStamp mAnimationReadyTime;
// The count of pixels that were painted in the current transaction.
uint32_t mPaintedPixelCount;
// The payload associated with currently pending painting work, for
// client layer managers that typically means payload that is part of the
// 'upcoming transaction', for HostLayerManagers this typically means
// what has been included in received transactions to be presented on the
// next composite.
// IMPORTANT: Clients should take care to clear this or risk it slowly
// growing out of control.
InfallibleTArray<CompositionPayload> mPayload;
public:
/*

Просмотреть файл

@ -13,6 +13,7 @@
#include "mozilla/DefineEnum.h" // for MOZ_DEFINE_ENUM
#include "mozilla/gfx/Point.h" // for IntPoint
#include "mozilla/Maybe.h"
#include "mozilla/TimeStamp.h" // for TimeStamp
#include "mozilla/TypedEnumBits.h"
#include "nsRegion.h"
#include "nsStyleConsts.h"
@ -410,8 +411,24 @@ MOZ_DEFINE_ENUM_CLASS_WITH_BASE(ScrollDirection, uint32_t, (
eVertical,
eHorizontal
));
MOZ_DEFINE_ENUM_CLASS_WITH_BASE(CompositionPayloadType, uint8_t, (
eKeyPress,
eAPZScroll,
eAPZPinchZoom
));
// clang-format on
struct CompositionPayload {
bool operator ==(const CompositionPayload& aOther) const {
return mType == aOther.mType && mTimeStamp == aOther.mTimeStamp;
}
/* The type of payload that is in this composition */
CompositionPayloadType mType;
/* When this payload was generated */
TimeStamp mTimeStamp;
};
} // namespace layers
} // namespace mozilla

Просмотреть файл

@ -696,9 +696,12 @@ void ClientLayerManager::ForwardTransaction(bool aScheduleComposite) {
mPaintSequenceNumber, mIsRepeatTransaction,
mTransactionIdAllocator->GetVsyncId(),
mTransactionIdAllocator->GetVsyncStart(), refreshStart, mTransactionStart,
mURL, &sent);
mURL, &sent, mPayload);
if (ok) {
if (sent) {
// Our payload has now been dispatched.
mPayload.Clear();
mNeedsComposite = false;
}
} else if (HasShadowManager()) {

Просмотреть файл

@ -975,6 +975,8 @@ void LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion,
mProfilerScreenshotGrabber.MaybeProcessQueue();
RecordFrame();
// Our payload has now been presented.
mPayload.Clear();
}
#if defined(MOZ_WIDGET_ANDROID)

Просмотреть файл

@ -712,6 +712,29 @@ struct ParamTraits<mozilla::layers::SimpleLayerAttributes>
template <>
struct ParamTraits<mozilla::layers::ScrollUpdateInfo>
: public PlainOldDataSerializer<mozilla::layers::ScrollUpdateInfo> {};
template <>
struct ParamTraits<mozilla::layers::CompositionPayloadType>
: public ContiguousEnumSerializerInclusive<
mozilla::layers::CompositionPayloadType,
mozilla::layers::CompositionPayloadType::eKeyPress,
mozilla::layers::kHighestCompositionPayloadType> {};
template <>
struct ParamTraits<mozilla::layers::CompositionPayload>
{
typedef mozilla::layers::CompositionPayload paramType;
static void Write(Message* aMsg, const paramType& aParam) {
WriteParam(aMsg, aParam.mType);
WriteParam(aMsg, aParam.mTimeStamp);
}
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) {
return ReadParam(aMsg, aIter, &aResult->mType) &&
ReadParam(aMsg, aIter, &aResult->mTimeStamp);
}
};
} /* namespace IPC */

Просмотреть файл

@ -47,6 +47,7 @@ using mozilla::layers::ScrollableLayerGuid::ViewID from "mozilla/layers/Scrollab
using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h";
using mozilla::layers::LayerHandle from "mozilla/layers/LayersTypes.h";
using mozilla::layers::CompositableHandle from "mozilla/layers/LayersTypes.h";
using mozilla::layers::CompositionPayload from "mozilla/layers/LayersTypes.h";
using mozilla::layers::SimpleLayerAttributes from "mozilla/layers/LayerAttributes.h";
using mozilla::CrossProcessSemaphoreHandle from "mozilla/ipc/CrossProcessSemaphore.h";
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
@ -560,6 +561,10 @@ struct TransactionInfo
TimeStamp transactionStart;
nsCString url;
TimeStamp fwdTime;
/* This provides some timing information on any content that is meant to be
* presented during this transaction.
*/
CompositionPayload[] payload;
};
union MaybeTransform {

Просмотреть файл

@ -532,7 +532,7 @@ bool ShadowLayerForwarder::EndTransaction(
const mozilla::TimeStamp& aVsyncStart,
const mozilla::TimeStamp& aRefreshStart,
const mozilla::TimeStamp& aTransactionStart, const nsCString& aURL,
bool* aSent) {
bool* aSent, const InfallibleTArray<CompositionPayload>& aPayload) {
*aSent = false;
TransactionInfo info;
@ -680,6 +680,7 @@ bool ShadowLayerForwarder::EndTransaction(
#if defined(ENABLE_FRAME_LATENCY_LOG)
info.fwdTime() = TimeStamp::Now();
#endif
info.payload() = aPayload;
TargetConfig targetConfig(mTxn->mTargetBounds, mTxn->mTargetRotation,
mTxn->mTargetOrientation, aRegionToClear);

Просмотреть файл

@ -256,7 +256,9 @@ class ShadowLayerForwarder final : public LayersIPCActor,
const mozilla::TimeStamp& aVsyncTime,
const mozilla::TimeStamp& aRefreshStart,
const mozilla::TimeStamp& aTransactionStart,
const nsCString& aURL, bool* aSent);
const nsCString& aURL, bool* aSent,
const InfallibleTArray<CompositionPayload>& aPayload =
InfallibleTArray<CompositionPayload>());
/**
* Set an actor through which layer updates will be pushed.

Просмотреть файл

@ -304,6 +304,8 @@ void LayerManagerMLGPU::Composite() {
// performs invalidation against the clean layer tree.
mClonedLayerTreeProperties = nullptr;
mClonedLayerTreeProperties = LayerProperties::CloneFrom(mRoot);
mPayload.Clear();
}
void LayerManagerMLGPU::RenderLayers() {

Просмотреть файл

@ -522,6 +522,9 @@ void WebRenderLayerManager::DidComposite(
// the end of the method invocation.
RefPtr<WebRenderLayerManager> selfRef = this;
// XXX - Currently we don't track this. Make sure it doesn't just grow though.
mPayload.Clear();
// |aTransactionId| will be > 0 if the compositor is acknowledging a shadow
// layers transaction.
if (aTransactionId.IsValid()) {