From e887fa594f5eb3a88601e68c4c7b073bd719e565 Mon Sep 17 00:00:00 2001 From: John Hoford Date: Tue, 30 Jul 2013 16:02:10 -0700 Subject: clean up some bugs and update the icons Change-Id: I6952bae8cfea2ec64064f3126eece93687c02eae --- .../filters/FilterGradRepresentation.java | 62 ++++++++-------------- .../filtershow/filters/ImageFilterGrad.java | 11 ---- .../android/gallery3d/filtershow/filters/grad.rs | 10 ---- .../gallery3d/filtershow/imageshow/ImageGrad.java | 9 ++-- 4 files changed, 26 insertions(+), 66 deletions(-) (limited to 'src/com/android/gallery3d') diff --git a/src/com/android/gallery3d/filtershow/filters/FilterGradRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterGradRepresentation.java index 1bfce6f05..64e7fb0c9 100644 --- a/src/com/android/gallery3d/filtershow/filters/FilterGradRepresentation.java +++ b/src/com/android/gallery3d/filtershow/filters/FilterGradRepresentation.java @@ -42,7 +42,7 @@ public class FilterGradRepresentation extends FilterRepresentation super("Grad"); setSerializationName(SERIALIZATION_NAME); creatExample(); - setOverlayId(R.drawable.filtershow_button_colors_vignette); + setOverlayId(R.drawable.filtershow_button_grad); setFilterClass(ImageFilterGrad.class); setTextId(R.string.grad); setEditorId(EditorGrad.ID); @@ -63,7 +63,7 @@ public class FilterGradRepresentation extends FilterRepresentation static class Band { private boolean mask = true; - private boolean active = true; + private int xPos1 = -1; private int yPos1 = 100; private int xPos2 = -1; @@ -71,7 +71,7 @@ public class FilterGradRepresentation extends FilterRepresentation private int brightness = 40; private int contrast = 0; private int saturation = 0; - private boolean inking; + public Band() { } @@ -85,7 +85,6 @@ public class FilterGradRepresentation extends FilterRepresentation public Band(Band copy) { mask = copy.mask; - active = copy.active; xPos1 = copy.xPos1; yPos1 = copy.yPos1; xPos2 = copy.xPos2; @@ -93,7 +92,6 @@ public class FilterGradRepresentation extends FilterRepresentation brightness = copy.brightness; contrast = copy.contrast; saturation = copy.saturation; - inking = copy.inking; } } @@ -112,7 +110,6 @@ public class FilterGradRepresentation extends FilterRepresentation private void creatExample() { Band p = new Band(); p.mask = false; - p.active = true; p.xPos1 = -1; p.yPos1 = 100; p.xPos2 = -1; @@ -120,7 +117,6 @@ public class FilterGradRepresentation extends FilterRepresentation p.brightness = 40; p.contrast = 0; p.saturation = 0; - p.inking = false; mBands.add(0, p); mCurrentBand = p; trimVector(); @@ -155,7 +151,26 @@ public class FilterGradRepresentation extends FilterRepresentation @Override public boolean equals(FilterRepresentation representation) { if (representation instanceof FilterGradRepresentation) { - return true; // TODO much more extensive equals needed + FilterGradRepresentation rep = (FilterGradRepresentation) representation; + int n = getNumberOfBands(); + if (rep.getNumberOfBands() != n) { + return false; + } + for (int i = 0; i < mBands.size(); i++) { + Band b1 = mBands.get(i); + Band b2 = rep.mBands.get(i); + if (b1.mask != b2.mask + || b1.brightness != b2.brightness + || b1.contrast != b2.contrast + || b1.saturation != b2.saturation + || b1.xPos1 != b2.xPos1 + || b1.xPos2 != b2.xPos2 + || b1.yPos1 != b2.yPos1 + || b1.yPos2 != b2.yPos2) { + return false; + } + } + return true; } return false; } @@ -170,17 +185,6 @@ public class FilterGradRepresentation extends FilterRepresentation return count; } - public void toggleInking() { - mCurrentBand.inking = !mCurrentBand.inking; - } - - public void setInking(boolean on) { - for (Band point : mBands) { - point.inking = false; - } - mCurrentBand.inking = on; - } - public int addBand(Rect rect) { mBands.add(0, mCurrentBand = new Band(rect.centerX(), rect.centerY())); mCurrentBand.mask = false; @@ -278,17 +282,6 @@ public class FilterGradRepresentation extends FilterRepresentation return ret; } - public boolean[] getActive() { - boolean[] ret = new boolean[mBands.size()]; - int i = 0; - String s = ""; - for (Band point : mBands) { - ret[i++] = point.active; - s += (point.active) ? "1" : "0"; - } - return ret; - } - public int[] getXPos1() { int[] ret = new int[mBands.size()]; int i = 0; @@ -352,15 +345,6 @@ public class FilterGradRepresentation extends FilterRepresentation return ret; } - public boolean[] getInking() { - boolean[] ret = new boolean[mBands.size()]; - int i = 0; - for (Band point : mBands) { - ret[i++] = point.inking; - } - return ret; - } - public int getParameter(int type) { switch (type){ case PARAM_BRIGHTNESS: diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java index e5e9f13f5..cbdfaa623 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java @@ -117,15 +117,6 @@ public class ImageFilterGrad extends ImageFilterRS { mScript.set_inputHeight(height); } - private boolean hasInk() { - boolean[] ink = mParameters.getInking(); - for (int i = 0; i < ink.length; i++) { - if (ink[i]) - return true; - } - return false; - } - @Override protected void runFilter() { int[] x1 = mParameters.getXPos1(); @@ -151,7 +142,6 @@ public class ImageFilterGrad extends ImageFilterRS { } mScript.set_mask(mParameters.getMask()); - mScript.set_active(mParameters.getActive()); mScript.set_xPos1(x1); mScript.set_yPos1(y1); mScript.set_xPos2(x2); @@ -160,7 +150,6 @@ public class ImageFilterGrad extends ImageFilterRS { mScript.set_brightness(mParameters.getBrightness()); mScript.set_contrast(mParameters.getContrast()); mScript.set_saturation(mParameters.getSaturation()); - mScript.set_inking(mParameters.getInking()); mScript.invoke_setupGradParams(); runSelectiveAdjust( diff --git a/src/com/android/gallery3d/filtershow/filters/grad.rs b/src/com/android/gallery3d/filtershow/filters/grad.rs index 42e1e5faf..ddbafd349 100644 --- a/src/com/android/gallery3d/filtershow/filters/grad.rs +++ b/src/com/android/gallery3d/filtershow/filters/grad.rs @@ -27,8 +27,6 @@ static const float Bf = 0.114f; //static const float size_scale = 0.01f; typedef struct { - bool active; - bool inking; rs_matrix3x3 colorMatrix; float rgbOff; float dx; @@ -38,7 +36,6 @@ typedef struct { int mNumberOfLines; // input data bool mask[MAX_POINTS]; -bool active[MAX_POINTS]; int xPos1[MAX_POINTS]; int yPos1[MAX_POINTS]; int xPos2[MAX_POINTS]; @@ -47,8 +44,6 @@ int size[MAX_POINTS]; int brightness[MAX_POINTS]; int contrast[MAX_POINTS]; int saturation[MAX_POINTS]; -bool inking[MAX_POINTS]; - // generated data static UPointData grads[MAX_POINTS]; @@ -56,7 +51,6 @@ static UPointData grads[MAX_POINTS]; void setupGradParams() { int k = 0; for (int i = 0; i < MAX_POINTS; i++) { - grads[i].active = false; if (!mask[i]) { continue; } @@ -67,7 +61,6 @@ void setupGradParams() { float denom = (y2 * y2 - 2 * y1 * y2 + x2 * x2 - 2 * x1 * x2 + y1 * y1 + x1 * x1); if (denom == 0) { - grads[i].active = false; continue; } grads[k].dy = (y1 - y2) / denom; @@ -94,9 +87,6 @@ void setupGradParams() { rsMatrixSet(&grads[i].colorMatrix, 1, 2, b * Gt); rsMatrixSet(&grads[i].colorMatrix, 2, 2, b * (Bt + S)); - - grads[k].active = true; - grads[k].inking = inking[i]; k++; } mNumberOfLines = k; diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageGrad.java b/src/com/android/gallery3d/filtershow/imageshow/ImageGrad.java index ef72e8a6e..b55cc2bc4 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageGrad.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageGrad.java @@ -30,7 +30,7 @@ public class ImageGrad extends ImageShow { private static final String LOGTAG = "ImageGrad"; private FilterGradRepresentation mGradRep; private EditorGrad mEditorGrad; - private int mMinTouchDist; + private float mMinTouchDist; private int mActiveHandle = -1; private GradControl mEllipse; @@ -48,6 +48,8 @@ public class ImageGrad extends ImageShow { public ImageGrad(Context context, AttributeSet attrs) { super(context, attrs); + Resources res = context.getResources(); + mMinTouchDist = res.getDimensionPixelSize(R.dimen.gradcontrol_min_touch_dist); mEllipse = new GradControl(context); mEllipse.setShowReshapeHandles(false); } @@ -56,10 +58,6 @@ public class ImageGrad extends ImageShow { public boolean onTouchEvent(MotionEvent event) { int mask = event.getActionMasked(); - if (mask == MotionEvent.ACTION_DOWN || mask == MotionEvent.ACTION_UP) { - mGradRep.setInking(MotionEvent.ACTION_DOWN == mask); - } - if (mActiveHandle == -1) { if (MotionEvent.ACTION_DOWN != mask) { return super.onTouchEvent(event); @@ -87,7 +85,6 @@ public class ImageGrad extends ImageShow { if (pos != -1) { mGradRep.setSelectedPoint(pos); - mGradRep.setInking(true); resetImageCaches(this); mEditorGrad.updateSeekBar(mGradRep); mEditorGrad.commitLocalRepresentation(); -- cgit v1.2.3