diff options
author | nicolasroard <nicolasroard@google.com> | 2013-07-02 11:00:01 -0700 |
---|---|---|
committer | nicolasroard <nicolasroard@google.com> | 2013-07-02 12:42:21 -0700 |
commit | 7f7755f76210a500e6ce63bfa880f23303556294 (patch) | |
tree | 67b3e0f6f031c8548c15557eb769de91094ff2c1 /src/com/android/gallery3d/filtershow/presets | |
parent | cf68d2f5d9f886995797a3fc8e844a0602227224 (diff) | |
download | android_packages_apps_Gallery2-7f7755f76210a500e6ce63bfa880f23303556294.tar.gz android_packages_apps_Gallery2-7f7755f76210a500e6ce63bfa880f23303556294.tar.bz2 android_packages_apps_Gallery2-7f7755f76210a500e6ce63bfa880f23303556294.zip |
Pipeline refactoring
Remove the temp representations and instead use a triple
buffer for ImagePresets.
Change-Id: I4cdcfbe4941af72b38fe42385085ff4a20eb78cc
Diffstat (limited to 'src/com/android/gallery3d/filtershow/presets')
-rw-r--r-- | src/com/android/gallery3d/filtershow/presets/ImagePreset.java | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java index 4ec39f765..d36bafd43 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java @@ -147,17 +147,15 @@ public class ImagePreset { if (representation == null) { return; } - synchronized (mFilters) { - if (representation instanceof GeometryMetadata) { - setGeometry((GeometryMetadata) representation); - } else { - int position = getPositionForRepresentation(representation); - if (position == -1) { - return; - } - FilterRepresentation old = mFilters.elementAt(position); - old.updateTempParametersFrom(representation); + if (representation instanceof GeometryMetadata) { + setGeometry((GeometryMetadata) representation); + } else { + int position = getPositionForRepresentation(representation); + if (position == -1) { + return; } + FilterRepresentation old = mFilters.elementAt(position); + old.useParametersFrom(representation); } MasterImage.getImage().invalidatePreview(); fillImageStateAdapter(MasterImage.getImage().getState()); @@ -175,7 +173,7 @@ public class ImagePreset { return mDoApplyFilters; } - public synchronized GeometryMetadata getGeometry() { + public GeometryMetadata getGeometry() { for (FilterRepresentation representation : mFilters) { if (representation instanceof GeometryMetadata) { return (GeometryMetadata) representation; @@ -223,7 +221,7 @@ public class ImagePreset { return true; } - public synchronized void setGeometry(GeometryMetadata representation) { + public void setGeometry(GeometryMetadata representation) { GeometryMetadata geoData = getGeometry(); if (geoData != representation) { geoData.set(representation); @@ -425,7 +423,6 @@ public class ImagePreset { // Returns a new bitmap. if (mDoApplyGeometry) { GeometryMetadata geoData = getGeometry(); - geoData.synchronizeRepresentation(); bitmap = environment.applyRepresentation(geoData, bitmap); } return bitmap; @@ -436,7 +433,6 @@ public class ImagePreset { FilterRepresentation border = getFilterRepresentationForType( FilterRepresentation.TYPE_BORDER); if (border != null && mDoApplyGeometry) { - border.synchronizeRepresentation(); bitmap = environment.applyRepresentation(border, bitmap); if (environment.getQuality() == FilterEnvironment.QUALITY_FINAL) { UsageStatistics.onEvent(UsageStatistics.COMPONENT_EDITOR, @@ -463,11 +459,7 @@ public class ImagePreset { "SaveFilters", "Total", to - from + 1); } for (int i = from; i < to; i++) { - FilterRepresentation representation = null; - synchronized (mFilters) { - representation = mFilters.elementAt(i); - representation.synchronizeRepresentation(); - } + FilterRepresentation representation = mFilters.elementAt(i); if (representation instanceof GeometryMetadata) { // skip the geometry as it's already applied. continue; @@ -496,7 +488,6 @@ public class ImagePreset { FilterRepresentation border = getFilterRepresentationForType( FilterRepresentation.TYPE_BORDER); if (border != null && mDoApplyGeometry) { - border.synchronizeRepresentation(); // TODO: should keep the bitmap around Allocation bitmapIn = in; if (copyOut) { @@ -518,11 +509,7 @@ public class ImagePreset { to = mFilters.size(); } for (int i = from; i < to; i++) { - FilterRepresentation representation = null; - synchronized (mFilters) { - representation = mFilters.elementAt(i); - representation.synchronizeRepresentation(); - } + FilterRepresentation representation = mFilters.elementAt(i); if (representation instanceof GeometryMetadata) { // skip the geometry as it's already applied. continue; @@ -544,10 +531,7 @@ public class ImagePreset { return false; } for (int i = 0; i < mFilters.size(); i++) { - FilterRepresentation representation = null; - synchronized (mFilters) { - representation = mFilters.elementAt(i); - } + FilterRepresentation representation = mFilters.elementAt(i); if (representation instanceof GeometryMetadata && ((GeometryMetadata) representation).hasModifications()) { return false; @@ -703,4 +687,16 @@ public class ImagePreset { FiltersManager filtersManager = FiltersManager.getManager(); return filtersManager.createFilterFromName(name); } + + public void updateWith(ImagePreset preset) { + if (preset.mFilters.size() != mFilters.size()) { + Log.e(LOGTAG, "Updating a preset with an incompatible one"); + return; + } + for (int i = 0; i < mFilters.size(); i++) { + FilterRepresentation destRepresentation = mFilters.elementAt(i); + FilterRepresentation sourceRepresentation = preset.mFilters.elementAt(i); + destRepresentation.useParametersFrom(sourceRepresentation); + } + } } |