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

Commit f4795f51 authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

Use kTopLeft_GrSurfaceOrigin when generating a GPU buffer for CPU readback.

When attempting to read back a buffer from the GPU, Skia will perform a
y-flip of the buffer in CPU memory if the buffer does not have a
top-left origin.

Test: CtsUiRenderingTestCases
Bug: 119366261
Change-Id: I93ec93cc31209cbdd9b886b0d1020fda3aac646e
parent 260d75ff
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -164,14 +164,15 @@ bool Readback::copyLayerInto(Layer* layer, const SkRect* srcRect, const SkRect*
     * with reading incorrect data from EGLImage backed SkImage (likely a driver bug).
     */
    sk_sp<SkSurface> tmpSurface = SkSurface::MakeRenderTarget(mRenderThread.getGrContext(),
                                                              SkBudgeted::kYes, bitmap->info());
                                                              SkBudgeted::kYes, bitmap->info(), 0,
                                                              kTopLeft_GrSurfaceOrigin, nullptr);

    // if we can't generate a GPU surface that matches the destination bitmap (e.g. 565) then we
    // attempt to do the intermediate rendering step in 8888
    if (!tmpSurface.get()) {
        SkImageInfo tmpInfo = bitmap->info().makeColorType(SkColorType::kN32_SkColorType);
        tmpSurface = SkSurface::MakeRenderTarget(mRenderThread.getGrContext(), SkBudgeted::kYes,
                                                 tmpInfo);
                                                 tmpInfo, 0, kTopLeft_GrSurfaceOrigin, nullptr);
        if (!tmpSurface.get()) {
            ALOGW("Unable to generate GPU buffer in a format compatible with the provided bitmap");
            return false;