Bug 1835804 - Completely block from doing audio decoding on Content and RDD r=alwu
[gecko.git] / gfx / layers / TransactionIdAllocator.h
blobc9f545470f3e82a59f417ca31f0918e7d3732315
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef GFX_TRANSACTION_ID_ALLOCATOR_H
8 #define GFX_TRANSACTION_ID_ALLOCATOR_H
10 #include "nsISupportsImpl.h"
11 #include "mozilla/layers/LayersTypes.h"
12 #include "mozilla/TimeStamp.h"
13 #include "mozilla/VsyncDispatcher.h"
15 namespace mozilla {
16 namespace layers {
18 class TransactionIdAllocator {
19 protected:
20 virtual ~TransactionIdAllocator() = default;
22 public:
23 NS_INLINE_DECL_REFCOUNTING(TransactionIdAllocator)
25 /**
26 * Allocate a unique id number for the current refresh tick, can
27 * only be called while IsInRefresh().
29 * If too many id's are allocated without being returned then
30 * the refresh driver will suspend until they catch up. This
31 * "throttling" behaviour can be skipped by passing aThrottle=false.
32 * Otherwise call sites should generally be passing aThrottle=true.
34 virtual TransactionId GetTransactionId(bool aThrottle) = 0;
36 /**
37 * Return the transaction id that for the last non-revoked transaction.
38 * This allows the caller to tell whether a composite was triggered by
39 * a paint that occurred after a call to TransactionId().
41 virtual TransactionId LastTransactionId() const = 0;
43 /**
44 * Notify that all work (including asynchronous composites)
45 * for a given transaction id has been completed.
47 * If the refresh driver has been suspended because
48 * of having too many outstanding id's, then this may
49 * resume it.
51 virtual void NotifyTransactionCompleted(TransactionId aTransactionId) = 0;
53 /**
54 * Revoke a transaction id that isn't needed to track
55 * completion of asynchronous work. This is similar
56 * to NotifyTransactionCompleted except avoids
57 * return ordering issues.
59 virtual void RevokeTransactionId(TransactionId aTransactionId) = 0;
61 /**
62 * Stop waiting for pending transactions, if any.
64 * This is used when ClientLayerManager is assigning to another refresh
65 * driver, and the current refresh driver may never receive transaction
66 * completed notifications.
68 virtual void ClearPendingTransactions() = 0;
70 /**
71 * Transaction id is usually initialized as 0, however when ClientLayerManager
72 * switches to another refresh driver, completed transactions of the previous
73 * refresh driver could be delivered and confuse the newly adopted refresh
74 * driver. To prevent this situation, use this function to reset transaction
75 * id to the last transaction id from previous refresh driver, so that all
76 * completed transactions of previous refresh driver will be ignored.
78 virtual void ResetInitialTransactionId(TransactionId aTransactionId) = 0;
80 /**
81 * Get the start time of the current refresh tick.
83 virtual mozilla::TimeStamp GetTransactionStart() = 0;
85 virtual VsyncId GetVsyncId() = 0;
87 virtual mozilla::TimeStamp GetVsyncStart() = 0;
90 } // namespace layers
91 } // namespace mozilla
93 #endif /* GFX_TRANSACTION_ID_ALLOCATOR_H */