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

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

Merge changes from topic 'vr_wm'

* changes:
  VR: Add ability to pass layer info through SurfaceFlinger
  VR: Create VR implementation for HWC HIDL interface
parents 1478db5b 2f5f8a51
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -48,6 +48,10 @@ LOCAL_C_INCLUDES := \
LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\"
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES

ifeq ($(TARGET_IN_VR_MODE),true)
    LOCAL_CFLAGS += -DIN_VR_MODE
endif

ifeq ($(TARGET_USES_HWC2),true)
    LOCAL_CFLAGS += -DUSE_HWC2
    LOCAL_SRC_FILES += \
@@ -130,6 +134,7 @@ LOCAL_CFLAGS += -fvisibility=hidden -Werror=format

LOCAL_STATIC_LIBRARIES := libhwcomposer-command-buffer libtrace_proto libvkjson
LOCAL_SHARED_LIBRARIES := \
    android.dvr.composer@1.0 \
    android.hardware.graphics.allocator@2.0 \
    android.hardware.graphics.composer@2.1 \
    libcutils \
+44 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#undef LOG_TAG
#define LOG_TAG "HwcComposer"

#include <android/dvr/composer/1.0/IVrComposerClient.h>
#include <inttypes.h>
#include <log/log.h>

@@ -24,6 +25,7 @@

namespace android {

using dvr::composer::V1_0::IVrComposerClient;
using hardware::Return;
using hardware::hidl_vec;
using hardware::hidl_handle;
@@ -102,10 +104,37 @@ Error unwrapRet(Return<Error>& ret)

} // anonymous namespace

Composer::Composer()
    : mWriter(kWriterInitialSize)
Composer::CommandWriter::CommandWriter(uint32_t initialMaxSize)
    : CommandWriterBase(initialMaxSize) {}

Composer::CommandWriter::~CommandWriter()
{
}

void Composer::CommandWriter::setLayerInfo(uint32_t type, uint32_t appId)
{
    constexpr uint16_t kSetLayerInfoLength = 2;
    beginCommand(
        static_cast<IComposerClient::Command>(
            IVrComposerClient::VrCommand::SET_LAYER_INFO),
        kSetLayerInfoLength);
    write(type);
    write(appId);
    endCommand();
}

Composer::Composer() : mWriter(kWriterInitialSize)
{
#if defined(IN_VR_MODE)
    mIsInVrMode = true;
#endif

    if (mIsInVrMode) {
        mComposer = IComposer::getService("vr_hwcomposer");
    } else {
        mComposer = IComposer::getService("hwcomposer");
    }

    if (mComposer == nullptr) {
        LOG_ALWAYS_FATAL("failed to get hwcomposer service");
    }
@@ -589,6 +618,18 @@ Error Composer::setLayerZOrder(Display display, Layer layer, uint32_t z)
    return Error::NONE;
}

Error Composer::setLayerInfo(Display display, Layer layer, uint32_t type,
                             uint32_t appId)
{
    if (mIsInVrMode)
    {
        mWriter.selectDisplay(display);
        mWriter.selectLayer(layer);
        mWriter.setLayerInfo(type, appId);
    }
    return Error::NONE;
}

Error Composer::execute()
{
    // prepare input command queue
+13 −2
Original line number Diff line number Diff line
@@ -215,8 +215,17 @@ public:
    Error setLayerVisibleRegion(Display display, Layer layer,
            const std::vector<IComposerClient::Rect>& visible);
    Error setLayerZOrder(Display display, Layer layer, uint32_t z);

    Error setLayerInfo(Display display, Layer layer, uint32_t type,
                       uint32_t appId);
private:
    class CommandWriter : public CommandWriterBase {
    public:
        CommandWriter(uint32_t initialMaxSize);
        ~CommandWriter() override;

        void setLayerInfo(uint32_t type, uint32_t appId);
    };

    // Many public functions above simply write a command into the command
    // queue to batch the calls.  validateDisplay and presentDisplay will call
    // this function to execute the command queue.
@@ -228,8 +237,10 @@ private:
    // 64KiB minus a small space for metadata such as read/write pointers
    static constexpr size_t kWriterInitialSize =
        64 * 1024 / sizeof(uint32_t) - 16;
    CommandWriterBase mWriter;
    CommandWriter mWriter;
    CommandReader mReader;

    bool mIsInVrMode = false;
};

} // namespace Hwc2
+12 −0
Original line number Diff line number Diff line
@@ -1424,4 +1424,16 @@ Error Layer::setZOrder(uint32_t z)
    return static_cast<Error>(intError);
}

Error Layer::setInfo(uint32_t type, uint32_t appId)
{
#ifdef BYPASS_IHWC
  (void)type;
  (void)appId;
  int32_t intError = 0;
#else
  auto intError = mDevice.mComposer->setLayerInfo(mDisplayId, mId, type, appId);
#endif
  return static_cast<Error>(intError);
}

} // namespace HWC2
+1 −0
Original line number Diff line number Diff line
@@ -405,6 +405,7 @@ public:
    [[clang::warn_unused_result]] Error setVisibleRegion(
            const android::Region& region);
    [[clang::warn_unused_result]] Error setZOrder(uint32_t z);
    [[clang::warn_unused_result]] Error setInfo(uint32_t type, uint32_t appId);

private:
    std::weak_ptr<Display> mDisplay;
Loading