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

Commit 0f6a4129 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

Attach color space information when attach and queue buffer.

Currently when calling attachAndQueueBuffer, the color space information is
lost. This results in color shift if the color space doesn't match the color
space of the surface.

BUG: b/135002842, b/131928312
Test: boot. Manually verified on P19
Change-Id: I1d77c9994f50d9a2f5cfde96ca805f7142fddfab
parent 57e20651
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -1920,7 +1920,8 @@ status_t Surface::getAndFlushRemovedBuffers(std::vector<sp<GraphicBuffer>>* out)
    return OK;
}

status_t Surface::attachAndQueueBuffer(Surface* surface, sp<GraphicBuffer> buffer) {
status_t Surface::attachAndQueueBufferWithDataspace(Surface* surface, sp<GraphicBuffer> buffer,
                                                    Dataspace dataspace) {
    if (buffer == nullptr) {
        return BAD_VALUE;
    }
@@ -1929,6 +1930,11 @@ status_t Surface::attachAndQueueBuffer(Surface* surface, sp<GraphicBuffer> buffe
    if (err != OK) {
        return err;
    }
    ui::Dataspace tmpDataspace = surface->getBuffersDataSpace();
    err = surface->setBuffersDataSpace(dataspace);
    if (err != OK) {
        return err;
    }
    err = surface->attachBuffer(buffer->getNativeBuffer());
    if (err != OK) {
        return err;
@@ -1937,6 +1943,10 @@ status_t Surface::attachAndQueueBuffer(Surface* surface, sp<GraphicBuffer> buffe
    if (err != OK) {
        return err;
    }
    err = surface->setBuffersDataSpace(tmpDataspace);
    if (err != OK) {
        return err;
    }
    err = surface->disconnect(NATIVE_WINDOW_API_CPU);
    return err;
}
+2 −1
Original line number Diff line number Diff line
@@ -292,7 +292,8 @@ public:

    ui::Dataspace getBuffersDataSpace();

    static status_t attachAndQueueBuffer(Surface* surface, sp<GraphicBuffer> buffer);
    static status_t attachAndQueueBufferWithDataspace(Surface* surface, sp<GraphicBuffer> buffer,
                                                      ui::Dataspace dataspace);

protected:
    enum { NUM_BUFFER_SLOTS = BufferQueueDefs::NUM_BUFFER_SLOTS };