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

Commit da53ed09 authored by Robert Carr's avatar Robert Carr Committed by android-build-merger
Browse files

Merge changes I653b84e7,Ieafdc14a into nyc-dev am: abddf727

am: ab864913

* commit 'ab864913':
  Apply position updates immediately.
  Move crop outside of geometry state.

Change-Id: I79522d22667d008d88943a6c8b15e0d2bf19c65d
parents 133887e6 ab864913
Loading
Loading
Loading
Loading
+80 −85
Original line number Original line Diff line number Diff line
@@ -120,8 +120,8 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client,
    mCurrentState.active.w = w;
    mCurrentState.active.w = w;
    mCurrentState.active.h = h;
    mCurrentState.active.h = h;
    mCurrentState.active.transform.set(0, 0);
    mCurrentState.active.transform.set(0, 0);
    mCurrentState.active.crop.makeInvalid();
    mCurrentState.crop.makeInvalid();
    mCurrentState.active.finalCrop.makeInvalid();
    mCurrentState.finalCrop.makeInvalid();
    mCurrentState.z = 0;
    mCurrentState.z = 0;
#ifdef USE_HWC2
#ifdef USE_HWC2
    mCurrentState.alpha = 1.0f;
    mCurrentState.alpha = 1.0f;
@@ -374,8 +374,9 @@ Rect Layer::computeBounds() const {
Rect Layer::computeBounds(const Region& activeTransparentRegion) const {
Rect Layer::computeBounds(const Region& activeTransparentRegion) const {
    const Layer::State& s(getDrawingState());
    const Layer::State& s(getDrawingState());
    Rect win(s.active.w, s.active.h);
    Rect win(s.active.w, s.active.h);
    if (!s.active.crop.isEmpty()) {

        win.intersect(s.active.crop, &win);
    if (!s.crop.isEmpty()) {
        win.intersect(s.crop, &win);
    }
    }
    // subtract the transparent region and snap to the bounds
    // subtract the transparent region and snap to the bounds
    return reduce(win, activeTransparentRegion);
    return reduce(win, activeTransparentRegion);
@@ -386,7 +387,7 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
    // layer's size.
    // layer's size.
    FloatRect crop(getContentCrop());
    FloatRect crop(getContentCrop());


    // the active.crop is the area of the window that gets cropped, but not
    // the crop is the area of the window that gets cropped, but not
    // scaled in any ways.
    // scaled in any ways.
    const State& s(getDrawingState());
    const State& s(getDrawingState());


@@ -398,16 +399,16 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
    // a viewport clipping and a window transform. we should use floating point to fix this.
    // a viewport clipping and a window transform. we should use floating point to fix this.


    Rect activeCrop(s.active.w, s.active.h);
    Rect activeCrop(s.active.w, s.active.h);
    if (!s.active.crop.isEmpty()) {
    if (!s.crop.isEmpty()) {
        activeCrop = s.active.crop;
        activeCrop = s.crop;
    }
    }


    activeCrop = s.active.transform.transform(activeCrop);
    activeCrop = s.active.transform.transform(activeCrop);
    if (!activeCrop.intersect(hw->getViewport(), &activeCrop)) {
    if (!activeCrop.intersect(hw->getViewport(), &activeCrop)) {
        activeCrop.clear();
        activeCrop.clear();
    }
    }
    if (!s.active.finalCrop.isEmpty()) {
    if (!s.finalCrop.isEmpty()) {
        if(!activeCrop.intersect(s.active.finalCrop, &activeCrop)) {
        if(!activeCrop.intersect(s.finalCrop, &activeCrop)) {
            activeCrop.clear();
            activeCrop.clear();
        }
        }
    }
    }
@@ -543,8 +544,8 @@ void Layer::setGeometry(
    // apply the layer's transform, followed by the display's global transform
    // apply the layer's transform, followed by the display's global transform
    // here we're guaranteed that the layer's transform preserves rects
    // here we're guaranteed that the layer's transform preserves rects
    Region activeTransparentRegion(s.activeTransparentRegion);
    Region activeTransparentRegion(s.activeTransparentRegion);
    if (!s.active.crop.isEmpty()) {
    if (!s.crop.isEmpty()) {
        Rect activeCrop(s.active.crop);
        Rect activeCrop(s.crop);
        activeCrop = s.active.transform.transform(activeCrop);
        activeCrop = s.active.transform.transform(activeCrop);
#ifdef USE_HWC2
#ifdef USE_HWC2
        if(!activeCrop.intersect(displayDevice->getViewport(), &activeCrop)) {
        if(!activeCrop.intersect(displayDevice->getViewport(), &activeCrop)) {
@@ -573,8 +574,8 @@ void Layer::setGeometry(
                s.active.w, activeCrop.bottom));
                s.active.w, activeCrop.bottom));
    }
    }
    Rect frame(s.active.transform.transform(computeBounds(activeTransparentRegion)));
    Rect frame(s.active.transform.transform(computeBounds(activeTransparentRegion)));
    if (!s.active.finalCrop.isEmpty()) {
    if (!s.finalCrop.isEmpty()) {
        if(!frame.intersect(s.active.finalCrop, &frame)) {
        if(!frame.intersect(s.finalCrop, &frame)) {
            frame.clear();
            frame.clear();
        }
        }
    }
    }
@@ -799,15 +800,15 @@ void Layer::updateCursorPosition(const sp<const DisplayDevice>& displayDevice) {
    // Apply the layer's transform, followed by the display's global transform
    // Apply the layer's transform, followed by the display's global transform
    // Here we're guaranteed that the layer's transform preserves rects
    // Here we're guaranteed that the layer's transform preserves rects
    Rect win(s.active.w, s.active.h);
    Rect win(s.active.w, s.active.h);
    if (!s.active.crop.isEmpty()) {
    if (!s.crop.isEmpty()) {
        win.intersect(s.active.crop, &win);
        win.intersect(s.crop, &win);
    }
    }
    // Subtract the transparent region and snap to the bounds
    // Subtract the transparent region and snap to the bounds
    Rect bounds = reduce(win, s.activeTransparentRegion);
    Rect bounds = reduce(win, s.activeTransparentRegion);
    Rect frame(s.active.transform.transform(bounds));
    Rect frame(s.active.transform.transform(bounds));
    frame.intersect(displayDevice->getViewport(), &frame);
    frame.intersect(displayDevice->getViewport(), &frame);
    if (!s.active.finalCrop.isEmpty()) {
    if (!s.finalCrop.isEmpty()) {
        frame.intersect(s.active.finalCrop, &frame);
        frame.intersect(s.finalCrop, &frame);
    }
    }
    auto& displayTransform(displayDevice->getTransform());
    auto& displayTransform(displayDevice->getTransform());
    auto position = displayTransform.transform(frame);
    auto position = displayTransform.transform(frame);
@@ -848,15 +849,15 @@ Rect Layer::getPosition(
    // apply the layer's transform, followed by the display's global transform
    // apply the layer's transform, followed by the display's global transform
    // here we're guaranteed that the layer's transform preserves rects
    // here we're guaranteed that the layer's transform preserves rects
    Rect win(s.active.w, s.active.h);
    Rect win(s.active.w, s.active.h);
    if (!s.active.crop.isEmpty()) {
    if (!s.crop.isEmpty()) {
        win.intersect(s.active.crop, &win);
        win.intersect(s.crop, &win);
    }
    }
    // subtract the transparent region and snap to the bounds
    // subtract the transparent region and snap to the bounds
    Rect bounds = reduce(win, s.activeTransparentRegion);
    Rect bounds = reduce(win, s.activeTransparentRegion);
    Rect frame(s.active.transform.transform(bounds));
    Rect frame(s.active.transform.transform(bounds));
    frame.intersect(hw->getViewport(), &frame);
    frame.intersect(hw->getViewport(), &frame);
    if (!s.active.finalCrop.isEmpty()) {
    if (!s.finalCrop.isEmpty()) {
        frame.intersect(s.active.finalCrop, &frame);
        frame.intersect(s.finalCrop, &frame);
    }
    }
    const Transform& tr(hw->getTransform());
    const Transform& tr(hw->getTransform());
    return Rect(tr.transform(frame));
    return Rect(tr.transform(frame));
@@ -1014,9 +1015,9 @@ void Layer::drawWithOpenGL(const sp<const DisplayDevice>& hw,
     */
     */
    Rect win(computeBounds());
    Rect win(computeBounds());


    if (!s.active.finalCrop.isEmpty()) {
    if (!s.finalCrop.isEmpty()) {
        win = s.active.transform.transform(win);
        win = s.active.transform.transform(win);
        if (!win.intersect(s.active.finalCrop, &win)) {
        if (!win.intersect(s.finalCrop, &win)) {
            win.clear();
            win.clear();
        }
        }
        win = s.active.transform.inverse().transform(win);
        win = s.active.transform.inverse().transform(win);
@@ -1179,8 +1180,8 @@ void Layer::computeGeometry(const sp<const DisplayDevice>& hw, Mesh& mesh,
    const Transform tr(hw->getTransform());
    const Transform tr(hw->getTransform());
    const uint32_t hw_h = hw->getHeight();
    const uint32_t hw_h = hw->getHeight();
    Rect win(s.active.w, s.active.h);
    Rect win(s.active.w, s.active.h);
    if (!s.active.crop.isEmpty()) {
    if (!s.crop.isEmpty()) {
        win.intersect(s.active.crop, &win);
        win.intersect(s.crop, &win);
    }
    }
    // subtract the transparent region and snap to the bounds
    // subtract the transparent region and snap to the bounds
    win = reduce(win, s.activeTransparentRegion);
    win = reduce(win, s.activeTransparentRegion);
@@ -1197,11 +1198,11 @@ void Layer::computeGeometry(const sp<const DisplayDevice>& hw, Mesh& mesh,
        rt = s.active.transform.transform(rt);
        rt = s.active.transform.transform(rt);
    }
    }


    if (!s.active.finalCrop.isEmpty()) {
    if (!s.finalCrop.isEmpty()) {
        boundPoint(&lt, s.active.finalCrop);
        boundPoint(&lt, s.finalCrop);
        boundPoint(&lb, s.active.finalCrop);
        boundPoint(&lb, s.finalCrop);
        boundPoint(&rb, s.active.finalCrop);
        boundPoint(&rb, s.finalCrop);
        boundPoint(&rt, s.active.finalCrop);
        boundPoint(&rt, s.finalCrop);
    }
    }


    Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>());
    Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>());
@@ -1397,38 +1398,26 @@ uint32_t Layer::doTransaction(uint32_t flags) {
        ALOGD_IF(DEBUG_RESIZE,
        ALOGD_IF(DEBUG_RESIZE,
                "doTransaction: geometry (layer=%p '%s'), tr=%02x, scalingMode=%d\n"
                "doTransaction: geometry (layer=%p '%s'), tr=%02x, scalingMode=%d\n"
                "  current={ active   ={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }\n"
                "  current={ active   ={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }\n"
                "            requested={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }}\n"
                "            requested={ wh={%4u,%4u} }}\n"
                "  drawing={ active   ={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }\n"
                "  drawing={ active   ={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }\n"
                "            requested={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }}\n",
                "            requested={ wh={%4u,%4u} }}\n",
                this, getName().string(), mCurrentTransform, mCurrentScalingMode,
                this, getName().string(), mCurrentTransform, mCurrentScalingMode,
                c.active.w, c.active.h,
                c.active.w, c.active.h,
                c.active.crop.left,
                c.crop.left,
                c.active.crop.top,
                c.crop.top,
                c.active.crop.right,
                c.crop.right,
                c.active.crop.bottom,
                c.crop.bottom,
                c.active.crop.getWidth(),
                c.crop.getWidth(),
                c.active.crop.getHeight(),
                c.crop.getHeight(),
                c.requested.w, c.requested.h,
                c.requested.w, c.requested.h,
                c.requested.crop.left,
                c.requested.crop.top,
                c.requested.crop.right,
                c.requested.crop.bottom,
                c.requested.crop.getWidth(),
                c.requested.crop.getHeight(),
                s.active.w, s.active.h,
                s.active.w, s.active.h,
                s.active.crop.left,
                s.crop.left,
                s.active.crop.top,
                s.crop.top,
                s.active.crop.right,
                s.crop.right,
                s.active.crop.bottom,
                s.crop.bottom,
                s.active.crop.getWidth(),
                s.crop.getWidth(),
                s.active.crop.getHeight(),
                s.crop.getHeight(),
                s.requested.w, s.requested.h,
                s.requested.w, s.requested.h);
                s.requested.crop.left,
                s.requested.crop.top,
                s.requested.crop.right,
                s.requested.crop.bottom,
                s.requested.crop.getWidth(),
                s.requested.crop.getHeight());


        // record the new size, form this point on, when the client request
        // record the new size, form this point on, when the client request
        // a buffer, it'll get the new size.
        // a buffer, it'll get the new size.
@@ -1504,7 +1493,13 @@ bool Layer::setPosition(float x, float y) {
    if (mCurrentState.requested.transform.tx() == x && mCurrentState.requested.transform.ty() == y)
    if (mCurrentState.requested.transform.tx() == x && mCurrentState.requested.transform.ty() == y)
        return false;
        return false;
    mCurrentState.sequence++;
    mCurrentState.sequence++;

    // We update the requested and active position simultaneously because
    // we want to apply the position portion of the transform matrix immediately,
    // but still delay scaling when resizing a SCALING_MODE_FREEZE layer.
    mCurrentState.requested.transform.set(x, y);
    mCurrentState.requested.transform.set(x, y);
    mCurrentState.active.transform.set(x, y);

    mCurrentState.modified = true;
    mCurrentState.modified = true;
    setTransactionFlags(eTransactionNeeded);
    setTransactionFlags(eTransactionNeeded);
    return true;
    return true;
@@ -1566,19 +1561,19 @@ bool Layer::setFlags(uint8_t flags, uint8_t mask) {
    return true;
    return true;
}
}
bool Layer::setCrop(const Rect& crop) {
bool Layer::setCrop(const Rect& crop) {
    if (mCurrentState.requested.crop == crop)
    if (mCurrentState.crop == crop)
        return false;
        return false;
    mCurrentState.sequence++;
    mCurrentState.sequence++;
    mCurrentState.requested.crop = crop;
    mCurrentState.crop = crop;
    mCurrentState.modified = true;
    mCurrentState.modified = true;
    setTransactionFlags(eTransactionNeeded);
    setTransactionFlags(eTransactionNeeded);
    return true;
    return true;
}
}
bool Layer::setFinalCrop(const Rect& crop) {
bool Layer::setFinalCrop(const Rect& crop) {
    if (mCurrentState.requested.finalCrop == crop)
    if (mCurrentState.finalCrop == crop)
        return false;
        return false;
    mCurrentState.sequence++;
    mCurrentState.sequence++;
    mCurrentState.requested.finalCrop = crop;
    mCurrentState.finalCrop = crop;
    mCurrentState.modified = true;
    mCurrentState.modified = true;
    setTransactionFlags(eTransactionNeeded);
    setTransactionFlags(eTransactionNeeded);
    return true;
    return true;
@@ -1741,11 +1736,15 @@ Region Layer::latchBuffer(bool& recomputeVisibleRegions)
            Layer::State& current;
            Layer::State& current;
            bool& recomputeVisibleRegions;
            bool& recomputeVisibleRegions;
            bool stickyTransformSet;
            bool stickyTransformSet;
            const char* name;

            Reject(Layer::State& front, Layer::State& current,
            Reject(Layer::State& front, Layer::State& current,
                    bool& recomputeVisibleRegions, bool stickySet)
                    bool& recomputeVisibleRegions, bool stickySet,
                    const char* name)
                : front(front), current(current),
                : front(front), current(current),
                  recomputeVisibleRegions(recomputeVisibleRegions),
                  recomputeVisibleRegions(recomputeVisibleRegions),
                  stickyTransformSet(stickySet) {
                  stickyTransformSet(stickySet),
                  name(name) {
            }
            }


            virtual bool reject(const sp<GraphicBuffer>& buf,
            virtual bool reject(const sp<GraphicBuffer>& buf,
@@ -1788,32 +1787,28 @@ Region Layer::latchBuffer(bool& recomputeVisibleRegions)
                    }
                    }


                    ALOGD_IF(DEBUG_RESIZE,
                    ALOGD_IF(DEBUG_RESIZE,
                            "latchBuffer/reject: buffer (%ux%u, tr=%02x), scalingMode=%d\n"
                            "[%s] latchBuffer/reject: buffer (%ux%u, tr=%02x), scalingMode=%d\n"
                            "  drawing={ active   ={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }\n"
                            "  drawing={ active   ={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }\n"
                            "            requested={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }}\n",
                            "            requested={ wh={%4u,%4u} }}\n",
                            name,
                            bufWidth, bufHeight, item.mTransform, item.mScalingMode,
                            bufWidth, bufHeight, item.mTransform, item.mScalingMode,
                            front.active.w, front.active.h,
                            front.active.w, front.active.h,
                            front.active.crop.left,
                            front.crop.left,
                            front.active.crop.top,
                            front.crop.top,
                            front.active.crop.right,
                            front.crop.right,
                            front.active.crop.bottom,
                            front.crop.bottom,
                            front.active.crop.getWidth(),
                            front.crop.getWidth(),
                            front.active.crop.getHeight(),
                            front.crop.getHeight(),
                            front.requested.w, front.requested.h,
                            front.requested.w, front.requested.h);
                            front.requested.crop.left,
                            front.requested.crop.top,
                            front.requested.crop.right,
                            front.requested.crop.bottom,
                            front.requested.crop.getWidth(),
                            front.requested.crop.getHeight());
                }
                }


                if (!isFixedSize && !stickyTransformSet) {
                if (!isFixedSize && !stickyTransformSet) {
                    if (front.active.w != bufWidth ||
                    if (front.active.w != bufWidth ||
                        front.active.h != bufHeight) {
                        front.active.h != bufHeight) {
                        // reject this buffer
                        // reject this buffer
                        ALOGE("rejecting buffer: bufWidth=%d, bufHeight=%d, front.active.{w=%d, h=%d}",
                        ALOGE("[%s] rejecting buffer: "
                                bufWidth, bufHeight, front.active.w, front.active.h);
                                "bufWidth=%d, bufHeight=%d, front.active.{w=%d, h=%d}",
                                name, bufWidth, bufHeight, front.active.w, front.active.h);
                        return true;
                        return true;
                    }
                    }
                }
                }
@@ -1843,7 +1838,7 @@ Region Layer::latchBuffer(bool& recomputeVisibleRegions)
        };
        };


        Reject r(mDrawingState, getCurrentState(), recomputeVisibleRegions,
        Reject r(mDrawingState, getCurrentState(), recomputeVisibleRegions,
                getProducerStickyTransform() != 0);
                getProducerStickyTransform() != 0, mName.string());




        // Check all of our local sync points to ensure that all transactions
        // Check all of our local sync points to ensure that all transactions
@@ -2086,10 +2081,10 @@ void Layer::dump(String8& result, Colorizer& colorizer) const
#endif
#endif
            "      client=%p\n",
            "      client=%p\n",
            s.layerStack, s.z, s.active.transform.tx(), s.active.transform.ty(), s.active.w, s.active.h,
            s.layerStack, s.z, s.active.transform.tx(), s.active.transform.ty(), s.active.w, s.active.h,
            s.active.crop.left, s.active.crop.top,
            s.crop.left, s.crop.top,
            s.active.crop.right, s.active.crop.bottom,
            s.crop.right, s.crop.bottom,
            s.active.finalCrop.left, s.active.finalCrop.top,
            s.finalCrop.left, s.finalCrop.top,
            s.active.finalCrop.right, s.active.finalCrop.bottom,
            s.finalCrop.right, s.finalCrop.bottom,
            isOpaque(s), contentDirty,
            isOpaque(s), contentDirty,
            s.alpha, s.flags,
            s.alpha, s.flags,
            s.active.transform[0][0], s.active.transform[0][1],
            s.active.transform[0][0], s.active.transform[0][1],
+4 −3
Original line number Original line Diff line number Diff line
@@ -93,12 +93,10 @@ public:
    struct Geometry {
    struct Geometry {
        uint32_t w;
        uint32_t w;
        uint32_t h;
        uint32_t h;
        Rect crop;
        Rect finalCrop;
        Transform transform;
        Transform transform;


        inline bool operator ==(const Geometry& rhs) const {
        inline bool operator ==(const Geometry& rhs) const {
            return (w == rhs.w && h == rhs.h && crop == rhs.crop);
          return (w == rhs.w && h == rhs.h);
        }
        }
        inline bool operator !=(const Geometry& rhs) const {
        inline bool operator !=(const Geometry& rhs) const {
            return !operator ==(rhs);
            return !operator ==(rhs);
@@ -121,6 +119,9 @@ public:
        int32_t sequence; // changes when visible regions can change
        int32_t sequence; // changes when visible regions can change
        bool modified;
        bool modified;


        Rect crop;
        Rect finalCrop;

        // If set, defers this state update until the Layer identified by handle
        // If set, defers this state update until the Layer identified by handle
        // receives a frame with the given frameNumber
        // receives a frame with the given frameNumber
        sp<IBinder> handle;
        sp<IBinder> handle;