Loading src/com/android/gallery3d/photoeditor/FilterStack.java +13 −20 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.gallery3d.photoeditor; import android.graphics.Bitmap; import android.media.effect.EffectContext; import com.android.gallery3d.photoeditor.filters.Filter; Loading @@ -44,7 +43,6 @@ public class FilterStack { private final PhotoView photoView; private final StackListener stackListener; private EffectContext effectContext; private Photo source; private Runnable queuedTopFilterChange; private volatile boolean paused; Loading @@ -54,15 +52,6 @@ public class FilterStack { this.stackListener = stackListener; } private void clearBuffers() { for (int i = 0; i < buffers.length; i++) { if (buffers[i] != null) { buffers[i].clear(); buffers[i] = null; } } } private void reallocateBuffer(int target) { int other = target ^ 1; buffers[target] = Photo.create(buffers[other].width(), buffers[other].height()); Loading @@ -70,7 +59,12 @@ public class FilterStack { private void invalidate() { // In/out buffers need redrawn by re-applying filters on source photo. clearBuffers(); for (int i = 0; i < buffers.length; i++) { if (buffers[i] != null) { buffers[i].clear(); buffers[i] = null; } } if (source != null) { buffers[0] = Photo.create(source.width(), source.height()); reallocateBuffer(1); Loading Loading @@ -98,7 +92,7 @@ public class FilterStack { buffers[out].clear(); reallocateBuffer(out); } appliedStack.get(filterIndex).process(effectContext, input, buffers[out]); appliedStack.get(filterIndex).process(input, buffers[out]); return buffers[out]; } return null; Loading Loading @@ -229,19 +223,18 @@ public class FilterStack { public void onPause() { // Flush pending queued operations and release effect-context before GL context is lost. // Use pause-flag to avoid lengthy runnable in GL thread blocking onPause(). // Use the flag to break from lengthy invalidate() in GL thread for not blocking onPause(). paused = true; photoView.flush(); photoView.queueEvent(new Runnable() { @Override public void run() { if (effectContext != null) { effectContext.release(); effectContext = null; Filter.releaseContext(); for (int i = 0; i < buffers.length; i++) { // Textures will be automatically deleted when GL context is lost. buffers[i] = null; } photoView.setPhoto(null); clearBuffers(); } }); photoView.onPause(); Loading @@ -254,7 +247,7 @@ public class FilterStack { @Override public void run() { // Create effect context after GL context is created or recreated. effectContext = EffectContext.createWithCurrentGlContext(); Filter.createContextWithCurrentGlContext(); } }); paused = false; Loading src/com/android/gallery3d/photoeditor/filters/AutoFixFilter.java +2 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.gallery3d.photoeditor.filters; import android.media.effect.Effect; import android.media.effect.EffectContext; import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; Loading @@ -40,8 +39,8 @@ public class AutoFixFilter extends Filter { } @Override public void process(EffectContext context, Photo src, Photo dst) { Effect effect = getEffect(context, EffectFactory.EFFECT_AUTOFIX); public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_AUTOFIX); effect.setParameter("scale", scale); effect.apply(src.texture(), src.width(), src.height(), dst.texture()); } Loading src/com/android/gallery3d/photoeditor/filters/ColorTemperatureFilter.java +2 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.gallery3d.photoeditor.filters; import android.media.effect.Effect; import android.media.effect.EffectContext; import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; Loading @@ -40,8 +39,8 @@ public class ColorTemperatureFilter extends Filter { } @Override public void process(EffectContext context, Photo src, Photo dst) { Effect effect = getEffect(context, EffectFactory.EFFECT_TEMPERATURE); public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_TEMPERATURE); effect.setParameter("scale", scale); effect.apply(src.texture(), src.width(), src.height(), dst.texture()); } Loading src/com/android/gallery3d/photoeditor/filters/CropFilter.java +2 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.gallery3d.photoeditor.filters; import android.graphics.RectF; import android.media.effect.Effect; import android.media.effect.EffectContext; import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; Loading @@ -39,11 +38,11 @@ public class CropFilter extends Filter { } @Override public void process(EffectContext context, Photo src, Photo dst) { public void process(Photo src, Photo dst) { dst.changeDimension(Math.round(bounds.width() * src.width()), Math.round(bounds.height() * src.height())); Effect effect = getEffect(context, EffectFactory.EFFECT_CROP); Effect effect = getEffect(EffectFactory.EFFECT_CROP); effect.setParameter("xorigin", Math.round(bounds.left * src.width())); effect.setParameter("yorigin", Math.round(bounds.top * src.height())); effect.setParameter("width", dst.width()); Loading src/com/android/gallery3d/photoeditor/filters/CrossProcessFilter.java +2 −3 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.gallery3d.photoeditor.filters; import android.media.effect.EffectContext; import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; Loading @@ -31,8 +30,8 @@ public class CrossProcessFilter extends Filter { } @Override public void process(EffectContext context, Photo src, Photo dst) { getEffect(context, EffectFactory.EFFECT_CROSSPROCESS).apply( public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_CROSSPROCESS).apply( src.texture(), src.width(), src.height(), dst.texture()); } } Loading
src/com/android/gallery3d/photoeditor/FilterStack.java +13 −20 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.gallery3d.photoeditor; import android.graphics.Bitmap; import android.media.effect.EffectContext; import com.android.gallery3d.photoeditor.filters.Filter; Loading @@ -44,7 +43,6 @@ public class FilterStack { private final PhotoView photoView; private final StackListener stackListener; private EffectContext effectContext; private Photo source; private Runnable queuedTopFilterChange; private volatile boolean paused; Loading @@ -54,15 +52,6 @@ public class FilterStack { this.stackListener = stackListener; } private void clearBuffers() { for (int i = 0; i < buffers.length; i++) { if (buffers[i] != null) { buffers[i].clear(); buffers[i] = null; } } } private void reallocateBuffer(int target) { int other = target ^ 1; buffers[target] = Photo.create(buffers[other].width(), buffers[other].height()); Loading @@ -70,7 +59,12 @@ public class FilterStack { private void invalidate() { // In/out buffers need redrawn by re-applying filters on source photo. clearBuffers(); for (int i = 0; i < buffers.length; i++) { if (buffers[i] != null) { buffers[i].clear(); buffers[i] = null; } } if (source != null) { buffers[0] = Photo.create(source.width(), source.height()); reallocateBuffer(1); Loading Loading @@ -98,7 +92,7 @@ public class FilterStack { buffers[out].clear(); reallocateBuffer(out); } appliedStack.get(filterIndex).process(effectContext, input, buffers[out]); appliedStack.get(filterIndex).process(input, buffers[out]); return buffers[out]; } return null; Loading Loading @@ -229,19 +223,18 @@ public class FilterStack { public void onPause() { // Flush pending queued operations and release effect-context before GL context is lost. // Use pause-flag to avoid lengthy runnable in GL thread blocking onPause(). // Use the flag to break from lengthy invalidate() in GL thread for not blocking onPause(). paused = true; photoView.flush(); photoView.queueEvent(new Runnable() { @Override public void run() { if (effectContext != null) { effectContext.release(); effectContext = null; Filter.releaseContext(); for (int i = 0; i < buffers.length; i++) { // Textures will be automatically deleted when GL context is lost. buffers[i] = null; } photoView.setPhoto(null); clearBuffers(); } }); photoView.onPause(); Loading @@ -254,7 +247,7 @@ public class FilterStack { @Override public void run() { // Create effect context after GL context is created or recreated. effectContext = EffectContext.createWithCurrentGlContext(); Filter.createContextWithCurrentGlContext(); } }); paused = false; Loading
src/com/android/gallery3d/photoeditor/filters/AutoFixFilter.java +2 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.gallery3d.photoeditor.filters; import android.media.effect.Effect; import android.media.effect.EffectContext; import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; Loading @@ -40,8 +39,8 @@ public class AutoFixFilter extends Filter { } @Override public void process(EffectContext context, Photo src, Photo dst) { Effect effect = getEffect(context, EffectFactory.EFFECT_AUTOFIX); public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_AUTOFIX); effect.setParameter("scale", scale); effect.apply(src.texture(), src.width(), src.height(), dst.texture()); } Loading
src/com/android/gallery3d/photoeditor/filters/ColorTemperatureFilter.java +2 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.gallery3d.photoeditor.filters; import android.media.effect.Effect; import android.media.effect.EffectContext; import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; Loading @@ -40,8 +39,8 @@ public class ColorTemperatureFilter extends Filter { } @Override public void process(EffectContext context, Photo src, Photo dst) { Effect effect = getEffect(context, EffectFactory.EFFECT_TEMPERATURE); public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_TEMPERATURE); effect.setParameter("scale", scale); effect.apply(src.texture(), src.width(), src.height(), dst.texture()); } Loading
src/com/android/gallery3d/photoeditor/filters/CropFilter.java +2 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.gallery3d.photoeditor.filters; import android.graphics.RectF; import android.media.effect.Effect; import android.media.effect.EffectContext; import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; Loading @@ -39,11 +38,11 @@ public class CropFilter extends Filter { } @Override public void process(EffectContext context, Photo src, Photo dst) { public void process(Photo src, Photo dst) { dst.changeDimension(Math.round(bounds.width() * src.width()), Math.round(bounds.height() * src.height())); Effect effect = getEffect(context, EffectFactory.EFFECT_CROP); Effect effect = getEffect(EffectFactory.EFFECT_CROP); effect.setParameter("xorigin", Math.round(bounds.left * src.width())); effect.setParameter("yorigin", Math.round(bounds.top * src.height())); effect.setParameter("width", dst.width()); Loading
src/com/android/gallery3d/photoeditor/filters/CrossProcessFilter.java +2 −3 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.gallery3d.photoeditor.filters; import android.media.effect.EffectContext; import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; Loading @@ -31,8 +30,8 @@ public class CrossProcessFilter extends Filter { } @Override public void process(EffectContext context, Photo src, Photo dst) { getEffect(context, EffectFactory.EFFECT_CROSSPROCESS).apply( public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_CROSSPROCESS).apply( src.texture(), src.width(), src.height(), dst.texture()); } }