• 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_client.h>
9 #include <private/dvr/buffer_hub_queue_client.h>
10 #include <private/dvr/display_protocol.h>
11 
12 namespace android {
13 namespace dvr {
14 namespace display {
15 
16 class Surface : public pdx::ClientBase<Surface> {
17  public:
18   // Utility named constructor. This can be removed once ClientBase::Create is
19   // refactored to return Status<T> types.
CreateSurface(const SurfaceAttributes & attributes)20   static pdx::Status<std::unique_ptr<Surface>> CreateSurface(
21       const SurfaceAttributes& attributes) {
22     int error;
23     pdx::Status<std::unique_ptr<Surface>> status;
24     if (auto surface = Create(attributes, &error))
25       status.SetValue(std::move(surface));
26     else
27       status.SetError(error);
28     return status;
29   }
30 
surface_id()31   int surface_id() const { return surface_id_; }
z_order()32   int z_order() const { return z_order_; }
visible()33   bool visible() const { return visible_; }
34 
35   pdx::Status<void> SetVisible(bool visible);
36   pdx::Status<void> SetZOrder(int z_order);
37   pdx::Status<void> SetAttributes(const SurfaceAttributes& attributes);
38 
39   // Creates an empty queue.
40   pdx::Status<std::unique_ptr<ProducerQueue>> CreateQueue(uint32_t width,
41                                                           uint32_t height,
42                                                           uint32_t format,
43                                                           size_t metadata_size);
44 
45   // Creates a queue and populates it with |capacity| buffers of the specified
46   // parameters.
47   pdx::Status<std::unique_ptr<ProducerQueue>> CreateQueue(uint32_t width,
48                                                           uint32_t height,
49                                                           uint32_t layer_count,
50                                                           uint32_t format,
51                                                           uint64_t usage,
52                                                           size_t capacity,
53                                                           size_t metadata_size);
54 
55  private:
56   friend BASE;
57 
58   int surface_id_ = -1;
59   int z_order_ = 0;
60   bool visible_ = false;
61 
62   // TODO(eieio,avakulenko): Remove error param once pdx::ClientBase::Create()
63   // returns Status<T>.
64   explicit Surface(const SurfaceAttributes& attributes, int* error = nullptr);
65   explicit Surface(pdx::LocalChannelHandle channel_handle,
66                    int* error = nullptr);
67 
68   Surface(const Surface&) = delete;
69   void operator=(const Surface&) = delete;
70 };
71 
72 class DisplayClient : public pdx::ClientBase<DisplayClient> {
73  public:
74   pdx::Status<Metrics> GetDisplayMetrics();
75   pdx::Status<std::string> GetConfigurationData(ConfigFileType config_type);
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