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

Commit fede5ccc authored by Sushil Chauhan's avatar Sushil Chauhan Committed by Linux Build Service Account
Browse files

SurfaceFlinger: Add support to set RGBA color on Dim Layer

SF client can set RGBA color on Dim Layer. Black is default color.

CRs-Fixed: 1047307
Change-Id: I74d3b14b365a9ac8aaf2ecbf906ba00711643f53
parent ade61bb3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ public:
    status_t    setSize(const sp<IBinder>& id, uint32_t w, uint32_t h);
    status_t    setCrop(const sp<IBinder>& id, const Rect& crop);
    status_t    setFinalCrop(const sp<IBinder>& id, const Rect& crop);
    status_t    setColor(const sp<IBinder>& id, uint32_t color);
    status_t    setLayerStack(const sp<IBinder>& id, uint32_t layerStack);
    status_t    deferTransactionUntil(const sp<IBinder>& id,
            const sp<IBinder>& handle, uint64_t frameNumber);
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public:
    status_t    setMatrix(float dsdx, float dtdx, float dsdy, float dtdy);
    status_t    setCrop(const Rect& crop);
    status_t    setFinalCrop(const Rect& crop);
    status_t    setColor(uint32_t color);

    // If the size changes in this transaction, position updates specified
    // in this transaction will not complete until a buffer of the new size
+3 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ struct layer_state_t {
        eFinalCropChanged           = 0x00000400,
        eOverrideScalingModeChanged = 0x00000800,
        ePositionAppliesWithResize  = 0x00001000,
        eColorChanged               = 0x00002000,
    };

    layer_state_t()
@@ -64,7 +65,7 @@ struct layer_state_t {
            alpha(0), flags(0), mask(0),
            reserved(0), crop(Rect::INVALID_RECT),
            finalCrop(Rect::INVALID_RECT), frameNumber(0),
            overrideScalingMode(-1)
            overrideScalingMode(-1), color(0)
    {
        matrix.dsdx = matrix.dtdy = 1.0f;
        matrix.dsdy = matrix.dtdx = 0.0f;
@@ -99,6 +100,7 @@ struct layer_state_t {
            int32_t         overrideScalingMode;
            // non POD must be last. see write/read
            Region          transparentRegion;
            uint32_t        color;
};

struct ComposerState {
+21 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2016, The Linux Foundation. All rights reserved.
 * Not a Contribution
 *
 *
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -167,6 +171,8 @@ public:
            const sp<IBinder>& id, int32_t overrideScalingMode);
    status_t setPositionAppliesWithResize(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id);
    status_t setColor(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id, uint32_t color);

    void setDisplaySurface(const sp<IBinder>& token,
            const sp<IGraphicBufferProducer>& bufferProducer);
@@ -457,6 +463,17 @@ status_t Composer::setPositionAppliesWithResize(
    return NO_ERROR;
}

status_t Composer::setColor(const sp<SurfaceComposerClient>& client,
        const sp<IBinder>& id, uint32_t color) {
    Mutex::Autolock _l(mLock);
    layer_state_t* s = getLayerStateLocked(client, id);
    if (!s)
        return BAD_INDEX;
    s->what |= layer_state_t::eColorChanged;
    s->color = color;
    return NO_ERROR;
}

// ---------------------------------------------------------------------------

DisplayState& Composer::getDisplayStateLocked(const sp<IBinder>& token) {
@@ -704,6 +721,10 @@ status_t SurfaceComposerClient::setPositionAppliesWithResize(
    return getComposer().setPositionAppliesWithResize(this, id);
}

status_t SurfaceComposerClient::setColor(const sp<IBinder>& id, uint32_t color) {
    return getComposer().setColor(this, id, color);
}

// ----------------------------------------------------------------------------

void SurfaceComposerClient::setDisplaySurface(const sp<IBinder>& token,
+9 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2016, The Linux Foundation. All rights reserved.
 * Not a Contribution
 *
 *
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -162,6 +166,11 @@ status_t SurfaceControl::setFinalCrop(const Rect& crop) {
    if (err < 0) return err;
    return mClient->setFinalCrop(mHandle, crop);
}
status_t SurfaceControl::setColor(uint32_t color) {
    status_t err = validate();
    if (err < 0) return err;
    return mClient->setColor(mHandle, color);
}

status_t SurfaceControl::deferTransactionUntil(sp<IBinder> handle,
        uint64_t frameNumber) {
Loading