• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef ANDROID_DVR_DISPLAY_CLIENT_H_
2 #define ANDROID_DVR_DISPLAY_CLIENT_H_
3 
4 #include <dvr/dvr_api.h>
5 #include <hardware/hwcomposer.h>
6 #include <pdx/client.h>
7 #include <pdx/file_handle.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.
CreateSurface(const SurfaceAttributes & attributes)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 
surface_id()30   int surface_id() const { return surface_id_; }
z_order()31   int z_order() const { return z_order_; }
visible()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(uint32_t width,
40                                                           uint32_t height,
41                                                           uint32_t format,
42                                                           size_t metadata_size);
43 
44   // Creates a queue and populates it with |capacity| buffers of the specified
45   // parameters.
46   pdx::Status<std::unique_ptr<ProducerQueue>> CreateQueue(uint32_t width,
47                                                           uint32_t height,
48                                                           uint32_t layer_count,
49                                                           uint32_t format,
50                                                           uint64_t usage,
51                                                           size_t capacity,
52                                                           size_t metadata_size);
53 
54  private:
55   friend BASE;
56 
57   int surface_id_ = -1;
58   int z_order_ = 0;
59   bool visible_ = false;
60 
61   // TODO(eieio,avakulenko): Remove error param once pdx::ClientBase::Create()
62   // returns Status<T>.
63   explicit Surface(const SurfaceAttributes& attributes, int* error = nullptr);
64   explicit Surface(pdx::LocalChannelHandle channel_handle,
65                    int* error = nullptr);
66 
67   Surface(const Surface&) = delete;
68   void operator=(const Surface&) = delete;
69 };
70 
71 class DisplayClient : public pdx::ClientBase<DisplayClient> {
72  public:
73   pdx::Status<Metrics> GetDisplayMetrics();
74   pdx::Status<std::string> GetConfigurationData(ConfigFileType config_type);
75   pdx::Status<uint8_t> GetDisplayIdentificationPort();
76   pdx::Status<std::unique_ptr<IonBuffer>> SetupGlobalBuffer(
77       DvrGlobalBufferKey key, size_t size, uint64_t usage);
78   pdx::Status<void> DeleteGlobalBuffer(DvrGlobalBufferKey key);
79   pdx::Status<std::unique_ptr<IonBuffer>> GetGlobalBuffer(
80       DvrGlobalBufferKey key);
81   pdx::Status<std::unique_ptr<Surface>> CreateSurface(
82       const SurfaceAttributes& attributes);
83 
84   // Temporary query for current VR status. Will be removed later.
85   pdx::Status<bool> IsVrAppRunning();
86 
87  private:
88   friend BASE;
89 
90   explicit DisplayClient(int* error = nullptr);
91 
92   DisplayClient(const DisplayClient&) = delete;
93   void operator=(const DisplayClient&) = delete;
94 };
95 
96 }  // namespace display
97 }  // namespace dvr
98 }  // namespace android
99 
100 #endif  // ANDROID_DVR_DISPLAY_CLIENT_H_
101