diff --git a/Live/src/main/AndroidManifest.xml b/Live/src/main/AndroidManifest.xml index 5ed1b10..d87ecd1 100644 --- a/Live/src/main/AndroidManifest.xml +++ b/Live/src/main/AndroidManifest.xml @@ -7,22 +7,4 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Live/src/main/java/com/frank/live/LiveApplication.java b/Live/src/main/java/com/frank/live/LiveApplication.java deleted file mode 100644 index 5375976..0000000 --- a/Live/src/main/java/com/frank/live/LiveApplication.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.frank.live; - -import android.app.Application; - -public class LiveApplication extends Application { - - private static LiveApplication context; - - @Override - public void onCreate() { - super.onCreate(); - context = this; - } - - public static LiveApplication getInstance() { - return context; - } - -} diff --git a/Live/src/main/java/com/frank/live/PushActivity.java b/Live/src/main/java/com/frank/live/PushActivity.java deleted file mode 100644 index 359931d..0000000 --- a/Live/src/main/java/com/frank/live/PushActivity.java +++ /dev/null @@ -1,308 +0,0 @@ - -package com.frank.live; - -import android.Manifest; -import android.annotation.TargetApi; -import android.app.Activity; -import android.content.res.Configuration; -import android.graphics.Bitmap; -import android.hardware.Camera; -import android.os.Bundle; -import android.os.Environment; - -import androidx.annotation.NonNull; - -import android.util.Log; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceHolder.Callback; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.WindowManager; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemSelectedListener; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.Spinner; - -import com.frank.live.view.SmartCameraView; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; - -public class PushActivity extends Activity implements Callback { - private static String TAG = PushActivity.class.getSimpleName(); - - private SmartCameraView mSmartCameraView; - -// MagicFilterType magicType = MagicFilterType.SUNRISE; - - private Button btnMute; - - private boolean isStart = false; - - private boolean is_mute = false; - - private int mDegree; - - private Spinner beautyTypeSelector; - - private ImageView img_photo; - - private boolean takePhoto; - - private final static int videoWidth = 640; - private final static int videoHeight = 360; - private final static String[] permissions = new String[]{Manifest.permission.CAMERA}; - private final static int CODE_CAMERA = 1001; - - private final static String[] beautySelector = new String[]{ - LiveApplication.getInstance().getString(R.string.effect_beauty), - LiveApplication.getInstance().getString(R.string.effect_cool), - LiveApplication.getInstance().getString(R.string.effect_sunrise), - LiveApplication.getInstance().getString(R.string.effect_sketch), - LiveApplication.getInstance().getString(R.string.effect_white), - LiveApplication.getInstance().getString(R.string.effect_romantic), - LiveApplication.getInstance().getString(R.string.effect_raw) - }; - - @Override - public void onCreate(Bundle savedInstanceState) { - - super.onCreate(savedInstanceState); - - requestPermissions(); - - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - - setContentView(R.layout.activity_push); - - initView(); - initListener(); - } - - @TargetApi(23) - private void requestPermissions() { - requestPermissions(permissions, CODE_CAMERA); - } - - private void initView() { - //SurfaceView - mSmartCameraView = findViewById(R.id.gl_surfaceview); - //beauty type - beautyTypeSelector = findViewById(R.id.beauty_type_selector); - //mute - btnMute = findViewById(R.id.button_mute); - //take photo - img_photo = findViewById(R.id.img_photo); - } - - private void initListener() { - - ArrayAdapter adapterBeautyType = new ArrayAdapter<>(this, - android.R.layout.simple_spinner_item, beautySelector); - adapterBeautyType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - beautyTypeSelector.setAdapter(adapterBeautyType); - beautyTypeSelector.setOnItemSelectedListener(new OnItemSelectedListener() { - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - - switch (position) { - case 0: - switchCameraFilter(MagicFilterType.BEAUTY); - break; - case 1: - switchCameraFilter(MagicFilterType.COOL); - break; - case 2: - switchCameraFilter(MagicFilterType.SUNRISE); - break; - case 3: - switchCameraFilter(MagicFilterType.SKETCH); - break; - case 4: - switchCameraFilter(MagicFilterType.WHITECAT); - break; - case 5: - switchCameraFilter(MagicFilterType.ROMANCE); - break; - default: - switchCameraFilter(MagicFilterType.NONE); - break; - } - } - - @Override - public void onNothingSelected(AdapterView parent) { - - } - }); - - btnMute.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - is_mute = !is_mute; - - if (is_mute) { - btnMute.setText(getString(R.string.voice)); - } else { - btnMute.setText(getString(R.string.mute)); - } - } - }); - - //preview data callback(RGBA) - mSmartCameraView.setPreviewCallback(new SmartCameraView.PreviewCallback() { - @Override - public void onGetRgbaFrame(byte[] data, int width, int height) { - - if (takePhoto) { - takePhoto = false; - Log.i(TAG, "takePhoto..."); - doTakePhoto(data, width, height); - } - - } - }); - - img_photo.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - takePhoto = true; - } - }); - - } - - private void switchCameraFilter(MagicFilterType type) { - mSmartCameraView.setFilter(type); - } - - /** - * take photo - * - * @param data preview data - * @param width the width of photo - * @param height the height of photo - */ - private void doTakePhoto(byte[] data, int width, int height) { - Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - ByteBuffer buffer = ByteBuffer.wrap(data); - bitmap.copyPixelsFromBuffer(buffer); - - Log.i(TAG, "doTakePhoto..."); - FileOutputStream fileOutputStream = null; - String PATH = Environment.getExternalStorageDirectory().getPath(); - String filePath = PATH + File.separator + "hello" + ".jpg"; - try { - fileOutputStream = new FileOutputStream(filePath); - bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream); - fileOutputStream.flush(); - } catch (IOException e) { - e.printStackTrace(); - Log.e(TAG, "doTakePhoto error=" + e.toString()); - } finally { - if (fileOutputStream != null) { - try { - fileOutputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - @Override - public void surfaceCreated(SurfaceHolder holder) { - Log.i(TAG, "surfaceCreated.."); - } - - @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - Log.i(TAG, "surfaceChanged.."); - } - - @Override - public void surfaceDestroyed(SurfaceHolder holder) { - Log.i(TAG, "Surface Destroyed"); - } - - public void onConfigurationChanged(Configuration newConfig) { - try { - super.onConfigurationChanged(newConfig); - Log.i(TAG, "onConfigurationChanged, start:" + isStart); - setCameraDisplayOrientation(this, getCameraId()); - mSmartCameraView.setPreviewOrientation(newConfig.orientation, mDegree); - } catch (Exception ex) { - Log.e(TAG, "error=" + ex.toString()); - } - } - - private int getCameraId() { - return mSmartCameraView.getCameraId(); - } - - public void setPreviewResolution(int width, int height) { - mSmartCameraView.setPreviewResolution(width, height); - } - - private void setCameraDisplayOrientation(Activity activity, int cameraId) { - Camera.CameraInfo info = new Camera.CameraInfo(); - Camera.getCameraInfo(cameraId, info); - int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); - int degrees = 0; - switch (rotation) { - case Surface.ROTATION_0: - degrees = 0; - break; - case Surface.ROTATION_90: - degrees = 90; - break; - case Surface.ROTATION_180: - degrees = 180; - break; - case Surface.ROTATION_270: - degrees = 270; - break; - } - int result; - if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { - result = (info.orientation + degrees) % 360; - result = (360 - result) % 360; - } else { - // back-facing - result = (info.orientation - degrees + 360) % 360; - } - Log.i(TAG, "curDegree: " + result); - mDegree = result; - } - - @Override - protected void onDestroy() { - if (isStart) { - isStart = false; - if (mSmartCameraView != null) { - mSmartCameraView.stopCamera(); - } - Log.i(TAG, "onDestroy StopPublish"); - } - super.onDestroy(); - finish(); - } - - @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (permissions.length > 0 && grantResults.length > 0) { - setPreviewResolution(videoWidth, videoHeight); - if (!mSmartCameraView.startCamera()) { - Log.e(TAG, "startCamera error..."); - } - } - } - -} \ No newline at end of file diff --git a/Live/src/main/java/com/frank/live/view/SmartCameraView.java b/Live/src/main/java/com/frank/live/view/SmartCameraView.java deleted file mode 100644 index e36a06a..0000000 --- a/Live/src/main/java/com/frank/live/view/SmartCameraView.java +++ /dev/null @@ -1,372 +0,0 @@ -package com.frank.live.view; - -import android.content.Context; -import android.content.res.Configuration; -import android.graphics.ImageFormat; -import android.graphics.SurfaceTexture; -import android.hardware.Camera; -import android.opengl.GLES20; -import android.opengl.GLSurfaceView; -import android.opengl.Matrix; -import android.util.AttributeSet; -import android.util.Log; - -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterFactory; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; -import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -public class SmartCameraView extends GLSurfaceView implements GLSurfaceView.Renderer { - - private GPUImageFilter magicFilter; - private SurfaceTexture surfaceTexture; - private int mOESTextureId = OpenGLUtils.NO_TEXTURE; - private int mSurfaceWidth; - private int mSurfaceHeight; - private int mPreviewWidth; - private int mPreviewHeight; - - private float mInputAspectRatio; - private float mOutputAspectRatio; - private float[] mProjectionMatrix = new float[16]; - private float[] mSurfaceMatrix = new float[16]; - private float[] mTransformMatrix = new float[16]; - - private Camera mCamera; - private ByteBuffer mGLPreviewBuffer; - private int mCamId = -1; - private int mPreviewRotation = 0; - private int mPreviewOrientation = Configuration.ORIENTATION_PORTRAIT; - - private Thread worker; - private final Object writeLock = new Object(); - private ConcurrentLinkedQueue mGLIntBufferCache = new ConcurrentLinkedQueue<>(); - private PreviewCallback mPrevCb; - - private final String TAG = "SmartCameraView"; - - public SmartCameraView(Context context) { - this(context, null); - } - - public SmartCameraView(Context context, AttributeSet attrs) { - super(context, attrs); - - setEGLContextClientVersion(2); - setRenderer(this); - setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); - } - - @Override - public void onSurfaceCreated(GL10 gl, EGLConfig config) { - Log.e(TAG, "Run into onSurfaceCreated..."); - - GLES20.glDisable(GL10.GL_DITHER); - GLES20.glClearColor(0, 0, 0, 0); - - magicFilter = new GPUImageFilter(MagicFilterType.NONE); - magicFilter.init(getContext().getApplicationContext()); - magicFilter.onInputSizeChanged(mPreviewWidth, mPreviewHeight); - - mOESTextureId = OpenGLUtils.getExternalOESTextureID(); - - surfaceTexture = new SurfaceTexture(mOESTextureId); - surfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() { - @Override - public void onFrameAvailable(SurfaceTexture surfaceTexture) { - requestRender(); - } - }); - - // For camera preview on activity creation - if (mCamera != null) { - try { - mCamera.setPreviewTexture(surfaceTexture); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } - - Log.i(TAG, "Run out of onSurfaceCreated..."); - } - - @Override - public void onSurfaceChanged(GL10 gl, int width, int height) { - Log.i(TAG, "Run into onSurfaceChanged...width: " + width + ", height: " + height); - GLES20.glViewport(0, 0, width, height); - mSurfaceWidth = width; - mSurfaceHeight = height; - magicFilter.onDisplaySizeChanged(width, height); - - mOutputAspectRatio = width > height ? (float) width / height : (float) height / width; - float aspectRatio = mOutputAspectRatio / mInputAspectRatio; - - if (width > height) { - Matrix.orthoM(mProjectionMatrix, 0, -1.0f, 1.0f, -aspectRatio, aspectRatio, -1.0f, 1.0f); - } else { - Matrix.orthoM(mProjectionMatrix, 0, -aspectRatio, aspectRatio, -1.0f, 1.0f, -1.0f, 1.0f); - } - - Log.i(TAG, "Run out onSurfaceChanged--"); - } - - @Override - public void onDrawFrame(GL10 gl) { - - GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); - - surfaceTexture.updateTexImage(); - - surfaceTexture.getTransformMatrix(mSurfaceMatrix); - - Matrix.multiplyMM(mTransformMatrix, 0, mSurfaceMatrix, 0, mProjectionMatrix, 0); - magicFilter.setTextureTransformMatrix(mTransformMatrix); - - magicFilter.onDrawFrame(mOESTextureId); - - mGLIntBufferCache.add(magicFilter.getGLFboBuffer()); - synchronized (writeLock) { - writeLock.notifyAll(); - } - } - - public void setPreviewCallback(PreviewCallback cb) { - mPrevCb = cb; - } - - public int[] setPreviewResolution(int width, int height) { - getHolder().setFixedSize(width, height); - - mCamera = openCamera(); - mPreviewWidth = width; - mPreviewHeight = height; - - mCamera.getParameters().setPreviewSize(mPreviewWidth, mPreviewHeight); - - mGLPreviewBuffer = ByteBuffer.allocate(mPreviewWidth * mPreviewHeight * 4); - - mInputAspectRatio = mPreviewWidth > mPreviewHeight ? - (float) mPreviewWidth / mPreviewHeight : (float) mPreviewHeight / mPreviewWidth; - - return new int[]{mPreviewWidth, mPreviewHeight}; - } - - public boolean setFilter(final MagicFilterType type) { - if (mCamera == null) { - return false; - } - - queueEvent(new Runnable() { - @Override - public void run() { - if (magicFilter != null) { - magicFilter.destroy(); - } - magicFilter = MagicFilterFactory.initFilters(type); - if (magicFilter != null) { - magicFilter.init(getContext().getApplicationContext()); - magicFilter.onInputSizeChanged(mPreviewWidth, mPreviewHeight); - magicFilter.onDisplaySizeChanged(mSurfaceWidth, mSurfaceHeight); - } - } - }); - requestRender(); - return true; - } - - private void deleteTextures() { - if (mOESTextureId != OpenGLUtils.NO_TEXTURE) { - queueEvent(new Runnable() { - @Override - public void run() { - GLES20.glDeleteTextures(1, new int[]{mOESTextureId}, 0); - mOESTextureId = OpenGLUtils.NO_TEXTURE; - } - }); - } - } - - public void setCameraId(int id) { - mCamId = id; - } - - public void setPreviewOrientation(int orientation, int degree) { - mPreviewOrientation = orientation; - mPreviewRotation = degree; - - mCamera.setDisplayOrientation(degree); - - } - - public int getCameraId() { - return mCamId; - } - - public boolean startCamera() { - worker = new Thread(new Runnable() { - @Override - public void run() { - while (!Thread.interrupted()) { - while (!mGLIntBufferCache.isEmpty()) { - IntBuffer picture = mGLIntBufferCache.poll(); - mGLPreviewBuffer.asIntBuffer().put(picture.array()); - mPrevCb.onGetRgbaFrame(mGLPreviewBuffer.array(), mPreviewWidth, mPreviewHeight); - } - // Waiting for next frame - synchronized (writeLock) { - try { - // isEmpty() may take some time, so we set timeout to detect next frame - writeLock.wait(500); - } catch (InterruptedException ie) { - worker.interrupt(); - } - } - } - } - }); - worker.start(); - - if (mCamera == null) { - mCamera = openCamera(); - if (mCamera == null) { - return false; - } - } - - Camera.Parameters params = mCamera.getParameters(); - - List supportedFocusModes = params.getSupportedFocusModes(); - if (!supportedFocusModes.isEmpty()) { - if (supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) { - params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); - } else { - params.setFocusMode(supportedFocusModes.get(0)); - } - } - - params.setPictureSize(mPreviewWidth, mPreviewHeight); - params.setPreviewSize(mPreviewWidth, mPreviewHeight); - - int VFPS = 15; - int[] range = adaptFpsRange(VFPS, params.getSupportedPreviewFpsRange()); - params.setPreviewFpsRange(range[0], range[1]); - params.setPreviewFormat(ImageFormat.NV21); - - params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); - params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_AUTO); - params.setSceneMode(Camera.Parameters.SCENE_MODE_AUTO); - if (!params.getSupportedFocusModes().isEmpty()) { - params.setFocusMode(params.getSupportedFocusModes().get(0)); - } - mCamera.setParameters(params); - - mCamera.setDisplayOrientation(mPreviewRotation); - - try { - mCamera.setPreviewTexture(surfaceTexture); - } catch (IOException e) { - e.printStackTrace(); - } - - GetParameters(mCamera); - - mCamera.startPreview(); - - return true; - } - - public void stopCamera() { - if (worker != null) { - worker.interrupt(); - try { - worker.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - worker.interrupt(); - } - mGLIntBufferCache.clear(); - worker = null; - } - - if (mCamera != null) { - mCamera.stopPreview(); - mCamera.release(); - mCamera = null; - } - } - - public void GetParameters(Camera camera) { - List pictureSizes = camera.getParameters().getSupportedPictureSizes(); - List previewSizes = camera.getParameters().getSupportedPreviewSizes(); - Camera.Size psize; - for (int i = 0; i < pictureSizes.size(); i++) { - psize = pictureSizes.get(i); - Log.i(TAG, psize.width + " x " + psize.height); - } - for (int i = 0; i < previewSizes.size(); i++) { - psize = previewSizes.get(i); - Log.i(TAG, psize.width + " x " + psize.height); - } - } - - private Camera openCamera() { - Camera camera; - if (mCamId < 0) { - Camera.CameraInfo info = new Camera.CameraInfo(); - - int numCameras = Camera.getNumberOfCameras(); - int frontCamId = -1; - int backCamId = -1; - for (int i = 0; i < numCameras; i++) { - Camera.getCameraInfo(i, info); - if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) { - backCamId = i; - } else if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { - frontCamId = i; - break; - } - } - if (frontCamId != -1) { - mCamId = frontCamId; - } else if (backCamId != -1) { - mCamId = backCamId; - } else { - mCamId = 0; - } - } - camera = Camera.open(mCamId); - - return camera; - } - - private int[] adaptFpsRange(int expectedFps, List fpsRanges) { - expectedFps *= 1000; - int[] closestRange = fpsRanges.get(0); - int measure = Math.abs(closestRange[0] - expectedFps) + Math.abs(closestRange[1] - expectedFps); - for (int[] range : fpsRanges) { - if (range[0] <= expectedFps && range[1] >= expectedFps) { - int curMeasure = Math.abs(range[0] - expectedFps) + Math.abs(range[1] - expectedFps); - if (curMeasure < measure) { - closestRange = range; - measure = curMeasure; - } - } - } - return closestRange; - } - - public interface PreviewCallback { - - void onGetRgbaFrame(byte[] data, int width, int height); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicAmaroFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicAmaroFilter.java deleted file mode 100644 index 398bf5d..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicAmaroFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicAmaroFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1,-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1,-1}; - private int mGLStrengthLocation; - - public MagicAmaroFilter(){ - super(MagicFilterType.AMARO, R.raw.amaro); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for (int i = 0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/brannan_blowout.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/overlaymap.png"); - inputTextureHandles[2] = OpenGLUtils.loadTexture(getContext(), "filter/amaromap.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicAntiqueFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicAntiqueFilter.java deleted file mode 100644 index fba5a08..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicAntiqueFilter.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicAntiqueFilter extends GPUImageFilter{ - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - - public MagicAntiqueFilter(){ - super(MagicFilterType.ANTIQUE, R.raw.antique); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - this.mToneCurveTexture[0] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (this.mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (this.mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(this.mToneCurveTextureUniformLocation, 3); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[2048]; - int[] arrayOfInt1 = { 0, 1, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 15, 15, 16, 17, 18, 19, 20, 21, 22, 23, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, 49, 50, 51, 52, 53, 55, 56, 57, 58, 59, 61, 62, 63, 64, 66, 67, 68, 69, 71, 72, 73, 74, 76, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89, 90, 91, 93, 94, 95, 96, 98, 99, 100, 102, 103, 104, 106, 107, 108, 110, 111, 112, 114, 115, 116, 118, 119, 120, 122, 123, 124, 126, 127, 128, 130, 131, 132, 134, 135, 136, 137, 139, 140, 141, 143, 144, 145, 146, 148, 149, 150, 152, 153, 154, 155, 157, 158, 159, 160, 161, 163, 164, 165, 166, 168, 169, 170, 171, 172, 173, 175, 176, 177, 178, 179, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 211, 212, 213, 214, 215, 216, 216, 217, 218, 219, 220, 220, 221, 222, 223, 223, 224, 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 238, 239, 239, 240, 241, 241, 242, 242, 243, 244, 244, 245, 245, 246, 247, 247, 248, 248, 249, 249, 250, 251, 251, 252, 252, 253, 253, 254, 254, 255 }; - int[] arrayOfInt2 = { 15, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 43, 44, 45, 46, 48, 49, 50, 51, 52, 53, 55, 56, 57, 57, 58, 59, 61, 62, 63, 64, 66, 67, 68, 69, 71, 72, 72, 73, 74, 76, 77, 78, 79, 81, 82, 83, 85, 86, 87, 87, 89, 90, 91, 93, 94, 95, 96, 98, 99, 100, 102, 102, 103, 104, 106, 107, 108, 110, 111, 112, 114, 115, 116, 118, 118, 119, 120, 122, 123, 124, 126, 127, 128, 130, 131, 132, 134, 134, 135, 136, 137, 139, 140, 141, 143, 144, 145, 146, 148, 149, 149, 150, 152, 153, 154, 155, 157, 158, 159, 160, 161, 163, 163, 164, 165, 166, 168, 169, 170, 171, 172, 173, 175, 176, 177, 177, 178, 179, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 211, 212, 212, 213, 214, 215, 216, 216, 217, 218, 219, 220, 220, 221, 222, 222, 223, 223, 224, 225, 226, 226, 227, 228, 228, 229, 230, 230, 230, 231, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 238, 238, 239, 239, 240, 241, 241, 242, 242, 243, 244, 244, 245, 245, 245, 246, 247, 247, 248, 248, 249, 249, 250, 251, 251, 252, 252, 252, 253, 253, 254, 254, 255 }; - int[] arrayOfInt3 = { 87, 89, 89, 90, 90, 91, 91, 93, 93, 94, 95, 95, 96, 96, 98, 98, 99, 100, 100, 102, 102, 103, 103, 104, 104, 106, 107, 107, 108, 108, 110, 110, 111, 112, 112, 114, 114, 115, 115, 116, 118, 118, 119, 119, 120, 120, 122, 123, 123, 124, 124, 126, 126, 127, 128, 128, 130, 130, 131, 131, 132, 134, 134, 135, 135, 136, 136, 137, 139, 139, 140, 140, 141, 143, 143, 144, 144, 145, 146, 146, 148, 148, 149, 150, 150, 152, 152, 153, 154, 154, 155, 155, 157, 158, 158, 159, 159, 160, 161, 161, 163, 163, 164, 165, 165, 166, 168, 168, 169, 169, 170, 171, 171, 172, 173, 173, 175, 175, 176, 177, 177, 178, 179, 179, 180, 181, 181, 183, 183, 184, 185, 185, 186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 195, 195, 196, 197, 197, 198, 199, 199, 200, 201, 201, 202, 203, 204, 204, 205, 206, 206, 207, 208, 208, 209, 210, 211, 211, 211, 212, 212, 213, 214, 215, 215, 216, 216, 217, 217, 218, 219, 219, 220, 220, 221, 221, 222, 223, 223, 223, 224, 225, 226, 226, 226, 227, 228, 228, 228, 229, 230, 230, 230, 231, 232, 232, 232, 233, 234, 234, 235, 235, 236, 236, 237, 238, 238, 238, 239, 239, 240, 240, 241, 241, 242, 242, 242, 243, 244, 244, 244, 245, 245, 246, 247, 247, 247, 248, 248, 249, 249, 249, 250, 251, 251, 252, 252, 252, 253, 253, 254, 254, 254, 255 }; - int[] arrayOfInt4 = { 0, 1, 1, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16, 17, 17, 18, 19, 20, 20, 21, 22, 23, 24, 24, 25, 26, 27, 28, 29, 29, 30, 31, 32, 33, 34, 35, 36, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 75, 76, 78, 79, 80, 81, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 106, 107, 109, 110, 111, 113, 114, 115, 117, 118, 119, 121, 122, 123, 125, 126, 127, 129, 130, 131, 133, 134, 136, 137, 138, 140, 141, 142, 144, 145, 146, 148, 149, 150, 152, 153, 154, 156, 157, 158, 159, 161, 162, 163, 165, 166, 167, 168, 170, 171, 172, 173, 175, 176, 177, 178, 180, 181, 182, 183, 184, 186, 187, 188, 189, 190, 191, 192, 193, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 213, 214, 215, 216, 217, 218, 219, 219, 220, 221, 222, 223, 223, 224, 225, 226, 227, 227, 228, 229, 230, 230, 231, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 238, 239, 240, 240, 241, 242, 242, 243, 244, 244, 245, 245, 246, 247, 247, 248, 248, 249, 250, 250, 251, 251, 252, 253, 253, 254, 254, 255 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte[(3 + i * 4)] = ((byte)arrayOfInt4[i]); - } - int[] arrayOfInt5 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int j = 0; j < 256; j++){ - arrayOfByte[(1024 + j * 4)] = ((byte)arrayOfInt5[j]); - arrayOfByte[(1 + (1024 + j * 4))] = ((byte)arrayOfInt5[j]); - arrayOfByte[(2 + (1024 + j * 4))] = ((byte)arrayOfInt5[j]); - arrayOfByte[(3 + (1024 + j * 4))] = -1; - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicBeautyFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicBeautyFilter.java deleted file mode 100644 index 98e4626..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicBeautyFilter.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -/** - * Created by Administrator on 2016/5/22. - */ -public class MagicBeautyFilter extends GPUImageFilter { - private int mSingleStepOffsetLocation; - - public MagicBeautyFilter(){ - super(MagicFilterType.BEAUTY, R.raw.beauty); - } - - protected void onInit() { - super.onInit(); - mSingleStepOffsetLocation = GLES20.glGetUniformLocation(getProgram(), "singleStepOffset"); - } - - @Override - public void onInputSizeChanged(final int width, final int height) { - super.onInputSizeChanged(width, height); - setFloatVec2(mSingleStepOffsetLocation, new float[] {2.0f / width, 2.0f / height}); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicBlackCatFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicBlackCatFilter.java deleted file mode 100644 index dfd5565..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicBlackCatFilter.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicBlackCatFilter extends GPUImageFilter { - - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - - public MagicBlackCatFilter(){ - super(MagicFilterType.BLACKCAT, R.raw.blackcat); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - mToneCurveTexture[0] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[2048]; - int[] arrayOfInt1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 5, 7, 8, 10, 11, 13, 15, 16, 18, 20, 21, 23, 24, 26, 28, 29, 31, 33, 34, 36, 37, 39, 41, 42, 44, 45, 47, 49, 50, 52, 53, 55, 57, 58, 60, 61, 63, 65, 66, 68, 69, 71, 72, 74, 76, 77, 79, 80, 82, 83, 85, 86, 88, 90, 91, 93, 94, 96, 97, 99, 100, 102, 103, 105, 106, 108, 109, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124, 125, 127, 128, 129, 131, 132, 134, 135, 136, 138, 139, 141, 142, 143, 145, 146, 147, 149, 150, 151, 153, 154, 155, 157, 158, 159, 160, 162, 163, 164, 165, 167, 168, 169, 170, 172, 173, 174, 175, 176, 178, 179, 180, 181, 182, 183, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 199, 200, 201, 202, 203, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 215, 216, 217, 218, 219, 220, 220, 221, 222, 223, 224, 224, 225, 226, 227, 227, 228, 229, 229, 230, 231, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 238, 239, 240, 240, 241, 242, 242, 243, 243, 244, 245, 245, 246, 247, 247, 248, 248, 249, 250, 250, 251, 251, 252, 253, 253, 254, 254, 255 }; - int[] arrayOfInt2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 5, 7, 8, 10, 11, 13, 15, 16, 16, 18, 20, 21, 23, 24, 26, 28, 29, 31, 33, 34, 36, 37, 39, 41, 41, 42, 44, 45, 47, 49, 50, 52, 53, 55, 57, 58, 60, 61, 63, 65, 66, 68, 69, 71, 72, 74, 76, 77, 79, 80, 82, 83, 85, 86, 86, 88, 90, 91, 93, 94, 96, 97, 99, 100, 102, 103, 105, 106, 108, 109, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124, 125, 127, 128, 129, 131, 134, 135, 136, 138, 139, 141, 142, 143, 145, 146, 147, 149, 150, 151, 153, 154, 155, 157, 158, 159, 160, 162, 163, 164, 165, 167, 168, 169, 170, 172, 173, 174, 175, 176, 179, 180, 181, 182, 183, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 199, 200, 201, 203, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 215, 216, 217, 219, 220, 220, 221, 222, 223, 224, 224, 225, 226, 227, 227, 228, 229, 229, 230, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 238, 239, 240, 240, 242, 242, 243, 243, 244, 245, 245, 246, 247, 247, 248, 248, 249, 250, 251, 251, 252, 253, 253, 254, 254, 255 }; - int[] arrayOfInt3 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 3, 5, 7, 8, 10, 10, 11, 13, 15, 16, 18, 20, 20, 21, 23, 24, 26, 28, 29, 29, 31, 33, 34, 36, 37, 39, 39, 41, 42, 44, 45, 47, 49, 50, 50, 52, 53, 55, 57, 58, 60, 61, 63, 63, 65, 66, 68, 69, 71, 72, 74, 76, 77, 79, 79, 80, 82, 83, 85, 86, 88, 90, 91, 93, 94, 96, 97, 99, 100, 100, 102, 103, 105, 106, 108, 109, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124, 125, 127, 128, 129, 131, 132, 134, 135, 136, 138, 139, 141, 142, 143, 145, 146, 147, 149, 150, 151, 153, 154, 155, 157, 158, 159, 160, 162, 164, 165, 167, 168, 169, 170, 172, 173, 174, 175, 176, 178, 179, 180, 181, 182, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 199, 200, 201, 202, 203, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 215, 215, 216, 218, 219, 220, 220, 221, 222, 223, 224, 225, 226, 227, 227, 228, 229, 229, 230, 232, 232, 233, 234, 234, 235, 236, 236, 238, 238, 239, 240, 240, 241, 242, 243, 243, 244, 245, 245, 246, 247, 247, 248, 249, 250, 250, 251, 251, 252, 253, 254, 254, 255 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte[(3 + i * 4)] = -1; - } - int[] arrayOfInt4 = { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 12, 13, 13, 14, 14, 15, 16, 17, 18, 18, 19, 19, 20, 21, 21, 23, 24, 25, 26, 26, 26, 27, 28, 29, 30, 31, 32, 32, 33, 34, 35, 36, 37, 38, 38, 38, 39, 40, 41, 43, 44, 45, 45, 46, 47, 48, 49, 49, 50, 51, 52, 53, 54, 55, 56, 57, 57, 58, 59, 60, 61, 62, 63, 64, 65, 65, 66, 67, 68, 69, 70, 70, 71, 72, 74, 75, 76, 76, 77, 78, 79, 80, 81, 82, 82, 83, 85, 86, 87, 88, 89, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 101, 102, 103, 104, 105, 107, 107, 108, 109, 111, 112, 113, 114, 114, 115, 116, 117, 119, 120, 120, 121, 122, 123, 124, 125, 126, 126, 127, 128, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 139, 141, 142, 143, 144, 145, 145, 146, 147, 148, 149, 151, 151, 153, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163, 165, 166, 167, 168, 169, 170, 170, 171, 172, 173, 174, 175, 177, 178, 179, 180, 181, 182, 183, 183, 184, 185, 186, 189, 189, 190, 191, 192, 193, 194, 195, 195, 196, 198, 199, 201, 202, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 213, 214, 214, 215, 216, 218, 219, 220, 221, 221, 222, 223, 225, 227, 227, 228, 229, 230, 230, 230, 230, 230, 230, 230, 230, 230 }; - int[] arrayOfInt5 = { 0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 15, 15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 25, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, 81, 82, 83, 84, 86, 87, 88, 89, 91, 92, 93, 95, 96, 97, 99, 100, 101, 103, 104, 105, 107, 108, 109, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124, 125, 126, 128, 129, 131, 132, 134, 135, 137, 138, 140, 141, 142, 144, 145, 147, 148, 149, 151, 152, 154, 155, 156, 158, 159, 160, 162, 163, 164, 166, 167, 168, 170, 171, 172, 173, 175, 176, 177, 178, 180, 181, 182, 183, 184, 186, 187, 188, 189, 190, 191, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 220, 221, 222, 223, 224, 225, 225, 226, 227, 228, 229, 229, 230, 231, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 238, 239, 240, 240, 241, 241, 242, 243, 243, 244, 244, 245, 245, 246, 246, 247, 247, 248, 248, 249, 249, 250, 250, 251, 251, 252, 252, 252, 253, 253, 254, 254, 254, 255, 255 }; - int[] arrayOfInt6 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int j = 0; j < 256; j++){ - arrayOfByte[(1024 + j * 4)] = ((byte)arrayOfInt4[j]); - arrayOfByte[(1 + (1024 + j * 4))] = ((byte)arrayOfInt5[j]); - arrayOfByte[(2 + (1024 + j * 4))] = ((byte)arrayOfInt6[j]); - arrayOfByte[(3 + (1024 + j * 4))] = -1; - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicBrannanFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicBrannanFilter.java deleted file mode 100644 index 10dd89a..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicBrannanFilter.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicBrannanFilter extends GPUImageFilter{ - private int[] inputTextureHandles = {-1,-1,-1,-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1,-1,-1,-1}; - private int mGLStrengthLocation; - - public MagicBrannanFilter(){ - super(MagicFilterType.BRANNAN, R.raw.brannan); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for (int i = 0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/brannan_process.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/brannan_blowout.png"); - inputTextureHandles[2] = OpenGLUtils.loadTexture(getContext(), "filter/brannan_contrast.png"); - inputTextureHandles[3] = OpenGLUtils.loadTexture(getContext(), "filter/brannan_luma.png"); - inputTextureHandles[4] = OpenGLUtils.loadTexture(getContext(), "filter/brannan_screen.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicBrooklynFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicBrooklynFilter.java deleted file mode 100644 index f340296..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicBrooklynFilter.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicBrooklynFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1,-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1,-1}; - private int mGLStrengthLocation; - - public MagicBrooklynFilter(){ - super(MagicFilterType.BROOKLYN, R.raw.brooklyn); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for (int i = 0; i < inputTextureHandles.length; i++) { - inputTextureHandles[i] = -1; - } - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for (int i = 0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/brooklynCurves1.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/filter_map_first.png"); - inputTextureHandles[2] = OpenGLUtils.loadTexture(getContext(), "filter/brooklynCurves2.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicCalmFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicCalmFilter.java deleted file mode 100644 index b2406ad..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicCalmFilter.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -import java.nio.ByteBuffer; - -public class MagicCalmFilter extends GPUImageFilter{ - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - private int mMaskGrey1TextureId = -1; - private int mMaskGrey1UniformLocation; - private int mMaskGrey2TextureId = -1; - private int mMaskGrey2UniformLocation; - - public MagicCalmFilter(){ - super(MagicFilterType.CALM, R.raw.calm); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(3, new int[]{mToneCurveTexture[0], mMaskGrey1TextureId, mMaskGrey2TextureId}, 0); - mToneCurveTexture[0] = -1; - mMaskGrey1TextureId = -1; - mMaskGrey2TextureId = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey2TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE5); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey1TextureId); - GLES20.glUniform1i(mMaskGrey1UniformLocation, 4); - } - if (mMaskGrey2TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE5); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey2TextureId); - GLES20.glUniform1i(mMaskGrey2UniformLocation, 5); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - mMaskGrey1UniformLocation = GLES20.glGetUniformLocation(getProgram(), "grey1Frame"); - mMaskGrey2UniformLocation = GLES20.glGetUniformLocation(getProgram(), "grey2Frame"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[3072]; - int[] arrayOfInt1 = { 38, 39, 40, 41, 41, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 52, 53, 54, 55, 56, 57, 58, 58, 59, 60, 61, 62, 63, 64, 64, 65, 66, 67, 68, 69, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 81, 82, 83, 84, 85, 86, 87, 87, 88, 89, 90, 91, 92, 92, 93, 94, 95, 96, 97, 98, 98, 99, 100, 101, 102, 103, 104, 104, 105, 106, 107, 108, 109, 109, 110, 111, 112, 113, 114, 115, 115, 116, 117, 118, 119, 120, 121, 121, 122, 123, 124, 125, 126, 127, 127, 128, 129, 130, 131, 132, 132, 133, 134, 135, 136, 137, 138, 138, 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149, 149, 150, 151, 152, 153, 154, 155, 155, 156, 157, 158, 159, 160, 161, 161, 162, 163, 164, 165, 166, 166, 167, 168, 169, 170, 171, 172, 172, 173, 174, 175, 176, 177, 178, 178, 179, 180, 181, 182, 183, 184, 184, 185, 186, 187, 188, 189, 189, 190, 191, 192, 193, 194, 195, 195, 196, 197, 198, 199, 200, 201, 201, 202, 203, 204, 205, 206, 206, 207, 208, 209, 210, 211, 212, 212, 213, 214, 215, 216, 217, 218, 218, 219, 220, 221, 222, 223, 224, 224, 225, 226, 227, 228, 229, 229, 230, 231, 232, 233, 234, 235, 235, 236, 237, 238, 239, 240, 241, 241, 242, 243, 244, 245, 246, 246, 247, 248, 249, 250, 251, 252, 252, 253, 254, 255 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(3 + i * 4)] = -1; - } - int[] arrayOfInt2 = { 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 93, 94, 95, 96, 97, 98, 99, 99, 100, 101, 102, 103, 104, 104, 105, 106, 107, 108, 109, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 118, 119, 120, 121, 122, 123, 123, 124, 125, 126, 127, 127, 128, 129, 130, 131, 131, 132, 133, 134, 135, 135, 136, 137, 138, 139, 140, 140, 141, 142, 143, 144, 145, 145, 146, 147, 148, 149, 150, 150, 151, 152, 153, 154, 155, 156, 157, 157, 158, 159, 160, 161, 162, 163, 164, 165, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 196, 197, 198, 199, 200, 201, 202, 203, 204, 206, 207, 208, 209, 210, 211, 213, 214, 215, 216, 217, 218, 220, 221, 222, 223, 224, 226, 227, 228, 229, 230, 232, 233, 234, 235, 237, 238, 239, 240, 241, 243, 244, 245, 246, 248, 249, 250, 251, 253, 254, 255 }; - int[] arrayOfInt3 = { 0, 1, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 15, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 42, 43, 44, 46, 47, 48, 50, 51, 53, 54, 56, 57, 59, 60, 62, 64, 65, 67, 69, 70, 72, 74, 75, 77, 79, 80, 82, 84, 85, 87, 89, 91, 92, 94, 96, 97, 99, 101, 102, 104, 106, 107, 109, 111, 112, 114, 115, 117, 118, 120, 121, 123, 124, 126, 127, 129, 130, 132, 133, 134, 136, 137, 138, 140, 141, 142, 144, 145, 146, 147, 149, 150, 151, 152, 153, 155, 156, 157, 158, 159, 160, 161, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 184, 185, 186, 187, 188, 189, 190, 191, 191, 192, 193, 194, 195, 196, 196, 197, 198, 199, 200, 200, 201, 202, 203, 203, 204, 205, 206, 206, 207, 208, 209, 209, 210, 211, 211, 212, 213, 214, 214, 215, 216, 216, 217, 218, 218, 219, 220, 220, 221, 222, 222, 223, 224, 224, 225, 226, 226, 227, 227, 228, 229, 229, 230, 231, 231, 232, 233, 233, 234, 234, 235, 236, 236, 237, 237, 238, 239, 239, 240, 240, 241, 242, 242, 243, 243, 244, 245, 245, 246, 246, 247, 247, 248, 249, 249, 250, 250, 251, 252, 252, 253, 253, 254, 254, 255 }; - for (int j = 0; j < 256; j++){ - arrayOfByte[(1024 + j * 4)] = ((byte)arrayOfInt3[j]); - arrayOfByte[(1 + (1024 + j * 4))] = ((byte)arrayOfInt3[j]); - arrayOfByte[(2 + (1024 + j * 4))] = ((byte)arrayOfInt2[j]); - arrayOfByte[(3 + (1024 + j * 4))] = -1; - } - int[] arrayOfInt4 = { 0, 1, 3, 4, 5, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 27, 28, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 45, 46, 47, 49, 50, 51, 53, 54, 55, 57, 58, 59, 61, 62, 63, 64, 66, 67, 68, 70, 71, 72, 74, 75, 76, 77, 79, 80, 81, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 98, 99, 100, 101, 103, 104, 105, 106, 108, 109, 110, 111, 112, 114, 115, 116, 117, 118, 119, 121, 122, 123, 124, 125, 126, 128, 129, 130, 131, 132, 133, 134, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 175, 176, 177, 178, 179, 180, 181, 182, 183, 183, 184, 185, 186, 187, 188, 189, 189, 190, 191, 192, 193, 194, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 202, 203, 204, 205, 205, 206, 207, 208, 208, 209, 210, 211, 211, 212, 213, 214, 214, 215, 216, 216, 217, 218, 218, 219, 220, 221, 221, 222, 223, 223, 224, 225, 225, 226, 227, 227, 228, 229, 229, 230, 231, 231, 232, 233, 233, 234, 235, 235, 236, 237, 237, 238, 239, 239, 240, 240, 241, 242, 242, 243, 244, 244, 245, 246, 246, 247, 247, 248, 249, 249, 250, 251, 251, 252, 252, 253, 254, 254, 255 }; - int[] arrayOfInt5 = { 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 21, 21, 21, 22, 22, 23, 23, 24, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 33, 33, 34, 34, 35, 35, 36, 37, 37, 38, 38, 39, 40, 40, 41, 42, 42, 43, 44, 44, 45, 46, 47, 47, 48, 49, 49, 50, 51, 52, 53, 53, 54, 55, 56, 57, 57, 58, 59, 60, 61, 62, 63, 64, 65, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 81, 82, 83, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 96, 97, 98, 99, 101, 102, 103, 105, 106, 107, 109, 110, 111, 113, 114, 115, 117, 118, 120, 121, 123, 124, 126, 127, 129, 130, 132, 133, 135, 137, 138, 140, 142, 143, 145, 147, 148, 150, 152, 153, 155, 157, 159, 161, 162, 164, 166, 168, 170, 172, 174, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 247, 249, 251, 253, 255 }; - int[] arrayOfInt6 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int k = 0; k < 256; k++){ - arrayOfByte[(2048 + k * 4)] = ((byte)arrayOfInt4[k]); - arrayOfByte[(1 + (2048 + k * 4))] = ((byte)arrayOfInt5[k]); - arrayOfByte[(2 + (2048 + k * 4))] = ((byte)arrayOfInt6[k]); - arrayOfByte[(3 + (2048 + k * 4))] = -1; - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 3, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - mMaskGrey1TextureId = OpenGLUtils.loadTexture(getContext(), "filter/calm_mask1.jpg"); - mMaskGrey2TextureId = OpenGLUtils.loadTexture(getContext(), "filter/calm_mask2.jpg"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicCoolFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicCoolFilter.java deleted file mode 100644 index 25d94fb..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicCoolFilter.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicCoolFilter extends GPUImageFilter { - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - - public MagicCoolFilter(){ - super(MagicFilterType.COOL, R.raw.cool); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - this.mToneCurveTexture[0] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (this.mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre() { - if (this.mToneCurveTexture[0] != -1) { - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(this.mToneCurveTextureUniformLocation, 3); - } - } - - @Override - protected void onInit() { - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - } - - @Override - protected void onInitialized() { - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[2048]; - int[] arrayOfInt1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 16, 16, 17, 18, 19, 20, 20, 21, 22, 23, 24, 24, 25, 26, 27, 28, 28, 29, 30, 31, 32, 33, 33, 34, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 97, 98, 99, 100, 102, 103, 104, 105, 107, 108, 109, 111, 112, 113, 115, 116, 117, 119, 120, 121, 123, 124, 126, 127, 128, 130, 131, 133, 134, 136, 137, 139, 140, 142, 143, 145, 146, 148, 149, 151, 152, 154, 155, 157, 158, 160, 161, 163, 165, 166, 168, 169, 171, 173, 174, 176, 177, 179, 181, 182, 184, 185, 187, 189, 190, 192, 194, 195, 197, 199, 200, 202, 204, 205, 207, 209, 210, 212, 214, 216, 217, 219, 221, 222, 224, 226, 228, 229, 231, 233, 234, 236, 238, 240, 241, 243, 245, 246, 248, 250, 252, 253, 255 }; - int[] arrayOfInt2 = { 0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 250, 251, 252, 253, 254, 255 }; - int[] arrayOfInt3 = { 0, 3, 6, 9, 11, 14, 17, 20, 23, 26, 28, 31, 34, 37, 40, 43, 45, 48, 51, 54, 57, 59, 62, 65, 68, 70, 73, 76, 79, 81, 84, 87, 89, 92, 95, 97, 100, 102, 105, 108, 110, 113, 115, 118, 120, 123, 125, 128, 130, 133, 135, 137, 140, 142, 144, 147, 149, 151, 153, 156, 158, 160, 162, 164, 166, 168, 171, 173, 175, 177, 179, 180, 182, 184, 186, 188, 190, 191, 193, 195, 197, 198, 200, 201, 203, 205, 206, 207, 209, 210, 212, 213, 214, 216, 217, 218, 219, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 234, 235, 236, 237, 237, 238, 239, 240, 240, 241, 242, 242, 243, 243, 244, 244, 245, 245, 246, 246, 247, 247, 248, 248, 248, 249, 249, 249, 250, 250, 250, 251, 251, 251, 251, 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 253, 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt4 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 13, 17, 21, 24, 32, 36, 39, 46, 50, 53, 56, 62, 65, 68, 73, 75, 78, 80, 85, 87, 88, 92, 94, 95, 96, 99, 100, 102, 104, 106, 107, 109, 110, 112, 113, 115, 116, 117, 120, 121, 122, 123, 125, 126, 127, 129, 130, 131, 132, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 146, 147, 148, 149, 150, 151, 152, 154, 154, 155, 156, 158, 159, 159, 161, 162, 163, 163, 165, 166, 166, 168, 169, 169, 170, 172, 172, 173, 175, 175, 176, 177, 178, 179, 180, 181, 182, 182, 184, 184, 185, 186, 187, 188, 188, 190, 190, 191, 192, 193, 194, 194, 196, 196, 197, 197, 199, 199, 200, 201, 202, 202, 203, 204, 205, 205, 207, 207, 208, 208, 210, 210, 211, 212, 213, 213, 214, 215, 215, 216, 217, 218, 218, 219, 220, 221, 221, 222, 223, 223, 224, 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, 233, 234, 235, 235, 236, 237, 237, 238, 239, 239, 240, 240, 241, 242, 242, 243, 244, 244, 245, 246, 246, 247, 248, 248, 249, 249, 250, 251, 251, 252, 253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte[(3 + i * 4)] = ((byte)arrayOfInt4[i]); - } - int[] arrayOfInt5 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int j = 0; j < 256; j++){ - arrayOfByte[(1024 + j * 4)] = ((byte)arrayOfInt5[j]); - arrayOfByte[(1 + (1024 + j * 4))] = ((byte)arrayOfInt5[j]); - arrayOfByte[(2 + (1024 + j * 4))] = ((byte)arrayOfInt5[j]); - arrayOfByte[(3 + (1024 + j * 4))] = -1; - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicCrayonFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicCrayonFilter.java deleted file mode 100644 index 5f432eb..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicCrayonFilter.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -public class MagicCrayonFilter extends GPUImageFilter { - - private int mSingleStepOffsetLocation; - //1.0 - 5.0 - private int mStrengthLocation; - - public MagicCrayonFilter(){ - super(MagicFilterType.CRAYON, R.raw.crayon); - } - - @Override - protected void onInit() { - super.onInit(); - mSingleStepOffsetLocation = GLES20.glGetUniformLocation(getProgram(), "singleStepOffset"); - mStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - setFloat(mStrengthLocation, 2.0f); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mStrengthLocation, 0.5f); - } - - @Override - public void onInputSizeChanged(final int width, final int height) { - setFloatVec2(mSingleStepOffsetLocation, new float[] {1.0f / width, 1.0f / height}); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicEarlyBirdFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicEarlyBirdFilter.java deleted file mode 100644 index 2f53954..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicEarlyBirdFilter.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicEarlyBirdFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1,-1,-1,-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1,-1,-1,-1}; - protected int mGLStrengthLocation; - - public MagicEarlyBirdFilter(){ - super(MagicFilterType.EARLYBIRD, R.raw.earlybird); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for(int i=0; i < inputTextureUniformLocations.length; i++) - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture"+(2+i)); - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/earlybirdcurves.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/earlybirdoverlaymap_new.png"); - inputTextureHandles[2] = OpenGLUtils.loadTexture(getContext(), "filter/vignettemap_new.png"); - inputTextureHandles[3] = OpenGLUtils.loadTexture(getContext(), "filter/earlybirdblowout.png"); - inputTextureHandles[4] = OpenGLUtils.loadTexture(getContext(), "filter/earlybirdmap.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicEmeraldFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicEmeraldFilter.java deleted file mode 100644 index 967941a..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicEmeraldFilter.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicEmeraldFilter extends GPUImageFilter { - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - - public MagicEmeraldFilter(){ - super(MagicFilterType.EMERALD, R.raw.emerald); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - mToneCurveTexture[0] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[2048]; - int[] arrayOfInt1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 4, 7, 8, 9, 10, 12, 13, 14, 17, 18, 19, 21, 22, 23, 25, 26, 29, 30, 31, 32, 34, 35, 36, 39, 40, 41, 43, 44, 45, 46, 48, 50, 51, 53, 54, 55, 56, 58, 60, 61, 62, 64, 65, 66, 67, 69, 70, 72, 73, 75, 76, 77, 78, 79, 81, 82, 84, 85, 87, 88, 89, 90, 91, 92, 94, 96, 97, 98, 99, 101, 102, 103, 104, 105, 106, 107, 110, 111, 112, 113, 114, 115, 116, 117, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 173, 174, 175, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 184, 185, 186, 187, 188, 189, 190, 191, 191, 192, 193, 194, 195, 196, 197, 197, 198, 199, 200, 201, 201, 202, 203, 204, 205, 206, 206, 207, 208, 209, 210, 210, 211, 212, 213, 213, 214, 215, 216, 216, 217, 218, 219, 220, 220, 221, 222, 223, 223, 224, 225, 226, 226, 227, 228, 228, 229, 230, 231, 231, 232, 233, 234, 234, 235, 236, 236, 237, 237, 238, 239, 239, 240, 241, 242, 242, 243, 244, 244, 245, 246, 247, 247, 248, 249, 249, 250, 251, 251, 252, 253, 254, 254, 255 }; - int[] arrayOfInt2 = { 0, 0, 0, 0, 0, 0, 1, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 16, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 31, 32, 34, 35, 36, 37, 39, 40, 41, 43, 44, 45, 46, 48, 50, 51, 53, 54, 55, 56, 58, 59, 60, 61, 62, 64, 65, 66, 67, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 94, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 106, 107, 109, 111, 112, 113, 114, 115, 116, 117, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 136, 137, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 184, 185, 186, 188, 189, 190, 191, 191, 192, 193, 194, 195, 196, 197, 197, 198, 199, 200, 201, 201, 202, 203, 204, 205, 206, 206, 207, 209, 210, 210, 211, 212, 213, 213, 214, 215, 216, 216, 217, 218, 219, 220, 220, 221, 222, 223, 223, 224, 225, 226, 226, 227, 228, 229, 230, 231, 231, 232, 233, 234, 234, 235, 236, 237, 237, 238, 239, 239, 240, 241, 242, 242, 243, 244, 244, 245, 247, 247, 248, 249, 249, 250, 251, 251, 252, 253, 254, 254, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt3 = { 0, 1, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 31, 32, 34, 35, 36, 37, 39, 40, 41, 43, 44, 45, 46, 48, 49, 50, 51, 53, 54, 55, 56, 58, 59, 60, 61, 62, 64, 65, 66, 67, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 94, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 106, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 184, 185, 186, 187, 188, 189, 190, 191, 191, 192, 193, 194, 195, 196, 197, 197, 198, 199, 200, 201, 201, 202, 203, 204, 205, 206, 206, 207, 208, 209, 210, 210, 211, 212, 213, 213, 214, 215, 216, 216, 217, 218, 219, 220, 220, 221, 222, 223, 223, 224, 225, 226, 226, 227, 228, 228, 229, 230, 231, 231, 232, 233, 234, 234, 235, 236, 237, 237, 238, 239, 239, 240, 241, 242, 242, 243, 244, 244, 245, 246, 247, 247, 248, 249, 249, 250, 251, 251, 252, 253, 254, 254, 255 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte[(3 + i * 4)] = -1; - } - int[] arrayOfInt4 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 123, 124, 125, 126, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 164, 165, 166, 167, 168, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 200, 201, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 224, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt5 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 126, 127, 128, 129, 130, 131, 132, 133, 135, 136, 137, 138, 139, 140, 141, 142, 143, 145, 146, 147, 148, 149, 150, 151, 152, 154, 155, 156, 157, 158, 159, 160, 161, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 223, 224, 225, 226, 227, 228, 229, 229, 230, 231, 232, 233, 233, 234, 235, 236, 237, 237, 238, 239, 240, 240, 241, 242, 243, 243, 244, 245, 245, 246, 247, 247, 248, 249, 249, 250, 250, 251, 252, 252, 253, 253, 254, 254, 255 }; - int[] arrayOfInt6 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int j = 0; j < 256; j++){ - arrayOfByte[(1024 + j * 4)] = ((byte)arrayOfInt5[j]); - arrayOfByte[(1 + (1024 + j * 4))] = ((byte)arrayOfInt4[j]); - arrayOfByte[(2 + (1024 + j * 4))] = ((byte)arrayOfInt6[j]); - arrayOfByte[(3 + (1024 + j * 4))] = -1; - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicEvergreenFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicEvergreenFilter.java deleted file mode 100644 index 91c592f..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicEvergreenFilter.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicEvergreenFilter extends GPUImageFilter { - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - - public MagicEvergreenFilter(){ - super(MagicFilterType.EVERGREEN, R.raw.evergreen); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - mToneCurveTexture[0] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - } - @Override - protected void onInitialized() { - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[1024]; - int[] arrayOfInt1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 }; - int[] arrayOfInt2 = { 0, 1, 1, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 17, 18, 19, 20, 21, 21, 22, 23, 24, 24, 25, 26, 27, 28, 28, 29, 30, 31, 32, 32, 33, 34, 35, 36, 37, 38, 38, 39, 40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 112, 113, 115, 116, 117, 118, 119, 120, 122, 123, 124, 125, 126, 127, 129, 130, 131, 132, 133, 135, 136, 137, 138, 139, 140, 142, 143, 144, 145, 146, 148, 149, 150, 151, 152, 153, 155, 156, 157, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 174, 175, 177, 178, 179, 180, 181, 182, 183, 185, 186, 187, 188, 189, 190, 191, 192, 193, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 241, 242, 243, 244, 245, 246, 247, 247, 248, 249, 250, 251, 252, 252, 253, 254, 255 }; - int[] arrayOfInt3 = { 0, 2, 4, 6, 8, 10, 11, 13, 16, 17, 19, 20, 21, 23, 24, 25, 27, 28, 29, 31, 32, 33, 34, 36, 38, 39, 40, 42, 43, 44, 45, 46, 48, 49, 50, 51, 52, 53, 54, 56, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 128, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 144, 145, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 157, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 168, 169, 170, 171, 172, 173, 175, 176, 177, 177, 178, 179, 180, 181, 182, 183, 184, 185, 185, 186, 187, 188, 190, 191, 192, 193, 193, 194, 195, 196, 197, 198, 199, 200, 200, 201, 202, 203, 205, 206, 207, 207, 208, 209, 210, 211, 212, 213, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 225, 226, 227, 228, 229, 230, 231, 231, 232, 234, 235, 236, 237, 237, 238, 239, 240, 241, 242, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt4 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int i = 0; i < 256; i++) - { - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte[(3 + i * 4)] = ((byte)arrayOfInt4[i]); - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 1, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicFreudFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicFreudFilter.java deleted file mode 100644 index 9bbbaa9..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicFreudFilter.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicFreudFilter extends GPUImageFilter { - private int mTexelHeightUniformLocation; - private int mTexelWidthUniformLocation; - private int[] inputTextureHandles = {-1}; - private int[] inputTextureUniformLocations = {-1}; - private int mGLStrengthLocation; - - public MagicFreudFilter(){ - super(MagicFilterType.FREUD, R.raw.freud); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(1, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - for (int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for (int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - inputTextureUniformLocations[0] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture2"); - - mTexelWidthUniformLocation = GLES20.glGetUniformLocation(getProgram(), "inputImageTextureWidth"); - mTexelHeightUniformLocation = GLES20.glGetUniformLocation(getProgram(), "inputImageTextureHeight"); - - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/freud_rand.png"); - } - }); - } - - @Override - public void onInputSizeChanged(int width, int height) { - super.onInputSizeChanged(width, height); - GLES20.glUniform1f(mTexelWidthUniformLocation, (float)width); - GLES20.glUniform1f(mTexelHeightUniformLocation, (float)height); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicHealthyFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicHealthyFilter.java deleted file mode 100644 index 27bb7d3..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicHealthyFilter.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicHealthyFilter extends GPUImageFilter{ - - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - private int mMaskGrey1TextureId = -1; - private int mMaskGrey1UniformLocation; - private int mTexelHeightUniformLocation; - private int mTexelWidthUniformLocation; - - public MagicHealthyFilter(){ - super(MagicFilterType.HEALTHY, R.raw.healthy); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - mToneCurveTexture[0] = -1; - int[] texture = new int[1]; - texture[0] = mMaskGrey1TextureId; - GLES20.glDeleteTextures(1, texture, 0); - mMaskGrey1TextureId = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey1TextureId); - GLES20.glUniform1i(mMaskGrey1UniformLocation, 4); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - mMaskGrey1UniformLocation = GLES20.glGetUniformLocation(getProgram(), "mask"); - mTexelWidthUniformLocation = GLES20.glGetUniformLocation(getProgram(), "texelWidthOffset"); - mTexelHeightUniformLocation = GLES20.glGetUniformLocation(getProgram(), "texelHeightOffset"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[1024]; - int[] arrayOfInt1 = { 95, 95, 96, 97, 97, 98, 99, 99, 100, 101, 101, 102, 103, 104, 104, 105, 106, 106, 107, 108, 108, 109, 110, 111, 111, 112, 113, 113, 114, 115, 115, 116, 117, 117, 118, 119, 120, 120, 121, 122, 122, 123, 124, 124, 125, 126, 127, 127, 128, 129, 129, 130, 131, 131, 132, 133, 133, 134, 135, 136, 136, 137, 138, 138, 139, 140, 140, 141, 142, 143, 143, 144, 145, 145, 146, 147, 147, 148, 149, 149, 150, 151, 152, 152, 153, 154, 154, 155, 156, 156, 157, 158, 159, 159, 160, 161, 161, 162, 163, 163, 164, 165, 165, 166, 167, 168, 168, 169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177, 177, 178, 179, 179, 180, 181, 181, 182, 183, 184, 184, 185, 186, 186, 187, 188, 188, 189, 190, 191, 191, 192, 193, 193, 194, 195, 195, 196, 197, 197, 198, 199, 200, 200, 201, 202, 202, 203, 204, 204, 205, 206, 207, 207, 208, 209, 209, 210, 211, 211, 212, 213, 213, 214, 215, 216, 216, 217, 218, 218, 219, 220, 220, 221, 222, 223, 223, 224, 225, 225, 226, 227, 227, 228, 229, 229, 230, 231, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 239, 239, 240, 241, 241, 242, 243, 243, 244, 245, 245, 246, 247, 248, 248, 249, 250, 250, 251, 252, 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 61, 62, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 168, 169, 170, 171, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 204, 205, 206, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 219, 220, 221, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 234, 235, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 249, 249, 250, 251, 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt3 = { 0, 1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 95, 96, 97, 98, 99, 100, 101, 102, 103, 105, 106, 107, 108, 109, 110, 111, 112, 114, 115, 116, 117, 118, 119, 120, 121, 122, 124, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 249, 250, 251, 252, 253, 254, 255 }; - for (int i = 0; i < 256; i++) - { - arrayOfByte[(i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(3 + i * 4)] = -1; - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 1, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - } - }); - } - - @Override - public void onInputSizeChanged(int width, int height){ - super.onInputSizeChanged(width, height); - GLES20.glUniform1f(mTexelWidthUniformLocation, 1.0f / width); - GLES20.glUniform1f(mTexelHeightUniformLocation, 1.0f / height); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicHefeFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicHefeFilter.java deleted file mode 100644 index a7324e6..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicHefeFilter.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicHefeFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1,-1,-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1,-1,-1}; - private int mGLStrengthLocation; - - public MagicHefeFilter(){ - super(MagicFilterType.HEFE, R.raw.hefe); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) { - inputTextureHandles[i] = -1; - } - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for(int i=0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/edgeburn.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/hefemap.png"); - inputTextureHandles[2] = OpenGLUtils.loadTexture(getContext(), "filter/hefemetal.png"); - inputTextureHandles[3] = OpenGLUtils.loadTexture(getContext(), "filter/hefesoftlight.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicHudsonFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicHudsonFilter.java deleted file mode 100644 index 10669c5..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicHudsonFilter.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicHudsonFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1,-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1,-1}; - private int mGLStrengthLocation; - - public MagicHudsonFilter(){ - super(MagicFilterType.HUDSON, R.raw.hudson); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for(int i=0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/ohudsonbackground.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/overlaymap.png"); - inputTextureHandles[2] = OpenGLUtils.loadTexture(getContext(), "filter/hudsonmap.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicImageAdjustFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicImageAdjustFilter.java deleted file mode 100644 index 6b1a027..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicImageAdjustFilter.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.seu.magicfilter.advanced; - -import com.seu.magicfilter.base.MagicBaseGroupFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageBrightnessFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageContrastFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageExposureFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageHueFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageSaturationFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageSharpenFilter; - -import java.util.ArrayList; -import java.util.List; - -public class MagicImageAdjustFilter extends MagicBaseGroupFilter { - - public MagicImageAdjustFilter() { - super(initFilters()); - } - - private static List initFilters(){ - List filters = new ArrayList(); - filters.add(new GPUImageContrastFilter()); - filters.add(new GPUImageBrightnessFilter()); - filters.add(new GPUImageExposureFilter()); - filters.add(new GPUImageHueFilter()); - filters.add(new GPUImageSaturationFilter()); - filters.add(new GPUImageSharpenFilter()); - return filters; - } - - public void setSharpness(final float range){ - ((GPUImageSharpenFilter) filters.get(5)).setSharpness(range); - } - - public void setHue(final float range){ - ((GPUImageHueFilter) filters.get(3)).setHue(range); - } - - public void setBrightness(final float range){ - ((GPUImageBrightnessFilter) filters.get(1)).setBrightness(range); - } - - public void setContrast(final float range){ - ((GPUImageContrastFilter) filters.get(0)).setContrast(range); - } - - public void setSaturation(final float range){ - ((GPUImageSaturationFilter) filters.get(4)).setSaturation(range); - } - - public void setExposure(final float range){ - ((GPUImageExposureFilter) filters.get(2)).setExposure(range); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicInkwellFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicInkwellFilter.java deleted file mode 100644 index da48b76..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicInkwellFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicInkwellFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1}; - private int[] inputTextureUniformLocations = {-1}; - private int mGLStrengthLocation; - - public MagicInkwellFilter(){ - super(MagicFilterType.INKWELL, R.raw.inkwell); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(1, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for(int i = 0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/inkwellmap.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicKevinFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicKevinFilter.java deleted file mode 100644 index 3e44423..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicKevinFilter.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicKevinFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1}; - private int[] inputTextureUniformLocations = {-1}; - private int mGLStrengthLocation; - - public MagicKevinFilter(){ - super(MagicFilterType.KEVIN, R.raw.kevin_new); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(1, inputTextureHandles, 0); - for (int i = 0; i < inputTextureHandles.length; i++) { - inputTextureHandles[i] = -1; - } - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for(int i = 0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/kelvinmap.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicLatteFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicLatteFilter.java deleted file mode 100644 index d6f5a6a..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicLatteFilter.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicLatteFilter extends GPUImageFilter { - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - - public MagicLatteFilter(){ - super(MagicFilterType.LATTE, R.raw.latte); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - mToneCurveTexture[0] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[2048]; - int[] arrayOfInt1 = { 5, 6, 8, 9, 11, 12, 14, 15, 16, 18, 19, 21, 22, 23, 25, 26, 28, 29, 30, 32, 33, 34, 36, 37, 39, 40, 41, 43, 44, 45, 46, 48, 49, 50, 52, 53, 54, 55, 56, 58, 59, 60, 61, 62, 64, 65, 66, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 108, 109, 110, 111, 112, 113, 114, 115, 115, 116, 117, 118, 119, 120, 120, 121, 122, 123, 124, 125, 125, 126, 127, 128, 129, 130, 130, 131, 132, 133, 134, 134, 135, 136, 137, 137, 138, 139, 140, 141, 141, 142, 143, 144, 145, 145, 146, 147, 148, 148, 149, 150, 151, 151, 152, 153, 154, 155, 155, 156, 157, 158, 158, 159, 160, 161, 162, 162, 163, 164, 165, 166, 166, 167, 168, 169, 170, 170, 171, 172, 173, 174, 174, 175, 176, 177, 178, 178, 179, 180, 181, 182, 183, 183, 184, 185, 186, 187, 188, 189, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 }; - int[] arrayOfInt2 = { 5, 6, 8, 11, 12, 14, 15, 18, 19, 21, 22, 25, 26, 28, 29, 32, 33, 34, 36, 39, 40, 41, 43, 44, 46, 48, 49, 50, 52, 54, 55, 56, 58, 59, 61, 62, 64, 65, 66, 67, 69, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 108, 108, 109, 110, 111, 112, 113, 114, 115, 115, 116, 117, 118, 119, 120, 120, 121, 122, 123, 125, 125, 126, 127, 128, 129, 130, 130, 131, 132, 133, 134, 134, 135, 136, 137, 137, 138, 139, 140, 141, 141, 142, 143, 144, 145, 145, 146, 147, 148, 148, 149, 149, 150, 151, 151, 152, 153, 154, 155, 155, 156, 157, 158, 158, 159, 160, 161, 162, 162, 163, 164, 165, 165, 166, 166, 167, 168, 169, 170, 170, 171, 172, 173, 174, 174, 175, 175, 176, 177, 178, 178, 179, 180, 181, 182, 183, 183, 184, 184, 185, 186, 187, 188, 189, 189, 190, 191, 192, 192, 193, 194, 195, 196, 197, 198, 198, 199, 199, 200, 201, 202, 203, 204, 205, 206, 206, 207, 208, 209, 210, 211, 212, 213, 213, 214, 215, 215, 216, 217, 218, 219, 219, 220, 221, 222, 223, 224, 225, 226, 226, 227, 228, 229, 230, 231, 232, 232, 233, 234, 235, 237, 238, 239, 240, 240, 241, 242, 243, 244, 245, 246, 246, 247, 248, 249, 250, 251, 252, 252, 253, 254, 255 }; - int[] arrayOfInt3 = { 5, 6, 8, 11, 12, 14, 15, 16, 18, 21, 22, 23, 25, 26, 28, 30, 32, 33, 34, 36, 37, 40, 41, 43, 44, 45, 46, 49, 50, 52, 53, 54, 55, 58, 59, 60, 61, 62, 64, 66, 67, 68, 69, 71, 72, 73, 75, 76, 77, 78, 79, 80, 81, 83, 85, 86, 87, 88, 89, 90, 92, 93, 94, 95, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 106, 107, 108, 108, 109, 111, 112, 113, 114, 115, 115, 116, 117, 118, 119, 120, 120, 121, 123, 124, 125, 125, 126, 127, 128, 129, 130, 130, 131, 132, 133, 134, 134, 135, 136, 137, 137, 138, 139, 140, 141, 141, 142, 143, 144, 145, 145, 146, 147, 148, 148, 149, 150, 151, 151, 152, 153, 154, 155, 155, 156, 156, 157, 158, 158, 159, 160, 161, 162, 162, 163, 164, 165, 165, 166, 166, 167, 168, 169, 170, 170, 170, 171, 172, 173, 174, 174, 175, 176, 176, 177, 178, 178, 179, 180, 180, 181, 182, 183, 183, 184, 184, 185, 186, 187, 188, 189, 189, 189, 190, 191, 192, 192, 193, 194, 195, 196, 196, 197, 198, 198, 199, 199, 200, 201, 202, 202, 203, 204, 205, 206, 206, 207, 208, 209, 209, 210, 211, 212, 213, 213, 214, 215, 215, 215, 216, 217, 218, 218, 219, 220, 221, 221, 222, 223, 224, 224, 225, 226, 227, 227, 228, 229, 230, 230, 231, 232, 233, 233, 234, 235, 237, 237, 238, 239, 240, 240, 241, 242, 243, 243, 244 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte[(3 + i * 4)] = -1; - } - int[] arrayOfInt4 = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 10, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 61, 62, 63, 64, 66, 67, 68, 69, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 137, 138, 139, 140, 141, 143, 144, 145, 146, 147, 149, 150, 151, 152, 153, 155, 156, 157, 158, 159, 161, 162, 163, 164, 165, 167, 168, 169, 170, 171, 173, 174, 175, 176, 177, 179, 180, 181, 182, 184, 185, 186, 187, 188, 190, 191, 192, 193, 194, 196, 197, 198, 199, 200, 202, 203, 204, 205, 206, 208, 209, 210, 211, 212, 214, 215, 216, 217, 218, 220, 221, 222, 223, 224, 226, 227, 228, 229, 230, 232, 233, 234, 235, 236, 238, 239, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240 }; - int[] arrayOfInt5 = { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49, 51, 52, 53, 54, 56, 57, 58, 59, 61, 62, 63, 65, 66, 67, 69, 70, 71, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89, 90, 92, 93, 94, 96, 97, 99, 100, 101, 103, 104, 106, 107, 108, 110, 111, 113, 114, 116, 117, 119, 120, 121, 123, 124, 126, 127, 129, 130, 132, 133, 135, 136, 138, 139, 140, 142, 143, 145, 146, 147, 149, 150, 151, 153, 154, 155, 157, 158, 159, 160, 162, 163, 164, 165, 167, 168, 169, 170, 171, 173, 174, 175, 176, 177, 178, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 210, 211, 212, 213, 214, 215, 215, 216, 217, 218, 219, 219, 220, 221, 222, 222, 223, 224, 225, 225, 226, 227, 227, 228, 229, 229, 230, 231, 231, 232, 233, 233, 234, 234, 235, 236, 236, 237, 237, 238, 238, 239, 240, 240, 241, 241, 242, 242, 243, 243, 244, 244, 244, 245, 245, 246, 246, 247, 247, 247, 248, 248, 249, 249, 249, 250, 250, 250, 251, 251, 251, 252, 252, 252, 252, 253, 253, 253, 253, 254, 254, 254, 254, 255, 255, 255 }; - int[] arrayOfInt6 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int j = 0; j < 256; j++){ - arrayOfByte[(1024 + j * 4)] = ((byte)arrayOfInt5[j]); - arrayOfByte[(1 + (1024 + j * 4))] = ((byte)arrayOfInt4[j]); - arrayOfByte[(2 + (1024 + j * 4))] = ((byte)arrayOfInt6[j]); - arrayOfByte[(3 + (1024 + j * 4))] = -1; - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicLomoFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicLomoFilter.java deleted file mode 100644 index d81f990..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicLomoFilter.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicLomoFilter extends GPUImageFilter{ - private int[] inputTextureHandles = {-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1}; - private int mGLStrengthLocation; - - public MagicLomoFilter(){ - super(MagicFilterType.LOMO, R.raw.lomo); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for(int i=0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/vlomomap_new.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/vignette_map.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicN1977Filter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicN1977Filter.java deleted file mode 100644 index 2b964cc..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicN1977Filter.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicN1977Filter extends GPUImageFilter{ - private int[] inputTextureHandles = {-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1}; - private int mGLStrengthLocation; - - public MagicN1977Filter(){ - super(MagicFilterType.N1977, R.raw.n1977); - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for(int i=0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/n1977map.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/n1977blowout.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicNashvilleFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicNashvilleFilter.java deleted file mode 100644 index d5e7377..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicNashvilleFilter.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicNashvilleFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1}; - private int[] inputTextureUniformLocations = {-1}; - private int mGLStrengthLocation; - - public MagicNashvilleFilter(){ - super(MagicFilterType.NASHVILLE, R.raw.nashville); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(1, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) { - inputTextureHandles[i] = -1; - } - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for(int i=0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/nashvillemap.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicNostalgiaFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicNostalgiaFilter.java deleted file mode 100644 index 1db368e..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicNostalgiaFilter.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicNostalgiaFilter extends GPUImageFilter { - private int mBlurSizeUniformLocation; - private int mTexelWidthUniformLocation; - private int mTexelHeightUniformLocation; - private int[] mToneCurveTexture = { -1 }; - private int[] mToneCurveTexture2 = { -1 }; - private int mToneCurveTextureUniformLocation; - private int mToneCurveTextureUniformLocation2; - - public MagicNostalgiaFilter(){ - super(MagicFilterType.NOSTALGIA, R.raw.nostalgia); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - mToneCurveTexture[0] = -1; - GLES20.glDeleteTextures(1, mToneCurveTexture2, 0); - mToneCurveTexture2[0] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mToneCurveTexture2[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - if (mToneCurveTexture2[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation2, 4); - } - GLES20.glUniform1f(mBlurSizeUniformLocation, 1.0F); - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - mToneCurveTextureUniformLocation2 = GLES20.glGetUniformLocation(getProgram(), "curve2"); - mTexelWidthUniformLocation = GLES20.glGetUniformLocation(getProgram(), "texelWidthOffset"); - mTexelHeightUniformLocation = GLES20.glGetUniformLocation(getProgram(), "texelHeightOffset"); - mBlurSizeUniformLocation = GLES20.glGetUniformLocation(getProgram(), "blurSize"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte1 = new byte[2048]; - int[] arrayOfInt1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 5, 6, 8, 9, 11, 13, 15, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 39, 41, 43, 45, 47, 49, 50, 52, 54, 56, 57, 59, 61, 62, 64, 66, 68, 69, 71, 72, 74, 76, 77, 79, 80, 82, 84, 85, 87, 88, 90, 91, 93, 94, 96, 97, 98, 100, 101, 103, 104, 106, 107, 108, 110, 111, 112, 114, 115, 116, 118, 119, 120, 122, 123, 124, 125, 127, 128, 129, 130, 131, 133, 134, 135, 136, 137, 138, 140, 141, 142, 143, 144, 145, 146, 147, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 174, 175, 176, 177, 178, 179, 180, 181, 182, 182, 183, 184, 185, 186, 187, 188, 188, 189, 190, 191, 192, 193, 193, 194, 195, 196, 197, 197, 198, 199, 200, 201, 201, 202, 203, 204, 204, 205, 206, 207, 207, 208, 209, 210, 210, 211, 212, 213, 213, 214, 215, 216, 216, 217, 218, 219, 219, 220, 221, 221, 222, 223, 224, 224, 225, 226, 226, 227, 228, 228, 229, 230, 231, 231, 232, 233, 233, 234, 235, 235, 236, 237, 237, 238, 239, 240, 240, 241, 242, 242, 243, 244, 244, 245, 246, 246, 247, 248, 248, 249, 250, 250, 251, 252, 252, 253, 254, 254, 255 }; - int[] arrayOfInt2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 4, 6, 7, 9, 10, 12, 13, 14, 16, 17, 19, 20, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 36, 37, 39, 40, 42, 43, 44, 46, 47, 49, 50, 52, 53, 54, 56, 57, 59, 60, 61, 63, 64, 66, 67, 69, 70, 71, 73, 74, 75, 77, 78, 80, 81, 82, 84, 85, 87, 88, 89, 91, 92, 93, 95, 96, 97, 99, 100, 101, 103, 104, 105, 107, 108, 109, 111, 112, 113, 115, 116, 117, 119, 120, 121, 122, 124, 125, 126, 127, 129, 130, 131, 132, 134, 135, 136, 137, 139, 140, 141, 142, 144, 145, 146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 158, 159, 160, 161, 162, 163, 164, 165, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 203, 204, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 213, 214, 215, 216, 216, 217, 218, 219, 219, 220, 221, 222, 222, 223, 224, 225, 225, 226, 227, 227, 228, 229, 229, 230, 231, 231, 232, 233, 233, 234, 235, 235, 236, 237, 237, 238, 239, 239, 240, 241, 241, 242, 243, 243, 244, 244, 245, 246, 246, 247, 248, 248, 249, 249, 250, 251, 251, 252, 253, 253, 254, 254, 255 }; - int[] arrayOfInt3 = { 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 31, 33, 35, 37, 39, 41, 43, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 65, 67, 69, 71, 73, 75, 76, 78, 80, 82, 84, 85, 87, 89, 91, 92, 94, 96, 98, 99, 101, 102, 104, 106, 107, 109, 110, 112, 114, 115, 117, 118, 119, 121, 122, 124, 125, 126, 128, 129, 130, 132, 133, 134, 135, 137, 138, 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 175, 176, 177, 178, 178, 179, 180, 181, 181, 182, 183, 184, 184, 185, 186, 186, 187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 195, 195, 196, 197, 197, 198, 199, 200, 200, 201, 202, 202, 203, 204, 204, 205, 206, 206, 207, 208, 208, 209, 210, 210, 211, 212, 212, 213, 214, 214, 215, 216, 216, 217, 218, 218, 219, 220, 220, 221, 221, 222, 223, 223, 224, 225, 225, 226, 227, 227, 228, 229, 229, 230, 231, 231, 232, 233, 233, 234, 234, 235, 236, 236, 237, 238, 238, 239, 240, 240, 241, 242, 242, 243, 243, 244, 245, 245, 246, 247, 247, 248, 249, 249, 250, 251, 251, 252, 252, 253, 254, 254, 255 }; - int[] arrayOfInt4 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int i = 0; i < 256; i++){ - arrayOfByte1[(0 + i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte1[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte1[(2 + i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte1[(3 + i * 4)] = ((byte)arrayOfInt4[i]); - } - int[] arrayOfInt5 = { 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 32, 33, 34, 35, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 50, 51, 52, 53, 55, 56, 57, 58, 60, 61, 62, 64, 65, 66, 67, 69, 70, 71, 72, 74, 75, 76, 77, 79, 80, 81, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 112, 114, 115, 116, 117, 118, 119, 121, 122, 123, 124, 125, 126, 127, 128, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 174, 175, 176, 177, 178, 179, 180, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 198, 199, 200, 201, 202, 204, 205, 206, 207, 209, 210, 211, 213, 214, 215, 217, 218, 220, 221, 222, 224, 225, 227, 228, 230, 231, 233, 234, 235, 237, 238, 240, 241, 243, 244, 246, 247, 249, 250, 252, 253, 255 }; - int[] arrayOfInt6 = { 0, 3, 6, 8, 11, 14, 16, 18, 21, 24, 26, 29, 30, 33, 35, 37, 39, 41, 43, 45, 47, 49, 50, 52, 53, 54, 56, 58, 59, 61, 62, 63, 65, 65, 66, 68, 69, 70, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 112, 113, 114, 115, 115, 116, 117, 118, 119, 120, 121, 122, 123, 123, 124, 125, 126, 127, 127, 128, 129, 130, 131, 132, 133, 134, 135, 135, 135, 136, 137, 138, 139, 140, 140, 141, 142, 143, 144, 145, 146, 146, 147, 147, 148, 149, 149, 150, 151, 152, 153, 154, 154, 155, 156, 157, 158, 158, 159, 159, 160, 161, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168, 169, 170, 170, 170, 171, 172, 173, 173, 174, 175, 176, 176, 177, 178, 179, 179, 180, 181, 181, 182, 182, 183, 183, 184, 185, 186, 186, 187, 188, 188, 189, 190, 191, 191, 192, 193, 193, 194, 194, 194, 195, 196, 197, 197, 198, 199, 199, 200, 201, 201, 202, 203, 203, 204, 205, 205, 206, 206, 207, 207, 208, 209, 209, 210, 211, 211, 212, 213, 213, 214, 215, 215, 216, 217, 217, 217, 217, 218, 219, 219, 220, 221, 221, 222, 223, 223, 224, 225, 225, 226, 227, 227, 228, 228, 229, 229, 229, 230, 231, 231, 232, 232, 233, 234, 234, 235 }; - int[] arrayOfInt7 = { 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 96, 97, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 111, 112, 113, 115, 116, 118, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132, 134, 135, 137, 139, 140, 142, 143, 145, 147, 148, 150, 152, 153, 155, 156, 158, 160, 161, 163, 164, 166, 167, 169, 170, 172, 173, 175, 176, 178, 179, 180, 182, 183, 185, 186, 188, 189, 190, 192, 193, 194, 196, 197, 199, 200, 201, 203, 204, 205, 206, 208, 209, 210, 212, 213, 214, 216, 217, 218, 219, 221, 222, 223, 224, 226, 227, 228, 229, 231, 232, 233, 234, 236, 237, 238, 239, 240, 242, 243, 244, 245, 247, 248, 249, 250, 251, 253, 254, 255 }; - for (int j = 0; j < 256; j++){ - arrayOfByte1[(0 + (1024 + j * 4))] = ((byte)arrayOfInt5[j]); - arrayOfByte1[(1 + (1024 + j * 4))] = ((byte)arrayOfInt6[j]); - arrayOfByte1[(2 + (1024 + j * 4))] = ((byte)arrayOfInt7[j]); - arrayOfByte1[(3 + (1024 + j * 4))] = ((byte)arrayOfInt4[j]); - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte1)); - GLES20.glGenTextures(1, mToneCurveTexture2, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture2[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte2 = new byte[1024]; - int[] arrayOfInt8 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - int[] arrayOfInt9 = { 42, 43, 43, 44, 45, 45, 46, 47, 48, 48, 49, 50, 50, 51, 52, 52, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 62, 63, 64, 65, 65, 66, 67, 67, 68, 69, 70, 70, 71, 72, 72, 73, 74, 75, 75, 76, 77, 78, 78, 79, 80, 81, 81, 82, 83, 84, 84, 85, 86, 87, 87, 88, 89, 90, 91, 91, 92, 93, 94, 94, 95, 96, 97, 98, 98, 99, 100, 101, 102, 103, 103, 104, 105, 106, 107, 108, 108, 109, 110, 111, 112, 113, 113, 114, 115, 116, 117, 118, 119, 120, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 201, 202, 203, 204, 205, 206, 207, 207, 208, 209, 210, 211, 212, 212, 213, 214, 215, 216, 217, 217, 218, 219, 220, 221, 221, 222, 223, 224, 224, 225, 226, 227, 228, 228, 229, 230, 231, 231, 232, 233, 234, 234, 235, 236, 237, 237, 238, 239, 240, 240, 241, 242, 243, 243, 244, 245, 246, 246, 247, 248, 248, 249, 250, 251, 251, 252, 253, 254, 254, 255 }; - int[] arrayOfInt10 = { 15, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 203, 204, 205, 205, 206, 207, 208, 209, 210, 211, 211, 212, 213, 214, 215, 215, 216, 217, 218, 219, 219, 220, 221, 222, 222, 223, 224, 225, 225, 226, 227, 227, 228, 229, 230, 230, 231, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 238, 239, 240, 240, 241, 241, 242, 243, 243, 244, 245, 245, 246, 246, 247, 248, 248, 249, 250, 250, 251, 251, 252, 253, 253, 254, 254, 255 }; - int[] arrayOfInt11 = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 174, 175, 176, 177, 178, 179, 180, 181, 182, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 193, 194, 195, 196, 197, 197, 198, 199, 200, 201, 202, 203, 203, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 214, 214, 215, 216, 217, 218, 219, 219, 220, 221, 222, 223, 224, 224, 225, 226, 227, 228, 229, 229, 230, 231, 232, 233, 234, 234, 235, 236, 237, 238, 239, 239, 240, 241, 242, 243, 244, 244, 245, 246, 247, 248, 248, 249, 250, 251, 252, 253, 253, 254, 255 }; - for (int k = 0; k < 256; k++){ - arrayOfByte2[(0 + k * 4)] = ((byte)arrayOfInt9[k]); - arrayOfByte2[(1 + k * 4)] = ((byte)arrayOfInt10[k]); - arrayOfByte2[(2 + k * 4)] = ((byte)arrayOfInt11[k]); - arrayOfByte2[(3 + k * 4)] = ((byte)arrayOfInt8[k]); - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 1, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte2)); - } - }); - } - - @Override - public void onInputSizeChanged(int width, int height) { - super.onInputSizeChanged(width, height); - GLES20.glUniform1f(mTexelWidthUniformLocation, (1.0f / (float)width)); - GLES20.glUniform1f(mTexelHeightUniformLocation, (1.0f / (float)height)); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicPixelFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicPixelFilter.java deleted file mode 100644 index c9a7192..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicPixelFilter.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicPixelFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1}; - private int[] inputTextureUniformLocations = {-1}; - private int mGLStrengthLocation; - - public MagicPixelFilter(){ - super(MagicFilterType.PIXAR, R.raw.pixar); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(1, inputTextureHandles, 0); - for (int i = 0; i < inputTextureHandles.length; i++) { - inputTextureHandles[i] = -1; - } - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for (int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for (int i=0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ -// inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/pixar_curves.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicRiseFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicRiseFilter.java deleted file mode 100644 index 8cd4569..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicRiseFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - - -public class MagicRiseFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1,-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1,-1}; - - public MagicRiseFilter(){ - super(MagicFilterType.RISE, R.raw.rise); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for(int i=0; i < inputTextureUniformLocations.length; i++){ - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture"+(2+i)); - } - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/blackboard1024.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/overlaymap.png"); - inputTextureHandles[2] = OpenGLUtils.loadTexture(getContext(), "filter/risemap.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicRomanceFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicRomanceFilter.java deleted file mode 100644 index 4ca39fe..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicRomanceFilter.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicRomanceFilter extends GPUImageFilter { - - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - - public MagicRomanceFilter(){ - super(MagicFilterType.ROMANCE, R.raw.romance); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - mToneCurveTexture[0] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] romance_arrayOfByte = new byte[1024]; - int[] romance_arrayOfInt1 = { 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, 52, 53, 53, 53, 54, 54, 54, 55, 55, 56, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 64, 65, 65, 66, 67, 67, 68, 69, 69, 70, 71, 72, 73, 73, 74, 75, 76, 77, 78, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 100, 101, 102, 103, 104, 105, 106, 107, 109, 110, 111, 112, 113, 114, 116, 117, 118, 119, 120, 122, 123, 124, 125, 127, 128, 129, 130, 131, 133, 134, 135, 136, 138, 139, 140, 141, 143, 144, 145, 146, 148, 149, 150, 151, 153, 154, 155, 156, 158, 159, 160, 161, 162, 164, 165, 166, 167, 169, 170, 171, 172, 173, 175, 176, 177, 178, 179, 180, 182, 183, 184, 185, 186, 187, 188, 189, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 211, 212, 213, 214, 215, 216, 217, 218, 218, 219, 220, 221, 222, 222, 223, 224, 225, 226, 226, 227, 228, 229, 229, 230, 231, 232, 232, 233, 234, 234, 235, 236, 237, 237, 238, 239, 239, 240, 241, 241, 242, 243, 243, 244, 245, 245, 246, 247, 247, 248, 249, 249, 250, 251, 251, 252, 252, 253, 254, 254, 255 }; - int[] romance_arrayOfInt2 = { 0, 1, 1, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 14, 15, 16, 17, 17, 18, 19, 20, 20, 21, 22, 23, 23, 24, 25, 26, 26, 27, 28, 29, 30, 30, 31, 32, 33, 33, 34, 35, 36, 37, 38, 38, 39, 40, 41, 42, 43, 43, 44, 45, 46, 47, 48, 49, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 111, 112, 113, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 128, 129, 130, 131, 132, 133, 134, 136, 137, 138, 139, 140, 141, 142, 144, 145, 146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 157, 159, 160, 161, 162, 163, 164, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 }; - int[] romance_arrayOfInt3 = { 0, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 20, 21, 23, 25, 26, 28, 30, 31, 33, 34, 36, 38, 39, 41, 42, 44, 45, 47, 48, 50, 51, 53, 54, 56, 57, 59, 60, 62, 63, 65, 66, 67, 69, 70, 72, 73, 74, 76, 77, 78, 79, 81, 82, 83, 84, 86, 87, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 106, 107, 108, 109, 110, 111, 112, 112, 113, 114, 115, 116, 116, 117, 118, 119, 119, 120, 121, 122, 122, 123, 124, 124, 125, 126, 126, 127, 128, 128, 129, 130, 130, 131, 131, 132, 133, 133, 134, 134, 135, 136, 136, 137, 137, 138, 139, 139, 140, 140, 141, 141, 142, 143, 143, 144, 144, 145, 146, 146, 147, 147, 148, 149, 149, 150, 150, 151, 152, 152, 153, 154, 154, 155, 155, 156, 157, 157, 158, 159, 159, 160, 161, 162, 162, 163, 164, 164, 165, 166, 167, 168, 168, 169, 170, 171, 172, 172, 173, 174, 175, 176, 177, 177, 178, 179, 180, 181, 182, 183, 184, 185, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 251, 252, 253, 254, 255 }; - int[] romance_arrayOfInt4 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int i = 0; i < 256; i++){ - romance_arrayOfByte[(i * 4)] = ((byte)romance_arrayOfInt1[i]); - romance_arrayOfByte[(1 + i * 4)] = ((byte)romance_arrayOfInt2[i]); - romance_arrayOfByte[(2 + i * 4)] = ((byte)romance_arrayOfInt3[i]); - romance_arrayOfByte[(3 + i * 4)] = ((byte)romance_arrayOfInt4[i]); - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 1, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(romance_arrayOfByte)); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSakuraFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicSakuraFilter.java deleted file mode 100644 index 088899d..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSakuraFilter.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicSakuraFilter extends GPUImageFilter { - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - private int mTexelHeightUniformLocation; - private int mTexelWidthUniformLocation; - - public MagicSakuraFilter(){ - super(MagicFilterType.SAKURA, R.raw.romance); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - mToneCurveTexture[0] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - mTexelWidthUniformLocation = GLES20.glGetUniformLocation(getProgram(), "texelWidthOffset"); - mTexelHeightUniformLocation = GLES20.glGetUniformLocation(getProgram(), "texelHeightOffset"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[1024]; - int[] arrayOfInt = { 95, 95, 96, 97, 97, 98, 99, 99, 100, 101, 101, 102, 103, 104, 104, 105, 106, 106, 107, 108, 108, 109, 110, 111, 111, 112, 113, 113, 114, 115, 115, 116, 117, 117, 118, 119, 120, 120, 121, 122, 122, 123, 124, 124, 125, 126, 127, 127, 128, 129, 129, 130, 131, 131, 132, 133, 133, 134, 135, 136, 136, 137, 138, 138, 139, 140, 140, 141, 142, 143, 143, 144, 145, 145, 146, 147, 147, 148, 149, 149, 150, 151, 152, 152, 153, 154, 154, 155, 156, 156, 157, 158, 159, 159, 160, 161, 161, 162, 163, 163, 164, 165, 165, 166, 167, 168, 168, 169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177, 177, 178, 179, 179, 180, 181, 181, 182, 183, 184, 184, 185, 186, 186, 187, 188, 188, 189, 190, 191, 191, 192, 193, 193, 194, 195, 195, 196, 197, 197, 198, 199, 200, 200, 201, 202, 202, 203, 204, 204, 205, 206, 207, 207, 208, 209, 209, 210, 211, 211, 212, 213, 213, 214, 215, 216, 216, 217, 218, 218, 219, 220, 220, 221, 222, 223, 223, 224, 225, 225, 226, 227, 227, 228, 229, 229, 230, 231, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 239, 239, 240, 241, 241, 242, 243, 243, 244, 245, 245, 246, 247, 248, 248, 249, 250, 250, 251, 252, 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; - for (int i = 0; i < 256; i++) - { - arrayOfByte[(i * 4)] = ((byte)arrayOfInt[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt[i]); - arrayOfByte[(3 + i * 4)] = ((byte)arrayOfInt[i]); - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 1, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - } - }); - } - - @Override - public void onInputSizeChanged(int width, int height) { - super.onInputSizeChanged(width, height); - GLES20.glUniform1f(mTexelWidthUniformLocation, (1.0f / (float)width)); - GLES20.glUniform1f(mTexelHeightUniformLocation, (1.0f / (float)height)); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSierraFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicSierraFilter.java deleted file mode 100644 index 3857796..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSierraFilter.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicSierraFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1,-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1,-1}; - private int mGLStrengthLocation; - - public MagicSierraFilter(){ - super(MagicFilterType.SIERRA, R.raw.sierra); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit(){ - super.onInit(); - for(int i = 0; i < inputTextureUniformLocations.length; i++) - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture"+(2+i)); - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/sierravignette.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/overlaymap.png"); - inputTextureHandles[2] = OpenGLUtils.loadTexture(getContext(), "filter/sierramap.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSketchFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicSketchFilter.java deleted file mode 100644 index 733adf4..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSketchFilter.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -public class MagicSketchFilter extends GPUImageFilter { - - private int mSingleStepOffsetLocation; - //0.0 - 1.0 - private int mStrengthLocation; - - public MagicSketchFilter(){ - super(MagicFilterType.SKETCH, R.raw.sketch); - } - - @Override - protected void onInit() { - super.onInit(); - mSingleStepOffsetLocation = GLES20.glGetUniformLocation(getProgram(), "singleStepOffset"); - mStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - setFloat(mStrengthLocation, 0.5f); - } - - @Override - public void onInputSizeChanged(final int width, final int height) { - super.onInputSizeChanged(width, height); - setFloatVec2(mSingleStepOffsetLocation, new float[] {1.0f / width, 1.0f / height}); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSkinWhitenFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicSkinWhitenFilter.java deleted file mode 100644 index 44b8ef8..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSkinWhitenFilter.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicSkinWhitenFilter extends GPUImageFilter { - private int mTexelHeightUniformLocation; - private int mTexelWidthUniformLocation; - private int mToneCurveTextureUniformLocation; - private int[] mToneCurveTexture = new int[] {-1}; - - public MagicSkinWhitenFilter() { - super(MagicFilterType.SKINWHITEN, R.raw.skinwhiten); - } - - @Override - protected void onInit() { - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - mTexelWidthUniformLocation = GLES20.glGetUniformLocation(getProgram(), "texelWidthOffset"); - mTexelHeightUniformLocation = GLES20.glGetUniformLocation(getProgram(), "texelHeightOffset"); - - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - mToneCurveTexture[0] = -1; - } - - @Override - protected void onInitialized() { - super.onInitialized(); - runOnDraw(new Runnable() { - public void run() { - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[1024]; - int[] arrayOfInt1 = { 95, 95, 96, 97, 97, 98, 99, 99, 100, 101, 101, 102, 103, 104, 104, 105, 106, 106, 107, 108, 108, 109, 110, 111, 111, 112, 113, 113, 114, 115, 115, 116, 117, 117, 118, 119, 120, 120, 121, 122, 122, 123, 124, 124, 125, 126, 127, 127, 128, 129, 129, 130, 131, 131, 132, 133, 133, 134, 135, 136, 136, 137, 138, 138, 139, 140, 140, 141, 142, 143, 143, 144, 145, 145, 146, 147, 147, 148, 149, 149, 150, 151, 152, 152, 153, 154, 154, 155, 156, 156, 157, 158, 159, 159, 160, 161, 161, 162, 163, 163, 164, 165, 165, 166, 167, 168, 168, 169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177, 177, 178, 179, 179, 180, 181, 181, 182, 183, 184, 184, 185, 186, 186, 187, 188, 188, 189, 190, 191, 191, 192, 193, 193, 194, 195, 195, 196, 197, 197, 198, 199, 200, 200, 201, 202, 202, 203, 204, 204, 205, 206, 207, 207, 208, 209, 209, 210, 211, 211, 212, 213, 213, 214, 215, 216, 216, 217, 218, 218, 219, 220, 220, 221, 222, 223, 223, 224, 225, 225, 226, 227, 227, 228, 229, 229, 230, 231, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 239, 239, 240, 241, 241, 242, 243, 243, 244, 245, 245, 246, 247, 248, 248, 249, 250, 250, 251, 252, 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt2 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(3 + i * 4)] = -1; - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 1, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - } - }); - } - - @Override - protected void onDrawArraysPre() { - super.onDrawArraysPre(); - if(mToneCurveTexture[0] != -1) { - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(this.mToneCurveTextureUniformLocation, 3); - } - } - - @Override - protected void onDrawArraysAfter() { - super.onDrawArraysAfter(); - if (mToneCurveTexture[0] != -1) { - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - public void onInputSizeChanged(int width, int height) { - super.onInputSizeChanged(width, height); - GLES20.glUniform1f(mTexelWidthUniformLocation, (1.0f / (float)width)); - GLES20.glUniform1f(mTexelHeightUniformLocation, (1.0f / (float)height)); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSunriseFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicSunriseFilter.java deleted file mode 100644 index 3a08665..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSunriseFilter.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicSunriseFilter extends GPUImageFilter { - private int mMaskGrey1TextureId = -1; - private int mMaskGrey1UniformLocation; - private int mMaskGrey2TextureId = -1; - private int mMaskGrey2UniformLocation; - private int mMaskGrey3TextureId = -1; - private int mMaskGrey3UniformLocation; - private int[] mToneCurveTexture = { -1 }; - private int mToneCurveTextureUniformLocation; - - public MagicSunriseFilter(){ - super(MagicFilterType.SUNRISE, R.raw.sunrise); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - mToneCurveTexture[0] = -1; - GLES20.glDeleteTextures(1, new int[]{mMaskGrey1TextureId}, 0); - mMaskGrey1TextureId = -1; - GLES20.glDeleteTextures(1, new int[]{mMaskGrey2TextureId}, 0); - mMaskGrey2TextureId = -1; - GLES20.glDeleteTextures(1, new int[]{mMaskGrey3TextureId}, 0); - mMaskGrey3TextureId = -1; - } - - @Override - protected void onDrawArraysAfter() { - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey2TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE5); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey3TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE6); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre() { - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey1TextureId); - GLES20.glUniform1i(mMaskGrey1UniformLocation, 4); - } - if (mMaskGrey2TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE5); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey2TextureId); - GLES20.glUniform1i(mMaskGrey2UniformLocation, 5); - } - if (mMaskGrey3TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE6); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey3TextureId); - GLES20.glUniform1i(mMaskGrey3UniformLocation, 6); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - mMaskGrey1UniformLocation = GLES20.glGetUniformLocation(getProgram(), "grey1Frame"); - mMaskGrey2UniformLocation = GLES20.glGetUniformLocation(getProgram(), "grey2Frame"); - mMaskGrey3UniformLocation = GLES20.glGetUniformLocation(getProgram(), "grey3Frame"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[2048]; - int[] arrayOfInt1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 30, 31, 32, 34, 35, 36, 38, 39, 41, 42, 44, 45, 47, 49, 50, 52, 54, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 92, 94, 96, 98, 101, 103, 105, 107, 110, 111, 113, 115, 118, 120, 122, 124, 126, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 150, 152, 154, 156, 158, 159, 161, 162, 164, 166, 167, 169, 170, 172, 173, 174, 176, 177, 178, 180, 181, 182, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 200, 201, 202, 203, 203, 204, 205, 205, 207, 208, 208, 209, 209, 210, 210, 211, 211, 212, 212, 213, 213, 213, 214, 214, 215, 215, 215, 216, 216, 216, 216, 217, 217, 217, 218, 218, 218, 218, 219, 219, 219, 219, 219, 220, 220, 220, 220, 220, 220, 221, 221, 221, 221, 221, 222, 222, 222, 222, 222, 223, 223, 223, 223, 223, 224, 224, 224, 224, 224, 225, 225, 225, 225, 226, 226, 226, 227, 227, 227, 228, 228, 228, 229, 229, 230, 230, 230, 231, 231, 232, 232, 233, 233, 234, 234, 235, 235, 236, 236, 237, 238, 238, 239, 239, 241, 241, 242, 243, 243, 244, 245, 245, 246, 246, 247, 248, 248, 249, 250, 250, 251, 252, 252, 253, 254, 254, 255 }; - int[] arrayOfInt2 = { 0, 1, 3, 4, 5, 7, 8, 10, 11, 12, 14, 15, 17, 18, 19, 21, 22, 24, 25, 27, 28, 30, 31, 33, 34, 36, 37, 39, 40, 42, 44, 45, 47, 48, 50, 52, 54, 55, 57, 59, 61, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 83, 85, 87, 90, 92, 94, 96, 98, 101, 103, 105, 107, 110, 111, 113, 115, 117, 119, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 143, 145, 147, 149, 150, 152, 154, 155, 157, 158, 160, 161, 163, 164, 165, 167, 168, 169, 171, 172, 173, 174, 175, 176, 177, 179, 180, 181, 182, 183, 184, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 193, 193, 194, 195, 195, 196, 197, 197, 198, 198, 199, 199, 200, 200, 201, 201, 202, 202, 203, 203, 204, 204, 205, 205, 205, 207, 207, 208, 208, 208, 209, 209, 210, 210, 210, 211, 211, 211, 212, 212, 212, 213, 213, 213, 214, 214, 214, 215, 215, 215, 216, 216, 216, 217, 217, 217, 218, 218, 219, 219, 219, 220, 220, 220, 221, 221, 222, 222, 222, 223, 223, 224, 224, 225, 225, 225, 226, 226, 227, 227, 228, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, 233, 234, 234, 235, 235, 236, 236, 236, 237, 237, 238, 238, 239, 239, 241, 241, 242, 242, 243, 244, 244, 245, 245, 246, 246, 247, 247, 248, 248, 249, 249, 250, 250, 251, 251, 252, 252, 253, 253, 254, 254, 255 }; - int[] arrayOfInt3 = { 0, 1, 3, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15, 17, 18, 19, 21, 22, 23, 25, 26, 28, 29, 30, 32, 33, 35, 36, 38, 39, 41, 43, 44, 46, 47, 49, 51, 53, 54, 56, 58, 60, 62, 64, 66, 68, 69, 71, 73, 76, 78, 80, 82, 83, 85, 87, 89, 91, 93, 95, 97, 100, 102, 104, 106, 108, 110, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 130, 132, 134, 136, 138, 139, 141, 143, 145, 146, 148, 150, 151, 153, 155, 156, 158, 159, 161, 162, 164, 165, 167, 168, 169, 171, 172, 173, 175, 176, 177, 179, 180, 181, 182, 183, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 200, 201, 202, 203, 204, 204, 205, 207, 207, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 214, 215, 215, 215, 216, 216, 217, 217, 217, 218, 218, 218, 219, 219, 219, 220, 220, 220, 220, 221, 221, 221, 221, 222, 222, 222, 222, 223, 223, 223, 223, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 226, 226, 226, 226, 227, 227, 227, 227, 228, 228, 228, 228, 229, 229, 229, 230, 230, 230, 231, 231, 231, 232, 232, 233, 233, 233, 234, 234, 235, 235, 235, 236, 236, 237, 237, 238, 238, 239, 239, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 246, 247, 247, 248, 248, 249, 249, 250, 250, 251, 252, 252, 253, 253, 254, 254, 255 }; - int[] arrayOfInt4 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte[(3 + i * 4)] = ((byte)arrayOfInt4[i]); - } - int[] arrayOfInt5 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 82, 83, 85, 86, 87, 88, 89, 90, 92, 93, 94, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 112, 114, 115, 116, 117, 118, 119, 121, 122, 123, 124, 125, 126, 128, 129, 130, 131, 132, 133, 134, 136, 137, 138, 139, 140, 141, 143, 144, 145, 146, 147, 148, 150, 151, 152, 153, 154, 155, 156, 158, 159, 160, 161, 162, 163, 165, 166, 167, 168, 169, 170, 172, 173, 174, 175, 176, 177, 178, 180, 181, 182, 183, 184, 185, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 198, 199, 201, 202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221, 223, 224, 225, 226, 227, 228, 230, 231, 232, 233, 234, 235, 236, 238, 239, 240, 241, 242, 243, 245, 246, 247, 248, 249, 250, 252, 253, 254, 255 }; - int[] arrayOfInt6 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 5, 6, 7, 9, 10, 11, 12, 14, 15, 16, 17, 19, 20, 21, 22, 24, 25, 26, 27, 29, 30, 31, 32, 34, 35, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 49, 50, 51, 52, 53, 55, 56, 57, 58, 60, 61, 62, 63, 65, 66, 67, 68, 70, 71, 72, 73, 75, 76, 77, 78, 80, 81, 82, 83, 85, 86, 87, 88, 90, 91, 92, 93, 95, 96, 97, 98, 100, 101, 102, 103, 104, 106, 107, 108, 109, 111, 112, 113, 114, 116, 117, 118, 119, 121, 122, 123, 124, 126, 127, 128, 129, 131, 132, 133, 134, 136, 137, 138, 139, 141, 142, 143, 144, 146, 147, 148, 149, 151, 152, 153, 154, 155, 157, 158, 159, 160, 162, 163, 164, 165, 167, 168, 169, 170, 172, 173, 174, 175, 177, 178, 179, 180, 182, 183, 184, 185, 187, 188, 189, 190, 192, 193, 194, 195, 197, 198, 199, 200, 202, 203, 204, 205, 206, 208, 209, 210, 211, 213, 214, 215, 216, 218, 219, 220, 221, 223, 224, 225, 226, 228, 229, 230, 231, 233, 234, 235, 236, 238, 239, 240, 241, 243, 244, 245, 246, 248, 249, 250, 251, 253, 254, 255 }; - int[] arrayOfInt7 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49, 51, 52, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 98, 99, 100, 101, 102, 103, 105, 106, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 118, 119, 121, 122, 123, 124, 125, 126, 128, 129, 130, 131, 132, 133, 134, 136, 137, 138, 139, 140, 141, 142, 144, 145, 146, 147, 148, 149, 150, 152, 153, 154, 155, 156, 157, 159, 160, 161, 162, 163, 164, 165, 167, 168, 169, 170, 171, 172, 173, 175, 176, 177, 178, 179, 180, 181, 183, 184, 185, 186, 187, 188, 190, 191, 192, 193, 194, 195, 196, 198, 199, 200, 201, 202, 203, 204, 206, 207, 208, 209, 210, 211, 213, 214, 215, 216, 217, 218, 219, 221, 222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 237, 238, 239, 240, 241, 242, 244, 245, 246, 247, 248, 249, 250, 252, 253, 254, 255 }; - int[] arrayOfInt8 = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 12, 13, 14, 14, 15, 15, 16, 17, 17, 18, 19, 19, 20, 21, 22, 22, 23, 24, 24, 25, 26, 27, 27, 28, 29, 30, 31, 31, 32, 33, 34, 34, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 44, 44, 45, 46, 47, 48, 49, 50, 51, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 142, 143, 144, 145, 146, 147, 149, 150, 151, 152, 153, 155, 156, 157, 158, 159, 160, 162, 163, 164, 165, 166, 168, 169, 170, 171, 173, 174, 175, 176, 177, 179, 180, 181, 182, 184, 185, 186, 187, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 204, 205, 206, 208, 209, 210, 211, 213, 214, 215, 217, 218, 219, 221, 222, 223, 224, 226, 227, 228, 230, 231, 232, 234, 235, 236, 238, 239, 240, 242, 243, 244, 246, 247, 248, 250, 251, 252, 254, 255 }; - for (int j = 0; j < 256; j++){ - arrayOfByte[(1024 + j * 4)] = ((byte)arrayOfInt5[j]); - arrayOfByte[(1 + (1024 + j * 4))] = ((byte)arrayOfInt6[j]); - arrayOfByte[(2 + (1024 + j * 4))] = ((byte)arrayOfInt7[j]); - arrayOfByte[(3 + (1024 + j * 4))] = ((byte)arrayOfInt8[j]); - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glActiveTexture(GLES20.GL_TEXTURE5); - GLES20.glActiveTexture(GLES20.GL_TEXTURE6); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSunsetFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicSunsetFilter.java deleted file mode 100644 index 593e804..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSunsetFilter.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -import java.nio.ByteBuffer; - -public class MagicSunsetFilter extends GPUImageFilter { - private int mMaskGrey1TextureId = -1; - private int mMaskGrey1UniformLocation; - private int mMaskGrey2TextureId = -1; - private int mMaskGrey2UniformLocation; - private int[] mToneCurveTexture = { -1 }; - private int mToneCurveTextureUniformLocation; - - public MagicSunsetFilter(){ - super(MagicFilterType.SUNSET, R.raw.sunset); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(3, new int[]{mToneCurveTexture[0], mMaskGrey1TextureId, mMaskGrey2TextureId}, 0); - mToneCurveTexture[0] = -1; - mMaskGrey1TextureId = -1; - mMaskGrey2TextureId = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey2TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE5); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre() { - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey1TextureId); - GLES20.glUniform1i(mMaskGrey1UniformLocation, 4); - } - if (mMaskGrey2TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE5); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey2TextureId); - GLES20.glUniform1i(mMaskGrey2UniformLocation, 5); - } - } - - @Override - protected void onInit() { - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - mMaskGrey1UniformLocation = GLES20.glGetUniformLocation(getProgram(), "grey1Frame"); - mMaskGrey2UniformLocation = GLES20.glGetUniformLocation(getProgram(), "grey2Frame"); - } - - @Override - protected void onInitialized() { - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[2048]; - int[] arrayOfInt1 = { 0, 1, 2, 3, 5, 5, 7, 8, 9, 10, 11, 12, 13, 15, 16, 16, 18, 19, 20, 21, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 35, 36, 38, 39, 40, 41, 42, 44, 45, 47, 48, 49, 51, 52, 54, 55, 56, 59, 60, 62, 63, 64, 66, 67, 70, 71, 72, 74, 76, 78, 79, 80, 83, 84, 85, 88, 89, 90, 93, 94, 95, 98, 99, 100, 102, 104, 106, 107, 108, 109, 112, 113, 114, 116, 117, 118, 119, 120, 122, 124, 125, 126, 128, 129, 130, 131, 132, 132, 133, 135, 136, 137, 138, 139, 140, 141, 142, 142, 143, 145, 146, 147, 148, 148, 149, 150, 151, 151, 152, 153, 154, 155, 155, 156, 157, 157, 158, 159, 160, 160, 161, 162, 162, 163, 164, 165, 165, 166, 167, 167, 168, 169, 169, 170, 171, 171, 172, 173, 173, 174, 175, 175, 176, 177, 177, 178, 178, 179, 179, 180, 181, 181, 182, 183, 183, 184, 185, 185, 186, 187, 188, 188, 189, 190, 190, 191, 192, 193, 193, 194, 194, 194, 195, 196, 197, 197, 198, 199, 200, 201, 201, 202, 203, 204, 204, 205, 206, 207, 208, 208, 208, 209, 210, 211, 212, 212, 213, 214, 215, 216, 217, 218, 218, 219, 220, 221, 222, 222, 223, 224, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 234, 235, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 247, 248, 248, 249, 250, 251, 252, 253, 254, 255 }; - int[] arrayOfInt2 = { 0, 1, 2, 3, 4, 5, 6, 7, 9, 9, 10, 12, 12, 13, 14, 16, 16, 17, 19, 20, 20, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, 41, 42, 43, 44, 46, 47, 49, 50, 51, 53, 54, 56, 57, 59, 61, 62, 64, 65, 66, 69, 70, 72, 73, 76, 77, 78, 80, 82, 84, 85, 87, 89, 90, 93, 94, 95, 98, 99, 100, 103, 104, 106, 108, 109, 111, 112, 114, 116, 117, 118, 120, 122, 123, 124, 125, 126, 129, 130, 131, 132, 133, 135, 136, 137, 138, 139, 140, 141, 142, 143, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 162, 163, 164, 165, 165, 166, 167, 167, 168, 169, 170, 170, 171, 172, 172, 173, 173, 174, 175, 175, 176, 177, 177, 178, 178, 178, 179, 179, 180, 181, 181, 182, 182, 183, 184, 184, 185, 185, 186, 187, 187, 188, 188, 189, 190, 190, 191, 191, 192, 193, 193, 194, 194, 194, 195, 195, 196, 197, 197, 198, 199, 199, 200, 201, 202, 202, 203, 204, 204, 205, 206, 207, 208, 208, 208, 209, 210, 210, 211, 212, 213, 214, 215, 215, 216, 217, 218, 219, 220, 221, 222, 222, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 234, 235, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 249, 250, 251, 252, 253, 254, 255 }; - int[] arrayOfInt3 = { 0, 1, 2, 3, 4, 5, 5, 7, 8, 9, 9, 11, 12, 12, 13, 14, 16, 16, 17, 18, 20, 20, 21, 22, 23, 25, 25, 26, 27, 29, 30, 31, 31, 32, 34, 35, 36, 37, 39, 40, 41, 41, 42, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 56, 57, 59, 60, 61, 63, 64, 65, 66, 67, 69, 71, 72, 73, 74, 76, 78, 79, 80, 82, 83, 84, 85, 88, 89, 90, 92, 93, 94, 95, 98, 99, 100, 102, 103, 104, 106, 107, 108, 111, 112, 113, 114, 116, 117, 118, 119, 120, 122, 123, 124, 125, 126, 128, 129, 130, 131, 132, 133, 135, 136, 137, 138, 139, 140, 141, 142, 143, 145, 146, 147, 147, 148, 149, 150, 151, 152, 153, 154, 154, 155, 156, 157, 158, 159, 159, 160, 161, 162, 162, 163, 164, 165, 166, 166, 167, 168, 169, 169, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177, 178, 178, 178, 179, 179, 180, 181, 182, 182, 183, 184, 185, 185, 186, 187, 188, 188, 189, 190, 191, 191, 192, 193, 194, 194, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 203, 203, 204, 205, 206, 207, 208, 208, 209, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224, 225, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 235, 236, 237, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 249, 250, 251, 252, 253, 254, 255 }; - int[] arrayOfInt4 = { 0, 1, 3, 4, 6, 7, 9, 10, 12, 13, 14, 16, 17, 19, 20, 21, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36, 38, 39, 40, 42, 43, 44, 45, 47, 48, 49, 51, 52, 53, 54, 55, 57, 58, 59, 60, 62, 63, 64, 65, 66, 67, 69, 70, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 115, 116, 117, 118, 119, 120, 121, 121, 122, 123, 124, 125, 126, 126, 127, 128, 129, 130, 130, 131, 132, 133, 134, 135, 135, 136, 137, 138, 139, 140, 141, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 230, 231, 232, 233, 234, 235, 235, 236, 237, 238, 239, 239, 240, 241, 242, 243, 243, 244, 245, 245, 246, 247, 247, 248, 249, 249, 250, 251, 251, 252, 252, 253, 253, 254, 254, 255 }; - for (int i = 0; i < 256; i++) - { - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte[(3 + i * 4)] = ((byte)arrayOfInt4[i]); - } - int[] arrayOfInt5 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int j = 0; j < 256; j++) - { - arrayOfByte[(1024 + j * 4)] = ((byte)arrayOfInt5[j]); - arrayOfByte[(1 + (1024 + j * 4))] = ((byte)arrayOfInt5[j]); - arrayOfByte[(2 + (1024 + j * 4))] = ((byte)arrayOfInt5[j]); - arrayOfByte[(3 + (1024 + j * 4))] = -1; - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - mMaskGrey1TextureId = OpenGLUtils.loadTexture(getContext(), "filter/rise_mask1.jpg"); - mMaskGrey2TextureId = OpenGLUtils.loadTexture(getContext(), "filter/rise_mask2.jpg"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSutroFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicSutroFilter.java deleted file mode 100644 index fe5d977..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSutroFilter.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicSutroFilter extends GPUImageFilter { - private int[] inputTextureHandles = {-1,-1,-1,-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1,-1,-1,-1}; - private int mGLStrengthLocation; - - public MagicSutroFilter(){ - super(MagicFilterType.SUTRO, R.raw.sutro); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for (int i = 0; i < inputTextureHandles.length; i++) { - inputTextureHandles[i] = -1; - } - } - - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit() { - super.onInit(); - for(int i = 0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized() { - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/vignette_map.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/sutrometal.png"); - inputTextureHandles[2] = OpenGLUtils.loadTexture(getContext(), "filter/softlight.png"); - inputTextureHandles[3] = OpenGLUtils.loadTexture(getContext(), "filter/sutroedgeburn.png"); - inputTextureHandles[4] = OpenGLUtils.loadTexture(getContext(), "filter/sutrocurves.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSweetsFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicSweetsFilter.java deleted file mode 100644 index de98e69..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicSweetsFilter.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -import java.nio.ByteBuffer; - -public class MagicSweetsFilter extends GPUImageFilter { - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - private int mMaskGrey1TextureId = -1; - private int mMaskGrey1UniformLocation; - private int mLowPerformanceUniformLocation; - - public MagicSweetsFilter(){ - super(MagicFilterType.SWEETS, R.raw.sweets); - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(2, new int[]{mToneCurveTexture[0], mMaskGrey1TextureId}, 0); - mToneCurveTexture[0] = -1; - mMaskGrey1TextureId = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey1TextureId); - GLES20.glUniform1i(mMaskGrey1UniformLocation, 4); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - mMaskGrey1UniformLocation = GLES20.glGetUniformLocation(getProgram(), "grey1Frame"); - mLowPerformanceUniformLocation = GLES20.glGetUniformLocation(getProgram(), "lowPerformance"); - setInteger(mLowPerformanceUniformLocation, 1); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[1024]; - int[] arrayOfInt = { 0, 1, 2, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 24, 25, 26, 27, 28, 29, 30, 30, 31, 32, 33, 34, 35, 36, 37, 38, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84, 86, 87, 88, 89, 90, 92, 93, 94, 95, 96, 98, 99, 100, 101, 103, 104, 105, 106, 108, 109, 110, 111, 113, 114, 115, 116, 118, 119, 120, 121, 123, 124, 125, 126, 128, 129, 130, 132, 133, 134, 135, 137, 138, 139, 140, 142, 143, 144, 145, 147, 148, 149, 150, 152, 153, 154, 155, 157, 158, 159, 160, 161, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 174, 176, 177, 178, 179, 180, 181, 182, 183, 184, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 214, 215, 216, 217, 217, 218, 219, 220, 221, 222, 222, 223, 224, 225, 226, 227, 227, 228, 229, 230, 230, 231, 232, 233, 234, 234, 235, 236, 237, 237, 238, 239, 240, 240, 241, 242, 243, 243, 244, 245, 246, 246, 247, 248, 248, 249, 250, 251, 251, 252, 253, 254, 254, 255 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt[i]); - arrayOfByte[(3 + i * 4)] = ((byte)i); - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 1, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - mMaskGrey1TextureId = OpenGLUtils.loadTexture(getContext(), "filter/rise_mask2.jpg"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicTenderFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicTenderFilter.java deleted file mode 100644 index da82d62..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicTenderFilter.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -import java.nio.ByteBuffer; - -public class MagicTenderFilter extends GPUImageFilter{ - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - private int mMaskGrey1TextureId = -1; - private int mMaskGrey1UniformLocation; - - public MagicTenderFilter(){ - super(MagicFilterType.TENDER, R.raw.tender); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(2, new int[]{mToneCurveTexture[0], mMaskGrey1TextureId}, 0); - mToneCurveTexture[0] = -1; - mMaskGrey1TextureId = -1; - } - - @Override - protected void onDrawArraysAfter() { - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre() { - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey1TextureId); - GLES20.glUniform1i(mMaskGrey1UniformLocation, 4); - } - } - - @Override - protected void onInit() { - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - mMaskGrey1UniformLocation = GLES20.glGetUniformLocation(getProgram(), "grey1Frame"); - } - - @Override - protected void onInitialized() { - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[1024]; - int[] arrayOfInt1 = { 10, 12, 14, 15, 17, 19, 21, 22, 24, 26, 28, 29, 31, 33, 35, 38, 40, 41, 43, 45, 47, 48, 50, 52, 53, 55, 57, 58, 60, 61, 63, 65, 66, 68, 69, 71, 72, 74, 75, 77, 79, 80, 81, 83, 84, 86, 87, 89, 92, 93, 94, 96, 97, 99, 100, 101, 103, 104, 105, 107, 108, 109, 110, 112, 113, 114, 116, 117, 118, 119, 120, 122, 123, 124, 125, 126, 127, 129, 130, 131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163, 164, 165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 175, 176, 177, 178, 179, 179, 180, 181, 182, 182, 183, 184, 184, 185, 186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 195, 195, 196, 196, 197, 198, 198, 199, 200, 200, 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206, 207, 207, 208, 209, 209, 210, 210, 211, 211, 212, 212, 213, 213, 214, 214, 215, 215, 216, 216, 216, 217, 217, 218, 218, 219, 219, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224, 224, 224, 225, 225, 226, 226, 227, 227, 227, 228, 228, 229, 229, 230, 230, 230, 231, 231, 232, 232, 232, 233, 233, 234, 234, 234, 234, 235, 235, 236, 236, 236, 237, 237, 238, 238, 238, 239, 239, 240, 240, 240, 241, 241, 242, 242 }; - int[] arrayOfInt2 = { 10, 12, 14, 15, 17, 19, 19, 21, 22, 24, 26, 28, 29, 31, 33, 35, 36, 36, 38, 40, 41, 43, 45, 47, 48, 50, 52, 52, 53, 55, 57, 58, 60, 61, 63, 65, 66, 68, 69, 69, 71, 72, 74, 75, 77, 79, 80, 81, 83, 84, 86, 86, 87, 89, 90, 92, 93, 94, 96, 97, 99, 100, 101, 103, 103, 104, 105, 107, 108, 109, 110, 112, 113, 114, 116, 117, 118, 119, 120, 122, 122, 123, 124, 125, 126, 127, 129, 130, 131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163, 164, 165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 175, 176, 177, 178, 179, 179, 180, 181, 182, 182, 183, 184, 184, 185, 186, 187, 187, 188, 189, 190, 191, 191, 192, 193, 193, 194, 195, 195, 196, 196, 197, 198, 198, 199, 200, 200, 201, 201, 202, 202, 204, 204, 205, 205, 206, 206, 207, 207, 208, 209, 209, 210, 210, 211, 211, 212, 213, 213, 214, 214, 215, 215, 216, 216, 217, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224, 224, 224, 225, 226, 226, 227, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 232, 233, 233, 234, 234, 234, 235, 236, 236, 236, 237, 237, 238, 238, 238, 239, 239, 240, 240, 241, 241, 242, 242 }; - int[] arrayOfInt3 = { 10, 12, 12, 14, 15, 15, 17, 17, 19, 21, 21, 22, 24, 24, 26, 28, 28, 29, 31, 31, 33, 33, 35, 36, 36, 38, 40, 40, 41, 43, 43, 45, 47, 47, 48, 50, 52, 52, 53, 55, 55, 57, 58, 58, 60, 61, 63, 63, 65, 66, 68, 68, 69, 71, 71, 72, 74, 75, 77, 77, 79, 80, 81, 81, 83, 84, 86, 87, 87, 89, 90, 92, 93, 94, 94, 96, 97, 99, 100, 101, 103, 103, 104, 105, 107, 108, 109, 110, 112, 113, 113, 114, 116, 117, 118, 119, 120, 122, 123, 124, 125, 126, 127, 129, 130, 130, 131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163, 164, 165, 166, 166, 167, 169, 170, 171, 171, 172, 173, 174, 175, 175, 176, 178, 179, 179, 180, 181, 182, 182, 183, 184, 185, 186, 187, 187, 188, 189, 190, 191, 191, 192, 193, 193, 195, 195, 196, 196, 197, 198, 199, 200, 200, 201, 201, 202, 203, 204, 204, 205, 206, 206, 207, 207, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220, 221, 222, 222, 223, 223, 224, 224, 225, 225, 226, 227, 227, 227, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, 233, 234, 234, 235, 235, 236, 236, 237, 238, 238, 238, 239, 240, 240, 240, 241, 242, 242 }; - int[] arrayOfInt4 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte[(3 + i * 4)] = ((byte)arrayOfInt4[i]); - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 1, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - mMaskGrey1TextureId = OpenGLUtils.loadTexture(getContext(), "filter/bluevintage_mask1.jpg"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicToasterFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicToasterFilter.java deleted file mode 100644 index f860e3d..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicToasterFilter.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicToasterFilter extends GPUImageFilter{ - private int[] inputTextureHandles = {-1,-1,-1,-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1,-1,-1,-1}; - private int mGLStrengthLocation; - - public MagicToasterFilter(){ - super(MagicFilterType.TOASTER2, R.raw.toaster2_filter_shader); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter() { - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre() { - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - protected void onInit() { - super.onInit(); - for(int i = 0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - protected void onInitialized() { - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/toastermetal.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/toastersoftlight.png"); - inputTextureHandles[2] = OpenGLUtils.loadTexture(getContext(), "filter/toastercurves.png"); - inputTextureHandles[3] = OpenGLUtils.loadTexture(getContext(), "filter/toasteroverlaymapwarm.png"); - inputTextureHandles[4] = OpenGLUtils.loadTexture(getContext(), "filter/toastercolorshift.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicValenciaFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicValenciaFilter.java deleted file mode 100644 index de55a74..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicValenciaFilter.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicValenciaFilter extends GPUImageFilter{ - private int[] inputTextureHandles = {-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1}; - private int mGLStrengthLocation; - - public MagicValenciaFilter(){ - super(MagicFilterType.VALENCIA, R.raw.valencia); - } - - @Override - protected void onDrawArraysAfter() { - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre() { - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - public void onInit() { - super.onInit(); - for(int i = 0; i < inputTextureUniformLocations.length; i++) { - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture" + (2 + i)); - } - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - public void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) { - inputTextureHandles[i] = -1; - } - } - - @Override - public void onInitialized() { - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/valenciamap.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/valenciagradientmap.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicWaldenFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicWaldenFilter.java deleted file mode 100644 index f4163d5..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicWaldenFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicWaldenFilter extends GPUImageFilter { - - private int[] inputTextureHandles = {-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1}; - private int mGLStrengthLocation; - - public MagicWaldenFilter(){ - super(MagicFilterType.WALDEN, R.raw.walden); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3)); - } - } - - @Override - public void onInit(){ - super.onInit(); - for(int i = 0; i < inputTextureUniformLocations.length; i++) - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture"+(2+i)); - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - public void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/walden_map.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/vignette_map.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicWarmFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicWarmFilter.java deleted file mode 100644 index 9a9544c..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicWarmFilter.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicWarmFilter extends GPUImageFilter { - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - private int mMaskGrey1TextureId = -1; - private int mMaskGrey1UniformLocation; - private int mMaskGrey2TextureId = -1; - private int mMaskGrey2UniformLocation; - - public MagicWarmFilter(){ - super(MagicFilterType.WARM, R.raw.warm); - } - - @Override - public void onDestroy(){ - super.onDestroy(); - GLES20.glDeleteTextures(3, new int[]{mToneCurveTexture[0], mMaskGrey1TextureId, mMaskGrey2TextureId}, 0); - mToneCurveTexture[0] = -1; - mMaskGrey1TextureId = -1; - mMaskGrey2TextureId = -1; - } - - @Override - protected void onDrawArraysAfter(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - if (mMaskGrey2TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE5); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - if (mMaskGrey1TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE4); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey1TextureId); - GLES20.glUniform1i(mMaskGrey1UniformLocation, 4); - } - if (mMaskGrey2TextureId != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE5); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey2TextureId); - GLES20.glUniform1i(mMaskGrey2UniformLocation, 5); - } - } - - @Override - protected void onInit(){ - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - mMaskGrey1UniformLocation = GLES20.glGetUniformLocation(getProgram(), "layerImage"); - mMaskGrey2UniformLocation = GLES20.glGetUniformLocation(getProgram(), "greyFrame"); - } - - @Override - protected void onInitialized(){ - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[2048]; - int[] arrayOfInt1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 6, 9, 12, 14, 17, 20, 23, 25, 28, 31, 33, 35, 38, 40, 42, 44, 46, 48, 50, 52, 53, 55, 57, 58, 60, 61, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 80, 81, 82, 83, 83, 84, 85, 85, 86, 87, 87, 88, 88, 89, 90, 90, 91, 91, 92, 93, 93, 94, 94, 95, 96, 96, 97, 98, 99, 99, 100, 101, 102, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 114, 115, 116, 117, 119, 120, 121, 123, 124, 126, 127, 128, 130, 131, 133, 135, 136, 138, 139, 141, 143, 144, 146, 148, 149, 151, 153, 154, 156, 158, 159, 161, 163, 165, 166, 168, 170, 172, 173, 175, 177, 179, 180, 182, 184, 185, 187, 189, 190, 192, 194, 195, 197, 199, 200, 202, 203, 205, 207, 208, 210, 211, 213, 214, 215, 217, 218, 219, 221, 222, 223, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 238, 239, 240, 241, 241, 242, 243, 243, 244, 244, 245, 245, 246, 246, 247, 247, 248, 248, 249, 249, 249, 250, 250, 250, 251, 251, 251, 251, 252, 252, 252, 252, 253, 253, 253, 253, 253, 253, 254, 254, 254, 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt2 = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 87, 88, 89, 90, 91, 92, 93, 94, 95, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 235, 236, 237, 238, 239, 240, 241, 242 }; - int[] arrayOfInt3 = { 9, 10, 11, 11, 12, 13, 14, 15, 16, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 26, 26, 27, 28, 29, 30, 31, 31, 32, 33, 34, 35, 36, 36, 37, 38, 39, 40, 40, 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 59, 60, 60, 61, 62, 63, 64, 65, 66, 66, 67, 68, 69, 70, 71, 71, 72, 73, 74, 75, 76, 76, 77, 78, 79, 80, 81, 81, 82, 83, 84, 85, 86, 87, 87, 88, 89, 90, 91, 92, 93, 93, 94, 95, 96, 97, 98, 98, 99, 100, 101, 102, 103, 104, 104, 105, 106, 107, 108, 109, 110, 110, 111, 112, 113, 114, 115, 116, 116, 117, 118, 119, 120, 121, 122, 123, 123, 124, 125, 126, 127, 128, 129, 130, 130, 131, 132, 133, 134, 135, 136, 137, 137, 138, 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 160, 161, 162, 163, 164, 165, 166, 167, 168, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 225, 226, 227, 228, 229, 230 }; - int[] arrayOfInt4 = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 33, 34, 35, 37, 38, 40, 41, 42, 44, 45, 47, 48, 50, 51, 53, 54, 56, 58, 59, 61, 62, 64, 65, 67, 69, 70, 72, 73, 75, 77, 78, 80, 82, 83, 85, 86, 88, 90, 91, 93, 94, 96, 98, 99, 101, 102, 104, 105, 107, 108, 110, 111, 113, 114, 116, 117, 119, 120, 122, 123, 124, 126, 127, 129, 130, 131, 133, 134, 136, 137, 138, 140, 141, 142, 144, 145, 146, 147, 149, 150, 151, 153, 154, 155, 156, 157, 159, 160, 161, 162, 163, 165, 166, 167, 168, 169, 170, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 203, 204, 205, 206, 207, 208, 208, 209, 210, 211, 212, 212, 213, 214, 215, 216, 216, 217, 218, 218, 219, 220, 221, 221, 222, 223, 223, 224, 225, 225, 226, 227, 227, 228, 228, 229, 230, 230, 231, 231, 232, 233, 233, 234, 234, 235, 235, 236, 236, 237, 238, 238, 239, 239, 240, 240, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 246, 246, 247, 247, 248, 248, 249, 249, 249, 250, 250, 251, 251, 252, 252, 253, 253, 254, 254, 255, 255 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt3[i]); - arrayOfByte[(3 + i * 4)] = ((byte)arrayOfInt4[i]); - } - int[] arrayOfInt5 = { 0, 1, 1, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 11, 11, 12, 13, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20, 21, 21, 22, 23, 24, 24, 25, 26, 27, 28, 28, 28, 29, 30, 31, 31, 32, 33, 34, 35, 36, 36, 37, 38, 39, 39, 40, 41, 41, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 59, 60, 61, 62, 63, 63, 64, 65, 66, 68, 69, 70, 71, 71, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, 89, 90, 92, 93, 94, 95, 95, 97, 98, 99, 100, 102, 103, 104, 105, 106, 108, 109, 110, 111, 112, 114, 115, 116, 117, 118, 119, 122, 123, 124, 125, 126, 127, 129, 130, 131, 132, 133, 134, 135, 137, 138, 139, 141, 142, 143, 144, 145, 146, 148, 149, 150, 151, 152, 154, 155, 156, 157, 158, 159, 161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 173, 174, 175, 176, 177, 178, 179, 180, 183, 184, 185, 186, 187, 188, 190, 191, 192, 193, 194, 195, 196, 198, 199, 200, 201, 202, 203, 205, 206, 207, 208, 209, 210, 212, 213, 214, 215, 216, 217, 219, 220, 221, 222, 223, 224, 226, 227, 228, 229, 230, 231, 233, 234, 235, 236, 237, 239, 240, 241, 242, 243, 243, 244, 246, 247, 248, 249, 250, 251, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt6 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 69, 70, 71, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 133, 134, 135, 136, 137, 138, 139, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 154, 155, 156, 157, 158, 159, 161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 173, 174, 175, 176, 177, 178, 179, 180, 182, 183, 184, 185, 186, 187, 190, 191, 192, 193, 194, 195, 196, 198, 199, 200, 201, 202, 203, 205, 206, 207, 208, 209, 210, 212, 213, 214, 215, 216, 217, 220, 221, 222, 223, 224, 226, 227, 228, 229, 230, 231, 233, 234, 235, 236, 237, 239, 240, 241, 242, 243, 244, 246, 247, 249, 250, 251, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt7 = { 45, 45, 46, 46, 47, 47, 47, 47, 48, 48, 49, 49, 50, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 63, 63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 69, 69, 70, 70, 71, 71, 71, 72, 72, 73, 73, 74, 75, 75, 76, 76, 77, 78, 78, 79, 79, 80, 80, 80, 81, 82, 82, 83, 84, 84, 85, 86, 87, 87, 88, 89, 89, 90, 91, 92, 92, 93, 94, 95, 95, 95, 96, 97, 98, 98, 99, 100, 101, 102, 103, 103, 104, 105, 106, 107, 108, 109, 110, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 135, 136, 137, 138, 139, 141, 142, 143, 144, 146, 147, 148, 149, 150, 151, 152, 154, 156, 157, 158, 159, 160, 161, 162, 165, 166, 167, 168, 169, 170, 171, 173, 175, 176, 177, 178, 179, 180, 182, 183, 184, 186, 187, 188, 190, 191, 192, 193, 194, 195, 196, 198, 199, 200, 201, 202, 203, 205, 206, 207, 208, 209, 210, 212, 213, 214, 215, 216, 217, 217, 219, 220, 221, 222, 223, 224, 226, 227, 227, 228, 229, 230, 231, 233, 234, 235, 235, 236, 237, 239, 240, 241, 241, 242, 243, 244, 246, 246, 247, 248, 249, 250, 251, 251, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt8 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int j = 0; j < 256; j++){ - arrayOfByte[(1024 + j * 4)] = ((byte)arrayOfInt5[j]); - arrayOfByte[(1 + (1024 + j * 4))] = ((byte)arrayOfInt6[j]); - arrayOfByte[(2 + (1024 + j * 4))] = ((byte)arrayOfInt7[j]); - arrayOfByte[(3 + (1024 + j * 4))] = ((byte)arrayOfInt8[j]); - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicWhiteCatFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicWhiteCatFilter.java deleted file mode 100644 index 90c4698..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicWhiteCatFilter.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; - -import java.nio.ByteBuffer; - -public class MagicWhiteCatFilter extends GPUImageFilter{ - - private int[] mToneCurveTexture = {-1}; - private int mToneCurveTextureUniformLocation; - - public MagicWhiteCatFilter() { - super(MagicFilterType.WHITECAT, R.raw.whitecat); - } - - @Override - public void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(1, mToneCurveTexture, 0); - mToneCurveTexture[0] = -1; - } - - @Override - protected void onDrawArraysAfter() { - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre() { - if (mToneCurveTexture[0] != -1){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3); - } - } - - @Override - public void onInit() { - super.onInit(); - mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(getProgram(), "curve"); - } - - @Override - public void onInitialized() { - super.onInitialized(); - runOnDraw(new Runnable(){ - public void run(){ - GLES20.glGenTextures(1, mToneCurveTexture, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - byte[] arrayOfByte = new byte[2048]; - int[] arrayOfInt1 = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 69, 70, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 82, 83, 85, 86, 87, 88, 89, 90, 91, 92, 93, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 249, 250, 251, 252, 253, 254, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt2 = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 4, 5, 6, 7, 8, 10, 11, 12, 12, 13, 14, 16, 17, 18, 19, 19, 20, 22, 23, 24, 25, 26, 26, 28, 29, 30, 31, 32, 33, 35, 35, 36, 37, 38, 39, 41, 42, 42, 43, 44, 45, 46, 48, 49, 50, 50, 51, 52, 54, 55, 56, 57, 58, 58, 59, 61, 62, 63, 64, 65, 66, 66, 67, 69, 70, 71, 72, 73, 74, 75, 75, 77, 78, 79, 80, 81, 82, 83, 85, 85, 86, 87, 88, 89, 90, 91, 92, 93, 93, 95, 96, 97, 98, 99, 100, 101, 102, 103, 103, 104, 105, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 123, 124, 125, 126, 127, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 182, 183, 184, 185, 186, 187, 188, 189, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 217, 218, 219, 220, 221, 222, 223, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 236, 237, 238, 239, 240, 240 }; - for (int i = 0; i < 256; i++){ - arrayOfByte[(i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(1 + i * 4)] = ((byte)arrayOfInt1[i]); - arrayOfByte[(2 + i * 4)] = ((byte)arrayOfInt2[i]); - arrayOfByte[(3 + i * 4)] = -1; - } - int[] arrayOfInt3 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 6, 9, 14, 17, 19, 22, 25, 27, 30, 34, 36, 39, 41, 43, 45, 49, 51, 52, 54, 55, 57, 58, 61, 63, 64, 65, 67, 68, 69, 72, 73, 75, 76, 77, 78, 81, 82, 83, 84, 86, 87, 88, 90, 91, 93, 94, 95, 96, 97, 99, 100, 101, 102, 103, 105, 106, 108, 109, 110, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 123, 124, 125, 126, 126, 127, 128, 130, 131, 132, 133, 134, 135, 136, 138, 138, 139, 140, 141, 142, 144, 145, 146, 146, 147, 148, 149, 151, 152, 153, 153, 154, 155, 156, 158, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 168, 170, 171, 172, 172, 173, 174, 175, 176, 177, 178, 179, 180, 180, 181, 183, 183, 184, 185, 186, 186, 188, 189, 190, 190, 191, 192, 193, 194, 195, 196, 196, 197, 198, 199, 200, 201, 201, 202, 203, 204, 204, 206, 207, 207, 208, 209, 209, 211, 212, 212, 213, 214, 214, 215, 217, 217, 218, 219, 219, 220, 221, 222, 223, 224, 224, 225, 226, 227, 228, 228, 229, 230, 230, 231, 233, 233, 234, 235, 235, 236, 237, 238, 239, 239, 240, 241, 241, 242, 243, 244, 245, 245, 246, 247, 248, 249, 249, 250, 250, 251, 252, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; - int[] arrayOfInt4 = { 0, 2, 4, 6, 8, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 32, 34, 36, 38, 40, 42, 44, 46, 47, 49, 51, 53, 54, 56, 58, 60, 61, 63, 65, 66, 68, 70, 71, 73, 74, 76, 77, 79, 80, 82, 83, 85, 86, 88, 89, 91, 92, 93, 95, 96, 98, 99, 100, 101, 103, 104, 105, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 124, 125, 126, 127, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 203, 204, 205, 206, 206, 207, 208, 209, 210, 211, 212, 212, 213, 214, 215, 216, 216, 217, 218, 219, 219, 220, 221, 222, 222, 223, 224, 224, 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, 239, 240, 240, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 245, 246, 246, 247, 247, 247, 248, 248, 248, 249, 249, 249, 250, 250, 250, 251, 251, 251, 252, 252, 252, 252, 253, 253, 253, 253, 254, 254, 254, 254, 254, 255, 255, 255 }; - int[] arrayOfInt5 = { 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 29, 30, 29, 31, 31, 31, 31, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 48, 48, 49, 50, 51, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 100, 101, 103, 104, 105, 107, 108, 110, 111, 113, 115, 116, 118, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 135, 137, 139, 141, 143, 144, 146, 148, 150, 152, 154, 156, 158, 160, 163, 165, 167, 169, 171, 173, 175, 178, 180, 182, 185, 187, 189, 192, 194, 197, 199, 201, 204, 206, 209, 211, 214, 216, 219, 221, 224, 226, 229, 232, 234, 236, 239, 241, 245, 247, 250, 252, 255 }; - for (int j = 0; j < 256; j++){ - arrayOfByte[(1024 + j * 4)] = ((byte)arrayOfInt4[j]); - arrayOfByte[(1 + (1024 + j * 4))] = ((byte)arrayOfInt3[j]); - arrayOfByte[(2 + (1024 + j * 4))] = ((byte)arrayOfInt5[j]); - arrayOfByte[(3 + (1024 + j * 4))] = -1; - } - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(arrayOfByte)); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/advanced/MagicXproIIFilter.java b/Live/src/main/java/com/seu/magicfilter/advanced/MagicXproIIFilter.java deleted file mode 100644 index ef8298f..0000000 --- a/Live/src/main/java/com/seu/magicfilter/advanced/MagicXproIIFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.seu.magicfilter.advanced; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicXproIIFilter extends GPUImageFilter{ - private int[] inputTextureHandles = {-1,-1}; - private int[] inputTextureUniformLocations = {-1,-1}; - private int mGLStrengthLocation; - - public MagicXproIIFilter(){ - super(MagicFilterType.XPROII, R.raw.xproii_filter_shader); - } - - @Override - public void onDestroy() { - super.onDestroy(); - GLES20.glDeleteTextures(inputTextureHandles.length, inputTextureHandles, 0); - for(int i = 0; i < inputTextureHandles.length; i++) - inputTextureHandles[i] = -1; - } - - @Override - protected void onDrawArraysAfter(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3)); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - @Override - protected void onDrawArraysPre(){ - for(int i = 0; i < inputTextureHandles.length - && inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){ - GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) ); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]); - GLES20.glUniform1i(inputTextureUniformLocations[i], (i + 3)); - } - } - - @Override - public void onInit(){ - super.onInit(); - for(int i = 0; i < inputTextureUniformLocations.length; i++) - inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture"+(2+i)); - mGLStrengthLocation = GLES20.glGetUniformLocation(getProgram(), "strength"); - } - - @Override - public void onInitialized(){ - super.onInitialized(); - setFloat(mGLStrengthLocation, 1.0f); - runOnDraw(new Runnable(){ - public void run(){ - inputTextureHandles[0] = OpenGLUtils.loadTexture(getContext(), "filter/xpromap.png"); - inputTextureHandles[1] = OpenGLUtils.loadTexture(getContext(), "filter/vignettemap_new.png"); - } - }); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/base/MagicBaseGroupFilter.java b/Live/src/main/java/com/seu/magicfilter/base/MagicBaseGroupFilter.java deleted file mode 100644 index e283052..0000000 --- a/Live/src/main/java/com/seu/magicfilter/base/MagicBaseGroupFilter.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.seu.magicfilter.base; - - -import android.content.Context; -import android.opengl.GLES20; - -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.OpenGLUtils; - -import java.nio.FloatBuffer; -import java.util.List; - - -public class MagicBaseGroupFilter extends GPUImageFilter { - private static int[] frameBuffers = null; - private static int[] frameBufferTextures = null; - private int frameWidth = -1; - private int frameHeight = -1; - protected List filters; - - public MagicBaseGroupFilter(List filters) { - this.filters = filters; - } - - @Override - public void onDestroy() { - for (GPUImageFilter filter : filters) { - filter.destroy(); - } - destroyFramebuffers(); - } - - @Override - public void init(Context context) { - for (GPUImageFilter filter : filters) { - filter.init(context); - } - } - - @Override - public void onInputSizeChanged(final int width, final int height) { - super.onInputSizeChanged(width, height); - int size = filters.size(); - for (int i = 0; i < size; i++) { - filters.get(i).onInputSizeChanged(width, height); - } - if (frameBuffers != null && (frameWidth != width || frameHeight != height || frameBuffers.length != size - 1)) { - destroyFramebuffers(); - frameWidth = width; - frameHeight = height; - } - if (frameBuffers == null) { - frameBuffers = new int[size - 1]; - frameBufferTextures = new int[size - 1]; - - for (int i = 0; i < size - 1; i++) { - GLES20.glGenFramebuffers(1, frameBuffers, i); - - GLES20.glGenTextures(1, frameBufferTextures, i); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, frameBufferTextures[i]); - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, - GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffers[i]); - GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, - GLES20.GL_TEXTURE_2D, frameBufferTextures[i], 0); - - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - } - } - } - - @Override - public int onDrawFrame(final int textureId, final FloatBuffer cubeBuffer, - final FloatBuffer textureBuffer) { - if (frameBuffers == null || frameBufferTextures == null) { - return OpenGLUtils.NOT_INIT; - } - int size = filters.size(); - int previousTexture = textureId; - for (int i = 0; i < size; i++) { - GPUImageFilter filter = filters.get(i); - boolean isNotLast = i < size - 1; - if (isNotLast) { - GLES20.glViewport(0, 0, mInputWidth, mInputHeight); - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffers[i]); - GLES20.glClearColor(0, 0, 0, 0); - filter.onDrawFrame(previousTexture, mGLCubeBuffer, mGLTextureBuffer); - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - previousTexture = frameBufferTextures[i]; - } else { - GLES20.glViewport(0, 0, mOutputWidth, mOutputHeight); - filter.onDrawFrame(previousTexture, cubeBuffer, textureBuffer); - } - } - return OpenGLUtils.ON_DRAWN; - } - - public int onDrawFrame(int textureId) { - if (frameBuffers == null || frameBufferTextures == null) { - return OpenGLUtils.NOT_INIT; - } - int size = filters.size(); - int previousTexture = textureId; - for (int i = 0; i < size; i++) { - GPUImageFilter filter = filters.get(i); - boolean isNotLast = i < size - 1; - if (isNotLast) { - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffers[i]); - GLES20.glClearColor(0, 0, 0, 0); - filter.onDrawFrame(previousTexture, mGLCubeBuffer, mGLTextureBuffer); - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - previousTexture = frameBufferTextures[i]; - } else { - filter.onDrawFrame(previousTexture, mGLCubeBuffer, mGLTextureBuffer); - } - } - return OpenGLUtils.ON_DRAWN; - } - - private void destroyFramebuffers() { - if (frameBufferTextures != null) { - GLES20.glDeleteTextures(frameBufferTextures.length, frameBufferTextures, 0); - frameBufferTextures = null; - } - if (frameBuffers != null) { - GLES20.glDeleteFramebuffers(frameBuffers.length, frameBuffers, 0); - frameBuffers = null; - } - } - - public int getSize() { - return filters.size(); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/base/MagicLookupFilter.java b/Live/src/main/java/com/seu/magicfilter/base/MagicLookupFilter.java deleted file mode 100644 index 6c8253f..0000000 --- a/Live/src/main/java/com/seu/magicfilter/base/MagicLookupFilter.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.seu.magicfilter.base; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; - -public class MagicLookupFilter extends GPUImageFilter { - - protected String table; - - public MagicLookupFilter(String table) { - super(MagicFilterType.LOCKUP, R.raw.lookup); - this.table = table; - } - - private int mLookupTextureUniform; - private int mLookupSourceTexture = OpenGLUtils.NO_TEXTURE; - - protected void onInit() { - super.onInit(); - mLookupTextureUniform = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture2"); - } - - protected void onInitialized() { - super.onInitialized(); - runOnDraw(new Runnable() { - public void run() { - mLookupSourceTexture = OpenGLUtils.loadTexture(getContext(), table); - } - }); - } - - protected void onDestroy() { - super.onDestroy(); - int[] texture = new int[]{mLookupSourceTexture}; - GLES20.glDeleteTextures(1, texture, 0); - mLookupSourceTexture = -1; - } - - protected void onDrawArraysAfter() { - if (mLookupSourceTexture != -1) { - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - } - } - - protected void onDrawArraysPre() { - if (mLookupSourceTexture != -1) { - GLES20.glActiveTexture(GLES20.GL_TEXTURE3); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mLookupSourceTexture); - GLES20.glUniform1i(mLookupTextureUniform, 3); - } - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageBrightnessFilter.java b/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageBrightnessFilter.java deleted file mode 100644 index bc11872..0000000 --- a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageBrightnessFilter.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2012 CyberAgent - * - * 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. - */ - -package com.seu.magicfilter.base.gpuimage; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.utils.MagicFilterType; - -/** - * brightness value ranges from -1.0 to 1.0, with 0.0 as the normal level - */ -public class GPUImageBrightnessFilter extends GPUImageFilter { - - private int mBrightnessLocation; - private float mBrightness; - - public GPUImageBrightnessFilter() { - this(0.0f); - } - - public GPUImageBrightnessFilter(final float brightness) { - super(MagicFilterType.BRIGHTNESS, R.raw.brightness); - mBrightness = brightness; - } - - @Override - public void onInit() { - super.onInit(); - mBrightnessLocation = GLES20.glGetUniformLocation(getProgram(), "brightness"); - } - - @Override - public void onInitialized() { - super.onInitialized(); - setBrightness(mBrightness); - } - - public void setBrightness(final float brightness) { - mBrightness = brightness; - setFloat(mBrightnessLocation, mBrightness); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageContrastFilter.java b/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageContrastFilter.java deleted file mode 100644 index dc0b2c5..0000000 --- a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageContrastFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2012 CyberAgent - * - * 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. - */ - -package com.seu.magicfilter.base.gpuimage; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.utils.MagicFilterType; - - -/** - * Changes the contrast of the image.
- *
- * contrast value ranges from 0.0 to 4.0, with 1.0 as the normal level - */ -public class GPUImageContrastFilter extends GPUImageFilter { - - private int mContrastLocation; - private float mContrast; - - public GPUImageContrastFilter() { - this(1.0f); - } - - public GPUImageContrastFilter(float contrast) { - super(MagicFilterType.CONTRAST, R.raw.constrast); - mContrast = contrast; - } - - @Override - public void onInit() { - super.onInit(); - mContrastLocation = GLES20.glGetUniformLocation(getProgram(), "contrast"); - } - - @Override - public void onInitialized() { - super.onInitialized(); - setContrast(mContrast); - } - - public void setContrast(final float contrast) { - mContrast = contrast; - setFloat(mContrastLocation, mContrast); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageExposureFilter.java b/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageExposureFilter.java deleted file mode 100644 index 16e9a34..0000000 --- a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageExposureFilter.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2012 CyberAgent - * - * 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. - */ - -package com.seu.magicfilter.base.gpuimage; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.utils.MagicFilterType; - -/** - * exposure: The adjusted exposure (-10.0 - 10.0, with 0.0 as the default) - */ -public class GPUImageExposureFilter extends GPUImageFilter { - public static final String EXPOSURE_FRAGMENT_SHADER = "" + - " varying highp vec2 textureCoordinate;\n" + - " \n" + - " uniform sampler2D inputImageTexture;\n" + - " uniform highp float exposure;\n" + - " \n" + - " void main()\n" + - " {\n" + - " highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" + - " \n" + - " gl_FragColor = vec4(textureColor.rgb * pow(2.0, exposure), textureColor.w);\n" + - " } "; - - private int mExposureLocation; - private float mExposure; - - public GPUImageExposureFilter() { - this(0.0f); - } - - public GPUImageExposureFilter(final float exposure) { - super(MagicFilterType.EXPOSURE, R.raw.exposure); - mExposure = exposure; - } - - @Override - public void onInit() { - super.onInit(); - mExposureLocation = GLES20.glGetUniformLocation(getProgram(), "exposure"); - } - - @Override - public void onInitialized() { - super.onInitialized(); - setExposure(mExposure); - } - - public void setExposure(final float exposure) { - mExposure = exposure; - setFloat(mExposureLocation, mExposure); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageFilter.java b/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageFilter.java deleted file mode 100644 index cbabbee..0000000 --- a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageFilter.java +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright (C) 2012 CyberAgent - * - * 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. - */ - -package com.seu.magicfilter.base.gpuimage; - -import android.content.Context; -import android.graphics.PointF; -import android.opengl.GLES11Ext; -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.utils.MagicFilterType; -import com.seu.magicfilter.utils.OpenGLUtils; -import com.seu.magicfilter.utils.Rotation; -import com.seu.magicfilter.utils.TextureRotationUtil; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.util.LinkedList; - -public class GPUImageFilter { - - private boolean mIsInitialized; - private Context mContext; - private MagicFilterType mType = MagicFilterType.NONE; - private final LinkedList mRunOnDraw; - private final int mVertexShaderId; - private final int mFragmentShaderId; - - private int mGLProgId; - private int mGLPositionIndex; - private int mGLInputImageTextureIndex; - private int mGLTextureCoordinateIndex; - private int mGLTextureTransformIndex; - - protected int mInputWidth; - protected int mInputHeight; - protected int mOutputWidth; - protected int mOutputHeight; - protected FloatBuffer mGLCubeBuffer; - protected FloatBuffer mGLTextureBuffer; - - private int[] mGLCubeId; - private int[] mGLTextureCoordinateId; - private float[] mGLTextureTransformMatrix; - - private int[] mGLFboId; - private int[] mGLFboTexId; - private IntBuffer mGLFboBuffer; - - public GPUImageFilter() { - this(MagicFilterType.NONE); - } - - public GPUImageFilter(MagicFilterType type) { - this(type, R.raw.vertex, R.raw.fragment); - } - - public GPUImageFilter(MagicFilterType type, int fragmentShaderId) { - this(type, R.raw.vertex, fragmentShaderId); - } - - public GPUImageFilter(MagicFilterType type, int vertexShaderId, int fragmentShaderId) { - mType = type; - mRunOnDraw = new LinkedList<>(); - mVertexShaderId = vertexShaderId; - mFragmentShaderId = fragmentShaderId; - - mGLCubeBuffer = ByteBuffer.allocateDirect(TextureRotationUtil.CUBE.length * 4) - .order(ByteOrder.nativeOrder()) - .asFloatBuffer(); - mGLCubeBuffer.put(TextureRotationUtil.CUBE).position(0); - - mGLTextureBuffer = ByteBuffer.allocateDirect(TextureRotationUtil.TEXTURE_NO_ROTATION.length * 4) - .order(ByteOrder.nativeOrder()) - .asFloatBuffer(); - mGLTextureBuffer.put(TextureRotationUtil.getRotation(Rotation.NORMAL, false, true)).position(0); - } - - public void init(Context context) { - mContext = context; - onInit(); - onInitialized(); - } - - protected void onInit() { - initVbo(); - loadSamplerShader(); - } - - protected void onInitialized() { - mIsInitialized = true; - } - - public final void destroy() { - mIsInitialized = false; - destroyFboTexture(); - destoryVbo(); - GLES20.glDeleteProgram(mGLProgId); - onDestroy(); - } - - protected void onDestroy() { - } - - public void onInputSizeChanged(final int width, final int height) { - mInputWidth = width; - mInputHeight = height; - initFboTexture(width, height); - } - - public void onDisplaySizeChanged(final int width, final int height) { - mOutputWidth = width; - mOutputHeight = height; - } - - private void loadSamplerShader() { - mGLProgId = OpenGLUtils.loadProgram(OpenGLUtils.readShaderFromRawResource(getContext(), mVertexShaderId), - OpenGLUtils.readShaderFromRawResource(getContext(), mFragmentShaderId)); - mGLPositionIndex = GLES20.glGetAttribLocation(mGLProgId, "position"); - mGLTextureCoordinateIndex = GLES20.glGetAttribLocation(mGLProgId,"inputTextureCoordinate"); - mGLTextureTransformIndex = GLES20.glGetUniformLocation(mGLProgId, "textureTransform"); - mGLInputImageTextureIndex = GLES20.glGetUniformLocation(mGLProgId, "inputImageTexture"); - } - - private void initVbo() { - mGLCubeId = new int[1]; - mGLTextureCoordinateId = new int[1]; - - GLES20.glGenBuffers(1, mGLCubeId, 0); - GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mGLCubeId[0]); - GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mGLCubeBuffer.capacity() * 4, mGLCubeBuffer, GLES20.GL_STATIC_DRAW); - - GLES20.glGenBuffers(1, mGLTextureCoordinateId, 0); - GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mGLTextureCoordinateId[0]); - GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mGLTextureBuffer.capacity() * 4, mGLTextureBuffer, GLES20.GL_STATIC_DRAW); - } - - private void destoryVbo() { - if (mGLCubeId != null) { - GLES20.glDeleteBuffers(1, mGLCubeId, 0); - mGLCubeId = null; - } - if (mGLTextureCoordinateId != null) { - GLES20.glDeleteBuffers(1, mGLTextureCoordinateId, 0); - mGLTextureCoordinateId = null; - } - } - - private void initFboTexture(int width, int height) { - if (mGLFboId != null && (mInputWidth != width || mInputHeight != height)) { - destroyFboTexture(); - } - - mGLFboId = new int[1]; - mGLFboTexId = new int[1]; - mGLFboBuffer = IntBuffer.allocate(width * height); - - GLES20.glGenFramebuffers(1, mGLFboId, 0); - GLES20.glGenTextures(1, mGLFboTexId, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mGLFboTexId[0]); - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mGLFboId[0]); - GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mGLFboTexId[0], 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - } - - private void destroyFboTexture() { - if (mGLFboTexId != null) { - GLES20.glDeleteTextures(1, mGLFboTexId, 0); - mGLFboTexId = null; - } - if (mGLFboId != null) { - GLES20.glDeleteFramebuffers(1, mGLFboId, 0); - mGLFboId = null; - } - } - - public int onDrawFrame(final int textureId, final FloatBuffer cubeBuffer, final FloatBuffer textureBuffer) { - if (!mIsInitialized) { - return OpenGLUtils.NOT_INIT; - } - - GLES20.glUseProgram(mGLProgId); - runPendingOnDrawTasks(); - - GLES20.glEnableVertexAttribArray(mGLPositionIndex); - GLES20.glVertexAttribPointer(mGLPositionIndex, 2, GLES20.GL_FLOAT, false, 4 * 2, cubeBuffer); - - GLES20.glEnableVertexAttribArray(mGLTextureCoordinateIndex); - GLES20.glVertexAttribPointer(mGLTextureCoordinateIndex, 2, GLES20.GL_FLOAT, false, 4 * 2, textureBuffer); - - if (textureId != OpenGLUtils.NO_TEXTURE) { - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId); - GLES20.glUniform1i(mGLInputImageTextureIndex, 0); - } - - onDrawArraysPre(); - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - onDrawArraysAfter(); - - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); - - GLES20.glDisableVertexAttribArray(mGLPositionIndex); - GLES20.glDisableVertexAttribArray(mGLTextureCoordinateIndex); - - return OpenGLUtils.ON_DRAWN; - } - - public int onDrawFrame(int cameraTextureId) { - if (!mIsInitialized) { - return OpenGLUtils.NOT_INIT; - } - - if (mGLFboId == null) { - return OpenGLUtils.NO_TEXTURE; - } - - GLES20.glUseProgram(mGLProgId); - runPendingOnDrawTasks(); - - GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mGLCubeId[0]); - GLES20.glEnableVertexAttribArray(mGLPositionIndex); - GLES20.glVertexAttribPointer(mGLPositionIndex, 2, GLES20.GL_FLOAT, false, 4 * 2, 0); - - GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mGLTextureCoordinateId[0]); - GLES20.glEnableVertexAttribArray(mGLTextureCoordinateIndex); - GLES20.glVertexAttribPointer(mGLTextureCoordinateIndex, 2, GLES20.GL_FLOAT, false, 4 * 2, 0); - - GLES20.glUniformMatrix4fv(mGLTextureTransformIndex, 1, false, mGLTextureTransformMatrix, 0); - - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, cameraTextureId); - GLES20.glUniform1i(mGLInputImageTextureIndex, 0); - - onDrawArraysPre(); - - GLES20.glViewport(0, 0, mInputWidth, mInputHeight); - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mGLFboId[0]); - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - - GLES20.glReadPixels(0, 0, mInputWidth, mInputHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, mGLFboBuffer); - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - GLES20.glViewport(0, 0, mOutputWidth, mOutputHeight); - - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - - onDrawArraysAfter(); - - GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0); - - GLES20.glDisableVertexAttribArray(mGLPositionIndex); - GLES20.glDisableVertexAttribArray(mGLTextureCoordinateIndex); - - GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); - - return mGLFboTexId[0]; - } - - protected void onDrawArraysPre() {} - - protected void onDrawArraysAfter() {} - - private void runPendingOnDrawTasks() { - while (!mRunOnDraw.isEmpty()) { - mRunOnDraw.removeFirst().run(); - } - } - - public int getProgram() { - return mGLProgId; - } - - public IntBuffer getGLFboBuffer() { - return mGLFboBuffer; - } - - protected Context getContext() { - return mContext; - } - - protected MagicFilterType getFilterType() { - return mType; - } - - public void setTextureTransformMatrix(float[] mtx){ - mGLTextureTransformMatrix = mtx; - } - - protected void setInteger(final int location, final int intValue) { - runOnDraw(new Runnable() { - @Override - public void run() { - GLES20.glUniform1i(location, intValue); - } - }); - } - - protected void setFloat(final int location, final float floatValue) { - runOnDraw(new Runnable() { - @Override - public void run() { - GLES20.glUniform1f(location, floatValue); - } - }); - } - - protected void setFloatVec2(final int location, final float[] arrayValue) { - runOnDraw(new Runnable() { - @Override - public void run() { - GLES20.glUniform2fv(location, 1, FloatBuffer.wrap(arrayValue)); - } - }); - } - - protected void setFloatVec3(final int location, final float[] arrayValue) { - runOnDraw(new Runnable() { - @Override - public void run() { - GLES20.glUniform3fv(location, 1, FloatBuffer.wrap(arrayValue)); - } - }); - } - - protected void setFloatVec4(final int location, final float[] arrayValue) { - runOnDraw(new Runnable() { - @Override - public void run() { - GLES20.glUniform4fv(location, 1, FloatBuffer.wrap(arrayValue)); - } - }); - } - - protected void setFloatArray(final int location, final float[] arrayValue) { - runOnDraw(new Runnable() { - @Override - public void run() { - GLES20.glUniform1fv(location, arrayValue.length, FloatBuffer.wrap(arrayValue)); - } - }); - } - - protected void setPoint(final int location, final PointF point) { - runOnDraw(new Runnable() { - - @Override - public void run() { - float[] vec2 = new float[2]; - vec2[0] = point.x; - vec2[1] = point.y; - GLES20.glUniform2fv(location, 1, vec2, 0); - } - }); - } - - protected void setUniformMatrix3f(final int location, final float[] matrix) { - runOnDraw(new Runnable() { - - @Override - public void run() { - GLES20.glUniformMatrix3fv(location, 1, false, matrix, 0); - } - }); - } - - protected void setUniformMatrix4f(final int location, final float[] matrix) { - runOnDraw(new Runnable() { - - @Override - public void run() { - GLES20.glUniformMatrix4fv(location, 1, false, matrix, 0); - } - }); - } - - protected void runOnDraw(final Runnable runnable) { - synchronized (mRunOnDraw) { - mRunOnDraw.addLast(runnable); - } - } -} - diff --git a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageHueFilter.java b/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageHueFilter.java deleted file mode 100644 index 0ed2772..0000000 --- a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageHueFilter.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012 CyberAgent - * - * 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. - */ - -package com.seu.magicfilter.base.gpuimage; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.utils.MagicFilterType; - -public class GPUImageHueFilter extends GPUImageFilter { - - private float mHue; - private int mHueLocation; - - public GPUImageHueFilter() { - this(0.0f); - } - - public GPUImageHueFilter(final float hue) { - super(MagicFilterType.HUE, R.raw.hue); - mHue = hue; - } - - @Override - public void onInit() { - super.onInit(); - mHueLocation = GLES20.glGetUniformLocation(getProgram(), "hueAdjust"); - } - - @Override - public void onInitialized() { - super.onInitialized(); - setHue(mHue); - } - - public void setHue(final float hue) { - mHue = hue; - float hueAdjust = (mHue % 360.0f) * (float) Math.PI / 180.0f; - setFloat(mHueLocation, hueAdjust); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageSaturationFilter.java b/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageSaturationFilter.java deleted file mode 100644 index 5ecb7d3..0000000 --- a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageSaturationFilter.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2012 CyberAgent - * - * 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. - */ - -package com.seu.magicfilter.base.gpuimage; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.utils.MagicFilterType; - -/** - * saturation: The degree of saturation or desaturation to apply to the image (0.0 - 2.0, with 1.0 as the default) - */ -public class GPUImageSaturationFilter extends GPUImageFilter { - - private int mSaturationLocation; - private float mSaturation; - - public GPUImageSaturationFilter() { - this(1.0f); - } - - public GPUImageSaturationFilter(final float saturation) { - super(MagicFilterType.SATURATION, R.raw.saturation); - mSaturation = saturation; - } - - @Override - public void onInit() { - super.onInit(); - mSaturationLocation = GLES20.glGetUniformLocation(getProgram(), "saturation"); - } - - @Override - public void onInitialized() { - super.onInitialized(); - setSaturation(mSaturation); - } - - public void setSaturation(final float saturation) { - mSaturation = saturation; - setFloat(mSaturationLocation, mSaturation); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageSharpenFilter.java b/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageSharpenFilter.java deleted file mode 100644 index a9bef39..0000000 --- a/Live/src/main/java/com/seu/magicfilter/base/gpuimage/GPUImageSharpenFilter.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2012 CyberAgent - * - * 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. - */ - -package com.seu.magicfilter.base.gpuimage; - -import android.opengl.GLES20; - -import com.frank.live.R; -import com.seu.magicfilter.utils.MagicFilterType; - -/** - * Sharpens the picture.
- *
- * sharpness: from -4.0 to 4.0, with 0.0 as the normal level - */ -public class GPUImageSharpenFilter extends GPUImageFilter { - - private int mSharpnessLocation; - private float mSharpness; - private int mImageWidthFactorLocation; - private int mImageHeightFactorLocation; - - public GPUImageSharpenFilter() { - this(0.0f); - } - - public GPUImageSharpenFilter(final float sharpness) { - super(MagicFilterType.SHARPEN, R.raw.vertex_sharpen, R.raw.sharpen); - mSharpness = sharpness; - } - - @Override - public void onInit() { - super.onInit(); - mSharpnessLocation = GLES20.glGetUniformLocation(getProgram(), "sharpness"); - mImageWidthFactorLocation = GLES20.glGetUniformLocation(getProgram(), "imageWidthFactor"); - mImageHeightFactorLocation = GLES20.glGetUniformLocation(getProgram(), "imageHeightFactor"); - setSharpness(mSharpness); - } - - @Override - public void onInputSizeChanged(final int width, final int height) { - super.onInputSizeChanged(width, height); - setFloat(mImageWidthFactorLocation, 1.0f / width); - setFloat(mImageHeightFactorLocation, 1.0f / height); - } - - public void setSharpness(final float sharpness) { - mSharpness = sharpness; - setFloat(mSharpnessLocation, mSharpness); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/utils/MagicFilterFactory.java b/Live/src/main/java/com/seu/magicfilter/utils/MagicFilterFactory.java deleted file mode 100644 index ed50e53..0000000 --- a/Live/src/main/java/com/seu/magicfilter/utils/MagicFilterFactory.java +++ /dev/null @@ -1,163 +0,0 @@ -package com.seu.magicfilter.utils; - -import com.seu.magicfilter.advanced.MagicAmaroFilter; -import com.seu.magicfilter.advanced.MagicAntiqueFilter; -import com.seu.magicfilter.advanced.MagicBeautyFilter; -import com.seu.magicfilter.advanced.MagicBlackCatFilter; -import com.seu.magicfilter.advanced.MagicBrannanFilter; -import com.seu.magicfilter.advanced.MagicBrooklynFilter; -import com.seu.magicfilter.advanced.MagicCalmFilter; -import com.seu.magicfilter.advanced.MagicCoolFilter; -import com.seu.magicfilter.advanced.MagicCrayonFilter; -import com.seu.magicfilter.advanced.MagicEarlyBirdFilter; -import com.seu.magicfilter.advanced.MagicEmeraldFilter; -import com.seu.magicfilter.advanced.MagicEvergreenFilter; -import com.seu.magicfilter.advanced.MagicFreudFilter; -import com.seu.magicfilter.advanced.MagicHealthyFilter; -import com.seu.magicfilter.advanced.MagicHefeFilter; -import com.seu.magicfilter.advanced.MagicHudsonFilter; -import com.seu.magicfilter.advanced.MagicImageAdjustFilter; -import com.seu.magicfilter.advanced.MagicInkwellFilter; -import com.seu.magicfilter.advanced.MagicKevinFilter; -import com.seu.magicfilter.advanced.MagicLatteFilter; -import com.seu.magicfilter.advanced.MagicLomoFilter; -import com.seu.magicfilter.advanced.MagicN1977Filter; -import com.seu.magicfilter.advanced.MagicNashvilleFilter; -import com.seu.magicfilter.advanced.MagicNostalgiaFilter; -import com.seu.magicfilter.advanced.MagicPixelFilter; -import com.seu.magicfilter.advanced.MagicRiseFilter; -import com.seu.magicfilter.advanced.MagicRomanceFilter; -import com.seu.magicfilter.advanced.MagicSakuraFilter; -import com.seu.magicfilter.advanced.MagicSierraFilter; -import com.seu.magicfilter.advanced.MagicSketchFilter; -import com.seu.magicfilter.advanced.MagicSkinWhitenFilter; -import com.seu.magicfilter.advanced.MagicSunriseFilter; -import com.seu.magicfilter.advanced.MagicSunsetFilter; -import com.seu.magicfilter.advanced.MagicSutroFilter; -import com.seu.magicfilter.advanced.MagicSweetsFilter; -import com.seu.magicfilter.advanced.MagicTenderFilter; -import com.seu.magicfilter.advanced.MagicToasterFilter; -import com.seu.magicfilter.advanced.MagicValenciaFilter; -import com.seu.magicfilter.advanced.MagicWaldenFilter; -import com.seu.magicfilter.advanced.MagicWarmFilter; -import com.seu.magicfilter.advanced.MagicWhiteCatFilter; -import com.seu.magicfilter.advanced.MagicXproIIFilter; -import com.seu.magicfilter.base.MagicLookupFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageBrightnessFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageContrastFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageExposureFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageHueFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageSaturationFilter; -import com.seu.magicfilter.base.gpuimage.GPUImageSharpenFilter; - -public class MagicFilterFactory{ - - public static GPUImageFilter initFilters(MagicFilterType type) { - switch (type) { - case NONE: - return new GPUImageFilter(); - case WHITECAT: - return new MagicWhiteCatFilter(); - case BLACKCAT: - return new MagicBlackCatFilter(); - case SKINWHITEN: - return new MagicSkinWhitenFilter(); - case BEAUTY: - return new MagicBeautyFilter(); - case ROMANCE: - return new MagicRomanceFilter(); - case SAKURA: - return new MagicSakuraFilter(); - case AMARO: - return new MagicAmaroFilter(); - case WALDEN: - return new MagicWaldenFilter(); - case ANTIQUE: - return new MagicAntiqueFilter(); - case CALM: - return new MagicCalmFilter(); - case BRANNAN: - return new MagicBrannanFilter(); - case BROOKLYN: - return new MagicBrooklynFilter(); - case EARLYBIRD: - return new MagicEarlyBirdFilter(); - case FREUD: - return new MagicFreudFilter(); - case HEFE: - return new MagicHefeFilter(); - case HUDSON: - return new MagicHudsonFilter(); - case INKWELL: - return new MagicInkwellFilter(); - case KEVIN: - return new MagicKevinFilter(); - case LOCKUP: - return new MagicLookupFilter(""); - case LOMO: - return new MagicLomoFilter(); - case N1977: - return new MagicN1977Filter(); - case NASHVILLE: - return new MagicNashvilleFilter(); - case PIXAR: - return new MagicPixelFilter(); - case RISE: - return new MagicRiseFilter(); - case SIERRA: - return new MagicSierraFilter(); - case SUTRO: - return new MagicSutroFilter(); - case TOASTER2: - return new MagicToasterFilter(); - case VALENCIA: - return new MagicValenciaFilter(); - case XPROII: - return new MagicXproIIFilter(); - case EVERGREEN: - return new MagicEvergreenFilter(); - case HEALTHY: - return new MagicHealthyFilter(); - case COOL: - return new MagicCoolFilter(); - case EMERALD: - return new MagicEmeraldFilter(); - case LATTE: - return new MagicLatteFilter(); - case WARM: - return new MagicWarmFilter(); - case TENDER: - return new MagicTenderFilter(); - case SWEETS: - return new MagicSweetsFilter(); - case NOSTALGIA: - return new MagicNostalgiaFilter(); - case SUNRISE: - return new MagicSunriseFilter(); - case SUNSET: - return new MagicSunsetFilter(); - case CRAYON: - return new MagicCrayonFilter(); - case SKETCH: - return new MagicSketchFilter(); - //image adjust - case BRIGHTNESS: - return new GPUImageBrightnessFilter(); - case CONTRAST: - return new GPUImageContrastFilter(); - case EXPOSURE: - return new GPUImageExposureFilter(); - case HUE: - return new GPUImageHueFilter(); - case SATURATION: - return new GPUImageSaturationFilter(); - case SHARPEN: - return new GPUImageSharpenFilter(); - case IMAGE_ADJUST: - return new MagicImageAdjustFilter(); - default: - return null; - } - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/utils/MagicFilterType.java b/Live/src/main/java/com/seu/magicfilter/utils/MagicFilterType.java deleted file mode 100644 index 419c716..0000000 --- a/Live/src/main/java/com/seu/magicfilter/utils/MagicFilterType.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.seu.magicfilter.utils; - -/** - * Created by why8222 on 2016/2/25. - */ -public enum MagicFilterType { - NONE, - FAIRYTALE, - SUNRISE, - SUNSET, - WHITECAT, - BLACKCAT, - SKINWHITEN, - BEAUTY, - HEALTHY, - SWEETS, - ROMANCE, - SAKURA, - WARM, - ANTIQUE, - NOSTALGIA, - CALM, - LATTE, - TENDER, - COOL, - EMERALD, - EVERGREEN, - CRAYON, - SKETCH, - AMARO, - BRANNAN, - BROOKLYN, - EARLYBIRD, - FREUD, - HEFE, - HUDSON, - INKWELL, - KEVIN, - LOCKUP, - LOMO, - N1977, - NASHVILLE, - PIXAR, - RISE, - SIERRA, - SUTRO, - TOASTER2, - VALENCIA, - WALDEN, - XPROII, - //image adjust - CONTRAST, - BRIGHTNESS, - EXPOSURE, - HUE, - SATURATION, - SHARPEN, - IMAGE_ADJUST -} diff --git a/Live/src/main/java/com/seu/magicfilter/utils/OpenGLUtils.java b/Live/src/main/java/com/seu/magicfilter/utils/OpenGLUtils.java deleted file mode 100644 index 6de6bee..0000000 --- a/Live/src/main/java/com/seu/magicfilter/utils/OpenGLUtils.java +++ /dev/null @@ -1,230 +0,0 @@ -package com.seu.magicfilter.utils; - -import android.content.Context; -import android.content.res.AssetManager; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.opengl.GLES11Ext; -import android.opengl.GLES20; -import android.opengl.GLUtils; -import android.util.Log; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.Buffer; - -import javax.microedition.khronos.opengles.GL10; - -public class OpenGLUtils { - public static final int NO_TEXTURE = -1; - public static final int NOT_INIT = -1; - public static final int ON_DRAWN = 1; - - public static int loadTexture(Bitmap img, int usedTexId) { - return loadTexture(img, usedTexId, false); - } - - public static int loadTexture(Bitmap img, int usedTexId, boolean recyled) { - if(img == null) - return NO_TEXTURE; - int textures[] = new int[1]; - if (usedTexId == NO_TEXTURE) { - GLES20.glGenTextures(1, textures, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - - GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, img, 0); - } else { - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId); - GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, img); - textures[0] = usedTexId; - } - if(recyled) - img.recycle(); - return textures[0]; - } - - public static int loadTexture(Buffer data, int width, int height, int usedTexId) { - if(data == null) - return NO_TEXTURE; - int textures[] = new int[1]; - if (usedTexId == NO_TEXTURE) { - GLES20.glGenTextures(1, textures, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, - 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, data); - } else { - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId); - GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, width, - height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, data); - textures[0] = usedTexId; - } - return textures[0]; - } - - public static int loadTexture(Buffer data, int width, int height, int usedTexId, int type) { - if(data == null) - return NO_TEXTURE; - int textures[] = new int[1]; - if (usedTexId == NO_TEXTURE) { - GLES20.glGenTextures(1, textures, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, - GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, - 0, GLES20.GL_RGBA, type, data); - } else { - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId); - GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, width, - height, GLES20.GL_RGBA, type, data); - textures[0] = usedTexId; - } - return textures[0]; - } - - public static int loadTexture(final Context context, final String name){ - final int[] textureHandle = new int[1]; - - GLES20.glGenTextures(1, textureHandle, 0); - - if (textureHandle[0] != 0){ - - // Read in the resource - final Bitmap bitmap = getImageFromAssetsFile(context,name); - - // Bind to the texture in OpenGL - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]); - - // Set filtering - GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); - GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - // Load the bitmap into the bound texture. - GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0); - - // Recycle the bitmap, since its data has been loaded into OpenGL. - bitmap.recycle(); - } - - if (textureHandle[0] == 0){ - throw new RuntimeException("Error loading texture."); - } - - return textureHandle[0]; - } - - private static Bitmap getImageFromAssetsFile(Context context, String fileName){ - Bitmap image = null; - AssetManager am = context.getResources().getAssets(); - try{ - InputStream is = am.open(fileName); - image = BitmapFactory.decodeStream(is); - is.close(); - }catch (IOException e){ - e.printStackTrace(); - } - return image; - } - - public static int loadProgram(String strVSource, String strFSource) { - int iVShader; - int iFShader; - int iProgId; - int[] link = new int[1]; - iVShader = loadShader(strVSource, GLES20.GL_VERTEX_SHADER); - if (iVShader == 0) { - Log.d("Load Program", "Vertex Shader Failed"); - return 0; - } - iFShader = loadShader(strFSource, GLES20.GL_FRAGMENT_SHADER); - if (iFShader == 0) { - Log.d("Load Program", "Fragment Shader Failed"); - return 0; - } - - iProgId = GLES20.glCreateProgram(); - GLES20.glAttachShader(iProgId, iVShader); - GLES20.glAttachShader(iProgId, iFShader); - GLES20.glLinkProgram(iProgId); - GLES20.glGetProgramiv(iProgId, GLES20.GL_LINK_STATUS, link, 0); - if (link[0] <= 0) { - Log.d("Load Program", "Linking Failed"); - return 0; - } - GLES20.glDeleteShader(iVShader); - GLES20.glDeleteShader(iFShader); - return iProgId; - } - - private static int loadShader(String strSource, int iType) { - int[] compiled = new int[1]; - int iShader = GLES20.glCreateShader(iType); - GLES20.glShaderSource(iShader, strSource); - GLES20.glCompileShader(iShader); - GLES20.glGetShaderiv(iShader, GLES20.GL_COMPILE_STATUS, compiled, 0); - if (compiled[0] == 0) { - Log.e("Load Shader Failed", "Compilation\n" + GLES20.glGetShaderInfoLog(iShader)); - return 0; - } - return iShader; - } - - public static int getExternalOESTextureID(){ - int[] texture = new int[1]; - GLES20.glGenTextures(1, texture, 0); - GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, texture[0]); - GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, - GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR); - GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, - GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); - GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, - GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE); - GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, - GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE); - return texture[0]; - } - - public static String readShaderFromRawResource(Context context, int resourceId){ - final InputStream inputStream = context.getResources().openRawResource(resourceId); - final InputStreamReader inputStreamReader = new InputStreamReader(inputStream); - final BufferedReader bufferedReader = new BufferedReader(inputStreamReader); - - String nextLine; - final StringBuilder body = new StringBuilder(); - - try{ - while ((nextLine = bufferedReader.readLine()) != null){ - body.append(nextLine); - body.append('\n'); - } - } - catch (IOException e){ - return null; - } - return body.toString(); - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/utils/Rotation.java b/Live/src/main/java/com/seu/magicfilter/utils/Rotation.java deleted file mode 100644 index 105cc78..0000000 --- a/Live/src/main/java/com/seu/magicfilter/utils/Rotation.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2012 CyberAgent - * - * 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. - */ - -package com.seu.magicfilter.utils; - -public enum Rotation { - NORMAL, ROTATION_90, ROTATION_180, ROTATION_270; - - /** - * Retrieves the int representation of the Rotation. - * - * @return 0, 90, 180 or 270 - */ - public int asInt() { - switch (this) { - case NORMAL: return 0; - case ROTATION_90: return 90; - case ROTATION_180: return 180; - case ROTATION_270: return 270; - default: throw new IllegalStateException("Unknown Rotation!"); - } - } - - /** - * Create a Rotation from an integer. Needs to be either 0, 90, 180 or 270. - * - * @param rotation 0, 90, 180 or 270 - * @return Rotation object - */ - public static Rotation fromInt(int rotation) { - switch (rotation) { - case 0: return NORMAL; - case 90: return ROTATION_90; - case 180: return ROTATION_180; - case 270: return ROTATION_270; - case 360: return NORMAL; - default: throw new IllegalStateException( - rotation + " is an unknown rotation. Needs to be either 0, 90, 180 or 270!"); - } - } -} diff --git a/Live/src/main/java/com/seu/magicfilter/utils/TextureRotationUtil.java b/Live/src/main/java/com/seu/magicfilter/utils/TextureRotationUtil.java deleted file mode 100644 index f236305..0000000 --- a/Live/src/main/java/com/seu/magicfilter/utils/TextureRotationUtil.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2012 CyberAgent - * - * 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. - */ - -package com.seu.magicfilter.utils; - -public class TextureRotationUtil { - - public static final float TEXTURE_NO_ROTATION[] = { - 0.0f, 1.0f, - 1.0f, 1.0f, - 0.0f, 0.0f, - 1.0f, 0.0f, - }; - - public static final float TEXTURE_ROTATED_90[] = { - 1.0f, 1.0f, - 1.0f, 0.0f, - 0.0f, 1.0f, - 0.0f, 0.0f, - }; - public static final float TEXTURE_ROTATED_180[] = { - 1.0f, 0.0f, - 0.0f, 0.0f, - 1.0f, 1.0f, - 0.0f, 1.0f, - }; - public static final float TEXTURE_ROTATED_270[] = { - 0.0f, 0.0f, - 0.0f, 1.0f, - 1.0f, 0.0f, - 1.0f, 1.0f, - }; - - public static final float CUBE[] = { - -1.0f, -1.0f, - 1.0f, -1.0f, - -1.0f, 1.0f, - 1.0f, 1.0f, - }; - - private TextureRotationUtil() {} - - public static float[] getRotation(final Rotation rotation, final boolean flipHorizontal, - final boolean flipVertical) { - float[] rotatedTex; - switch (rotation) { - case ROTATION_90: - rotatedTex = TEXTURE_ROTATED_90; - break; - case ROTATION_180: - rotatedTex = TEXTURE_ROTATED_180; - break; - case ROTATION_270: - rotatedTex = TEXTURE_ROTATED_270; - break; - case NORMAL: - default: - rotatedTex = TEXTURE_NO_ROTATION; - break; - } - if (flipHorizontal) { - rotatedTex = new float[]{ - flip(rotatedTex[0]), rotatedTex[1], - flip(rotatedTex[2]), rotatedTex[3], - flip(rotatedTex[4]), rotatedTex[5], - flip(rotatedTex[6]), rotatedTex[7], - }; - } - if (flipVertical) { - rotatedTex = new float[]{ - rotatedTex[0], flip(rotatedTex[1]), - rotatedTex[2], flip(rotatedTex[3]), - rotatedTex[4], flip(rotatedTex[5]), - rotatedTex[6], flip(rotatedTex[7]), - }; - } - return rotatedTex; - } - - private static float flip(final float i) { - return i == 0.0f ? 1.0f : 0.0f; - } -} diff --git a/Live/src/main/res/layout/activity_push.xml b/Live/src/main/res/layout/activity_push.xml deleted file mode 100644 index 968fff8..0000000 --- a/Live/src/main/res/layout/activity_push.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - -