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

Commit 21f9b57d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "VR: Update VR HWC and VR WM to use GrallocMapper"

parents f188cb57 1c457103
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -91,6 +91,12 @@ public:
            uint32_t inLayerCount, uint32_t inUsage, uint32_t inStride,
            uint32_t inLayerCount, uint32_t inUsage, uint32_t inStride,
            native_handle_t* inHandle, bool keepOwnership);
            native_handle_t* inHandle, bool keepOwnership);


    // create a buffer from an existing handle using gralloc1
    GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
            uint32_t inLayerCount, uint32_t inProducerUsage,
            uint32_t inConsumerUsage, uint32_t inStride,
            native_handle_t* inHandle, bool keepOwnership);

    // create a buffer from an existing ANativeWindowBuffer
    // create a buffer from an existing ANativeWindowBuffer
    GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership);
    GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership);


+18 −0
Original line number Original line Diff line number Diff line
@@ -104,6 +104,24 @@ GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight,
    handle = inHandle;
    handle = inHandle;
}
}


GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight,
        PixelFormat inFormat, uint32_t inLayerCount, uint32_t inProducerUsage,
        uint32_t inConsumerUsage, uint32_t inStride,
        native_handle_t* inHandle, bool keepOwnership)
    : BASE(), mOwner(keepOwnership ? ownHandle : ownNone),
      mBufferMapper(GraphicBufferMapper::get()),
      mInitCheck(NO_ERROR), mId(getUniqueId()), mGenerationNumber(0)
{
    width  = static_cast<int>(inWidth);
    height = static_cast<int>(inHeight);
    stride = static_cast<int>(inStride);
    format = inFormat;
    layerCount = inLayerCount;
    usage  = static_cast<int>(inConsumerUsage | inProducerUsage);
    handle = inHandle;
}


GraphicBuffer::GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership)
GraphicBuffer::GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership)
    : BASE(), mOwner(keepOwnership ? ownHandle : ownNone),
    : BASE(), mOwner(keepOwnership ? ownHandle : ownNone),
      mBufferMapper(GraphicBufferMapper::get()),
      mBufferMapper(GraphicBufferMapper::get()),
+0 −2
Original line number Original line Diff line number Diff line
@@ -100,7 +100,6 @@ shared_libs := \


include $(CLEAR_VARS)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(src)
LOCAL_SRC_FILES := $(src)
LOCAL_C_INCLUDES := hardware/qcom/display/msm8996/libgralloc
LOCAL_STATIC_LIBRARIES := $(static_libs)
LOCAL_STATIC_LIBRARIES := $(static_libs)
LOCAL_SHARED_LIBRARIES := $(shared_libs)
LOCAL_SHARED_LIBRARIES := $(shared_libs)
LOCAL_SHARED_LIBRARIES += libgvr
LOCAL_SHARED_LIBRARIES += libgvr
@@ -117,7 +116,6 @@ include $(BUILD_SHARED_LIBRARY)


include $(CLEAR_VARS)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(native_src)
LOCAL_SRC_FILES := $(native_src)
LOCAL_C_INCLUDES := hardware/qcom/display/msm8996/libgralloc
LOCAL_STATIC_LIBRARIES := $(static_libs) libvrwm_binder
LOCAL_STATIC_LIBRARIES := $(static_libs) libvrwm_binder
LOCAL_SHARED_LIBRARIES := $(shared_libs)
LOCAL_SHARED_LIBRARIES := $(shared_libs)
LOCAL_SHARED_LIBRARIES += libgvr
LOCAL_SHARED_LIBRARIES += libgvr
+40 −43
Original line number Original line Diff line number Diff line
@@ -2,46 +2,43 @@ subdirs = [
  "1.0",
  "1.0",
]
]


//cc_library_shared {
cc_library_shared {
//  name: "libvrhwc",
  name: "libvrhwc",
//

//  srcs: [
  srcs: [
//    "impl/sync_timeline.cpp",
    "impl/sync_timeline.cpp",
//    "impl/vr_composer_view.cpp",
    "impl/vr_composer_view.cpp",
//    "impl/vr_hwc.cpp",
    "impl/vr_hwc.cpp",
//    "impl/vr_composer_client.cpp",
    "impl/vr_composer_client.cpp",
//  ],
  ],
//

//  static_libs: [
  static_libs: [
//    "libhwcomposer-client",
    "libhwcomposer-client",
//  ],
  ],
//

//  shared_libs: [
  shared_libs: [
//    "android.dvr.composer@1.0",
    "android.dvr.composer@1.0",
//    "android.hardware.graphics.composer@2.1",
    "android.hardware.graphics.composer@2.1",
//    "libbase",
    "libbase",
//    "libcutils",
    "libcutils",
//    "libfmq",
    "libfmq",
//    "libhardware",
    "libhardware",
//    "libhidlbase",
    "libhidlbase",
//    "libhidltransport",
    "libhidltransport",
//    "liblog",
    "liblog",
//    "libsync",
    "libsync",
//    "libui",
    "libui",
//    "libutils",
    "libutils",
//  ],
  ],
//

//  export_include_dirs: ["."],
  export_include_dirs: ["."],
//

//  include_dirs: [
  include_dirs: [
//    // Access to software sync timeline.
    // Access to software sync timeline.
//    "system/core/libsync",
    "system/core/libsync",
//
  ],
//    // Access to internal gralloc implementation.

//    "hardware/qcom/display/msm8996/libgralloc",
  cflags: [
//  ],
    "-DLOG_TAG=\"vrhwc\"",
//
  ],
//  cflags: [
}
//    "-DLOG_TAG=\"vrhwc\"",
//  ],
//}
+21 −7
Original line number Original line Diff line number Diff line
@@ -15,7 +15,6 @@
 */
 */
#include "vr_hwc.h"
#include "vr_hwc.h"


#include <gralloc_priv.h>
#include <ui/Fence.h>
#include <ui/Fence.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBufferMapper.h>
#include <ui/GraphicBufferMapper.h>
@@ -44,13 +43,28 @@ const Display kDefaultDisplayId = 1;
const Config kDefaultConfigId = 1;
const Config kDefaultConfigId = 1;


sp<GraphicBuffer> GetBufferFromHandle(const native_handle_t* handle) {
sp<GraphicBuffer> GetBufferFromHandle(const native_handle_t* handle) {
  // TODO(dnicoara): Fix this once gralloc1 is available.
  uint32_t width = 0, height = 0, stride = 0, layer_count = 1;
  private_handle_t* private_handle = private_handle_t::dynamicCast(handle);
  uint64_t producer_usage = 0, consumer_usage = 0;
  int32_t format = 0;

  GraphicBufferMapper& mapper = GraphicBufferMapper::get();
  if (mapper.getDimensions(handle, &width, &height) ||
      mapper.getStride(handle, &stride) ||
      mapper.getFormat(handle, &format) ||
      mapper.getProducerUsage(handle, &producer_usage) ||
      mapper.getConsumerUsage(handle, &consumer_usage)) {
    ALOGE("Failed to read handle properties");
    return nullptr;
  }

  // This will only succeed if gralloc has GRALLOC1_CAPABILITY_LAYERED_BUFFERS
  // capability. Otherwise assume a count of 1.
  mapper.getLayerCount(handle, &layer_count);

  sp<GraphicBuffer> buffer = new GraphicBuffer(
  sp<GraphicBuffer> buffer = new GraphicBuffer(
      private_handle->width, private_handle->height, private_handle->format, 1,
      width, height, format, layer_count, producer_usage, consumer_usage,
      GraphicBuffer::USAGE_HW_COMPOSER | GraphicBuffer::USAGE_HW_TEXTURE,
      stride, native_handle_clone(handle), true);
      private_handle->width, native_handle_clone(handle), true);
  if (mapper.registerBuffer(buffer.get()) != OK) {
  if (GraphicBufferMapper::get().registerBuffer(buffer.get()) != OK) {
    ALOGE("Failed to register buffer");
    ALOGE("Failed to register buffer");
    return nullptr;
    return nullptr;
  }
  }
Loading