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

Commit cc7bcd07 authored by John Hoford's avatar John Hoford Committed by Android (Google) Code Review
Browse files

Merge "Fix Curves" into gb-ub-photos-bryce

parents ef95774e d009e383
Loading
Loading
Loading
Loading
+30 −3
Original line number Diff line number Diff line
package com.android.gallery3d.filtershow.filters;

import android.util.Log;

import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.ui.Spline;

@@ -7,6 +9,8 @@ import com.android.gallery3d.filtershow.ui.Spline;
 * TODO: Insert description here. (generated by hoford)
 */
public class FilterCurvesRepresentation extends FilterRepresentation {
    private static final String LOGTAG = "FilterCurvesRepresentation";

    private Spline[] mSplines = new Spline[4];

    public FilterCurvesRepresentation() {
@@ -20,10 +24,33 @@ public class FilterCurvesRepresentation extends FilterRepresentation {
        setShowParameterValue(false);
        setShowUtilityPanel(true);
        setSupportsPartialRendering(true);
        for (int i = 0; i < mSplines.length; i++) {
            mSplines[i] = new Spline();
            mSplines[i].reset();
        reset();
    }

    @Override
    public FilterRepresentation clone() throws CloneNotSupportedException {
        FilterCurvesRepresentation rep = new FilterCurvesRepresentation();
        rep.useParametersFrom(this);
        return rep;
    }

    @Override
    public void useParametersFrom(FilterRepresentation a) {
        if (!(a instanceof FilterCurvesRepresentation)) {
            Log.v(LOGTAG, "cannot use parameters from " + a);
            return;
        }
        FilterCurvesRepresentation representation = (FilterCurvesRepresentation) a;
        Spline[] spline = new Spline[4];
        for (int i = 0; i < spline.length; i++) {
            Spline sp = representation.mSplines[i];
            if (sp != null) {
                spline[i] = new Spline(sp);
            } else {
                spline[i] = new Spline();
            }
        }
        mSplines = spline;
    }

    public boolean isNil() {
+4 −3
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.os.AsyncTask;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
@@ -157,7 +158,7 @@ public class ImageCurves extends ImageShow {
    }

    private Spline getSpline(int index) {
        return curves().getSpline(index);
        return mFilterCurvesRepresentation.getSpline(index);
    }

    @Override
@@ -169,8 +170,8 @@ public class ImageCurves extends ImageShow {
    }

    public void resetCurve() {
        if (curves() != null) {
            curves().reset();
        if (mFilterCurvesRepresentation != null) {
            mFilterCurvesRepresentation.reset();
            updateCachedImage();
        }
    }
+4 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ public class Spline {
    }

    public boolean isOriginal() {
        if (this.getNbPoints() > 2) {
        if (this.getNbPoints() != 2) {
            return false;
        }
        if (mPoints.elementAt(0).x != 0 || mPoints.elementAt(0).y != 1) {
@@ -378,6 +378,9 @@ public class Spline {

    public void deletePoint(int n) {
        mPoints.remove(n);
        if (mPoints.size() < 2) {
            reset();
        }
        Collections.sort(mPoints);
    }