summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2013-07-15 16:04:32 -0700
committerztenghui <ztenghui@google.com>2013-07-15 16:04:32 -0700
commit9448b353e8cb1936fb62262b8c4962cfd3765bab (patch)
treeebbd615e368992c6ac80b233d89ab53bc1b86343 /src
parentd4d6505a75371dbfac01beaa2059e0b2075e990f (diff)
downloadandroid_packages_apps_Snap-9448b353e8cb1936fb62262b8c4962cfd3765bab.tar.gz
android_packages_apps_Snap-9448b353e8cb1936fb62262b8c4962cfd3765bab.tar.bz2
android_packages_apps_Snap-9448b353e8cb1936fb62262b8c4962cfd3765bab.zip
Add equality check into FilterCurveRep
Consequently add equality check support in Spline and ControlPoint. bug:9468909 Change-Id: I8078b994beac4056ca92e76da0e15d618389e56e
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java23
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/MasterImage.java4
-rw-r--r--src/com/android/gallery3d/filtershow/ui/ControlPoint.java17
-rw-r--r--src/com/android/gallery3d/filtershow/ui/Spline.java22
4 files changed, 64 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java
index a71aa8863..569ead957 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java
@@ -58,6 +58,7 @@ public class FilterCurvesRepresentation extends FilterRepresentation {
mSplines = spline;
}
+ @Override
public boolean isNil() {
for (int i = 0; i < MAX_SPLINE_NUMBER; i++) {
if (getSpline(i) != null && !getSpline(i).isOriginal()) {
@@ -67,6 +68,27 @@ public class FilterCurvesRepresentation extends FilterRepresentation {
return true;
}
+ @Override
+ public boolean equals(FilterRepresentation representation) {
+ if (!super.equals(representation)) {
+ return false;
+ }
+
+ if (!(representation instanceof FilterCurvesRepresentation)) {
+ return false;
+ } else {
+ FilterCurvesRepresentation curve =
+ (FilterCurvesRepresentation) representation;
+ for (int i = 0; i < MAX_SPLINE_NUMBER; i++) {
+ if (!getSpline(i).sameValues(curve.getSpline(i))) {
+ return false;
+ }
+ }
+ }
+ // Every spline matches, therefore they are the same.
+ return true;
+ }
+
public void reset() {
Spline spline = new Spline();
@@ -81,6 +103,7 @@ public class FilterCurvesRepresentation extends FilterRepresentation {
public void setSpline(int splineIndex, Spline s) {
mSplines[splineIndex] = s;
}
+
public Spline getSpline(int splineIndex) {
return mSplines[splineIndex];
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
index 08d8c45eb..ed09fb116 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
@@ -198,7 +198,7 @@ public class MasterImage implements RenderingRequestCaller {
return false;
}
int sw = SMALL_BITMAP_DIM;
- int sh = (int) (sw * (float) mOriginalBitmapLarge.getHeight() / (float) mOriginalBitmapLarge
+ int sh = (int) (sw * (float) mOriginalBitmapLarge.getHeight() / mOriginalBitmapLarge
.getWidth());
mOriginalBitmapSmall = Bitmap.createScaledBitmap(mOriginalBitmapLarge, sw, sh, true);
mZoomOrientation = mOrientation;
@@ -325,7 +325,7 @@ public class MasterImage implements RenderingRequestCaller {
if (loadedPreset == null) {
return mPreset.hasModifications();
} else {
- return !mPreset.equals(getLoadedPreset());
+ return !mPreset.equals(loadedPreset);
}
}
}
diff --git a/src/com/android/gallery3d/filtershow/ui/ControlPoint.java b/src/com/android/gallery3d/filtershow/ui/ControlPoint.java
index 73589d373..a95364b27 100644
--- a/src/com/android/gallery3d/filtershow/ui/ControlPoint.java
+++ b/src/com/android/gallery3d/filtershow/ui/ControlPoint.java
@@ -30,6 +30,23 @@ public class ControlPoint implements Comparable {
y = point.y;
}
+ public boolean sameValues(ControlPoint other) {
+ if (this == other) {
+ return true;
+ }
+ if (other == null) {
+ return false;
+ }
+
+ if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x)) {
+ return false;
+ }
+ if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y)) {
+ return false;
+ }
+ return true;
+ }
+
public ControlPoint copy() {
return new ControlPoint(x, y);
}
diff --git a/src/com/android/gallery3d/filtershow/ui/Spline.java b/src/com/android/gallery3d/filtershow/ui/Spline.java
index cadf2fd9c..5b931a98c 100644
--- a/src/com/android/gallery3d/filtershow/ui/Spline.java
+++ b/src/com/android/gallery3d/filtershow/ui/Spline.java
@@ -83,6 +83,28 @@ public class Spline {
return Color.WHITE;
}
+ public boolean sameValues(Spline other) {
+ if (this == other) {
+ return true;
+ }
+ if (other == null) {
+ return false;
+ }
+
+ if (getNbPoints() != other.getNbPoints()) {
+ return false;
+ }
+
+ for (int i = 0; i < getNbPoints(); i++) {
+ ControlPoint p = mPoints.elementAt(i);
+ ControlPoint otherPoint = other.mPoints.elementAt(i);
+ if (!p.sameValues(otherPoint)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
private void didMovePoint(ControlPoint point) {
mCurrentControlPoint = point;
}