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

Commit 73b81e75 authored by Andy McFadden's avatar Andy McFadden
Browse files

Minor fixes to android.graphics.Matrix

Tweaked equals() and finalize(), introduced trivial hashCode().

(Also picked up a handful of automatic trailing-space removals.)

Bug 9756081

Change-Id: I4639cf1e970a16179fa6c0d24785f4d0dfbe58ed
parent 4a909500
Loading
Loading
Loading
Loading
+29 −13
Original line number Diff line number Diff line
@@ -270,10 +270,20 @@ public class Matrix {

    /** Returns true iff obj is a Matrix and its values equal our values.
    */
    @Override
    public boolean equals(Object obj) {
        return obj != null &&
               obj instanceof Matrix &&
               native_equals(native_instance, ((Matrix)obj).native_instance);
        //if (obj == this) return true;     -- NaN value would mean matrix != itself
        if (!(obj instanceof Matrix)) return false;
        return native_equals(native_instance, ((Matrix)obj).native_instance);
    }

    @Override
    public int hashCode() {
        // This should generate the hash code by performing some arithmetic operation on all
        // the matrix elements -- our equals() does an element-by-element comparison, and we
        // need to ensure that the hash code for two equal objects is the same.  We're not
        // really using this at the moment, so we take the easy way out.
        return 44;
    }

    /** Set the matrix to identity */
@@ -736,6 +746,7 @@ public class Matrix {
        native_setValues(native_instance, values);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder(64);
        sb.append("Matrix{");
@@ -783,8 +794,13 @@ public class Matrix {

    }

    @Override
    protected void finalize() throws Throwable {
        try {
            finalizer(native_instance);
        } finally {
            super.finalize();
        }
    }

    /*package*/ final int ni() {