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

Commit ae4d0538 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Use std::array and default copy assignment for PointerCoords

Bug: 245989146
Test: atest inputflinger_tests
Change-Id: I5e008d03184204a2f34f369e2d5958f6cd4de952
parent 15c01e27
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -366,7 +366,7 @@ struct PointerCoords {

    // Values of axes that are stored in this structure packed in order by axis id
    // for each axis that is present in the structure according to 'bits'.
    float values[MAX_AXES];
    std::array<float, MAX_AXES> values;

    inline void clear() {
        BitSet64::clear(bits);
@@ -406,7 +406,8 @@ struct PointerCoords {
        return !(*this == other);
    }

    void copyFrom(const PointerCoords& other);
    inline void copyFrom(const PointerCoords& other) { *this = other; }
    PointerCoords& operator=(const PointerCoords&) = default;

private:
    void tooManyAxes(int axis);
+0 −8
Original line number Diff line number Diff line
@@ -438,14 +438,6 @@ bool PointerCoords::operator==(const PointerCoords& other) const {
    return true;
}

void PointerCoords::copyFrom(const PointerCoords& other) {
    bits = other.bits;
    uint32_t count = BitSet64::count(bits);
    for (uint32_t i = 0; i < count; i++) {
        values[i] = other.values[i];
    }
}

void PointerCoords::transform(const ui::Transform& transform) {
    const vec2 xy = transform.transform(getXYValue());
    setAxisValue(AMOTION_EVENT_AXIS_X, xy.x);
+2 −2
Original line number Diff line number Diff line
@@ -304,8 +304,8 @@ static void getHalPropertiesAndCoords(const NotifyMotionArgs& args,
        common::PointerCoords coords;
        // OK to copy bits because we have static_assert for pointerCoords axes
        coords.bits = args.pointerCoords[i].bits;
        coords.values = std::vector<float>(args.pointerCoords[i].values,
                                           args.pointerCoords[i].values +
        coords.values = std::vector<float>(args.pointerCoords[i].values.cbegin(),
                                           args.pointerCoords[i].values.cbegin() +
                                                   BitSet64::count(args.pointerCoords[i].bits));
        outPointerCoords.push_back(coords);
    }