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

Commit bb09b436 authored by Courtney Goeltzenleuchter's avatar Courtney Goeltzenleuchter
Browse files

Make dataspace accessible to surface flinger

http://b/29940137

Keep track of dataspace in GLConsumer and make it
available to surfaceflinger's Layer class.

Test: TBD
Change-Id: I099dc6d8424909c5fc31bfe2d05a656695c4251b
parent 5f541b96
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -146,6 +146,10 @@ public:
    // documented by the source.
    int64_t getTimestamp();

    // getDataSpace retrieves the DataSpace associated with the texture image
    // set by the most recent call to updateTexImage.
    android_dataspace getCurrentDataSpace();

    // getFrameNumber retrieves the frame number associated with the texture
    // image set by the most recent call to updateTexImage.
    //
@@ -414,6 +418,10 @@ private:
    // gets set each time updateTexImage is called.
    int64_t mCurrentTimestamp;

    // mCurrentDataSpace is the dataspace for the current texture. It
    // gets set each time updateTexImage is called.
    android_dataspace mCurrentDataSpace;

    // mCurrentFrameNumber is the frame counter for the current texture.
    // It gets set each time updateTexImage is called.
    uint64_t mCurrentFrameNumber;
+10 −0
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ GLConsumer::GLConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex,
    mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
    mCurrentFence(Fence::NO_FENCE),
    mCurrentTimestamp(0),
    mCurrentDataSpace(HAL_DATASPACE_UNKNOWN),
    mCurrentFrameNumber(0),
    mDefaultWidth(1),
    mDefaultHeight(1),
@@ -185,6 +186,7 @@ GLConsumer::GLConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t texTarget,
    mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
    mCurrentFence(Fence::NO_FENCE),
    mCurrentTimestamp(0),
    mCurrentDataSpace(HAL_DATASPACE_UNKNOWN),
    mCurrentFrameNumber(0),
    mDefaultWidth(1),
    mDefaultHeight(1),
@@ -321,6 +323,7 @@ status_t GLConsumer::releaseTexImage() {
        mCurrentCrop.makeInvalid();
        mCurrentTransform = 0;
        mCurrentTimestamp = 0;
        mCurrentDataSpace = HAL_DATASPACE_UNKNOWN;
        mCurrentFence = Fence::NO_FENCE;
        mCurrentFenceTime = FenceTime::NO_FENCE;

@@ -488,6 +491,7 @@ status_t GLConsumer::updateAndReleaseLocked(const BufferItem& item,
    mCurrentTransform = item.mTransform;
    mCurrentScalingMode = item.mScalingMode;
    mCurrentTimestamp = item.mTimestamp;
    mCurrentDataSpace = item.mDataSpace;
    mCurrentFence = item.mFence;
    mCurrentFenceTime = item.mFenceTime;
    mCurrentFrameNumber = item.mFrameNumber;
@@ -914,6 +918,12 @@ nsecs_t GLConsumer::getTimestamp() {
    return mCurrentTimestamp;
}

android_dataspace GLConsumer::getCurrentDataSpace() {
    GLC_LOGV("getCurrentDataSpace");
    Mutex::Autolock lock(mMutex);
    return mCurrentDataSpace;
}

uint64_t GLConsumer::getFrameNumber() {
    GLC_LOGV("getFrameNumber");
    Mutex::Autolock lock(mMutex);
+21 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client,
    mCurrentState.flags = layerFlags;
    mCurrentState.sequence = 0;
    mCurrentState.requested = mCurrentState.active;
    mCurrentState.dataSpace = HAL_DATASPACE_UNKNOWN;

    // drawing state & current state are identical
    mDrawingState = mCurrentState;
@@ -751,6 +752,14 @@ void Layer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) {
        setCompositionType(hwcId, HWC2::Composition::Device);
    }

    ALOGV("setPerFrameData: dataspace = %d", mCurrentState.dataSpace);
    error = hwcLayer->setDataspace(mCurrentState.dataSpace);
    if (error != HWC2::Error::None) {
        ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(),
              mCurrentState.dataSpace, to_string(error).c_str(),
              static_cast<int32_t>(error));
    }

    auto acquireFence = mSurfaceFlingerConsumer->getCurrentFence();
    error = hwcLayer->setBuffer(mActiveBuffer->handle, acquireFence);
    if (error != HWC2::Error::None) {
@@ -1680,6 +1689,16 @@ bool Layer::setLayerStack(uint32_t layerStack) {
    return true;
}

bool Layer::setDataSpace(android_dataspace dataSpace) {
    if (mCurrentState.dataSpace == dataSpace)
        return false;
    mCurrentState.sequence++;
    mCurrentState.dataSpace = dataSpace;
    mCurrentState.modified = true;
    setTransactionFlags(eTransactionNeeded);
    return true;
}

void Layer::deferTransactionUntil(const sp<IBinder>& handle,
        uint64_t frameNumber) {
    mCurrentState.handle = handle;
@@ -1993,6 +2012,8 @@ Region Layer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime)
        recomputeVisibleRegions = true;
     }

    setDataSpace(mSurfaceFlingerConsumer->getCurrentDataSpace());

    Rect crop(mSurfaceFlingerConsumer->getCurrentCrop());
    const uint32_t transform(mSurfaceFlingerConsumer->getCurrentTransform());
    const uint32_t scalingMode(mSurfaceFlingerConsumer->getCurrentScalingMode());
+2 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ public:
        // dependent.
        Region activeTransparentRegion;
        Region requestedTransparentRegion;
        android_dataspace dataSpace;
    };

    // -----------------------------------------------------------------------
@@ -164,6 +165,7 @@ public:
    bool setCrop(const Rect& crop, bool immediate);
    bool setFinalCrop(const Rect& crop);
    bool setLayerStack(uint32_t layerStack);
    bool setDataSpace(android_dataspace dataSpace);
    void deferTransactionUntil(const sp<IBinder>& handle, uint64_t frameNumber);
    bool setOverrideScalingMode(int32_t overrideScalingMode);