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