From cd30c320370ed9007562235891153a741ece19c7 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 7 Dec 2018 23:26:53 +0000 Subject: [PATCH] Bug 1510853 - Make TransactionId usable for other 64bit identifiers. r=jrmuizel MozReview-Commit-ID: 9qX9A7ZGWS8 Differential Revision: https://phabricator.services.mozilla.com/D13349 --HG-- extra : moz-landing-system : lando --- gfx/layers/LayersTypes.h | 32 ++++++++++++++++++++--------- gfx/layers/ipc/LayersMessageUtils.h | 6 +++--- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/gfx/layers/LayersTypes.h b/gfx/layers/LayersTypes.h index be53a3f11fa3..413d4cb2bd4a 100644 --- a/gfx/layers/LayersTypes.h +++ b/gfx/layers/LayersTypes.h @@ -79,39 +79,51 @@ struct LayersId { }; }; -struct TransactionId { - uint64_t mId; +template +struct BaseTransactionId { + uint64_t mId = 0; bool IsValid() const { return mId != 0; } - MOZ_MUST_USE TransactionId Next() const { return TransactionId{mId + 1}; } + MOZ_MUST_USE BaseTransactionId Next() const { + return BaseTransactionId{mId + 1}; + } - MOZ_MUST_USE TransactionId Prev() const { return TransactionId{mId - 1}; } + MOZ_MUST_USE BaseTransactionId Prev() const { + return BaseTransactionId{mId - 1}; + } - int64_t operator-(const TransactionId& aOther) const { + int64_t operator-(const BaseTransactionId& aOther) const { return mId - aOther.mId; } // Allow explicit cast to a uint64_t for now explicit operator uint64_t() const { return mId; } - bool operator<(const TransactionId& aOther) const { return mId < aOther.mId; } + bool operator<(const BaseTransactionId& aOther) const { + return mId < aOther.mId; + } - bool operator<=(const TransactionId& aOther) const { + bool operator<=(const BaseTransactionId& aOther) const { return mId <= aOther.mId; } - bool operator>(const TransactionId& aOther) const { return mId > aOther.mId; } + bool operator>(const BaseTransactionId& aOther) const { + return mId > aOther.mId; + } - bool operator>=(const TransactionId& aOther) const { + bool operator>=(const BaseTransactionId& aOther) const { return mId >= aOther.mId; } - bool operator==(const TransactionId& aOther) const { + bool operator==(const BaseTransactionId& aOther) const { return mId == aOther.mId; } }; +class TransactionIdType {}; +typedef BaseTransactionId TransactionId; + struct LayersObserverEpoch { uint64_t mId; diff --git a/gfx/layers/ipc/LayersMessageUtils.h b/gfx/layers/ipc/LayersMessageUtils.h index 89ca16c582e8..383018e0a7a6 100644 --- a/gfx/layers/ipc/LayersMessageUtils.h +++ b/gfx/layers/ipc/LayersMessageUtils.h @@ -38,9 +38,9 @@ template <> struct ParamTraits : public PlainOldDataSerializer {}; -template <> -struct ParamTraits - : public PlainOldDataSerializer {}; +template +struct ParamTraits> + : public PlainOldDataSerializer> {}; template <> struct ParamTraits