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

Commit fababf51 authored by Saurabh Shah's avatar Saurabh Shah Committed by Giulio Cervera
Browse files

SurfaceTextureClient: Add support for external only usage flags.

Add support for GRALLOC_USAGE_EXTERNAL_ONLY and
GRALLOC_USAGE_EXTERNAL_BLOCK to be set as a part of usage flags.
These flags if present will be cached by SurfaceTextureClient.
Incoming usage flags will be ORed with these, if present.

(cherry picked from commit dcbd475319bae2f5d0613bf62d8324169e6ab79d)

Change-Id: I366f6a664805e8944663600dc3b1f82530275873
parent a335541c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -168,6 +168,16 @@ private:
    mutable Region              mOldDirtyRegion;
#endif
    bool                        mConnectedToCpu;

#ifdef QCOM_HARDWARE
    // mReqExtUsage is a flag set by app to mark a layer for display on
    // external panels only. Depending on the value of this flag mReqUsage
    // will be ORed with existing values.
    // Possible values GRALLOC_USAGE_EXTERNAL_ONLY and
    // GRALLOC_USAGE_EXTERNAL_BLOCK
    // It is initialized to 0
    uint32_t mReqExtUsage;
#endif
};

}; // namespace android
+21 −0
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ void SurfaceTextureClient::init() {
    mReqHeight = 0;
    mReqFormat = 0;
    mReqUsage = 0;
#ifdef QCOM_HARDWARE
    mReqExtUsage = 0;
#endif
    mTimestamp = NATIVE_WINDOW_TIMESTAMP_AUTO;
    mDefaultWidth = 0;
    mDefaultHeight = 0;
@@ -473,7 +476,25 @@ int SurfaceTextureClient::setUsage(uint32_t reqUsage)
{
    LOGV("SurfaceTextureClient::setUsage");
    Mutex::Autolock lock(mMutex);
#ifdef QCOM_HARDWARE
    if (reqUsage & GRALLOC_USAGE_EXTERNAL_ONLY) {
        //Set explicitly, since reqUsage may have other values.
        mReqExtUsage = GRALLOC_USAGE_EXTERNAL_ONLY;
        //This flag is never independent. Always an add-on to
        //GRALLOC_USAGE_EXTERNAL_ONLY
        if(reqUsage & GRALLOC_USAGE_EXTERNAL_BLOCK) {
            mReqExtUsage |= GRALLOC_USAGE_EXTERNAL_BLOCK;
        }
    }
    // For most cases mReqExtUsage will be 0.
    // reqUsage could come from app or driver. When it comes from app
    // and subsequently from driver, the latter ends up overwriting
    // the existing values. We cache certain values in mReqExtUsage
    // to avoid being overwritten.
    mReqUsage = reqUsage | mReqExtUsage;
#else
    mReqUsage = reqUsage;
#endif
    return OK;
}