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

Commit e3f51f51 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.

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

#ifdef QCOM_BSP
    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);
    }
#endif

    sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE);
+36 −25
Original line number Diff line number Diff line
@@ -350,6 +350,37 @@ 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();
        // calculate the inverse transform
        if (invTransform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
            invTransform ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
                    NATIVE_WINDOW_TRANSFORM_FLIP_H;
        }
        // and apply to the current transform
        transform = transform * Transform(invTransform);
    }
    return transform;
}

void Layer::setGeometry(
    const sp<const DisplayDevice>& hw,
        HWComposer::HWCLayerInterface& layer)
@@ -405,30 +436,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();
        // calculate the inverse transform
        if (invTransform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
            invTransform ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
                    NATIVE_WINDOW_TRANSFORM_FLIP_H;
        }
        // and apply to the current transform
        transform = transform * Transform(invTransform);
    }
    Transform transform = computeBufferTransform(hw);

    // this gives us only the "orientation" component of the transform
    const uint32_t orientation = transform.getOrientation();
@@ -440,6 +448,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
@@ -453,7 +463,8 @@ void Layer::setPerFrameData(const sp<const DisplayDevice>& hw,

#ifdef QCOM_BSP
    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
@@ -333,6 +333,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,