1 #ifndef ANDROID_DVR_DISPLAY_CLIENT_H_ 2 #define ANDROID_DVR_DISPLAY_CLIENT_H_ 3 4 #include <hardware/hwcomposer.h> 5 #include <pdx/client.h> 6 #include <pdx/file_handle.h> 7 #include <private/dvr/buffer_hub_client.h> 8 #include <private/dvr/buffer_hub_queue_client.h> 9 #include <private/dvr/display_protocol.h> 10 11 namespace android { 12 namespace dvr { 13 namespace display { 14 15 class Surface : public pdx::ClientBase<Surface> { 16 public: 17 // Utility named constructor. This can be removed once ClientBase::Create is 18 // refactored to return Status<T> types. 19 static pdx::Status<std::unique_ptr<Surface>> CreateSurface( 20 const SurfaceAttributes& attributes) { 21 int error; 22 pdx::Status<std::unique_ptr<Surface>> status; 23 if (auto surface = Create(attributes, &error)) 24 status.SetValue(std::move(surface)); 25 else 26 status.SetError(error); 27 return status; 28 } 29 30 int surface_id() const { return surface_id_; } 31 int z_order() const { return z_order_; } 32 bool visible() const { return visible_; } 33 34 pdx::Status<void> SetVisible(bool visible); 35 pdx::Status<void> SetZOrder(int z_order); 36 pdx::Status<void> SetAttributes(const SurfaceAttributes& attributes); 37 38 // Creates an empty queue. 39 pdx::Status<std::unique_ptr<ProducerQueue>> CreateQueue(); 40 41 // Creates a queue and populates it with |capacity| buffers of the specified 42 // parameters. 43 pdx::Status<std::unique_ptr<ProducerQueue>> CreateQueue(uint32_t width, 44 uint32_t height, 45 uint32_t layer_count, 46 uint32_t format, 47 uint64_t usage, 48 size_t capacity); 49 50 private: 51 friend BASE; 52 53 int surface_id_ = -1; 54 int z_order_ = 0; 55 bool visible_ = false; 56 57 // TODO(eieio,avakulenko): Remove error param once pdx::ClientBase::Create() 58 // returns Status<T>. 59 explicit Surface(const SurfaceAttributes& attributes, int* error = nullptr); 60 explicit Surface(pdx::LocalChannelHandle channel_handle, 61 int* error = nullptr); 62 63 Surface(const Surface&) = delete; 64 void operator=(const Surface&) = delete; 65 }; 66 67 class DisplayClient : public pdx::ClientBase<DisplayClient> { 68 public: 69 pdx::Status<Metrics> GetDisplayMetrics(); 70 pdx::Status<std::unique_ptr<IonBuffer>> GetNamedBuffer( 71 const std::string& name); 72 pdx::Status<std::unique_ptr<Surface>> CreateSurface( 73 const SurfaceAttributes& attributes); 74 75 // Temporary query for current VR status. Will be removed later. 76 pdx::Status<bool> IsVrAppRunning(); 77 78 private: 79 friend BASE; 80 81 explicit DisplayClient(int* error = nullptr); 82 83 DisplayClient(const DisplayClient&) = delete; 84 void operator=(const DisplayClient&) = delete; 85 }; 86 87 } // namespace display 88 } // namespace dvr 89 } // namespace android 90 91 #endif // ANDROID_DVR_DISPLAY_CLIENT_H_ 92