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

Commit 60fb539c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Align SurfaceView better to overscroll stretch" into main

parents fe3d8f6f 08828204
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -214,3 +214,13 @@ flag {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
  name: "surfaceview_stretch_alignment"
  namespace: "core_graphics"
  description: "Fix SurfaceView alignment when overscroll stretch is occurring"
  bug: "419836766"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}
+55 −26
Original line number Diff line number Diff line
@@ -15,6 +15,9 @@
 */

#define ATRACE_TAG ATRACE_TAG_VIEW
#ifdef __linux__
#include <com_android_graphics_hwui_flags.h>
#endif
#include <Animator.h>
#include <DamageAccumulator.h>
#include <Matrix.h>
@@ -36,6 +39,14 @@ using namespace uirenderer;
        ? (reinterpret_cast<RenderNode*>(renderNodePtr)->setPropertyFieldsDirty(dirtyFlag), true) \
        : false)

bool surfaceview_stretch_alignment() {
#ifdef __linux__
    return com::android::graphics::hwui::flags::surfaceview_stretch_alignment();
#else
    return true;
#endif
}

// ----------------------------------------------------------------------------
// DisplayList view properties
// ----------------------------------------------------------------------------
@@ -708,6 +719,23 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
                info.damageAccumulator->findNearestStretchEffect();
            const StretchEffect* effect = result.stretchEffect;
            if (effect) {
                if (surfaceview_stretch_alignment()) {
                    auto& parentBounds = result.parentBounds;
                    auto parentWidth = parentBounds.width();
                    auto parentHeight = parentBounds.height();
                    float normalized;
                    normalized = targetBounds.top / parentHeight;
                    targetBounds.top = effect->computeStretchedPositionY(normalized) * parentHeight;
                    normalized = targetBounds.bottom / parentHeight;
                    targetBounds.bottom =
                            effect->computeStretchedPositionY(normalized) * parentHeight;

                    normalized = targetBounds.left / parentWidth;
                    targetBounds.left = effect->computeStretchedPositionX(normalized) * parentWidth;
                    normalized = targetBounds.right / parentWidth;
                    targetBounds.right =
                            effect->computeStretchedPositionX(normalized) * parentWidth;
                } else {
                    // Compute the number of pixels that the stretching container
                    // scales by.
                    // Then compute the scale factor that the child would need
@@ -734,6 +762,7 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
                    targetBounds.top = dst.top();
                    targetBounds.right = dst.right();
                    targetBounds.bottom = dst.bottom();
                }
            } else {
                return;
            }