| Jiwen 'Steve' Cai | 2e06c1c | 2018-07-30 21:35:32 -0700 | [diff] [blame] | 1 | #ifndef ANDROID_DVR_BUFFERHUBD_BUFFER_NODE_H_ | 
|  | 2 | #define ANDROID_DVR_BUFFERHUBD_BUFFER_NODE_H_ | 
|  | 3 |  | 
|  | 4 | #include <private/dvr/ion_buffer.h> | 
|  | 5 |  | 
|  | 6 | namespace android { | 
|  | 7 | namespace dvr { | 
|  | 8 |  | 
|  | 9 | class BufferNode { | 
|  | 10 | public: | 
|  | 11 | // Creates a BufferNode from existing IonBuffers, i.e. creating from an | 
|  | 12 | // existing ProducerChannel. | 
|  | 13 | BufferNode(IonBuffer buffer, IonBuffer metadata_buffer, | 
|  | 14 | size_t user_metadata_size); | 
|  | 15 |  | 
|  | 16 | // Allocates a new BufferNode. | 
|  | 17 | BufferNode(uint32_t width, uint32_t height, uint32_t layer_count, | 
|  | 18 | uint32_t format, uint64_t usage, size_t user_metadata_size); | 
|  | 19 |  | 
|  | 20 | // Returns whether the object holds a valid graphic buffer. | 
|  | 21 | bool IsValid() const { | 
|  | 22 | return buffer_.IsValid() && metadata_buffer_.IsValid(); | 
|  | 23 | } | 
|  | 24 |  | 
|  | 25 | size_t user_metadata_size() const { return user_metadata_size_; } | 
|  | 26 | uint64_t active_buffer_bit_mask() const { return active_buffer_bit_mask_; } | 
|  | 27 | void set_buffer_state_bit(uint64_t buffer_state_bit) { | 
|  | 28 | active_buffer_bit_mask_ |= buffer_state_bit; | 
|  | 29 | } | 
|  | 30 |  | 
|  | 31 | // Used to take out IonBuffers. | 
|  | 32 | IonBuffer& buffer() { return buffer_; } | 
|  | 33 | IonBuffer& metadata_buffer() { return metadata_buffer_; } | 
|  | 34 |  | 
|  | 35 | // Used to access IonBuffers. | 
|  | 36 | const IonBuffer& buffer() const { return buffer_; } | 
|  | 37 | const IonBuffer& metadata_buffer() const { return metadata_buffer_; } | 
|  | 38 |  | 
|  | 39 | private: | 
|  | 40 | // Gralloc buffer handles. | 
|  | 41 | IonBuffer buffer_; | 
|  | 42 | IonBuffer metadata_buffer_; | 
|  | 43 |  | 
|  | 44 | // Size of user requested metadata. | 
|  | 45 | const size_t user_metadata_size_; | 
|  | 46 |  | 
|  | 47 | // All active buffer bits. Valid bits are the lower 63 bits, while the | 
|  | 48 | // highest bit is reserved for the exclusive writing and should not be set. | 
|  | 49 | uint64_t active_buffer_bit_mask_ = 0ULL; | 
|  | 50 | }; | 
|  | 51 |  | 
|  | 52 | }  // namespace dvr | 
|  | 53 | }  // namespace android | 
|  | 54 |  | 
|  | 55 | #endif  // ANDROID_DVR_BUFFERHUBD_BUFFER_NODE_H_ |