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

Commit 68ac0bcf authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "C2AllocatorGralloc: Resolve implementation defined format." into main

parents c6464fd9 9d482890
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <aidl/android/hardware/graphics/common/PlaneLayoutComponentType.h>
#include <android/hardware/graphics/common/1.2/types.h>
#include <cutils/native_handle.h>
#include <drm/drm_fourcc.h>
#include <gralloctypes/Gralloc4.h>
#include <hardware/gralloc.h>
#include <ui/GraphicBufferAllocator.h>
@@ -478,7 +479,25 @@ c2_status_t C2AllocationGralloc::map(
    // 'NATIVE' on Android means LITTLE_ENDIAN
    constexpr C2PlaneInfo::endianness_t kEndianness = C2PlaneInfo::NATIVE;

    switch (mFormat) {
    // Try to resolve IMPLEMENTATION_DEFINED format to accurate format if
    // possible.
    uint32_t format = mFormat;
    uint32_t fourCc;
    if (format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED &&
        !GraphicBufferMapper::get().getPixelFormatFourCC(mBuffer, &fourCc)) {
        switch (fourCc)  {
            case DRM_FORMAT_XBGR8888:
                 format = static_cast<uint32_t>(PixelFormat4::RGBX_8888);
                 break;
            case DRM_FORMAT_ABGR8888:
                 format = static_cast<uint32_t>(PixelFormat4::RGBA_8888);
                 break;
            default:
                 break;
        }
    }

    switch (format) {
        case static_cast<uint32_t>(PixelFormat4::RGBA_1010102): {
            // TRICKY: this is used for media as YUV444 in the case when it is queued directly to a
            // Surface. In all other cases it is RGBA. We don't know which case it is here, so