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

Commit 6db8d6e9 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Use Transform in InputDispatcher"

parents 0d155525 1ff3d1e3
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -158,10 +158,6 @@ struct InputWindowInfo : public Parcelable {
    // in scaling of the TOUCH_MAJOR/TOUCH_MINOR axis.
    float globalScaleFactor = 1.0f;

    // Scaling factors applied to individual windows.
    float windowXScale = 1.0f;
    float windowYScale = 1.0f;

    // Transform applied to individual windows.
    ui::Transform transform;

+15 −5
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ bool InputWindowInfo::operator==(const InputWindowInfo& info) const {
            info.frameLeft == frameLeft && info.frameTop == frameTop &&
            info.frameRight == frameRight && info.frameBottom == frameBottom &&
            info.surfaceInset == surfaceInset && info.globalScaleFactor == globalScaleFactor &&
            info.windowXScale == windowXScale && info.windowYScale == windowYScale &&
            info.transform == transform &&
            info.touchableRegion.hasSameRects(touchableRegion) && info.visible == visible &&
            info.canReceiveKeys == canReceiveKeys && info.trustedOverlay == trustedOverlay &&
            info.hasFocus == hasFocus && info.hasWallpaper == hasWallpaper &&
@@ -93,8 +93,12 @@ status_t InputWindowInfo::writeToParcel(android::Parcel* parcel) const {
        parcel->writeInt32(frameBottom) ?:
        parcel->writeInt32(surfaceInset) ?:
        parcel->writeFloat(globalScaleFactor) ?:
        parcel->writeFloat(windowXScale) ?:
        parcel->writeFloat(windowYScale) ?:
        parcel->writeFloat(transform.dsdx()) ?:
        parcel->writeFloat(transform.dtdx()) ?:
        parcel->writeFloat(transform.tx()) ?:
        parcel->writeFloat(transform.dtdy()) ?:
        parcel->writeFloat(transform.dsdy()) ?:
        parcel->writeFloat(transform.ty()) ?:
        parcel->writeBool(visible) ?:
        parcel->writeBool(canReceiveKeys) ?:
        parcel->writeBool(hasFocus) ?:
@@ -132,14 +136,19 @@ status_t InputWindowInfo::readFromParcel(const android::Parcel* parcel) {

    flags = Flags<Flag>(parcel->readInt32());
    type = static_cast<Type>(parcel->readInt32());
    float dsdx, dtdx, tx, dtdy, dsdy, ty;
    status = parcel->readInt32(&frameLeft) ?:
        parcel->readInt32(&frameTop) ?:
        parcel->readInt32(&frameRight) ?:
        parcel->readInt32(&frameBottom) ?:
        parcel->readInt32(&surfaceInset) ?:
        parcel->readFloat(&globalScaleFactor) ?:
        parcel->readFloat(&windowXScale) ?:
        parcel->readFloat(&windowYScale) ?:
        parcel->readFloat(&dsdx) ?:
        parcel->readFloat(&dtdx) ?:
        parcel->readFloat(&tx) ?:
        parcel->readFloat(&dtdy) ?:
        parcel->readFloat(&dsdy) ?:
        parcel->readFloat(&ty) ?:
        parcel->readBool(&visible) ?:
        parcel->readBool(&canReceiveKeys) ?:
        parcel->readBool(&hasFocus) ?:
@@ -165,6 +174,7 @@ status_t InputWindowInfo::readFromParcel(const android::Parcel* parcel) {
    }

    touchableRegionCropHandle = parcel->readStrongBinder();
    transform.set(std::array<float, 9>{dsdx, dtdx, tx, dtdy, dsdy, ty, 0, 0, 1});

    return OK;
}
+2 −4
Original line number Diff line number Diff line
@@ -53,8 +53,7 @@ TEST(InputWindowInfo, Parcelling) {
    i.frameBottom = 19;
    i.surfaceInset = 17;
    i.globalScaleFactor = 0.3;
    i.windowXScale = 0.4;
    i.windowYScale = 0.5;
    i.transform.set(std::array<float, 9>{0.4, -1, 100, 0.5, 0, 40, 0, 0, 1});
    i.visible = false;
    i.canReceiveKeys = false;
    i.hasFocus = false;
@@ -85,8 +84,7 @@ TEST(InputWindowInfo, Parcelling) {
    ASSERT_EQ(i.frameBottom, i2.frameBottom);
    ASSERT_EQ(i.surfaceInset, i2.surfaceInset);
    ASSERT_EQ(i.globalScaleFactor, i2.globalScaleFactor);
    ASSERT_EQ(i.windowXScale, i2.windowXScale);
    ASSERT_EQ(i.windowYScale, i2.windowYScale);
    ASSERT_EQ(i.transform, i2.transform);
    ASSERT_EQ(i.visible, i2.visible);
    ASSERT_EQ(i.canReceiveKeys, i2.canReceiveKeys);
    ASSERT_EQ(i.hasFocus, i2.hasFocus);
+8 −0
Original line number Diff line number Diff line
@@ -133,6 +133,14 @@ float Transform::dsdy() const {
    return mMatrix[1][1];
}

float Transform::getScaleX() const {
    return sqrt(dsdx() * dsdx()) + (dtdx() * dtdx());
}

float Transform::getScaleY() const {
    return sqrt((dtdy() * dtdy()) + (dsdy() * dsdy()));
}

void Transform::reset() {
    mType = IDENTITY;
    for(size_t i = 0; i < 3; i++) {
+3 −0
Original line number Diff line number Diff line
@@ -74,6 +74,9 @@ public:
    float dtdy() const;
    float dsdy() const;

    float getScaleX() const;
    float getScaleY() const;

    // modify the transform
    void        reset();
    void        set(float tx, float ty);
Loading