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

Commit 23d74380 authored by Prabhanjan Kandula's avatar Prabhanjan Kandula Committed by Linux Build Service Account
Browse files

sf : Fix vertices & texture coordinates computation.

Compute crop and display frame for GPU composition also
in the same way it's done for HWC and compute vertices
and texture coordinates for GPU composition. This avoids
pixel shifts in output of GPU composition & overlays.

Change-Id: Ia4c649ef236f5684fb76ff1b4b802a9d01c1da0c
parent c8cbc20d
Loading
Loading
Loading
Loading
+40 −18
Original line number Diff line number Diff line
@@ -421,7 +421,7 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
    return crop;
}

Transform Layer::computeBufferTransform(const sp<const DisplayDevice>& hw)
Transform Layer::computeBufferTransform(const sp<const DisplayDevice>& hw) const
{
    const State& s(getDrawingState());
    const Transform& tr(hw->getTransform());
@@ -797,22 +797,22 @@ void Layer::drawWithOpenGL(const sp<const DisplayDevice>& hw,

    computeGeometry(hw, mMesh, useIdentityTransform);

    /*
     * NOTE: the way we compute the texture coordinates here produces
     * different results than when we take the HWC path -- in the later case
     * the "source crop" is rounded to texel boundaries.
     * This can produce significantly different results when the texture
     * is scaled by a large amount.
     *
     * The GL code below is more logical (imho), and the difference with
     * HWC is due to a limitation of the HWC API to integers -- a question
     * is suspend is whether we should ignore this problem or revert to
     * GL composition when a buffer scaling is applied (maybe with some
     * minimal value)? Or, we could make GL behave like HWC -- but this feel
     * like more of a hack.
     */
    const Rect win(computeBounds());

    // Compute the crops exactly in the way we are doing
    // for HWC & program texture coordinates for the clipped
    // source after transformation.
    Rect win(s.active.w, s.active.h);
    if(!s.active.crop.isEmpty()) {
        win = s.active.crop;
    }
#ifdef QCOM_BSP
    win = s.transform.transform(win);
    win.intersect(hw->getViewport(), &win);
    win = s.transform.inverse().transform(win);
    win.intersect(Rect(s.active.w, s.active.h), &win);
    win = reduce(win, s.activeTransparentRegion);
#else
    win = reduce(win, s.activeTransparentRegion);
#endif
    float left   = float(win.left)   / float(s.active.w);
    float top    = float(win.top)    / float(s.active.h);
    float right  = float(win.right)  / float(s.active.w);
@@ -880,15 +880,37 @@ void Layer::computeGeometry(const sp<const DisplayDevice>& hw, Mesh& mesh,
        bool useIdentityTransform) const
{
    const Layer::State& s(getDrawingState());
    const Transform tr(useIdentityTransform ?
    Transform tr(useIdentityTransform ?
            hw->getTransform() : hw->getTransform() * s.transform);
    const uint32_t hw_h = hw->getHeight();
    Rect win(s.active.w, s.active.h);
    if (!s.active.crop.isEmpty()) {
        win.intersect(s.active.crop, &win);
    }

#ifdef QCOM_BSP
    win = s.transform.transform(win);
    win.intersect(hw->getViewport(), &win);
    win = s.transform.inverse().transform(win);
    win.intersect(Rect(s.active.w, s.active.h), &win);
    win = reduce(win, s.activeTransparentRegion);
    Transform transform = computeBufferTransform(hw);
    const uint32_t orientation = transform.getOrientation();
    // If rotation or pre-rotation is there we can't match HWC 100%.
    // Still, we can make sure input vertices to GPU is based ROI on screen
    // after applying layer transform.

    if (!(mTransformHint | mCurrentTransform | orientation)) {
        tr = hw->getTransform();
        if(!useIdentityTransform) {
            win = s.transform.transform(win);
            win.intersect(hw->getViewport(), &win);
        }
    }
#else
    // subtract the transparent region and snap to the bounds
    win = reduce(win, s.activeTransparentRegion);
#endif

    Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>());
    position[0] = tr.transform(win.left,  win.top);
+1 −1
Original line number Diff line number Diff line
@@ -352,7 +352,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);
    Transform computeBufferTransform(const sp<const DisplayDevice>& hw) const;

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