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

Commit e0b83ae1 authored by Jeykumar Sankaran's avatar Jeykumar Sankaran Committed by Steve Kondik
Browse files

frameworks/native: Modify dirtyRect only on GPU pre-rotation

Modify layer dirtyRect only when the buffers are pre-rotated by
GPU, not when the buffers are scheduled to be rotated during
composition.

Conflicts:
        services/surfaceflinger/Layer.cpp

Change-Id: I283833b9989be3032ce03fd955cea500b9bc4ae4
parent 9163a89a
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -325,8 +325,12 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) {
    Rect crop;
    mCrop.intersect(Rect(buffer->width, buffer->height), &crop);

    Rect dirtyRect = mDirtyRect.isEmpty() ?
        Rect(buffer->width, buffer->height) : mDirtyRect;
    Rect dirtyRect = mDirtyRect;
    if(dirtyRect.isEmpty()) {
        int drWidth = mUserWidth ? mUserWidth : mDefaultWidth;
        int drHeight = mUserHeight ? mUserHeight : mDefaultHeight;
        dirtyRect = Rect(drWidth, drHeight);
    }

    sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE);
    IGraphicBufferProducer::QueueBufferOutput output;
+46 −34
Original line number Diff line number Diff line
@@ -385,6 +385,47 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
    return crop;
}

Transform Layer::computeBufferTransform(const sp<const DisplayDevice>& hw)
{
    const State& s(getDrawingState());
    const Transform& tr(hw->getTransform());
    /*
     * Transformations are applied in this order:
     * 1) buffer orientation/flip/mirror
     * 2) state transformation (window manager)
     * 3) layer orientation (screen orientation)
     * (NOTE: the matrices are multiplied in reverse order)
     */

    const Transform bufferOrientation(mCurrentTransform);
    Transform transform(tr * s.transform * bufferOrientation);

    if (mSurfaceFlingerConsumer->getTransformToDisplayInverse()) {
        /*
         * the code below applies the display's inverse transform to the buffer
         */
        uint32_t invTransform = hw->getOrientationTransform();
        uint32_t t_orientation = transform.getOrientation();
        // calculate the inverse transform
        if (invTransform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
            invTransform ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
                    NATIVE_WINDOW_TRANSFORM_FLIP_H;
            // If the transform has been rotated the axis of flip has been swapped
            // so we need to swap which flip operations we are performing
            bool is_h_flipped = (t_orientation & NATIVE_WINDOW_TRANSFORM_FLIP_H) != 0;
            bool is_v_flipped = (t_orientation & NATIVE_WINDOW_TRANSFORM_FLIP_V) != 0;
            if (is_h_flipped != is_v_flipped) {
                t_orientation ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
                        NATIVE_WINDOW_TRANSFORM_FLIP_H;
        }

        }
        // and apply to the current transform
        transform = Transform(t_orientation) * Transform(invTransform);
    }
    return transform;
}

void Layer::setGeometry(
    const sp<const DisplayDevice>& hw,
        HWComposer::HWCLayerInterface& layer)
@@ -431,39 +472,7 @@ void Layer::setGeometry(
    layer.setCrop(computeCrop(hw));
    layer.setPlaneAlpha(s.alpha);

    /*
     * Transformations are applied in this order:
     * 1) buffer orientation/flip/mirror
     * 2) state transformation (window manager)
     * 3) layer orientation (screen orientation)
     * (NOTE: the matrices are multiplied in reverse order)
     */

    const Transform bufferOrientation(mCurrentTransform);
    Transform transform(tr * s.transform * bufferOrientation);

    if (mSurfaceFlingerConsumer->getTransformToDisplayInverse()) {
        /*
         * the code below applies the display's inverse transform to the buffer
         */
        uint32_t invTransform = hw->getOrientationTransform();
        uint32_t t_orientation = transform.getOrientation();
        // calculate the inverse transform
        if (invTransform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
            invTransform ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
                    NATIVE_WINDOW_TRANSFORM_FLIP_H;
            // If the transform has been rotated the axis of flip has been swapped
            // so we need to swap which flip operations we are performing
            bool is_h_flipped = (t_orientation & NATIVE_WINDOW_TRANSFORM_FLIP_H) != 0;
            bool is_v_flipped = (t_orientation & NATIVE_WINDOW_TRANSFORM_FLIP_V) != 0;
            if (is_h_flipped != is_v_flipped) {
                t_orientation ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
                        NATIVE_WINDOW_TRANSFORM_FLIP_H;
            }
        }
        // and apply to the current transform
        transform = Transform(t_orientation) * Transform(invTransform);
    }
    Transform transform = computeBufferTransform(hw);

    // this gives us only the "orientation" component of the transform
    const uint32_t orientation = transform.getOrientation();
@@ -475,6 +484,8 @@ void Layer::setGeometry(
    }
}



void Layer::setPerFrameData(const sp<const DisplayDevice>& hw,
        HWComposer::HWCLayerInterface& layer) {
    // we have to set the visible region on every frame because
@@ -495,7 +506,8 @@ void Layer::setPerFrameData(const sp<const DisplayDevice>& hw,
    }

    Rect dirtyRect =  mSurfaceFlingerConsumer->getCurrentDirtyRect();
    if((mActiveBuffer != NULL) && mTransformHint &&
    int bufferOrientation = computeBufferTransform(hw).getOrientation();
    if((mActiveBuffer != NULL) && mTransformHint && !bufferOrientation &&
       (mTransformHint != NATIVE_WINDOW_TRANSFORM_FLIP_H) &&
       (mTransformHint != NATIVE_WINDOW_TRANSFORM_FLIP_V)) {
        /* DirtyRect is generated by HWR without any knowledge of GPU
+1 −0
Original line number Diff line number Diff line
@@ -341,6 +341,7 @@ private:
    FloatRect computeCrop(const sp<const DisplayDevice>& hw) const;
    bool isCropped() const;
    static bool getOpacityForFormat(uint32_t format);
    Transform computeBufferTransform(const sp<const DisplayDevice>& hw);

    // drawing
    void clearWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip,