Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3abd8faa authored by Santos Cordon's avatar Santos Cordon Committed by android-build-merger
Browse files

Merge "Add DVR method to get native display metrics" into oc-dr1-dev

am: f412b2b9

Change-Id: I4cfecf4ccc8bd5a8c3b9c3c11d885ac0233b71d3
parents 2e30c8e0 f412b2b9
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -223,4 +223,38 @@ int dvrGetGlobalBuffer(DvrGlobalBufferKey key, DvrBuffer** out_buffer) {
  return 0;
}

int dvrGetNativeDisplayMetrics(size_t sizeof_metrics,
                               DvrNativeDisplayMetrics* metrics) {
  ALOGE_IF(sizeof_metrics != sizeof(DvrNativeDisplayMetrics),
           "dvrGetNativeDisplayMetrics: metrics struct mismatch, your dvr api "
           "header is out of date.");

  auto client = DisplayClient::Create();
  if (!client) {
    ALOGE("dvrGetNativeDisplayMetrics: Failed to create display client!");
    return -ECOMM;
  }

  if (metrics == nullptr) {
    ALOGE("dvrGetNativeDisplayMetrics: output metrics buffer must be non-null");
    return -EINVAL;
  }

  auto status = client->GetDisplayMetrics();

  if (!status) {
    return -status.error();
  }

  if (sizeof_metrics >= 20) {
    metrics->display_width = status.get().display_width;
    metrics->display_height = status.get().display_height;
    metrics->display_x_dpi = status.get().display_x_dpi;
    metrics->display_y_dpi = status.get().display_y_dpi;
    metrics->vsync_period_ns = status.get().vsync_period_ns;
  }

  return 0;
}

}  // extern "C"
+15 −0
Original line number Diff line number Diff line
@@ -41,6 +41,19 @@ typedef int32_t DvrGlobalBufferKey;
typedef struct DvrSurfaceAttributeValue DvrSurfaceAttributeValue;
typedef struct DvrSurfaceAttribute DvrSurfaceAttribute;

// Note: To avoid breaking others during active development, only modify this
// struct by appending elements to the end.
// If you do feel we should to re-arrange or remove elements, please make a
// note of it, and wait until we're about to finalize for an API release to do
// so.
typedef struct DvrNativeDisplayMetrics {
  uint32_t display_width;
  uint32_t display_height;
  uint32_t display_x_dpi;
  uint32_t display_y_dpi;
  uint32_t vsync_period_ns;
} DvrNativeDisplayMetrics;

// native_handle contains the fds for the underlying ION allocations inside
// the gralloc buffer. This is needed temporarily while GPU vendors work on
// better support for AHardwareBuffer via glBindSharedBuffer APIs. See
@@ -200,6 +213,8 @@ typedef int (*DvrSurfaceCreateWriteBufferQueuePtr)(
    DvrSurface* surface, uint32_t width, uint32_t height, uint32_t format,
    uint32_t layer_count, uint64_t usage, size_t capacity, size_t metadata_size,
    DvrWriteBufferQueue** queue_out);
typedef int (*DvrGetNativeDisplayMetricsPtr)(size_t sizeof_metrics,
                                             DvrNativeDisplayMetrics* metrics);

// dvr_vsync.h
typedef int (*DvrVSyncClientCreatePtr)(DvrVSyncClient** client_out);
+3 −0
Original line number Diff line number Diff line
@@ -148,3 +148,6 @@ DVR_V1_API_ENTRY(HwcFrameGetLayerDamagedRegion);

// Virtual touchpad client
DVR_V1_API_ENTRY(VirtualTouchpadScroll);

// Read the native display metrics from the hardware composer
DVR_V1_API_ENTRY(GetNativeDisplayMetrics);
+11 −0
Original line number Diff line number Diff line
@@ -97,6 +97,17 @@ int dvrDeleteGlobalBuffer(DvrGlobalBufferKey key);
// @return 0 on success. Otherwise returns a negative error value.
int dvrGetGlobalBuffer(DvrGlobalBufferKey key, DvrBuffer** out_buffer);

// Read the native device display metrics as reported by the hardware composer.
// This is useful as otherwise the device metrics are only reported as
// relative to the current device orientation.
// @param sizeof_metrics the size of the passed in metrics struct. This is used
//   to ensure we don't break each other during active development.
// @param metrics on success holds the retrieved device metrics.
// @return 0 on success. Otherwise returns a negative error value (typically
//   this means the display service is not available).
int dvrGetNativeDisplayMetrics(size_t metrics_struct_size,
                               DvrNativeDisplayMetrics* metrics);

__END_DECLS

#endif  // ANDROID_DVR_SURFACE_H_