summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2013-02-27 08:41:19 -0800
committerJohn Hoford <hoford@google.com>2013-02-27 17:32:01 -0800
commit54b3d67486c05343471e520cdc8d9b882cb0483f (patch)
tree77f598ad8e912bf57922ef82129b344f5dc74e1a /src
parent91b7dda504552881be7ece059373d33ccfb2d369 (diff)
downloadandroid_packages_apps_Snap-54b3d67486c05343471e520cdc8d9b882cb0483f.tar.gz
android_packages_apps_Snap-54b3d67486c05343471e520cdc8d9b882cb0483f.tar.bz2
android_packages_apps_Snap-54b3d67486c05343471e520cdc8d9b882cb0483f.zip
refactor the geometry code
Change-Id: I5b0381ec5e127aabf37924af64fbeb490755bc9a
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java18
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java28
2 files changed, 40 insertions, 6 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index 83f2a1b87..5dd72c9cd 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -30,6 +30,7 @@ public class FilterRepresentation implements Cloneable {
private int mEditorId = BasicEditor.ID;
private int mButtonId = 0;
private int mOverlayId = 0;
+ private boolean mOverlayOnly = false;
private boolean mShowEditingControls = true;
private boolean mShowParameterValue = true;
private boolean mShowUtilityPanel = true;
@@ -58,6 +59,7 @@ public class FilterRepresentation implements Cloneable {
representation.setEditorId(getEditorId());
representation.setButtonId(getButtonId());
representation.setOverlayId(getOverlayId());
+ representation.setOverlayOnly(getOverlayOnly());
representation.setShowEditingControls(showEditingControls());
representation.setShowParameterValue(showParameterValue());
representation.setShowUtilityPanel(showUtilityPanel());
@@ -77,6 +79,7 @@ public class FilterRepresentation implements Cloneable {
&& representation.mEditorId == mEditorId
&& representation.mButtonId == mButtonId
&& representation.mOverlayId == mOverlayId
+ && representation.mOverlayOnly == mOverlayOnly
&& representation.mShowEditingControls == mShowEditingControls
&& representation.mShowParameterValue == mShowParameterValue
&& representation.mShowUtilityPanel == mShowUtilityPanel) {
@@ -181,10 +184,23 @@ public class FilterRepresentation implements Cloneable {
mOverlayId = overlayId;
}
- public int getEditorId() {
+ public boolean getOverlayOnly() {
+ return mOverlayOnly;
+ }
+
+ public void setOverlayOnly(boolean value) {
+ mOverlayOnly = value;
+ }
+
+ final public int getEditorId() {
return mEditorId;
}
+ public int[] getEditorIds() {
+ return new int[] {
+ mEditorId };
+ }
+
public void setEditorId(int editorId) {
mEditorId = editorId;
}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index 1400fd4de..7ceed733b 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -130,9 +130,13 @@ public class ImagePreset {
public void updateFilterRepresentation(FilterRepresentation representation) {
synchronized (mFilters) {
- int position = getPositionForRepresentation(representation);
- FilterRepresentation old = mFilters.elementAt(position);
- old.updateTempParametersFrom(representation);
+ if (representation instanceof GeometryMetadata) {
+ setGeometry((GeometryMetadata) representation);
+ } else {
+ int position = getPositionForRepresentation(representation);
+ FilterRepresentation old = mFilters.elementAt(position);
+ old.updateTempParametersFrom(representation);
+ }
}
MasterImage.getImage().invalidatePreview();
}
@@ -191,6 +195,7 @@ public class ImagePreset {
public synchronized void setGeometry(GeometryMetadata m) {
mGeoData.set(m);
+ MasterImage.getImage().notifyGeometryChange();
}
private void setBorder(FilterRepresentation filter) {
@@ -327,7 +332,10 @@ public class ImagePreset {
}
public void addFilter(FilterRepresentation representation) {
- Log.v(LOGTAG, "*** Add Filter *** " + representation);
+ if (representation instanceof GeometryMetadata) {
+ setGeometry((GeometryMetadata) representation);
+ return;
+ }
if (representation.getPriority() == FilterRepresentation.TYPE_BORDER) {
setHistoryName(representation.getName());
setBorder(representation);
@@ -359,6 +367,9 @@ public class ImagePreset {
}
public FilterRepresentation getRepresentation(FilterRepresentation filterRepresentation) {
+ if (filterRepresentation instanceof GeometryMetadata) {
+ return mGeoData;
+ }
for (int i = 0; i < mFilters.size(); i++) {
FilterRepresentation representation = mFilters.elementAt(i);
if (representation.getFilterClass() == filterRepresentation.getFilterClass()) {
@@ -384,7 +395,14 @@ public class ImagePreset {
public Bitmap applyGeometry(Bitmap bitmap) {
// Apply any transform -- 90 rotate, flip, straighten, crop
// Returns a new bitmap.
- return mGeoData.apply(bitmap, mScaleFactor, mQuality);
+ if (mDoApplyGeometry) {
+ ImageFilter filter = FiltersManager.getManager().getFilterForRepresentation(mGeoData);
+ mGeoData.synchronizeRepresentation();
+ filter.useRepresentation(mGeoData);
+ filter.setImagePreset(this);
+ bitmap = filter.apply(bitmap, mScaleFactor, mQuality);
+ }
+ return bitmap;
}
public Bitmap applyBorder(Bitmap bitmap) {