diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-08-16 20:52:57 +0200 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2013-08-16 20:52:57 +0200 |
commit | e3ee74f67cd53973aec43357c3c4093f5881f6db (patch) | |
tree | b54e7f5391fb07a75a00f4c9c8f51eaef4829d8c | |
parent | 582a5243721eda91cc9d2f7a1d5f00cb6fbf6ec0 (diff) | |
download | android_packages_wallpapers_PhotoPhase-e3ee74f67cd53973aec43357c3c4093f5881f6db.tar.gz android_packages_wallpapers_PhotoPhase-e3ee74f67cd53973aec43357c3c4093f5881f6db.tar.bz2 android_packages_wallpapers_PhotoPhase-e3ee74f67cd53973aec43357c3c4093f5881f6db.zip |
Add a null effect instead of no apply effect
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
4 files changed, 72 insertions, 2 deletions
diff --git a/src/org/cyanogenmod/wallpapers/photophase/effects/Effects.java b/src/org/cyanogenmod/wallpapers/photophase/effects/Effects.java index 665fa49..ef28ee5 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/effects/Effects.java +++ b/src/org/cyanogenmod/wallpapers/photophase/effects/Effects.java @@ -37,7 +37,7 @@ public class Effects { */ public enum EFFECTS { /** - * No effect + * @see PhotoPhaseEffectFactory#EFFECT_NULL */ NO_EFFECT, /** @@ -287,6 +287,13 @@ public class Effects { effect.setParameter("scale", .5f); } } + + // Instead of not to apply any effect, just use one null effect to follow the same + // effect model. This allow to use the same height when Effect.apply is applied for all + // the frames + if (effect == null && EffectFactory.isEffectSupported(PhotoPhaseEffectFactory.EFFECT_NULL)) { + effect = effectFactory.createEffect(PhotoPhaseEffectFactory.EFFECT_NULL); + } return effect; } } diff --git a/src/org/cyanogenmod/wallpapers/photophase/effects/NullEffect.java b/src/org/cyanogenmod/wallpapers/photophase/effects/NullEffect.java new file mode 100644 index 0000000..ca53fe4 --- /dev/null +++ b/src/org/cyanogenmod/wallpapers/photophase/effects/NullEffect.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 The CyanogenMod Project + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// +// Based on the shaders of kodemongki: +// http://kodemongki.blogspot.com.es/2011/06/kameraku-custom-shader-effects-example.html +// + +package org.cyanogenmod.wallpapers.photophase.effects; + +import android.media.effect.EffectContext; + +/** + * This effect only copies the source texture to the destination texture.<br/> + * <table> + * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr> + * </table> + */ +public class NullEffect extends PhotoPhaseEffect { + + private static final String FRAGMENT_SHADER = + "precision mediump float;\n" + + "uniform sampler2D tex_sampler;\n" + + "varying vec2 v_texcoord;\n" + + "void main(void)\n" + + "{\n" + + " gl_FragColor = texture2D(tex_sampler, v_texcoord);\n" + + "}"; + + /** + * Constructor of <code>NullEffect</code>. + * + * @param ctx The effect context + * @param name The effect name + */ + public NullEffect(EffectContext ctx, String name) { + super(ctx, NullEffect.class.getName()); + init(VERTEX_SHADER, FRAGMENT_SHADER); + } + +} diff --git a/src/org/cyanogenmod/wallpapers/photophase/effects/PhotoPhaseEffectFactory.java b/src/org/cyanogenmod/wallpapers/photophase/effects/PhotoPhaseEffectFactory.java index 8755acf..450bb47 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/effects/PhotoPhaseEffectFactory.java +++ b/src/org/cyanogenmod/wallpapers/photophase/effects/PhotoPhaseEffectFactory.java @@ -73,6 +73,15 @@ public class PhotoPhaseEffectFactory { public static final String EFFECT_MIRROR = "org.cyanogenmod.wallpapers.photophase.effects.MirrorEffect"; /** + * <p>Doesn't apply any effect.</p> + * <p>Available parameters:</p> + * <table> + * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr> + * </table> + */ + public static final String EFFECT_NULL = "org.cyanogenmod.wallpapers.photophase.effects.NullEffect"; + + /** * <p>Applies an outline effect to the image.</p> * <p>Available parameters:</p> * <table> diff --git a/src/org/cyanogenmod/wallpapers/photophase/utils/Utils.java b/src/org/cyanogenmod/wallpapers/photophase/utils/Utils.java index f4337f6..ec5e0e8 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/utils/Utils.java +++ b/src/org/cyanogenmod/wallpapers/photophase/utils/Utils.java @@ -61,7 +61,7 @@ public class Utils { /** * Method that returns a random number between two numbers. * - * @param low The low number + * @param low The low number * @param high The high number * @return int The random number */ |