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

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

composer: support gralloc 4.0

Add support for gralloc 4.0 to composer.

Bug: 136016160
Test: Compiles and boots

Change-Id: I2609f20348f795a7c4e966d7420b36fa27daa054
parent de3781df
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ cc_library_shared {
        "android.hardware.graphics.composer@2.1",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@3.0",
        "android.hardware.graphics.mapper@4.0",
        "libcutils",
        "libhardware", // TODO remove hwcomposer2.h dependency
        "libhidlbase",
@@ -31,6 +32,7 @@ cc_library_shared {
        "android.hardware.graphics.composer@2.1",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@3.0",
        "android.hardware.graphics.mapper@4.0",
        "libhardware",
        "libhidlbase",
        "liblog",
+18 −0
Original line number Diff line number Diff line
@@ -26,6 +26,12 @@ namespace V2_1 {
namespace hal {

bool ComposerHandleImporter::init() {
    mMapper4 = mapper::V4_0::IMapper::getService();
    if (mMapper4) {
        return true;
    }
    ALOGI_IF(!mMapper4, "failed to get mapper 4.0 service, falling back to mapper 3.0");

    mMapper3 = mapper::V3_0::IMapper::getService();
    if (mMapper3) {
        return true;
@@ -66,6 +72,16 @@ Error ComposerHandleImporter::importBuffer(const native_handle_t* rawHandle,
            return Error::NO_RESOURCES;
        }
    }
    if (mMapper4) {
        mapper::V4_0::Error error;
        mMapper4->importBuffer(rawHandle, [&](const auto& tmpError, const auto& tmpBufferHandle) {
            error = tmpError;
            bufferHandle = static_cast<const native_handle_t*>(tmpBufferHandle);
        });
        if (error != mapper::V4_0::Error::NONE) {
            return Error::NO_RESOURCES;
        }
    }

    *outBufferHandle = bufferHandle;
    return Error::NONE;
@@ -77,6 +93,8 @@ void ComposerHandleImporter::freeBuffer(const native_handle_t* bufferHandle) {
            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)));
        } else if (mMapper4) {
            mMapper4->freeBuffer(static_cast<void*>(const_cast<native_handle_t*>(bufferHandle)));
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@

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

namespace android {
@@ -51,6 +52,7 @@ class ComposerHandleImporter {
  private:
    sp<mapper::V2_0::IMapper> mMapper2;
    sp<mapper::V3_0::IMapper> mMapper3;
    sp<mapper::V4_0::IMapper> mMapper4;
};

class ComposerHandleCache {