From e3ee74f67cd53973aec43357c3c4093f5881f6db Mon Sep 17 00:00:00 2001 From: Jorge Ruesga Date: Fri, 16 Aug 2013 20:52:57 +0200 Subject: Add a null effect instead of no apply effect Signed-off-by: Jorge Ruesga --- .../wallpapers/photophase/effects/Effects.java | 9 +++- .../wallpapers/photophase/effects/NullEffect.java | 54 ++++++++++++++++++++++ .../effects/PhotoPhaseEffectFactory.java | 9 ++++ .../wallpapers/photophase/utils/Utils.java | 2 +- 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/org/cyanogenmod/wallpapers/photophase/effects/NullEffect.java (limited to 'src') 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.
+ * + * + *
Parameter nameMeaningValid values
+ */ +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 NullEffect. + * + * @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 @@ -72,6 +72,15 @@ public class PhotoPhaseEffectFactory { */ public static final String EFFECT_MIRROR = "org.cyanogenmod.wallpapers.photophase.effects.MirrorEffect"; + /** + *

Doesn't apply any effect.

+ *

Available parameters:

+ * + * + *
Parameter nameMeaningValid values
+ */ + public static final String EFFECT_NULL = "org.cyanogenmod.wallpapers.photophase.effects.NullEffect"; + /** *

Applies an outline effect to the image.

*

Available parameters:

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 */ -- cgit v1.2.3