diff options
author | John Hoford <hoford@google.com> | 2013-02-28 01:43:44 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-02-28 01:43:44 +0000 |
commit | 680d30fad60bf7e7ffd9f6fca1e9ac8f36d6f4f0 (patch) | |
tree | 49df15b70fd09367076d403388b3277eb8c02b54 | |
parent | ac4e910c72e99d3b11e50b0174c89113ca981b6b (diff) | |
parent | 54b3d67486c05343471e520cdc8d9b882cb0483f (diff) | |
download | android_packages_apps_Snap-680d30fad60bf7e7ffd9f6fca1e9ac8f36d6f4f0.tar.gz android_packages_apps_Snap-680d30fad60bf7e7ffd9f6fca1e9ac8f36d6f4f0.tar.bz2 android_packages_apps_Snap-680d30fad60bf7e7ffd9f6fca1e9ac8f36d6f4f0.zip |
Merge "refactor the geometry code" into gb-ub-photos-bryce
-rw-r--r-- | res/layout/filtershow_activity.xml | 55 | ||||
-rw-r--r-- | res/values/filtershow_ids.xml | 4 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java | 18 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/presets/ImagePreset.java | 28 |
4 files changed, 45 insertions, 60 deletions
diff --git a/res/layout/filtershow_activity.xml b/res/layout/filtershow_activity.xml index e811ec742..0f94f9226 100644 --- a/res/layout/filtershow_activity.xml +++ b/res/layout/filtershow_activity.xml @@ -70,30 +70,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - <com.android.gallery3d.filtershow.imageshow.ImageStraighten - android:id="@+id/imageStraighten" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="gone" /> - - <com.android.gallery3d.filtershow.imageshow.ImageCrop - android:id="@+id/imageCrop" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="gone" /> - - <com.android.gallery3d.filtershow.imageshow.ImageRotate - android:id="@+id/imageRotate" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="gone" /> - - <com.android.gallery3d.filtershow.imageshow.ImageFlip - android:id="@+id/imageFlip" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="gone" /> - <com.android.gallery3d.filtershow.imageshow.ImageTinyPlanet android:id="@+id/imageTinyPlanet" android:layout_width="match_parent" @@ -203,37 +179,8 @@ android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_gravity="left" - android:orientation="horizontal"> - - <com.android.gallery3d.filtershow.ui.IconButton - android:id="@+id/straightenButton" - android:layout_height="match_parent" - style="@style/IconButton" - android:drawableTop="@drawable/filtershow_button_geometry_straighten" - android:text="@string/straighten" /> - - <com.android.gallery3d.filtershow.ui.IconButton - android:id="@+id/cropButton" - android:layout_height="match_parent" - style="@style/IconButton" - android:drawableTop="@drawable/filtershow_button_geometry_crop" - android:text="@string/crop" /> - - <com.android.gallery3d.filtershow.ui.IconButton - android:id="@+id/rotateButton" - android:layout_height="match_parent" - style="@style/IconButton" - android:drawableTop="@drawable/filtershow_button_geometry_rotate" - android:text="@string/rotate" /> - - <com.android.gallery3d.filtershow.ui.IconButton - android:id="@+id/flipButton" - android:layout_height="match_parent" - style="@style/IconButton" - android:drawableTop="@drawable/filtershow_button_geometry_flip" - android:text="@string/mirror" /> + android:orientation="horizontal" /> - </LinearLayout> </HorizontalScrollView> <HorizontalScrollView diff --git a/res/values/filtershow_ids.xml b/res/values/filtershow_ids.xml index 28e78166d..9380740ce 100644 --- a/res/values/filtershow_ids.xml +++ b/res/values/filtershow_ids.xml @@ -42,4 +42,8 @@ <item type="id" name="editorRedEye" /> <item type="id" name="imageOnlyEditor" /> <item type="id" name="vignetteEditor" /> + <item type="id" name="editorCrop" /> + <item type="id" name="editorFlip" /> + <item type="id" name="editorRotate" /> + <item type="id" name="editorStraighten" /> </resources> 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) { |