diff --git a/SPD-classes/src/main/java/com/watabou/gltextures/Gradient.java b/SPD-classes/src/main/java/com/watabou/gltextures/Gradient.java deleted file mode 100644 index f6cce8274..000000000 --- a/SPD-classes/src/main/java/com/watabou/gltextures/Gradient.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2015 Oleg Dolya - * - * Shattered Pixel Dungeon - * Copyright (C) 2014-2016 Evan Debenham - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see - */ - -package com.watabou.gltextures; - -import android.graphics.Bitmap; - -public class Gradient extends SmartTexture { - - public Gradient( int colors[] ) { - - super( Bitmap.createBitmap( colors.length, 1, Bitmap.Config.ARGB_8888 ) ); - - for (int i=0; i < colors.length; i++) { - bitmap.setPixel( i, 0, colors[i] ); - } - bitmap( bitmap ); - - filter( LINEAR, LINEAR ); - wrap( CLAMP, CLAMP ); - - TextureCache.add( Gradient.class, this ); - } -} \ No newline at end of file diff --git a/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java b/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java index 3bc649526..3b46fedf0 100644 --- a/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java +++ b/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java @@ -66,9 +66,9 @@ public class TextureCache { } } - public static SmartTexture createGradient( int width, int height, int... colors ) { + public static SmartTexture createGradient( int... colors ) { - final String key = "" + width + "x" + height + ":" + colors; + final String key = "" + colors; if (all.containsKey( key )) { @@ -76,13 +76,15 @@ public class TextureCache { } else { - Bitmap bmp = Bitmap.createBitmap( width, height, Bitmap.Config.ARGB_8888 ); - Canvas canvas = new Canvas( bmp ); - Paint paint = new Paint(); - paint.setShader( new LinearGradient( 0, 0, 0, height, colors, null, TileMode.CLAMP ) ); - canvas.drawPaint( paint ); - + Bitmap bmp = Bitmap.createBitmap( colors.length, 1, Bitmap.Config.ARGB_8888 ); + for (int i=0; i < colors.length; i++) { + bmp.setPixel( i, 0, colors[i] ); + } SmartTexture tx = new SmartTexture( bmp ); + + tx.filter( Texture.LINEAR, Texture.LINEAR ); + tx.wrap( Texture.CLAMP, Texture.CLAMP ); + all.put( key, tx ); return tx; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Flare.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Flare.java index 6b0f952ff..550655e74 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Flare.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Flare.java @@ -22,8 +22,8 @@ package com.shatteredpixel.shatteredpixeldungeon.effects; import android.annotation.SuppressLint; import android.opengl.GLES20; -import com.watabou.gltextures.Gradient; import com.watabou.gltextures.SmartTexture; +import com.watabou.gltextures.TextureCache; import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.NoosaScript; @@ -56,7 +56,7 @@ public class Flare extends Visual { super( 0, 0, 0, 0 ); int gradient[] = {0xFFFFFFFF, 0x00FFFFFF}; - texture = new Gradient( gradient ); + texture = TextureCache.createGradient( gradient ); this.nRays = nRays; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/SurfaceScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/SurfaceScene.java index 81a1ed1a0..3d646cdca 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/SurfaceScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/SurfaceScene.java @@ -29,8 +29,8 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.RatSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; -import com.watabou.gltextures.Gradient; import com.watabou.gltextures.SmartTexture; +import com.watabou.gltextures.TextureCache; import com.watabou.glwrap.Matrix; import com.watabou.glwrap.Quad; import com.watabou.input.Touchscreen.Touch; @@ -205,7 +205,7 @@ public class SurfaceScene extends PixelScene { public Sky( boolean dayTime ) { super( 0, 0, 1, 1 ); - texture = new Gradient( dayTime ? day : night ); + texture = TextureCache.createGradient( dayTime ? day : night ); float[] vertices = new float[16]; verticesBuffer = Quad.create();