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

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

Merge changes Ib821aa68,I7d63cdd1 into main

* changes:
  Support BGRA1010102 in bytesPerPixel()
  Check for allocation failure for the readback buffer
parents 7b415ac0 fca60966
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ uint32_t bytesPerPixel(PixelFormat format) {
        case PIXEL_FORMAT_RGBX_8888:
        case PIXEL_FORMAT_BGRA_8888:
        case PIXEL_FORMAT_RGBA_1010102:
        case PIXEL_FORMAT_BGRA_1010102:
            return 4;
        case PIXEL_FORMAT_RGB_888:
            return 3;
@@ -38,9 +39,12 @@ uint32_t bytesPerPixel(PixelFormat format) {
        case PIXEL_FORMAT_R_8:
            return 1;
    }

    return 0;
}



// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,8 @@ enum {
    PIXEL_FORMAT_R_16_UINT     = 0x39,
    PIXEL_FORMAT_RG_1616_UINT  = 0x3a,
    PIXEL_FORMAT_RGBA_10101010 = 0x3b,
    // we really need to kill this off >_>
    PIXEL_FORMAT_BGRA_1010102  = 0x43,
};

typedef int32_t PixelFormat;
+12 −6
Original line number Diff line number Diff line
@@ -7782,6 +7782,11 @@ SurfaceFlinger::setScreenshotSnapshotsAndDisplayState(ScreenshotArgs& args) {
                                                                         attributes.format),
                                                                 1 /* layerCount */, usage,
                                                                 "screenshot");

                            if (const auto status = readbackBuffer->initCheck(); status != OK) {
                                ALOGE("Failed to allocate readback buffer :(: %d", status);
                                return base::unexpected<status_t>(INVALID_OPERATION);
                            } else {
                                mReadbackRequests.emplace_back(*asPhysicalDisplayId(displayId),
                                                               readbackBuffer, args.captureListener,
                                                               args.preserveDisplayColors,
@@ -7791,6 +7796,7 @@ SurfaceFlinger::setScreenshotSnapshotsAndDisplayState(ScreenshotArgs& args) {
                            }
                        }
                    }
                }

                // Non-threaded RenderEngine eventually returns to the main thread a 2nd time
                // to complete the screenshot. Release fences should only be added during the 2nd