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

Commit e20b1127 authored by Marissa Wall's avatar Marissa Wall
Browse files

graphics: change composer 2.1 to support allocator/mapper 3.0

Change composer 2.1's ComposerResources to support the new major versions
of IAllocator and IMapper.

Bug: 120493579
Test: vts
Change-Id: I888364d302ba8c7f7ad30070dcad3ed738b4c663
parent bd1ca518
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ cc_library_shared {
    shared_libs: [
        "android.hardware.graphics.composer@2.1",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@3.0",
        "libbase",
        "libcutils",
        "libfmq",
+2 −0
Original line number Diff line number Diff line
@@ -20,11 +20,13 @@ cc_library_headers {
    shared_libs: [
        "android.hardware.graphics.composer@2.1",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@3.0",
        "libhardware", // TODO remove hwcomposer2.h dependency
    ],
    export_shared_lib_headers: [
        "android.hardware.graphics.composer@2.1",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@3.0",
        "libhardware",
    ],
    header_libs: [
+41 −12
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <vector>

#include <android/hardware/graphics/mapper/2.0/IMapper.h>
#include <android/hardware/graphics/mapper/3.0/IMapper.h>
#include <log/log.h>

namespace android {
@@ -39,9 +40,16 @@ namespace hal {
class ComposerHandleImporter {
   public:
    bool init() {
        mMapper = mapper::V2_0::IMapper::getService();
        ALOGE_IF(!mMapper, "failed to get mapper service");
        return mMapper != nullptr;
        mMapper3 = mapper::V3_0::IMapper::getService();
        if (mMapper3) {
            return true;
        }
        ALOGW_IF(!mMapper3, "failed to get mapper 3.0 service");

        mMapper2 = mapper::V2_0::IMapper::getService();
        ALOGE_IF(!mMapper2, "failed to get mapper 2.0 service");

        return mMapper2 != nullptr;
    }

    Error importBuffer(const native_handle_t* rawHandle, const native_handle_t** outBufferHandle) {
@@ -50,15 +58,29 @@ class ComposerHandleImporter {
            return Error::NONE;
        }

        mapper::V2_0::Error error;
        const native_handle_t* bufferHandle;
        mMapper->importBuffer(rawHandle, [&](const auto& tmpError, const auto& tmpBufferHandle) {
        if (mMapper2) {
            mapper::V2_0::Error error;
            mMapper2->importBuffer(
                rawHandle, [&](const auto& tmpError, const auto& tmpBufferHandle) {
                    error = tmpError;
                    bufferHandle = static_cast<const native_handle_t*>(tmpBufferHandle);
                });
            if (error != mapper::V2_0::Error::NONE) {
                return Error::NO_RESOURCES;
            }
        }
        if (mMapper3) {
            mapper::V3_0::Error error;
            mMapper3->importBuffer(
                rawHandle, [&](const auto& tmpError, const auto& tmpBufferHandle) {
                    error = tmpError;
                    bufferHandle = static_cast<const native_handle_t*>(tmpBufferHandle);
                });
            if (error != mapper::V3_0::Error::NONE) {
                return Error::NO_RESOURCES;
            }
        }

        *outBufferHandle = bufferHandle;
        return Error::NONE;
@@ -66,7 +88,13 @@ class ComposerHandleImporter {

    void freeBuffer(const native_handle_t* bufferHandle) {
        if (bufferHandle) {
            mMapper->freeBuffer(static_cast<void*>(const_cast<native_handle_t*>(bufferHandle)));
            if (mMapper2) {
                mMapper2->freeBuffer(
                    static_cast<void*>(const_cast<native_handle_t*>(bufferHandle)));
            } else if (mMapper3) {
                mMapper3->freeBuffer(
                    static_cast<void*>(const_cast<native_handle_t*>(bufferHandle)));
            }
        }
    }

@@ -91,7 +119,8 @@ class ComposerHandleImporter {
    }

   private:
    sp<mapper::V2_0::IMapper> mMapper;
    sp<mapper::V2_0::IMapper> mMapper2;
    sp<mapper::V3_0::IMapper> mMapper3;
};

class ComposerHandleCache {
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ LOCAL_SHARED_LIBRARIES := \
        android.hardware.graphics.composer@2.1 \
        android.hardware.graphics.composer@2.2 \
        android.hardware.graphics.mapper@2.0 \
        android.hardware.graphics.mapper@3.0 \
        libbase \
        libbinder \
        libcutils \
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ cc_binary {
        "android.hardware.graphics.composer@2.2",
        "android.hardware.graphics.composer@2.3",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@3.0",
        "libbase",
        "libbinder",
        "libcutils",