Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 17 | #ifndef ANDROID_SF_SHARED_BUFFER_STACK_H |
| 18 | #define ANDROID_SF_SHARED_BUFFER_STACK_H |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | #include <cutils/compiler.h> |
| 24 | |
| 25 | #include <utils/Debug.h> |
| 26 | #include <utils/threads.h> |
| 27 | #include <utils/String8.h> |
| 28 | |
| 29 | #include <ui/Rect.h> |
| 30 | |
| 31 | namespace android { |
| 32 | // --------------------------------------------------------------------------- |
| 33 | |
| 34 | /* |
| 35 | * These classes manage a stack of buffers in shared memory. |
| 36 | * |
| 37 | * SharedClient: represents a client with several stacks |
| 38 | * SharedBufferStack: represents a stack of buffers |
| 39 | * SharedBufferClient: manipulates the SharedBufferStack from the client side |
| 40 | * SharedBufferServer: manipulates the SharedBufferStack from the server side |
| 41 | * |
| 42 | * Buffers can be dequeued until there are none available, they can be locked |
| 43 | * unless they are in use by the server, which is only the case for the last |
| 44 | * dequeue-able buffer. When these various conditions are not met, the caller |
| 45 | * waits until the condition is met. |
| 46 | * |
| 47 | * |
| 48 | * CAVEATS: |
| 49 | * |
| 50 | * In the current implementation there are several limitations: |
| 51 | * - buffers must be locked in the same order they've been dequeued |
| 52 | * - buffers must be enqueued in the same order they've been locked |
| 53 | * - dequeue() is not reentrant |
| 54 | * - no error checks are done on the condition above |
| 55 | * |
| 56 | */ |
| 57 | |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 58 | // ---------------------------------------------------------------------------- |
| 59 | |
| 60 | class Region; |
| 61 | class SharedBufferStack; |
| 62 | class SharedClient; |
| 63 | |
| 64 | // ---------------------------------------------------------------------------- |
| 65 | |
Mathias Agopian | cdaaf32 | 2010-04-05 16:21:53 -0700 | [diff] [blame] | 66 | // 4 * (11 + 7 + (1 + 2*NUM_RECT_MAX) * NUM_BUFFER_MAX) * NUM_LAYERS_MAX |
Mathias Agopian | e9e4d54 | 2010-04-15 18:48:26 -0700 | [diff] [blame] | 67 | // 4 * (11 + 7 + (1 + 2*7)*16) * 31 |
| 68 | // 1032 * 31 |
| 69 | // = ~27 KiB (31992) |
Mathias Agopian | cdaaf32 | 2010-04-05 16:21:53 -0700 | [diff] [blame] | 70 | |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 71 | class SharedBufferStack |
| 72 | { |
| 73 | friend class SharedClient; |
| 74 | friend class SharedBufferBase; |
| 75 | friend class SharedBufferClient; |
| 76 | friend class SharedBufferServer; |
| 77 | |
| 78 | public: |
Mathias Agopian | dd9a3a7 | 2010-05-18 17:06:55 -0700 | [diff] [blame] | 79 | // When changing these values, the COMPILE_TIME_ASSERT at the end of this |
| 80 | // file need to be updated. |
| 81 | static const unsigned int NUM_LAYERS_MAX = 31; |
| 82 | static const unsigned int NUM_BUFFER_MAX = 16; |
Mathias Agopian | 082a4d8 | 2010-05-21 14:19:50 -0700 | [diff] [blame] | 83 | static const unsigned int NUM_BUFFER_MIN = 2; |
Mathias Agopian | dd9a3a7 | 2010-05-18 17:06:55 -0700 | [diff] [blame] | 84 | static const unsigned int NUM_DISPLAY_MAX = 4; |
| 85 | |
Mathias Agopian | 9e3ebf8 | 2009-09-17 01:35:28 -0700 | [diff] [blame] | 86 | struct Statistics { // 4 longs |
| 87 | typedef int32_t usecs_t; |
| 88 | usecs_t totalTime; |
| 89 | usecs_t reserved[3]; |
| 90 | }; |
Mathias Agopian | e9e4d54 | 2010-04-15 18:48:26 -0700 | [diff] [blame] | 91 | |
| 92 | struct SmallRect { |
| 93 | uint16_t l, t, r, b; |
| 94 | }; |
| 95 | |
| 96 | struct FlatRegion { // 52 bytes = 4 * (1 + 2*N) |
| 97 | static const unsigned int NUM_RECT_MAX = 6; |
| 98 | uint32_t count; |
| 99 | SmallRect rects[NUM_RECT_MAX]; |
| 100 | }; |
| 101 | |
| 102 | struct BufferData { |
| 103 | FlatRegion dirtyRegion; |
| 104 | SmallRect crop; |
| 105 | }; |
Mathias Agopian | 9e3ebf8 | 2009-09-17 01:35:28 -0700 | [diff] [blame] | 106 | |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 107 | SharedBufferStack(); |
Mathias Agopian | 4fc61bf | 2009-09-10 19:41:18 -0700 | [diff] [blame] | 108 | void init(int32_t identity); |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 109 | status_t setDirtyRegion(int buffer, const Region& reg); |
Mathias Agopian | e9e4d54 | 2010-04-15 18:48:26 -0700 | [diff] [blame] | 110 | status_t setCrop(int buffer, const Rect& reg); |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 111 | Region getDirtyRegion(int buffer) const; |
| 112 | |
| 113 | // these attributes are part of the conditions/updates |
| 114 | volatile int32_t head; // server's current front buffer |
| 115 | volatile int32_t available; // number of dequeue-able buffers |
| 116 | volatile int32_t queued; // number of buffers waiting for post |
| 117 | volatile int32_t inUse; // buffer currently in use by SF |
Mathias Agopian | 3dbf98c | 2009-09-10 16:55:13 -0700 | [diff] [blame] | 118 | volatile status_t status; // surface's status code |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 119 | |
| 120 | // not part of the conditions |
| 121 | volatile int32_t reallocMask; |
Mathias Agopian | 86f69c1 | 2010-04-27 21:08:20 -0700 | [diff] [blame] | 122 | volatile int8_t index[NUM_BUFFER_MAX]; |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 123 | |
| 124 | int32_t identity; // surface's identity (const) |
Mathias Agopian | cbbf27f | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 125 | int32_t token; // surface's token (for debugging) |
| 126 | int32_t reserved32[1]; |
Mathias Agopian | 9e3ebf8 | 2009-09-17 01:35:28 -0700 | [diff] [blame] | 127 | Statistics stats; |
Mathias Agopian | cdaaf32 | 2010-04-05 16:21:53 -0700 | [diff] [blame] | 128 | int32_t reserved; |
Mathias Agopian | e9e4d54 | 2010-04-15 18:48:26 -0700 | [diff] [blame] | 129 | BufferData buffers[NUM_BUFFER_MAX]; // 960 bytes |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | // ---------------------------------------------------------------------------- |
| 133 | |
Mathias Agopian | 5cc61b1 | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 134 | // 32 KB max |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 135 | class SharedClient |
| 136 | { |
| 137 | public: |
| 138 | SharedClient(); |
| 139 | ~SharedClient(); |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 140 | status_t validate(size_t token) const; |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 141 | |
| 142 | private: |
| 143 | friend class SharedBufferBase; |
| 144 | friend class SharedBufferClient; |
| 145 | friend class SharedBufferServer; |
| 146 | |
| 147 | // FIXME: this should be replaced by a lock-less primitive |
| 148 | Mutex lock; |
| 149 | Condition cv; |
Mathias Agopian | dd9a3a7 | 2010-05-18 17:06:55 -0700 | [diff] [blame] | 150 | SharedBufferStack surfaces[ SharedBufferStack::NUM_LAYERS_MAX ]; |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | // ============================================================================ |
| 154 | |
| 155 | class SharedBufferBase |
| 156 | { |
| 157 | public: |
Mathias Agopian | dd9a3a7 | 2010-05-18 17:06:55 -0700 | [diff] [blame] | 158 | SharedBufferBase(SharedClient* sharedClient, int surface, |
Mathias Agopian | d46758b | 2009-10-06 19:00:57 -0700 | [diff] [blame] | 159 | int32_t identity); |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 160 | ~SharedBufferBase(); |
Mathias Agopian | defd1bd | 2009-10-02 18:12:30 -0700 | [diff] [blame] | 161 | status_t getStatus() const; |
Mathias Agopian | ba0fab3 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 162 | int32_t getIdentity() const; |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 163 | size_t getFrontBuffer() const; |
| 164 | String8 dump(char const* prefix) const; |
| 165 | |
| 166 | protected: |
| 167 | SharedClient* const mSharedClient; |
| 168 | SharedBufferStack* const mSharedStack; |
Mathias Agopian | d46758b | 2009-10-06 19:00:57 -0700 | [diff] [blame] | 169 | const int mIdentity; |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 170 | |
| 171 | friend struct Update; |
| 172 | friend struct QueueUpdate; |
| 173 | |
| 174 | struct ConditionBase { |
| 175 | SharedBufferStack& stack; |
| 176 | inline ConditionBase(SharedBufferBase* sbc) |
| 177 | : stack(*sbc->mSharedStack) { } |
Mathias Agopian | 41623bf | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 178 | virtual ~ConditionBase() { }; |
| 179 | virtual bool operator()() const = 0; |
| 180 | virtual const char* name() const = 0; |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 181 | }; |
Mathias Agopian | 41623bf | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 182 | status_t waitForCondition(const ConditionBase& condition); |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 183 | |
| 184 | struct UpdateBase { |
| 185 | SharedBufferStack& stack; |
| 186 | inline UpdateBase(SharedBufferBase* sbb) |
| 187 | : stack(*sbb->mSharedStack) { } |
| 188 | }; |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 189 | template <typename T> |
| 190 | status_t updateCondition(T update); |
| 191 | }; |
| 192 | |
| 193 | template <typename T> |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 194 | status_t SharedBufferBase::updateCondition(T update) { |
| 195 | SharedClient& client( *mSharedClient ); |
| 196 | Mutex::Autolock _l(client.lock); |
| 197 | ssize_t result = update(); |
| 198 | client.cv.broadcast(); |
| 199 | return result; |
| 200 | } |
| 201 | |
| 202 | // ---------------------------------------------------------------------------- |
| 203 | |
| 204 | class SharedBufferClient : public SharedBufferBase |
| 205 | { |
| 206 | public: |
Mathias Agopian | d46758b | 2009-10-06 19:00:57 -0700 | [diff] [blame] | 207 | SharedBufferClient(SharedClient* sharedClient, int surface, int num, |
| 208 | int32_t identity); |
| 209 | |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 210 | ssize_t dequeue(); |
| 211 | status_t undoDequeue(int buf); |
| 212 | |
| 213 | status_t lock(int buf); |
| 214 | status_t queue(int buf); |
| 215 | bool needNewBuffer(int buffer) const; |
| 216 | status_t setDirtyRegion(int buffer, const Region& reg); |
Mathias Agopian | e9e4d54 | 2010-04-15 18:48:26 -0700 | [diff] [blame] | 217 | status_t setCrop(int buffer, const Rect& reg); |
Mathias Agopian | 9e3ebf8 | 2009-09-17 01:35:28 -0700 | [diff] [blame] | 218 | |
Mathias Agopian | dd9a3a7 | 2010-05-18 17:06:55 -0700 | [diff] [blame] | 219 | |
| 220 | class SetBufferCountCallback { |
| 221 | friend class SharedBufferClient; |
| 222 | virtual status_t operator()(int bufferCount) const = 0; |
| 223 | protected: |
| 224 | virtual ~SetBufferCountCallback() { } |
| 225 | }; |
| 226 | status_t setBufferCount(int bufferCount, const SetBufferCountCallback& ipc); |
| 227 | |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 228 | private: |
| 229 | friend struct Condition; |
| 230 | friend struct DequeueCondition; |
| 231 | friend struct LockCondition; |
| 232 | |
| 233 | struct QueueUpdate : public UpdateBase { |
| 234 | inline QueueUpdate(SharedBufferBase* sbb); |
| 235 | inline ssize_t operator()(); |
| 236 | }; |
| 237 | |
| 238 | struct UndoDequeueUpdate : public UpdateBase { |
| 239 | inline UndoDequeueUpdate(SharedBufferBase* sbb); |
| 240 | inline ssize_t operator()(); |
| 241 | }; |
| 242 | |
| 243 | // -- |
| 244 | |
| 245 | struct DequeueCondition : public ConditionBase { |
| 246 | inline DequeueCondition(SharedBufferClient* sbc); |
Mathias Agopian | 41623bf | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 247 | inline bool operator()() const; |
| 248 | inline const char* name() const { return "DequeueCondition"; } |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 249 | }; |
| 250 | |
| 251 | struct LockCondition : public ConditionBase { |
| 252 | int buf; |
| 253 | inline LockCondition(SharedBufferClient* sbc, int buf); |
Mathias Agopian | 41623bf | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 254 | inline bool operator()() const; |
| 255 | inline const char* name() const { return "LockCondition"; } |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 256 | }; |
| 257 | |
Mathias Agopian | dd9a3a7 | 2010-05-18 17:06:55 -0700 | [diff] [blame] | 258 | int32_t computeTail() const; |
| 259 | |
| 260 | mutable RWLock mLock; |
| 261 | int mNumBuffers; |
| 262 | |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 263 | int32_t tail; |
Mathias Agopian | 43d8a28 | 2010-04-27 16:11:38 -0700 | [diff] [blame] | 264 | int32_t undoDequeueTail; |
Mathias Agopian | 86f69c1 | 2010-04-27 21:08:20 -0700 | [diff] [blame] | 265 | int32_t queued_head; |
Mathias Agopian | 9e3ebf8 | 2009-09-17 01:35:28 -0700 | [diff] [blame] | 266 | // statistics... |
Mathias Agopian | dd9a3a7 | 2010-05-18 17:06:55 -0700 | [diff] [blame] | 267 | nsecs_t mDequeueTime[SharedBufferStack::NUM_BUFFER_MAX]; |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 268 | }; |
| 269 | |
| 270 | // ---------------------------------------------------------------------------- |
| 271 | |
| 272 | class SharedBufferServer : public SharedBufferBase |
| 273 | { |
| 274 | public: |
Mathias Agopian | 4fc61bf | 2009-09-10 19:41:18 -0700 | [diff] [blame] | 275 | SharedBufferServer(SharedClient* sharedClient, int surface, int num, |
| 276 | int32_t identity); |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 277 | |
| 278 | ssize_t retireAndLock(); |
| 279 | status_t unlock(int buffer); |
Mathias Agopian | 3dbf98c | 2009-09-10 16:55:13 -0700 | [diff] [blame] | 280 | void setStatus(status_t status); |
Mathias Agopian | fb6ae66 | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 281 | status_t reallocateAll(); |
| 282 | status_t reallocateAllExcept(int buffer); |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 283 | status_t assertReallocate(int buffer); |
Mathias Agopian | 68174b1 | 2009-10-07 16:44:10 -0700 | [diff] [blame] | 284 | int32_t getQueuedCount() const; |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 285 | Region getDirtyRegion(int buffer) const; |
| 286 | |
Mathias Agopian | 5cc61b1 | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 287 | status_t resize(int newNumBuffers); |
| 288 | |
Mathias Agopian | 9e3ebf8 | 2009-09-17 01:35:28 -0700 | [diff] [blame] | 289 | SharedBufferStack::Statistics getStats() const; |
| 290 | |
| 291 | |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 292 | private: |
Mathias Agopian | 5cc61b1 | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 293 | /* |
| 294 | * BufferList is basically a fixed-capacity sorted-vector of |
| 295 | * unsigned 5-bits ints using a 32-bits int as storage. |
| 296 | * it has efficient iterators to find items in the list and not in the list. |
| 297 | */ |
| 298 | class BufferList { |
| 299 | size_t mCapacity; |
| 300 | uint32_t mList; |
| 301 | public: |
Mathias Agopian | dd9a3a7 | 2010-05-18 17:06:55 -0700 | [diff] [blame] | 302 | BufferList(size_t c = SharedBufferStack::NUM_BUFFER_MAX) |
| 303 | : mCapacity(c), mList(0) { } |
Mathias Agopian | 5cc61b1 | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 304 | status_t add(int value); |
| 305 | status_t remove(int value); |
Mathias Agopian | 68f929b | 2010-05-21 14:51:33 -0700 | [diff] [blame] | 306 | uint32_t getMask() const { return mList; } |
Mathias Agopian | 5cc61b1 | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 307 | |
| 308 | class const_iterator { |
| 309 | friend class BufferList; |
| 310 | uint32_t mask, curr; |
| 311 | const_iterator(uint32_t mask) : |
Mathias Agopian | e1f6105 | 2010-05-17 17:27:26 -0700 | [diff] [blame] | 312 | mask(mask), curr(__builtin_clz(mask)) { |
| 313 | } |
Mathias Agopian | 5cc61b1 | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 314 | public: |
| 315 | inline bool operator == (const const_iterator& rhs) const { |
| 316 | return mask == rhs.mask; |
| 317 | } |
| 318 | inline bool operator != (const const_iterator& rhs) const { |
| 319 | return mask != rhs.mask; |
| 320 | } |
| 321 | inline int operator *() const { return curr; } |
Mathias Agopian | e1f6105 | 2010-05-17 17:27:26 -0700 | [diff] [blame] | 322 | inline const const_iterator& operator ++() { |
| 323 | mask &= ~(1<<(31-curr)); |
| 324 | curr = __builtin_clz(mask); |
Mathias Agopian | 5cc61b1 | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 325 | return *this; |
| 326 | } |
| 327 | }; |
| 328 | |
| 329 | inline const_iterator begin() const { |
| 330 | return const_iterator(mList); |
| 331 | } |
| 332 | inline const_iterator end() const { |
| 333 | return const_iterator(0); |
| 334 | } |
| 335 | inline const_iterator free_begin() const { |
| 336 | uint32_t mask = (1 << (32-mCapacity)) - 1; |
| 337 | return const_iterator( ~(mList | mask) ); |
| 338 | } |
| 339 | }; |
| 340 | |
Mathias Agopian | dd9a3a7 | 2010-05-18 17:06:55 -0700 | [diff] [blame] | 341 | // this protects mNumBuffers and mBufferList |
| 342 | mutable RWLock mLock; |
| 343 | int mNumBuffers; |
Mathias Agopian | 5cc61b1 | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 344 | BufferList mBufferList; |
| 345 | |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 346 | struct UnlockUpdate : public UpdateBase { |
| 347 | const int lockedBuffer; |
| 348 | inline UnlockUpdate(SharedBufferBase* sbb, int lockedBuffer); |
| 349 | inline ssize_t operator()(); |
| 350 | }; |
| 351 | |
| 352 | struct RetireUpdate : public UpdateBase { |
| 353 | const int numBuffers; |
| 354 | inline RetireUpdate(SharedBufferBase* sbb, int numBuffers); |
| 355 | inline ssize_t operator()(); |
| 356 | }; |
| 357 | |
Mathias Agopian | 3dbf98c | 2009-09-10 16:55:13 -0700 | [diff] [blame] | 358 | struct StatusUpdate : public UpdateBase { |
| 359 | const status_t status; |
| 360 | inline StatusUpdate(SharedBufferBase* sbb, status_t status); |
| 361 | inline ssize_t operator()(); |
| 362 | }; |
| 363 | |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 364 | struct ReallocateCondition : public ConditionBase { |
| 365 | int buf; |
| 366 | inline ReallocateCondition(SharedBufferBase* sbb, int buf); |
Mathias Agopian | 41623bf | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 367 | inline bool operator()() const; |
| 368 | inline const char* name() const { return "ReallocateCondition"; } |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 369 | }; |
| 370 | }; |
| 371 | |
| 372 | // =========================================================================== |
| 373 | |
| 374 | struct display_cblk_t |
| 375 | { |
| 376 | uint16_t w; |
| 377 | uint16_t h; |
| 378 | uint8_t format; |
| 379 | uint8_t orientation; |
| 380 | uint8_t reserved[2]; |
| 381 | float fps; |
| 382 | float density; |
| 383 | float xdpi; |
| 384 | float ydpi; |
| 385 | uint32_t pad[2]; |
| 386 | }; |
| 387 | |
| 388 | struct surface_flinger_cblk_t // 4KB max |
| 389 | { |
| 390 | uint8_t connected; |
| 391 | uint8_t reserved[3]; |
| 392 | uint32_t pad[7]; |
Mathias Agopian | dd9a3a7 | 2010-05-18 17:06:55 -0700 | [diff] [blame] | 393 | display_cblk_t displays[SharedBufferStack::NUM_DISPLAY_MAX]; |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 394 | }; |
| 395 | |
| 396 | // --------------------------------------------------------------------------- |
| 397 | |
Mathias Agopian | cdaaf32 | 2010-04-05 16:21:53 -0700 | [diff] [blame] | 398 | COMPILE_TIME_ASSERT(sizeof(SharedClient) <= 32768) |
Mathias Agopian | 81e2a52 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 399 | COMPILE_TIME_ASSERT(sizeof(surface_flinger_cblk_t) <= 4096) |
| 400 | |
| 401 | // --------------------------------------------------------------------------- |
| 402 | }; // namespace android |
| 403 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 404 | #endif /* ANDROID_SF_SHARED_BUFFER_STACK_H */ |