Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_GUI_FRAMETIMESTAMPS_H |
| 18 | #define ANDROID_GUI_FRAMETIMESTAMPS_H |
| 19 | |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 20 | #include <ui/FenceTime.h> |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 21 | #include <utils/Flattenable.h> |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 22 | #include <utils/StrongPointer.h> |
| 23 | #include <utils/Timers.h> |
| 24 | |
| 25 | #include <array> |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 26 | #include <bitset> |
| 27 | #include <vector> |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 28 | |
| 29 | namespace android { |
| 30 | |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 31 | struct FrameEvents; |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 32 | class FrameEventHistoryDelta; |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 33 | class String8; |
| 34 | |
| 35 | |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 36 | // Identifiers for all the events that may be recorded or reported. |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 37 | enum class FrameEvent { |
| 38 | POSTED, |
Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 39 | REQUESTED_PRESENT, |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 40 | LATCH, |
Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 41 | ACQUIRE, |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 42 | FIRST_REFRESH_START, |
| 43 | LAST_REFRESH_START, |
Brian Anderson | b04c6f0 | 2016-10-21 12:57:46 -0700 | [diff] [blame] | 44 | GPU_COMPOSITION_DONE, |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 45 | DISPLAY_PRESENT, |
Brian Anderson | f638686 | 2016-10-31 16:34:13 -0700 | [diff] [blame] | 46 | DEQUEUE_READY, |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 47 | RELEASE, |
| 48 | EVENT_COUNT, // Not an actual event. |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 49 | }; |
| 50 | |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 51 | |
| 52 | // A collection of timestamps corresponding to a single frame. |
| 53 | struct FrameEvents { |
Brian Anderson | ed816e6 | 2016-10-26 16:12:21 -0700 | [diff] [blame] | 54 | static constexpr auto EVENT_COUNT = |
| 55 | static_cast<size_t>(FrameEvent::EVENT_COUNT); |
| 56 | static_assert(EVENT_COUNT <= 32, "Event count sanity check failed."); |
Brian Anderson | dc96fdf | 2017-03-20 16:54:25 -0700 | [diff] [blame] | 57 | static constexpr nsecs_t TIMESTAMP_PENDING = -2; |
Brian Anderson | ed816e6 | 2016-10-26 16:12:21 -0700 | [diff] [blame] | 58 | |
| 59 | static inline bool isValidTimestamp(nsecs_t time) { |
| 60 | return time != TIMESTAMP_PENDING; |
| 61 | } |
| 62 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 63 | bool hasPostedInfo() const; |
| 64 | bool hasRequestedPresentInfo() const; |
| 65 | bool hasLatchInfo() const; |
| 66 | bool hasFirstRefreshStartInfo() const; |
| 67 | bool hasLastRefreshStartInfo() const; |
| 68 | bool hasAcquireInfo() const; |
| 69 | bool hasGpuCompositionDoneInfo() const; |
| 70 | bool hasDisplayPresentInfo() const; |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 71 | bool hasReleaseInfo() const; |
Brian Anderson | f638686 | 2016-10-31 16:34:13 -0700 | [diff] [blame] | 72 | bool hasDequeueReadyInfo() const; |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 73 | |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 74 | void checkFencesForCompletion(); |
| 75 | void dump(String8& outString) const; |
| 76 | |
| 77 | bool valid{false}; |
Brian Anderson | 5ea5e59 | 2016-12-01 16:54:33 -0800 | [diff] [blame] | 78 | int connectId{0}; |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 79 | uint64_t frameNumber{0}; |
| 80 | |
| 81 | // Whether or not certain points in the frame's life cycle have been |
| 82 | // encountered help us determine if timestamps aren't available because |
| 83 | // a) we'll just never get them or b) they're not ready yet. |
| 84 | bool addPostCompositeCalled{false}; |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 85 | bool addReleaseCalled{false}; |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 86 | |
Brian Anderson | ed816e6 | 2016-10-26 16:12:21 -0700 | [diff] [blame] | 87 | nsecs_t postedTime{TIMESTAMP_PENDING}; |
| 88 | nsecs_t requestedPresentTime{TIMESTAMP_PENDING}; |
| 89 | nsecs_t latchTime{TIMESTAMP_PENDING}; |
| 90 | nsecs_t firstRefreshStartTime{TIMESTAMP_PENDING}; |
| 91 | nsecs_t lastRefreshStartTime{TIMESTAMP_PENDING}; |
| 92 | nsecs_t dequeueReadyTime{TIMESTAMP_PENDING}; |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 93 | |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 94 | std::shared_ptr<FenceTime> acquireFence{FenceTime::NO_FENCE}; |
| 95 | std::shared_ptr<FenceTime> gpuCompositionDoneFence{FenceTime::NO_FENCE}; |
| 96 | std::shared_ptr<FenceTime> displayPresentFence{FenceTime::NO_FENCE}; |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 97 | std::shared_ptr<FenceTime> releaseFence{FenceTime::NO_FENCE}; |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 100 | struct CompositorTiming { |
| 101 | nsecs_t deadline{0}; |
| 102 | nsecs_t interval{16666667}; |
Brian Anderson | d001058 | 2017-03-07 13:20:31 -0800 | [diff] [blame] | 103 | nsecs_t presentLatency{16666667}; |
Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 104 | }; |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 105 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 106 | // A short history of frames that are synchronized between the consumer and |
| 107 | // producer via deltas. |
| 108 | class FrameEventHistory { |
| 109 | public: |
| 110 | virtual ~FrameEventHistory(); |
| 111 | |
| 112 | FrameEvents* getFrame(uint64_t frameNumber); |
| 113 | FrameEvents* getFrame(uint64_t frameNumber, size_t* iHint); |
| 114 | void checkFencesForCompletion(); |
| 115 | void dump(String8& outString) const; |
| 116 | |
| 117 | static constexpr size_t MAX_FRAME_HISTORY = 8; |
| 118 | |
| 119 | protected: |
| 120 | std::array<FrameEvents, MAX_FRAME_HISTORY> mFrames; |
Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 121 | |
| 122 | CompositorTiming mCompositorTiming; |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | |
| 126 | // The producer's interface to FrameEventHistory |
| 127 | class ProducerFrameEventHistory : public FrameEventHistory { |
| 128 | public: |
| 129 | ~ProducerFrameEventHistory() override; |
| 130 | |
Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 131 | // Public for testing. |
| 132 | static nsecs_t snapToNextTick( |
| 133 | nsecs_t timestamp, nsecs_t tickPhase, nsecs_t tickInterval); |
| 134 | |
| 135 | nsecs_t getNextCompositeDeadline(const nsecs_t now) const; |
| 136 | nsecs_t getCompositeInterval() const { return mCompositorTiming.interval; } |
| 137 | nsecs_t getCompositeToPresentLatency() const { |
| 138 | return mCompositorTiming.presentLatency; |
| 139 | } |
| 140 | |
Brian Anderson | 3da8d27 | 2016-07-28 16:20:47 -0700 | [diff] [blame] | 141 | // virtual for testing. |
| 142 | virtual void updateAcquireFence( |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 143 | uint64_t frameNumber, std::shared_ptr<FenceTime>&& acquire); |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 144 | void applyDelta(const FrameEventHistoryDelta& delta); |
| 145 | |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 146 | void updateSignalTimes(); |
| 147 | |
Brian Anderson | 3da8d27 | 2016-07-28 16:20:47 -0700 | [diff] [blame] | 148 | protected: |
| 149 | void applyFenceDelta(FenceTimeline* timeline, |
| 150 | std::shared_ptr<FenceTime>* dst, |
| 151 | const FenceTime::Snapshot& src) const; |
| 152 | |
| 153 | // virtual for testing. |
| 154 | virtual std::shared_ptr<FenceTime> createFenceTime( |
| 155 | const sp<Fence>& fence) const; |
| 156 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 157 | size_t mAcquireOffset{0}; |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 158 | |
| 159 | // The consumer updates it's timelines in Layer and SurfaceFlinger since |
| 160 | // they can coordinate shared timelines better. The producer doesn't have |
| 161 | // shared timelines though, so just let it own and update all of them. |
| 162 | FenceTimeline mAcquireTimeline; |
| 163 | FenceTimeline mGpuCompositionDoneTimeline; |
| 164 | FenceTimeline mPresentTimeline; |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 165 | FenceTimeline mReleaseTimeline; |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | |
| 169 | // Used by the consumer to create a new frame event record that is |
| 170 | // partially complete. |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 171 | struct NewFrameEventsEntry { |
| 172 | uint64_t frameNumber{0}; |
| 173 | nsecs_t postedTime{0}; |
| 174 | nsecs_t requestedPresentTime{0}; |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 175 | std::shared_ptr<FenceTime> acquireFence{FenceTime::NO_FENCE}; |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 179 | // Used by the consumer to keep track of which fields it already sent to |
| 180 | // the producer. |
| 181 | class FrameEventDirtyFields { |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 182 | public: |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 183 | inline void reset() { mBitset.reset(); } |
| 184 | inline bool anyDirty() const { return mBitset.any(); } |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 185 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 186 | template <FrameEvent event> |
| 187 | inline void setDirty() { |
| 188 | constexpr size_t eventIndex = static_cast<size_t>(event); |
| 189 | static_assert(eventIndex < FrameEvents::EVENT_COUNT, "Bad index."); |
| 190 | mBitset.set(eventIndex); |
| 191 | } |
| 192 | |
| 193 | template <FrameEvent event> |
| 194 | inline bool isDirty() const { |
| 195 | constexpr size_t eventIndex = static_cast<size_t>(event); |
| 196 | static_assert(eventIndex < FrameEvents::EVENT_COUNT, "Bad index."); |
| 197 | return mBitset[eventIndex]; |
| 198 | } |
| 199 | |
| 200 | private: |
| 201 | std::bitset<FrameEvents::EVENT_COUNT> mBitset; |
| 202 | }; |
| 203 | |
| 204 | |
| 205 | // The consumer's interface to FrameEventHistory |
| 206 | class ConsumerFrameEventHistory : public FrameEventHistory { |
| 207 | public: |
| 208 | ~ConsumerFrameEventHistory() override; |
| 209 | |
Brian Anderson | 5ea5e59 | 2016-12-01 16:54:33 -0800 | [diff] [blame] | 210 | void onDisconnect(); |
| 211 | |
Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 212 | void initializeCompositorTiming(const CompositorTiming& compositorTiming); |
| 213 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 214 | void addQueue(const NewFrameEventsEntry& newEntry); |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 215 | void addLatch(uint64_t frameNumber, nsecs_t latchTime); |
| 216 | void addPreComposition(uint64_t frameNumber, nsecs_t refreshStartTime); |
| 217 | void addPostComposition(uint64_t frameNumber, |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 218 | const std::shared_ptr<FenceTime>& gpuCompositionDone, |
Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 219 | const std::shared_ptr<FenceTime>& displayPresent, |
| 220 | const CompositorTiming& compositorTiming); |
Brian Anderson | f638686 | 2016-10-31 16:34:13 -0700 | [diff] [blame] | 221 | void addRelease(uint64_t frameNumber, nsecs_t dequeueReadyTime, |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 222 | std::shared_ptr<FenceTime>&& release); |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 223 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 224 | void getAndResetDelta(FrameEventHistoryDelta* delta); |
| 225 | |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 226 | private: |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 227 | void getFrameDelta(FrameEventHistoryDelta* delta, |
| 228 | const std::array<FrameEvents, MAX_FRAME_HISTORY>::iterator& frame); |
| 229 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 230 | std::array<FrameEventDirtyFields, MAX_FRAME_HISTORY> mFramesDirty; |
Brian Anderson | 5ea5e59 | 2016-12-01 16:54:33 -0800 | [diff] [blame] | 231 | |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 232 | size_t mQueueOffset{0}; |
| 233 | size_t mCompositionOffset{0}; |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 234 | size_t mReleaseOffset{0}; |
Brian Anderson | 4565daa | 2016-12-13 15:41:28 -0800 | [diff] [blame] | 235 | |
Brian Anderson | 5ea5e59 | 2016-12-01 16:54:33 -0800 | [diff] [blame] | 236 | int mCurrentConnectId{0}; |
Brian Anderson | 4565daa | 2016-12-13 15:41:28 -0800 | [diff] [blame] | 237 | bool mProducerWantsEvents{false}; |
Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 238 | }; |
| 239 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 240 | |
| 241 | // A single frame update from the consumer to producer that can be sent |
| 242 | // through Binder. |
| 243 | // Although this may be sent multiple times for the same frame as new |
| 244 | // timestamps are set, Fences only need to be sent once. |
| 245 | class FrameEventsDelta : public Flattenable<FrameEventsDelta> { |
| 246 | friend class ProducerFrameEventHistory; |
| 247 | public: |
| 248 | FrameEventsDelta() = default; |
| 249 | FrameEventsDelta(size_t index, |
| 250 | const FrameEvents& frameTimestamps, |
| 251 | const FrameEventDirtyFields& dirtyFields); |
| 252 | |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 253 | // Movable. |
| 254 | FrameEventsDelta(FrameEventsDelta&& src) = default; |
| 255 | FrameEventsDelta& operator=(FrameEventsDelta&& src) = default; |
| 256 | // Not copyable. |
| 257 | FrameEventsDelta(const FrameEventsDelta& src) = delete; |
| 258 | FrameEventsDelta& operator=(const FrameEventsDelta& src) = delete; |
| 259 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 260 | // Flattenable implementation |
| 261 | size_t getFlattenedSize() const; |
| 262 | size_t getFdCount() const; |
| 263 | status_t flatten(void*& buffer, size_t& size, int*& fds, |
| 264 | size_t& count) const; |
| 265 | status_t unflatten(void const*& buffer, size_t& size, int const*& fds, |
| 266 | size_t& count); |
| 267 | |
| 268 | private: |
Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 269 | static constexpr size_t minFlattenedSize(); |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 270 | |
| 271 | size_t mIndex{0}; |
| 272 | uint64_t mFrameNumber{0}; |
| 273 | |
| 274 | bool mAddPostCompositeCalled{0}; |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 275 | bool mAddReleaseCalled{0}; |
| 276 | |
Brian Anderson | ed816e6 | 2016-10-26 16:12:21 -0700 | [diff] [blame] | 277 | nsecs_t mPostedTime{FrameEvents::TIMESTAMP_PENDING}; |
| 278 | nsecs_t mRequestedPresentTime{FrameEvents::TIMESTAMP_PENDING}; |
| 279 | nsecs_t mLatchTime{FrameEvents::TIMESTAMP_PENDING}; |
| 280 | nsecs_t mFirstRefreshStartTime{FrameEvents::TIMESTAMP_PENDING}; |
| 281 | nsecs_t mLastRefreshStartTime{FrameEvents::TIMESTAMP_PENDING}; |
| 282 | nsecs_t mDequeueReadyTime{FrameEvents::TIMESTAMP_PENDING}; |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 283 | |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 284 | FenceTime::Snapshot mGpuCompositionDoneFence; |
| 285 | FenceTime::Snapshot mDisplayPresentFence; |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 286 | FenceTime::Snapshot mReleaseFence; |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 287 | |
| 288 | // This is a static method with an auto return value so we can call |
| 289 | // it without needing const and non-const versions. |
Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 290 | template <typename ThisT> |
| 291 | static inline auto allFences(ThisT fed) -> |
Brian Anderson | 4e606e3 | 2017-03-16 15:34:57 -0700 | [diff] [blame] | 292 | std::array<decltype(&fed->mReleaseFence), 3> { |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 293 | return {{ |
Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 294 | &fed->mGpuCompositionDoneFence, &fed->mDisplayPresentFence, |
Brian Anderson | 4e606e3 | 2017-03-16 15:34:57 -0700 | [diff] [blame] | 295 | &fed->mReleaseFence |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 296 | }}; |
| 297 | } |
| 298 | }; |
| 299 | |
| 300 | |
| 301 | // A collection of updates from consumer to producer that can be sent |
| 302 | // through Binder. |
| 303 | class FrameEventHistoryDelta |
| 304 | : public Flattenable<FrameEventHistoryDelta> { |
| 305 | |
| 306 | friend class ConsumerFrameEventHistory; |
| 307 | friend class ProducerFrameEventHistory; |
| 308 | |
| 309 | public: |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 310 | FrameEventHistoryDelta() = default; |
| 311 | |
| 312 | // Movable. |
| 313 | FrameEventHistoryDelta(FrameEventHistoryDelta&& src) = default; |
| 314 | FrameEventHistoryDelta& operator=(FrameEventHistoryDelta&& src); |
| 315 | // Not copyable. |
| 316 | FrameEventHistoryDelta(const FrameEventHistoryDelta& src) = delete; |
| 317 | FrameEventHistoryDelta& operator=( |
| 318 | const FrameEventHistoryDelta& src) = delete; |
| 319 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 320 | // Flattenable implementation. |
| 321 | size_t getFlattenedSize() const; |
| 322 | size_t getFdCount() const; |
| 323 | status_t flatten(void*& buffer, size_t& size, int*& fds, |
| 324 | size_t& count) const; |
| 325 | status_t unflatten(void const*& buffer, size_t& size, int const*& fds, |
| 326 | size_t& count); |
| 327 | |
| 328 | private: |
Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 329 | static constexpr size_t minFlattenedSize(); |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 330 | |
| 331 | std::vector<FrameEventsDelta> mDeltas; |
Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 332 | CompositorTiming mCompositorTiming; |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 333 | }; |
| 334 | |
| 335 | |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 336 | } // namespace android |
| 337 | #endif |