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

Commit c1c05de4 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

fix camera API 2.0 orientation

we add a flag to ANativeWindow::setBufferTransform that means
"apply the inverse rotation of the display this buffer is displayed
onto to".

Bug: 10804238
Change-Id: Id2447676271950463e8dbcef1b95935c5c3f32b2
parent 799f5126
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -91,6 +91,10 @@ public:

        // Indicates whether this buffer has been seen by a consumer yet
        bool mAcquireCalled;

        // Indicates this buffer must be transformed by the inverse transform of the screen
        // it is displayed onto. This is applied after mTransform.
        bool mTransformToDisplayInverse;
    };


+1 −1
Original line number Diff line number Diff line
@@ -245,7 +245,7 @@ template <template<typename T> class BASE, typename T>
class TMatDebug {
public:
    String8 asString() const {
        return matrix::asString(*this);
        return matrix::asString( static_cast< const BASE<T>& >(*this) );
    }
};

+2 −1
Original line number Diff line number Diff line
@@ -557,7 +557,8 @@ status_t BufferQueue::queueBuffer(int buf,
        item.mAcquireCalled = mSlots[buf].mAcquireCalled;
        item.mGraphicBuffer = mSlots[buf].mGraphicBuffer;
        item.mCrop = crop;
        item.mTransform = transform;
        item.mTransform = transform & ~NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;
        item.mTransformToDisplayInverse = bool(transform & NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY);
        item.mScalingMode = scalingMode;
        item.mTimestamp = timestamp;
        item.mIsAutoTimestamp = isAutoTimestamp;
+6 −2
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ IGraphicBufferConsumer::BufferItem::BufferItem() :
    mFrameNumber(0),
    mBuf(INVALID_BUFFER_SLOT),
    mIsDroppable(false),
    mAcquireCalled(false) {
    mAcquireCalled(false),
    mTransformToDisplayInverse(false) {
    mCrop.makeInvalid();
}

@@ -60,7 +61,8 @@ size_t IGraphicBufferConsumer::BufferItem::getPodSize() const {
            sizeof(mFrameNumber) +
            sizeof(mBuf) +
            sizeof(mIsDroppable) +
            sizeof(mAcquireCalled);
            sizeof(mAcquireCalled) +
            sizeof(mTransformToDisplayInverse);
    return c;
}

@@ -130,6 +132,7 @@ status_t IGraphicBufferConsumer::BufferItem::flatten(
    FlattenableUtils::write(buffer, size, mBuf);
    FlattenableUtils::write(buffer, size, mIsDroppable);
    FlattenableUtils::write(buffer, size, mAcquireCalled);
    FlattenableUtils::write(buffer, size, mTransformToDisplayInverse);

    return NO_ERROR;
}
@@ -171,6 +174,7 @@ status_t IGraphicBufferConsumer::BufferItem::unflatten(
    FlattenableUtils::read(buffer, size, mBuf);
    FlattenableUtils::read(buffer, size, mIsDroppable);
    FlattenableUtils::read(buffer, size, mAcquireCalled);
    FlattenableUtils::read(buffer, size, mTransformToDisplayInverse);

    return NO_ERROR;
}
+19 −0
Original line number Diff line number Diff line
@@ -344,6 +344,25 @@ void DisplayDevice::setLayerStack(uint32_t stack) {

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

uint32_t DisplayDevice::getOrientationTransform() const {
    uint32_t transform = 0;
    switch (mOrientation) {
        case DisplayState::eOrientationDefault:
            transform = Transform::ROT_0;
            break;
        case DisplayState::eOrientation90:
            transform = Transform::ROT_90;
            break;
        case DisplayState::eOrientation180:
            transform = Transform::ROT_180;
            break;
        case DisplayState::eOrientation270:
            transform = Transform::ROT_270;
            break;
    }
    return transform;
}

status_t DisplayDevice::orientationToTransfrom(
        int orientation, int w, int h, Transform* tr)
{
Loading