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

Commit dd5ce773 authored by Daniel Nicoara's avatar Daniel Nicoara
Browse files

vr_wm: Import cloned buffer in VR HWC

Bug: b/35619417
Test: Compiled and tested on device. Ensured SurfaceFlinger content is
visible in VR mode.

Change-Id: Ic2e653c9771fd022079486704b9e7a412d18bfdc
parent 1dc50630
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ sp<GraphicBuffer> GetBufferFromHandle(const native_handle_t* handle) {
  int32_t format = 0;

  GraphicBufferMapper& mapper = GraphicBufferMapper::get();
  // Need to register |handle| otherwise we can't read its properties.
  if (mapper.registerBuffer(handle) != OK) {
    ALOGE("Failed to register buffer");
    return nullptr;
@@ -66,9 +67,15 @@ sp<GraphicBuffer> GetBufferFromHandle(const native_handle_t* handle) {
  // capability. Otherwise assume a count of 1.
  mapper.getLayerCount(handle, &layer_count);

  // NOTE: Can't re-use |handle| since we don't own it.
  sp<GraphicBuffer> buffer = new GraphicBuffer(
      width, height, format, layer_count, producer_usage, consumer_usage,
      stride, native_handle_clone(handle), true);
  // Need to register the cloned buffer otherwise it can't be used later on.
  if (mapper.registerBuffer(buffer.get()) != OK) {
    ALOGE("Failed to register cloned buffer");
    return nullptr;
  }

  return buffer;
}