OSDN Git Service

drm_hwcomposer: get gralloc buffer usage during hwc_set
authorZach Reizner <zachr@google.com>
Tue, 20 Oct 2015 17:58:19 +0000 (10:58 -0700)
committerZach Reizner <zachr@google.com>
Mon, 26 Oct 2015 16:38:34 +0000 (09:38 -0700)
This is needed during the layer composition planning phase to determine if a
layer is protected and therefore needs to be in its own overlay.

BUG=chrome-os-partner:43674

Change-Id: I33510a5a56b57aaaf55732149ae3e3d2f92ada79

drm_hwcomposer.h
drmhwcgralloc.h
hwcomposer.cpp

index 5a45782..4a8b4a3 100644 (file)
@@ -208,6 +208,7 @@ enum class DrmHwcBlending : int32_t {
 
 struct DrmHwcLayer {
   buffer_handle_t sf_handle = NULL;
+  int gralloc_buffer_usage = 0;
   DrmHwcBuffer buffer;
   DrmHwcNativeHandle handle;
   DrmHwcTransform transform = DrmHwcTransform::kIdentity;
index 43b36f9..880c8a4 100644 (file)
@@ -43,6 +43,13 @@ enum {
    *      void **priv);
    */
   GRALLOC_MODULE_PERFORM_GET_IMPORTER_PRIVATE = 0xffeeff02,
+
+  /* perform(const struct gralloc_module_t *mod,
+   *     int op,
+   *     buffer_handle_t buffer,
+   *     int *usage);
+   */
+  GRALLOC_MODULE_PERFORM_GET_USAGE = 0xffeeff03,
 };
 
 typedef struct hwc_drm_bo {
index 7b64bf2..de5c66f 100644 (file)
@@ -318,6 +318,18 @@ int DrmHwcLayer::InitFromHwcLayer(hwc_layer_1_t *sf_layer, Importer *importer,
   if (ret)
     return ret;
 
+  ret = gralloc->perform(gralloc, GRALLOC_MODULE_PERFORM_GET_USAGE,
+                         handle.get(), &gralloc_buffer_usage);
+  if (ret) {
+    // TODO(zachr): Once GRALLOC_MODULE_PERFORM_GET_USAGE is implemented, remove
+    // "ret = 0" and enable the error logging code.
+    ret = 0;
+#if 0
+    ALOGE("Failed to get usage for buffer %p (%d)", handle.get(), ret);
+    return ret;
+#endif
+  }
+
   return 0;
 }