listeners = sListeners.get(event);
65 | if (listeners != null) {
66 | for (final EventListener l : listeners) {
67 | caller.onDispatch(event, object, l);
68 | }
69 | }
70 | }
71 | }
72 |
73 | public static void dispatch(final int event, final Object object) {
74 | dispatch(event, object, new DispatchCaller() {
75 | @Override
76 | public void onDispatch(final int event, final Object object, final EventListener l) {
77 | if (l != null) {
78 | BaseApplication.post(new Runnable() {
79 | @Override
80 | public void run() {
81 | l.onEvent(event, object);
82 | }
83 | });
84 | }
85 | }
86 | });
87 | }
88 |
89 | public static void dispatchInstant(final int event, final Object object) {
90 | dispatch(event, object, new DispatchCaller() {
91 | @Override
92 | public void onDispatch(final int event, final Object object, final EventListener l) {
93 | if (l != null) {
94 | l.onEvent(event, object);
95 | }
96 | }
97 | });
98 | }
99 |
100 | private interface DispatchCaller {
101 | void onDispatch(int event, Object object, EventListener l);
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/EventListener.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library;
2 |
3 | /**
4 | * Created by dingjikerbo on 17/8/17.
5 | */
6 |
7 | public interface EventListener {
8 |
9 | void onEvent(int event, Object object);
10 | }
11 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/Face.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library;
2 |
3 | import static android.opengl.GLES20.glLineWidth;
4 |
5 | /**
6 | * Created by dingjikerbo on 2017/10/31.
7 | */
8 |
9 | public class Face extends Rect {
10 |
11 | public Face(int x1, int y1, int x2, int y2, int color) {
12 | super(x1, y1, x2, y2, color);
13 | }
14 |
15 | @Override
16 | public void draw() {
17 | glLineWidth(5f);
18 | super.draw();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/OffscreenSurface.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Google Inc. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.inuker.library;
18 |
19 | /**
20 | * Off-screen EGL surface (pbuffer).
21 | *
22 | * It's good practice to explicitly release() the surface, preferably from a "finally" block.
23 | */
24 | public class OffscreenSurface extends EglSurfaceBase {
25 | /**
26 | * Creates an off-screen surface with the specified width and height.
27 | */
28 | public OffscreenSurface(EglCore eglCore, int width, int height) {
29 | super(eglCore);
30 | createOffscreenSurface(width, height);
31 | }
32 |
33 | /**
34 | * Releases any resources associated with the surface.
35 | */
36 | public void release() {
37 | releaseEglSurface();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/Rect.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library;
2 |
3 | import android.graphics.Color;
4 |
5 | import com.inuker.library.program.RectProgram;
6 |
7 | import static android.opengl.GLES20.GL_LINE_STRIP;
8 | import static android.opengl.GLES20.glDrawArrays;
9 |
10 | /**
11 | * Created by dingjikerbo on 17/6/23.
12 | */
13 |
14 | public class Rect extends Shape {
15 |
16 | private static final int POSITION_COUNT = 2;
17 | private static final int COLOR_COUNT = 4;
18 | private static final int STRIDE = (POSITION_COUNT + COLOR_COUNT) * 4;
19 | private static final int POINTS_COUNT = 5;
20 |
21 | public Rect(int x1, int y1, int x2, int y2, int color) {
22 | float x1s = transferX(x1);
23 | float y1s = transferY(y1);
24 | float x2s = transferX(x2);
25 | float y2s = transferY(y2);
26 |
27 | float r = Color.red(color) / 255f;
28 | float g = Color.green(color) / 255f;
29 | float b = Color.blue(color) / 255f;
30 | float a = Color.alpha(color) / 255f;
31 |
32 | float[] data = new float[] {
33 | x1s, y1s, r, g, b, a,
34 | x1s, y2s, r, g, b, a,
35 | x2s, y2s, r, g, b, a,
36 | x2s, y1s, r, g, b, a,
37 | x1s, y1s, r, g, b, a,
38 | };
39 |
40 | mVertexArray = new VertexArray(data);
41 | }
42 |
43 | @Override
44 | public void bindData(RectProgram program) {
45 | mVertexArray.setVertexAttribPointer(0, program.getPositionLocation(),
46 | POSITION_COUNT, STRIDE);
47 |
48 | mVertexArray.setVertexAttribPointer(POSITION_COUNT, program.getColorLocation(),
49 | COLOR_COUNT, STRIDE);
50 | }
51 |
52 | @Override
53 | public void draw() {
54 | glDrawArrays(GL_LINE_STRIP, 0, POINTS_COUNT);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/RuntimeCounter.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library;
2 |
3 | /**
4 | * Created by dingjikerbo on 17/8/22.
5 | */
6 |
7 | public class RuntimeCounter {
8 |
9 | private int mCount;
10 |
11 | public long mSum;
12 |
13 | private volatile long mStart;
14 |
15 | public void add(long time) {
16 | mCount++;
17 | mSum += time;
18 | }
19 |
20 | public int getAvg() {
21 | return mCount > 0 ? (int) (mSum / mCount) : 0;
22 | }
23 |
24 | public void clear() {
25 | mCount = 0;
26 | mSum = 0;
27 | }
28 |
29 | public void start() {
30 | mStart = System.currentTimeMillis();
31 | }
32 |
33 | public void end() {
34 | long now = System.currentTimeMillis();
35 | add(now - mStart);
36 | mStart = now;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/Shape.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library;
2 |
3 | import com.inuker.library.program.ShaderProgram;
4 |
5 | /**
6 | * Created by dingjikerbo on 17/6/23.
7 | */
8 |
9 | public abstract class Shape {
10 |
11 | VertexArray mVertexArray;
12 |
13 | float transferX(int x) {
14 | return 2.0f * x / BaseApplication.getScreenWidth() - 1;
15 | }
16 |
17 | float transferY(int y) {
18 | return -2.0f * y / BaseApplication.getScreenHeight() + 1;
19 | }
20 |
21 | float transferL(int l) {
22 | return 2f * l / BaseApplication.getScreenHeight();
23 | }
24 |
25 | public abstract void bindData(T program);
26 |
27 | public abstract void draw();
28 | }
29 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/VertexArray.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library;
2 |
3 | import java.nio.ByteBuffer;
4 | import java.nio.ByteOrder;
5 | import java.nio.FloatBuffer;
6 |
7 | import static android.opengl.GLES20.GL_FLOAT;
8 | import static android.opengl.GLES20.glEnableVertexAttribArray;
9 | import static android.opengl.GLES20.glVertexAttribPointer;
10 |
11 | /**
12 | * Created by dingjikerbo on 17/6/22.
13 | */
14 |
15 | public class VertexArray {
16 |
17 | private final FloatBuffer floatBuffer;
18 |
19 | public VertexArray(float[] vertexData) {
20 | floatBuffer = ByteBuffer
21 | .allocateDirect(vertexData.length * 4)
22 | .order(ByteOrder.nativeOrder())
23 | .asFloatBuffer()
24 | .put(vertexData);
25 | }
26 |
27 | public void setVertexAttribPointer(int dataOffset, int attributeLocation,
28 | int componentCount, int stride) {
29 | floatBuffer.position(dataOffset);
30 | glVertexAttribPointer(attributeLocation, componentCount, GL_FLOAT,
31 | false, stride, floatBuffer);
32 | glEnableVertexAttribArray(attributeLocation);
33 |
34 | floatBuffer.position(0);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/encoder/AndroidMuxer.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library.encoder;
2 |
3 | import android.media.MediaCodec;
4 | import android.media.MediaFormat;
5 | import android.media.MediaMuxer;
6 |
7 | import com.inuker.library.utils.LogUtils;
8 |
9 | import java.io.IOException;
10 | import java.nio.ByteBuffer;
11 |
12 | /**
13 | * Created by dingjikerbo on 17/8/1.
14 | */
15 |
16 | public class AndroidMuxer {
17 |
18 | private final int mExpectedNumTracks = 2;
19 |
20 | private MediaMuxer mMuxer;
21 |
22 | private volatile boolean mStarted;
23 |
24 | private volatile int mNumTracks;
25 | private volatile int mNumReleases;
26 |
27 | public AndroidMuxer(String outputPath) {
28 | try {
29 | mMuxer = new MediaMuxer(outputPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
30 | } catch (IOException e) {
31 | e.printStackTrace();
32 | }
33 | }
34 |
35 | public int addTrack(MediaFormat trackFormat) {
36 | if (mStarted) {
37 | throw new IllegalStateException();
38 | }
39 |
40 | synchronized (mMuxer) {
41 | int track = mMuxer.addTrack(trackFormat);
42 |
43 | if (++mNumTracks == mExpectedNumTracks) {
44 | mMuxer.start();
45 | mStarted = true;
46 | }
47 |
48 | LogUtils.v(String.format("addTrack mNumTracks = %d", mNumTracks));
49 |
50 | return track;
51 | }
52 | }
53 |
54 | public boolean isStarted() {
55 | return mStarted;
56 | }
57 |
58 | public void writeSampleData(int trackIndex, ByteBuffer encodedData, MediaCodec.BufferInfo bufferInfo) {
59 | synchronized (mMuxer) {
60 | mMuxer.writeSampleData(trackIndex, encodedData, bufferInfo);
61 | }
62 | }
63 |
64 | public boolean release() {
65 | LogUtils.v("release");
66 | synchronized (mMuxer) {
67 | if (++mNumReleases == mNumTracks) {
68 | LogUtils.v(String.format("Muxer release"));
69 | mMuxer.stop();
70 | mMuxer.release();
71 | return true;
72 | }
73 | }
74 | return false;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/encoder/MovieEncoder1.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library.encoder;
2 |
3 | import android.content.Context;
4 | import android.graphics.ImageFormat;
5 |
6 | import com.inuker.library.program.YUVProgram;
7 |
8 | import java.nio.ByteBuffer;
9 | import java.nio.ByteOrder;
10 |
11 | /**
12 | * Created by dingjikerbo on 2017/10/31.
13 | */
14 |
15 | public class MovieEncoder1 extends BaseMovieEncoder {
16 |
17 | private YUVProgram mYUVProgram;
18 | private ByteBuffer mYUVBuffer;
19 |
20 | public MovieEncoder1(Context context, int width, int height) {
21 | super(context, width, height);
22 | }
23 |
24 | @Override
25 | public void onPrepareEncoder() {
26 | mYUVProgram = new YUVProgram(mContext, mWidth, mHeight);
27 | mYUVBuffer = ByteBuffer.allocateDirect(mWidth * mHeight * ImageFormat.getBitsPerPixel(ImageFormat.NV21) / 8)
28 | .order(ByteOrder.nativeOrder());
29 | }
30 |
31 | @Override
32 | public void onFrameAvailable(Object object, long timestamp) {
33 | byte[] data = (byte[]) object;
34 |
35 | if (mYUVBuffer == null) {
36 | return;
37 | }
38 |
39 | synchronized (mYUVBuffer) {
40 | mYUVBuffer.position(0);
41 | mYUVBuffer.put(data);
42 | }
43 |
44 | mHandler.sendMessage(mHandler.obtainMessage(MSG_FRAME_AVAILABLE,
45 | (int) (timestamp >> 32), (int) timestamp));
46 | }
47 |
48 | @Override
49 | public void onFrameAvailable() {
50 | mYUVProgram.useProgram();
51 | mYUVProgram.draw(mYUVBuffer.array());
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/encoder/MovieEncoder2.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library.encoder;
2 |
3 | import android.content.Context;
4 |
5 | import com.inuker.library.program.TextureProgram;
6 |
7 | /**
8 | * Created by dingjikerbo on 2017/10/31.
9 | */
10 |
11 | public class MovieEncoder2 extends BaseMovieEncoder {
12 |
13 | private int mTexture;
14 |
15 | private TextureProgram mProgram;
16 |
17 | public MovieEncoder2(Context context, int width, int height) {
18 | super(context, width, height);
19 | }
20 |
21 | @Override
22 | public void onPrepareEncoder() {
23 | mProgram = new TextureProgram(mContext, mWidth, mHeight);
24 | }
25 |
26 | @Override
27 | public void onFrameAvailable(Object o, long timestamp) {
28 | mTexture = (int) o;
29 | mHandler.sendMessage(mHandler.obtainMessage(MSG_FRAME_AVAILABLE,
30 | (int) (timestamp >> 32), (int) timestamp));
31 | }
32 |
33 | @Override
34 | public void onFrameAvailable() {
35 | mProgram.draw(mTexture);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/program/RectProgram.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library.program;
2 |
3 | import android.content.Context;
4 |
5 | import com.inuker.library.R;
6 |
7 | import static android.opengl.GLES20.glUniformMatrix4fv;
8 |
9 | /**
10 | * Created by dingjikerbo on 2017/10/31.
11 | */
12 |
13 | public class RectProgram extends ShapeProgram {
14 |
15 | public RectProgram(Context context) {
16 | super(context, R.raw.rect_vertex, R.raw.rect_fragment);
17 | }
18 |
19 | public void setUniform() {
20 | glUniformMatrix4fv(uMatrixLocation, 1, false, mMatrix, 0);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/program/ShaderProgram.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library.program;
2 |
3 | import android.content.Context;
4 |
5 | import com.inuker.library.utils.ResourceUtils;
6 | import com.inuker.library.utils.ShaderHelper;
7 |
8 | import static android.opengl.GLES20.glDeleteProgram;
9 | import static android.opengl.GLES20.glUseProgram;
10 |
11 | /**
12 | * Created by dingjikerbo on 17/8/16.
13 | */
14 |
15 | public class ShaderProgram {
16 |
17 | protected int mProgram;
18 |
19 | protected int mWidth, mHeight;
20 |
21 | protected final Context mContext;
22 |
23 | protected ShaderProgram(Context context, int vertexId, int fragId) {
24 | this(context, vertexId, fragId, 0, 0);
25 | }
26 |
27 | protected ShaderProgram(Context context, int vertexId, int fragId, int width, int height) {
28 | mContext = context;
29 |
30 | mProgram = ShaderHelper.buildProgram(ResourceUtils.readText(context, vertexId),
31 | ResourceUtils.readText(context, fragId));
32 |
33 | mWidth = width;
34 | mHeight = height;
35 | }
36 |
37 | public void useProgram() {
38 | glUseProgram(mProgram);
39 | }
40 |
41 | public void release() {
42 | glDeleteProgram(mProgram);
43 | mProgram = -1;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/program/ShapeProgram.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library.program;
2 |
3 | import android.content.Context;
4 |
5 | import static android.opengl.GLES20.glGetAttribLocation;
6 | import static android.opengl.GLES20.glGetUniformLocation;
7 | import static android.opengl.Matrix.setIdentityM;
8 |
9 | /**
10 | * Created by dingjikerbo on 2017/10/31.
11 | */
12 |
13 | public class ShapeProgram extends ShaderProgram {
14 |
15 | private final int aPositionLocation;
16 |
17 | private final int aColorLocation;
18 |
19 | protected final int uMatrixLocation;
20 |
21 | protected float[] mMatrix = new float[16];
22 |
23 | protected ShapeProgram(Context context, int vertex, int fragment) {
24 | super(context, vertex, fragment);
25 |
26 | useProgram();
27 | aPositionLocation = glGetAttribLocation(mProgram, "a_Position");
28 | aColorLocation = glGetAttribLocation(mProgram, "a_Color");
29 | uMatrixLocation = glGetUniformLocation(mProgram, "u_Matrix");
30 |
31 | setIdentityM(mMatrix, 0);
32 | // scaleM(mMatrix, 0, -1, 1, 1);
33 | }
34 |
35 | public int getPositionLocation() {
36 | return aPositionLocation;
37 | }
38 |
39 | public int getColorLocation() {
40 | return aColorLocation;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/program/TextureProgram.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library.program;
2 |
3 | import android.content.Context;
4 |
5 | import com.inuker.library.R;
6 | import com.inuker.library.utils.GlUtil;
7 |
8 | import java.nio.FloatBuffer;
9 |
10 | import static android.opengl.GLES20.GL_FLOAT;
11 | import static android.opengl.GLES20.GL_TEXTURE0;
12 | import static android.opengl.GLES20.GL_TEXTURE_2D;
13 | import static android.opengl.GLES20.GL_TRIANGLE_STRIP;
14 | import static android.opengl.GLES20.glActiveTexture;
15 | import static android.opengl.GLES20.glBindTexture;
16 | import static android.opengl.GLES20.glDrawArrays;
17 | import static android.opengl.GLES20.glEnableVertexAttribArray;
18 | import static android.opengl.GLES20.glGetAttribLocation;
19 | import static android.opengl.GLES20.glGetUniformLocation;
20 | import static android.opengl.GLES20.glVertexAttribPointer;
21 |
22 | /**
23 | * Created by dingjikerbo on 17/8/16.
24 | */
25 |
26 | public class TextureProgram extends ShaderProgram {
27 |
28 | private static final float FULL_RECTANGLE_COORDS[] = {
29 | -1.0f, -1.0f, // 0 bottom left
30 | 1.0f, -1.0f, // 1 bottom right
31 | -1.0f, 1.0f, // 2 top left
32 | 1.0f, 1.0f, // 3 top right
33 | };
34 |
35 | private static final float FULL_RECTANGLE_TEX_COORDS[] = {
36 | 0.0f, 0.0f, // 0 bottom left
37 | 1.0f, 0.0f, // 1 bottom right
38 | 0.0f, 1.0f, // 2 top left
39 | 1.0f, 1.0f // 3 top right
40 | };
41 | private static final FloatBuffer FULL_RECTANGLE_BUF =
42 | GlUtil.createFloatBuffer(FULL_RECTANGLE_COORDS);
43 | private static final FloatBuffer FULL_RECTANGLE_TEX_BUF =
44 | GlUtil.createFloatBuffer(FULL_RECTANGLE_TEX_COORDS);
45 |
46 | protected final int mUniformTextureLocation;
47 |
48 | private final int aPositionLocation;
49 | private final int aTextureCoordinatesLocation;
50 |
51 | public TextureProgram(Context context, int vertexShader, int fragmentShader, int width, int height) {
52 | super(context, vertexShader, fragmentShader, width, height);
53 |
54 | mUniformTextureLocation = glGetUniformLocation(mProgram, "s_texture");
55 |
56 | aPositionLocation = glGetAttribLocation(mProgram, "a_Position");
57 | aTextureCoordinatesLocation = glGetAttribLocation(mProgram, "a_TextureCoordinates");
58 | }
59 |
60 |
61 | public TextureProgram(Context context, int width, int height) {
62 | this(context, R.raw.tex_vertex, R.raw.tex_fragment, width, height);
63 | }
64 |
65 | public void draw(int texture) {
66 | useProgram();
67 |
68 | glActiveTexture(GL_TEXTURE0);
69 | glBindTexture(GL_TEXTURE_2D, texture);
70 |
71 | glEnableVertexAttribArray(aPositionLocation);
72 | glVertexAttribPointer(aPositionLocation, 2, GL_FLOAT, false, 8, FULL_RECTANGLE_BUF);
73 |
74 | glEnableVertexAttribArray(aTextureCoordinatesLocation);
75 | glVertexAttribPointer(aTextureCoordinatesLocation, 2, GL_FLOAT, false, 8, FULL_RECTANGLE_TEX_BUF);
76 |
77 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/utils/LogUtils.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library.utils;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.PrintWriter;
6 | import java.io.StringWriter;
7 | import java.io.Writer;
8 |
9 | /**
10 | * Created by dingjikerbo on 17/8/16.
11 | */
12 |
13 | public class LogUtils {
14 |
15 | private static final String TAG = "bush";
16 |
17 | public static void v(String msg) {
18 | Log.v(TAG, msg);
19 | }
20 |
21 | public static void v(String tag, String msg) {
22 | Log.v(tag, msg);
23 | }
24 |
25 | public static void e(String msg) {
26 | Log.e(TAG, msg);
27 | }
28 |
29 | public static void e(String tag, String msg) {
30 | Log.e(tag, msg);
31 | }
32 |
33 | public static void w(String msg) {
34 | Log.w(TAG, msg);
35 | }
36 |
37 | public static void w(String tag, String msg) {
38 | Log.w(tag, msg);
39 | }
40 |
41 | public static void e(Throwable e) {
42 | String s = getThrowableString(e);
43 | e(s);
44 | }
45 |
46 | private static String getThrowableString(Throwable e) {
47 | Writer writer = new StringWriter();
48 | PrintWriter printWriter = new PrintWriter(writer);
49 |
50 | while (e != null) {
51 | e.printStackTrace(printWriter);
52 | e = e.getCause();
53 | }
54 |
55 | String text = writer.toString();
56 |
57 | printWriter.close();
58 |
59 | return text;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/utils/NativeUtils.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library.utils;
2 |
3 | /**
4 | * Created by dingjikerbo on 17/8/22.
5 | */
6 |
7 | public class NativeUtils {
8 |
9 | static {
10 | System.loadLibrary("camera");
11 | }
12 |
13 | public static native void glReadPixels(int x, int y, int width, int height, int format, int type);
14 | }
15 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/utils/ResourceUtils.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library.utils;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 |
6 | import java.io.BufferedReader;
7 | import java.io.IOException;
8 | import java.io.InputStream;
9 | import java.io.InputStreamReader;
10 |
11 | /**
12 | * Created by dingjikerbo on 17/6/22.
13 | */
14 |
15 | public class ResourceUtils {
16 |
17 | public static String readText(Context context,
18 | int resourceId) {
19 | StringBuilder body = new StringBuilder();
20 |
21 | try {
22 | InputStream inputStream = context.getResources()
23 | .openRawResource(resourceId);
24 | InputStreamReader inputStreamReader = new InputStreamReader(
25 | inputStream);
26 | BufferedReader bufferedReader = new BufferedReader(
27 | inputStreamReader);
28 |
29 | String nextLine;
30 |
31 | while ((nextLine = bufferedReader.readLine()) != null) {
32 | body.append(nextLine);
33 | body.append('\n');
34 | }
35 | } catch (IOException e) {
36 | throw new RuntimeException(
37 | "Could not open resource: " + resourceId, e);
38 | } catch (Resources.NotFoundException nfe) {
39 | throw new RuntimeException("Resource not found: "
40 | + resourceId, nfe);
41 | }
42 |
43 | return body.toString();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/library/src/main/java/com/inuker/library/utils/TaskUtils.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library.utils;
2 |
3 | import android.os.AsyncTask;
4 |
5 | import java.util.concurrent.Executor;
6 |
7 | /**
8 | * Created by dingjikerbo on 17/8/22.
9 | */
10 |
11 | public class TaskUtils {
12 |
13 | public static void execute(final Runnable runnable) {
14 | execute(AsyncTask.THREAD_POOL_EXECUTOR, runnable);
15 | }
16 |
17 | public static void execute(final Executor executor, final Runnable runnable) {
18 | new AsyncTask() {
19 |
20 | @Override
21 | protected Void doInBackground(Void... params) {
22 | runnable.run();
23 | return null;
24 | }
25 | }.executeOnExecutor(executor);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/library/src/main/jni/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.4.1)
2 |
3 | set(CMAKE_VERBOSE_MAKEFILE on)
4 |
5 | set(CMAKE_CXX_FLAGS -std=c++11)
6 |
7 |
8 | add_library(camera
9 | SHARED
10 | camera.cpp)
11 |
12 | target_link_libraries(camera log GLESv3)
--------------------------------------------------------------------------------
/library/src/main/jni/camera.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by dingjikerbo on 17/6/1.
3 | //
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | #include
10 |
11 | #define TAG "bush"
12 |
13 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
14 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
15 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
16 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
17 | #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__)
18 |
19 | void native_glReadPixels(JNIEnv *env, jobject clazz, jint x, jint y, jint width, jint height, jint format, jint type) {
20 | glReadPixels(x, y, width, height, format, type, 0);
21 | }
22 |
23 | static JNINativeMethod gMethods[] = {
24 | {"glReadPixels", "(IIIIII)V", (void *) native_glReadPixels},
25 | };
26 |
27 | static int registerNativeMethods(JNIEnv *env, const char *className,
28 | JNINativeMethod *gMethods, int numMethods) {
29 | jclass clazz;
30 | clazz = env->FindClass(className);
31 | if (clazz == NULL) {
32 | return JNI_FALSE;
33 | }
34 | if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {
35 | return JNI_FALSE;
36 | }
37 |
38 | return JNI_TRUE;
39 | }
40 |
41 | static int registerNatives(JNIEnv *env) {
42 | const char *kClassName = "com/inuker/library/utils/NativeUtils"; //指定要注册的类
43 | return registerNativeMethods(env, kClassName, gMethods,
44 | sizeof(gMethods) / sizeof(gMethods[0]));
45 | }
46 |
47 | jint JNI_OnLoad(JavaVM *vm, void *reserved) {
48 | JNIEnv *env = NULL;
49 | if (vm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK) {
50 | return JNI_ERR;
51 | }
52 |
53 | if (!registerNatives(env)) {
54 | return JNI_ERR;
55 | }
56 |
57 | return JNI_VERSION_1_6;
58 | }
--------------------------------------------------------------------------------
/library/src/main/res/raw/oes_fragment.glsl:
--------------------------------------------------------------------------------
1 | #extension GL_OES_EGL_image_external : require
2 |
3 | precision mediump float;
4 |
5 | varying vec2 vTextureCoord;
6 | uniform samplerExternalOES sTexture;
7 |
8 | void main() {
9 | gl_FragColor = texture2D(sTexture, vTextureCoord);
10 | }
--------------------------------------------------------------------------------
/library/src/main/res/raw/oes_vertex.glsl:
--------------------------------------------------------------------------------
1 | uniform mat4 uMVPMatrix;
2 | uniform mat4 uTexMatrix;
3 |
4 | attribute vec4 aPosition;
5 | attribute vec4 aTextureCoord;
6 |
7 | varying vec2 vTextureCoord;
8 |
9 | void main() {
10 | gl_Position = uMVPMatrix * aPosition;
11 | vTextureCoord = (uTexMatrix * aTextureCoord).xy;
12 | }
--------------------------------------------------------------------------------
/library/src/main/res/raw/rect_fragment.glsl:
--------------------------------------------------------------------------------
1 | precision mediump float;
2 |
3 | varying vec4 v_Color;
4 |
5 | void main() {
6 | gl_FragColor = v_Color;
7 | }
--------------------------------------------------------------------------------
/library/src/main/res/raw/rect_vertex.glsl:
--------------------------------------------------------------------------------
1 | attribute vec4 a_Position;
2 | attribute vec4 a_Color;
3 |
4 | varying vec4 v_Color;
5 |
6 | uniform mat4 u_Matrix;
7 |
8 | void main() {
9 | v_Color = a_Color;
10 | gl_Position = u_Matrix * a_Position;
11 | }
--------------------------------------------------------------------------------
/library/src/main/res/raw/tex_fragment.glsl:
--------------------------------------------------------------------------------
1 | precision mediump float;
2 |
3 | varying vec2 v_TextureCoordinates;
4 |
5 | uniform sampler2D s_texture;
6 |
7 | void main() {
8 | gl_FragColor = texture2D(s_texture, v_TextureCoordinates);
9 |
10 | // float r = texture2D(s_texture, v_TextureCoordinates).r;
11 | // float g = texture2D(s_texture, v_TextureCoordinates).g;
12 | // float b = texture2D(s_texture, v_TextureCoordinates).b;
13 | // gl_FragColor = vec4(1.0, g, b, 1.0);
14 | }
--------------------------------------------------------------------------------
/library/src/main/res/raw/tex_vertex.glsl:
--------------------------------------------------------------------------------
1 | attribute vec4 a_Position;
2 | attribute vec2 a_TextureCoordinates;
3 |
4 | varying vec2 v_TextureCoordinates;
5 |
6 | void main() {
7 | v_TextureCoordinates = a_TextureCoordinates;
8 | gl_Position = a_Position;
9 | }
--------------------------------------------------------------------------------
/library/src/main/res/raw/yuv_fragment.glsl:
--------------------------------------------------------------------------------
1 | precision mediump float;
2 |
3 | varying vec2 v_TextureCoordinates;
4 |
5 | uniform sampler2D y_texture;
6 | uniform sampler2D uv_texture;
7 |
8 | void main() {
9 | float r, g, b, y, u, v;
10 |
11 | y = texture2D(y_texture, v_TextureCoordinates).r;
12 | u = texture2D(uv_texture, v_TextureCoordinates).a - 0.5;
13 | v = texture2D(uv_texture, v_TextureCoordinates).r - 0.5;
14 |
15 | r = y + 1.13983 * v;
16 | g = y - 0.39465 * u - 0.58060 * v;
17 | b = y + 2.03211 * u;
18 |
19 | gl_FragColor = vec4(r, g, b, 1.0);
20 | }
--------------------------------------------------------------------------------
/library/src/main/res/raw/yuv_vertex.glsl:
--------------------------------------------------------------------------------
1 | attribute vec4 a_Position;
2 | attribute vec2 a_TextureCoordinates;
3 |
4 | uniform mat4 uMVPMatrix;
5 |
6 | varying vec2 v_TextureCoordinates;
7 |
8 | void main() {
9 | gl_Position = uMVPMatrix * a_Position;
10 | v_TextureCoordinates = a_TextureCoordinates;
11 | }
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | library
3 |
4 |
--------------------------------------------------------------------------------
/library/src/test/java/com/inuker/library/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.library;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/multisurfacepreview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/multisurfacepreview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "26.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.inuker.multiglsurfacepreview"
9 | minSdkVersion 18
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | ndk {
17 | abiFilters "armeabi-v7a"
18 | }
19 |
20 | }
21 | buildTypes {
22 | release {
23 | minifyEnabled false
24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
25 | }
26 | }
27 | }
28 |
29 | dependencies {
30 | compile fileTree(dir: 'libs', include: ['*.jar'])
31 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
32 | exclude group: 'com.android.support', module: 'support-annotations'
33 | })
34 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
35 | testCompile 'junit:junit:4.12'
36 | compile project(path: ':library')
37 | }
38 |
--------------------------------------------------------------------------------
/multisurfacepreview/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/dingjikerbo/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/multisurfacepreview/src/androidTest/java/com/inuker/multiglsurfacepreview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.multiglsurfacepreview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.assertEquals;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.inuker.multiglsurfacepreview", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/java/com/inuker/multisurfacepreview/Events.java:
--------------------------------------------------------------------------------
1 | package com.inuker.multisurfacepreview;
2 |
3 | /**
4 | * Created by dingjikerbo on 17/8/19.
5 | */
6 |
7 | public class Events {
8 |
9 | public static final int EVENTS_DRAW = 1;
10 | }
11 |
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/java/com/inuker/multisurfacepreview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.inuker.multisurfacepreview;
2 |
3 | import android.opengl.EGLContext;
4 | import android.os.Bundle;
5 | import android.widget.FrameLayout;
6 |
7 | import com.inuker.library.BaseActivity;
8 | import com.inuker.library.utils.LogUtils;
9 |
10 | /**
11 | * 两个SurfaceView共享EglContext,CameraSurfaceView将相机预览绘制到
12 | * Texture,MiniSurfaceView再将该Texture处理后绘制到Display Surface
13 | */
14 | public class MainActivity extends BaseActivity {
15 |
16 | private CameraSurfaceView mLeftSurfaceView;
17 | private MiniSurfaceView mRightSurfaceView;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 |
24 | final FrameLayout left = (FrameLayout) findViewById(R.id.left);
25 | final FrameLayout right = (FrameLayout) findViewById(R.id.right);
26 |
27 | mLeftSurfaceView = new CameraSurfaceView(this);
28 | left.addView(mLeftSurfaceView);
29 |
30 | mLeftSurfaceView.getEglContext(new CameraSurfaceView.SurfaceCallback() {
31 | @Override
32 | public void onCallback(Object object) {
33 | LogUtils.v("SurfaceCallback %s", object.toString());
34 |
35 | mRightSurfaceView = new MiniSurfaceView(mContext, (EGLContext) object);
36 | right.addView(mRightSurfaceView);
37 |
38 | mRightSurfaceView.setZOrderOnTop(true);
39 | }
40 | });
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/java/com/inuker/multisurfacepreview/MiniSurfaceView.java:
--------------------------------------------------------------------------------
1 | package com.inuker.multisurfacepreview;
2 |
3 | import android.content.Context;
4 | import android.opengl.EGLContext;
5 | import android.os.Handler;
6 | import android.os.Message;
7 | import android.view.SurfaceHolder;
8 |
9 | import com.inuker.library.BaseSurfaceView;
10 | import com.inuker.library.EglCore;
11 | import com.inuker.library.EventDispatcher;
12 | import com.inuker.library.EventListener;
13 | import com.inuker.library.WindowSurface;
14 | import com.inuker.library.program.TextureProgram;
15 | import com.inuker.library.utils.GlUtil;
16 | import com.inuker.library.utils.LogUtils;
17 |
18 | import static com.inuker.multisurfacepreview.Events.EVENTS_DRAW;
19 |
20 | /**
21 | * Created by dingjikerbo on 17/8/17.
22 | */
23 |
24 | public class MiniSurfaceView extends BaseSurfaceView implements Handler.Callback, EventListener {
25 |
26 | private EglCore mEglCore;
27 |
28 | private EGLContext mSharedEGLContext;
29 |
30 | private WindowSurface mWindowSurface;
31 |
32 | private TextureProgram mTextureProgram;
33 |
34 | public MiniSurfaceView(Context context, EGLContext sharedContext) {
35 | super(context);
36 | mSharedEGLContext = sharedContext;
37 | LogUtils.v(String.format("Mini %s", sharedContext));
38 | }
39 |
40 | @Override
41 | public void onSurfaceCreated(SurfaceHolder holder) {
42 | mEglCore = new EglCore(mSharedEGLContext, EglCore.FLAG_TRY_GLES3);
43 |
44 | mWindowSurface = new WindowSurface(mEglCore, holder.getSurface(), false);
45 | mWindowSurface.makeCurrent();
46 |
47 | GlUtil.checkGlError("surfaceCreated");
48 |
49 | EventDispatcher.observe(EVENTS_DRAW, this);
50 | }
51 |
52 | @Override
53 | public void onSurfaceChanged(int width, int height) {
54 | mTextureProgram = new TextureProgram(getContext(), R.raw.tex_vertex, R.raw.filter_tex_fragment, width, height);
55 | GlUtil.checkGlError("surfaceChanged");
56 | }
57 |
58 | @Override
59 | public void onSurfaceDestroyed() {
60 | EventDispatcher.unObserve(EVENTS_DRAW, this);
61 |
62 | mTextureProgram.release();
63 | mWindowSurface.release();
64 | mEglCore.makeNothingCurrent();
65 | mEglCore.release();
66 | }
67 |
68 | private void onDrawFrame(int offscreenTexture) {
69 | // LogUtils.v(String.format("%s onDrawFrame %d", getClass().getSimpleName(), offscreenTexture));
70 | mTextureProgram.draw(offscreenTexture);
71 | mWindowSurface.swapBuffers();
72 |
73 | GlUtil.checkGlError("onDrawFrame");
74 | }
75 |
76 | @Override
77 | public void onEvent(int event, Object object) {
78 | if (mRenderHandler != null) {
79 | mRenderHandler.obtainMessage(2, object).sendToTarget();
80 | }
81 | }
82 |
83 | @Override
84 | public boolean handleMessage(Message msg) {
85 | switch (msg.what) {
86 | case 2:
87 | onDrawFrame((Integer) msg.obj);
88 | break;
89 | }
90 | return super.handleMessage(msg);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/multisurfacepreview/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/multisurfacepreview/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/multisurfacepreview/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/multisurfacepreview/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/multisurfacepreview/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/multisurfacepreview/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/multisurfacepreview/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/multisurfacepreview/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/multisurfacepreview/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/multisurfacepreview/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/raw/filter_tex_fragment.glsl:
--------------------------------------------------------------------------------
1 | precision mediump float;
2 |
3 | varying vec2 v_TextureCoordinates;
4 |
5 | uniform sampler2D s_texture;
6 |
7 | void main() {
8 | float r = texture2D(s_texture, v_TextureCoordinates).r;
9 | float g = texture2D(s_texture, v_TextureCoordinates).g;
10 | float b = texture2D(s_texture, v_TextureCoordinates).b;
11 | gl_FragColor = vec4(1.0, g, b, 1.0);
12 | }
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MultiGLSurfacePreview
3 |
4 |
--------------------------------------------------------------------------------
/multisurfacepreview/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/multisurfacepreview/src/test/java/com/inuker/multiglsurfacepreview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.multiglsurfacepreview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/recorder1/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/recorder1/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "26.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.inuker.recorder1"
9 | minSdkVersion 18
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
28 | exclude group: 'com.android.support', module: 'support-annotations'
29 | })
30 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
31 | testCompile 'junit:junit:4.12'
32 | compile project(path: ':library')
33 | }
34 |
--------------------------------------------------------------------------------
/recorder1/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/dingjikerbo/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/recorder1/src/androidTest/java/com/inuker/recorder1/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.recorder1;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.assertEquals;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.inuker.recorder1", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/recorder1/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/recorder1/src/main/java/com/inuker/recorder1/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.inuker.recorder1;
2 |
3 | import android.opengl.GLSurfaceView;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.FrameLayout;
8 |
9 | import com.inuker.library.BaseActivity;
10 |
11 | public class MainActivity extends BaseActivity implements View.OnClickListener {
12 |
13 | private FrameLayout mSurfaceContainer;
14 | private GLSurfaceView mGLSurfaceView;
15 | private Button mBtn;
16 |
17 | private CameraSurfaceRender mRender;
18 |
19 | private boolean mRecording;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 |
26 | mSurfaceContainer = (FrameLayout) findViewById(R.id.surface);
27 | mBtn = (Button) findViewById(R.id.btn);
28 |
29 | mBtn.setOnClickListener(this);
30 |
31 | mGLSurfaceView = new GLSurfaceView(this);
32 | mGLSurfaceView.setEGLContextClientVersion(3);
33 | mRender = new CameraSurfaceRender(mGLSurfaceView);
34 | mGLSurfaceView.setRenderer(mRender);
35 | mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
36 | }
37 |
38 | @Override
39 | protected void onPause() {
40 | mSurfaceContainer.removeAllViews();
41 | super.onPause();
42 | }
43 |
44 | @Override
45 | protected void onResume() {
46 | super.onResume();
47 | mSurfaceContainer.addView(mGLSurfaceView);
48 | }
49 |
50 | @Override
51 | public void onClick(View v) {
52 | if (mRecording) {
53 | mRecording = false;
54 | mBtn.setText("start");
55 | mRender.stopRecording();
56 | } else {
57 | mRecording = true;
58 | mRender.startRecording();
59 | mBtn.setText("stop");
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/recorder1/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/recorder1/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder1/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/recorder1/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder1/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/recorder1/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder1/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/recorder1/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder1/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/recorder1/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder1/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/recorder1/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder1/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/recorder1/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder1/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/recorder1/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder1/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/recorder1/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder1/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/recorder1/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder1/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/recorder1/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/recorder1/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | recorder1
3 |
4 |
--------------------------------------------------------------------------------
/recorder1/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/recorder1/src/test/java/com/inuker/recorder1/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.recorder1;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/recorder2/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/recorder2/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "26.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.inuker.recorder2"
9 | minSdkVersion 18
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
28 | exclude group: 'com.android.support', module: 'support-annotations'
29 | })
30 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
31 | testCompile 'junit:junit:4.12'
32 | compile project(path: ':library')
33 | }
34 |
--------------------------------------------------------------------------------
/recorder2/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/dingjikerbo/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/recorder2/src/androidTest/java/com/inuker/recorder2/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.recorder2;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.assertEquals;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.inuker.recorder2", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/recorder2/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/recorder2/src/main/java/com/inuker/recorder2/FaceRender.java:
--------------------------------------------------------------------------------
1 | package com.inuker.recorder2;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 |
6 | import com.inuker.library.Face;
7 | import com.inuker.library.program.RectProgram;
8 |
9 | /**
10 | * Created by dingjikerbo on 2017/10/31.
11 | */
12 |
13 | public class FaceRender {
14 |
15 | private static final int WIDTH = 200;
16 | private static final int HEIGHT = 200;
17 | private static final int XSTEP = 10;
18 | private static final int YSTEP = 10;
19 |
20 | private RectProgram mProgram;
21 |
22 | private int mX, mY;
23 |
24 | private boolean mXDirect = true, mYDirect = true;
25 |
26 | public FaceRender(Context context) {
27 | mProgram = new RectProgram(context);
28 | }
29 |
30 | public void draw() {
31 | mProgram.useProgram();
32 | mProgram.setUniform();
33 |
34 | Face face = new Face(mX, mY, mX + WIDTH, mY + HEIGHT, Color.RED);
35 |
36 | face.bindData(mProgram);
37 | face.draw();
38 |
39 | updateNext();
40 | }
41 |
42 | private void updateNext() {
43 | if (mXDirect) {
44 | mX += XSTEP;
45 | if (mX + WIDTH > MyApplication.getScreenWidth()) {
46 | mX = MyApplication.getScreenWidth() - WIDTH;
47 | mXDirect = false;
48 | }
49 | } else {
50 | mX -= XSTEP;
51 | if (mX < 0) {
52 | mX = 0;
53 | mXDirect = true;
54 | }
55 | }
56 | if (mYDirect) {
57 | mY += YSTEP;
58 | if (mY + HEIGHT > MyApplication.getScreenHeight()) {
59 | mY = MyApplication.getScreenHeight() - HEIGHT;
60 | mYDirect = false;
61 | }
62 | } else {
63 | mY -= YSTEP;
64 | if (mY < 0) {
65 | mY = 0;
66 | mYDirect = true;
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/recorder2/src/main/java/com/inuker/recorder2/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.inuker.recorder2;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.FrameLayout;
8 |
9 | public class MainActivity extends Activity implements View.OnClickListener {
10 |
11 | private CameraSurfaceView mSurfaceView;
12 |
13 | private FrameLayout mSurfaceContainer;
14 | private Button mBtn;
15 |
16 | private boolean mRecording;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 |
23 | mSurfaceContainer = (FrameLayout) findViewById(R.id.surface);
24 | mBtn = (Button) findViewById(R.id.btn);
25 | mBtn.setOnClickListener(this);
26 |
27 | mSurfaceView = new CameraSurfaceView(this);
28 | }
29 |
30 | @Override
31 | protected void onPause() {
32 | mSurfaceContainer.removeAllViews();
33 | super.onPause();
34 | }
35 |
36 | @Override
37 | protected void onResume() {
38 | super.onResume();
39 | mSurfaceContainer.addView(mSurfaceView);
40 | }
41 |
42 | @Override
43 | public void onClick(View v) {
44 | if (mRecording) {
45 | mRecording = false;
46 | mSurfaceView.stopRecording();
47 | mBtn.setText("start");
48 | } else {
49 | mRecording = true;
50 | mSurfaceView.startRecording();
51 | mBtn.setText("stop");
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/recorder2/src/main/java/com/inuker/recorder2/MyApplication.java:
--------------------------------------------------------------------------------
1 | package com.inuker.recorder2;
2 |
3 | import com.inuker.library.BaseApplication;
4 |
5 | /**
6 | * Created by dingjikerbo on 2017/10/31.
7 | */
8 |
9 | public class MyApplication extends BaseApplication {
10 |
11 | @Override
12 | public void onCreate() {
13 | super.onCreate();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/recorder2/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/recorder2/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder2/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/recorder2/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder2/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/recorder2/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder2/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/recorder2/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder2/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/recorder2/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder2/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/recorder2/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder2/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/recorder2/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder2/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/recorder2/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder2/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/recorder2/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder2/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/recorder2/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/recorder2/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/recorder2/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/recorder2/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | recorder2
3 |
4 |
--------------------------------------------------------------------------------
/recorder2/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/recorder2/src/test/java/com/inuker/recorder2/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.recorder2;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/rgbconverter/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/rgbconverter/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "26.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.inuker.rgbconverter1"
9 | minSdkVersion 18
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | ndk {
17 | abiFilters "armeabi-v7a"
18 | }
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | }
27 |
28 | dependencies {
29 | compile fileTree(dir: 'libs', include: ['*.jar'])
30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
31 | exclude group: 'com.android.support', module: 'support-annotations'
32 | })
33 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
34 | testCompile 'junit:junit:4.12'
35 | compile project(path: ':library')
36 | }
37 |
--------------------------------------------------------------------------------
/rgbconverter/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/dingjikerbo/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/rgbconverter/src/androidTest/java/com/inuker/rgbconverter1/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter1;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.assertEquals;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.inuker.rgbconverter1", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/java/com/inuker/rgbconverter/Events.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter;
2 |
3 | /**
4 | * Created by dingjikerbo on 17/8/21.
5 | */
6 |
7 | public class Events {
8 |
9 | public static final int BITMAP_AVAILABLE = 1;
10 |
11 | public static final int FPS_AVAILABLE = 2;
12 | }
13 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/java/com/inuker/rgbconverter/IRgbConverter.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter;
2 |
3 | /**
4 | * Created by dingjikerbo on 17/8/22.
5 | */
6 |
7 | public interface IRgbConverter {
8 |
9 | void start();
10 |
11 | void destroy();
12 |
13 | void frameDrawed();
14 |
15 | void frameAvailable(byte[] bytes);
16 | }
17 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/java/com/inuker/rgbconverter/ISurfaceContainer.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter;
2 |
3 | import android.content.Context;
4 | import android.view.ViewGroup;
5 |
6 | /**
7 | * Created by dingjikerbo on 17/8/22.
8 | */
9 |
10 | public interface ISurfaceContainer {
11 |
12 | Context getContext();
13 |
14 | ViewGroup getFullSurfaceContainer();
15 |
16 | ViewGroup getMiniSurfaceContainer();
17 |
18 | RgbConverter getRgbConverter();
19 | }
20 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/java/com/inuker/rgbconverter/LaunchActivity.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.Button;
8 |
9 | import com.inuker.library.BaseActivity;
10 |
11 | /**
12 | * Created by dingjikerbo on 17/8/22.
13 | */
14 |
15 | public class LaunchActivity extends BaseActivity {
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.launch_activity);
21 |
22 | ViewGroup container = (ViewGroup) findViewById(R.id.container);
23 |
24 | String[] converterTips = getResources().getStringArray(R.array.converters);
25 | for (int i = 0; i < converterTips.length; i++) {
26 | Button btn = new Button(this);
27 | btn.setText(converterTips[i]);
28 | btn.setOnClickListener(new ClickListener(i));
29 | container.addView(btn);
30 | }
31 | }
32 |
33 | private class ClickListener implements View.OnClickListener {
34 |
35 | int idx;
36 |
37 | ClickListener(int idx) {
38 | this.idx = idx;
39 | }
40 |
41 | @Override
42 | public void onClick(View v) {
43 | Intent intent = new Intent(mContext, MainActivity.class);
44 | intent.putExtra("index", idx + 1);
45 | startActivity(intent);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/java/com/inuker/rgbconverter/RgbConverter.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.ImageFormat;
6 | import android.opengl.GLES30;
7 |
8 | import com.inuker.library.BaseApplication;
9 | import com.inuker.library.EventDispatcher;
10 | import com.inuker.library.RuntimeCounter;
11 | import com.inuker.library.utils.GlUtil;
12 | import com.inuker.library.utils.LogUtils;
13 |
14 | import java.nio.ByteBuffer;
15 | import java.nio.ByteOrder;
16 |
17 | /**
18 | * Created by dingjikerbo on 17/8/21.
19 | */
20 |
21 | public abstract class RgbConverter implements IRgbConverter {
22 |
23 | final String TAG = getClass().getSimpleName();
24 |
25 | protected ByteBuffer mYUVBuffer;
26 |
27 | protected ByteBuffer mPixelBuffer;
28 |
29 | protected Context mContext;
30 |
31 | protected int mWidth, mHeight;
32 |
33 | protected RuntimeCounter mRuntimeCounter;
34 |
35 | public RgbConverter(Context context) {
36 | mContext = context;
37 |
38 | mWidth = BaseApplication.getScreenWidth();
39 | mHeight = BaseApplication.getScreenHeight();
40 |
41 | mYUVBuffer = ByteBuffer.allocateDirect(mWidth * mHeight * ImageFormat.getBitsPerPixel(ImageFormat.NV21) / 8)
42 | .order(ByteOrder.nativeOrder());
43 |
44 | mPixelBuffer = ByteBuffer.allocate(mWidth * mHeight * 4);
45 |
46 | mRuntimeCounter = new RuntimeCounter();
47 | }
48 |
49 | @Override
50 | public final void start() {
51 | onStart();
52 | GlUtil.checkGlError(String.format("%s start", TAG));
53 | }
54 |
55 | @Override
56 | public final void destroy() {
57 | onDestroy();
58 | mYUVBuffer = null;
59 | mPixelBuffer = null;
60 | System.gc();
61 | }
62 |
63 | @Override
64 | public final void frameDrawed() {
65 | onDrawFrame();
66 | }
67 |
68 | @Override
69 | public final void frameAvailable(byte[] bytes) {
70 | synchronized (mYUVBuffer) {
71 | mYUVBuffer.position(0);
72 | mYUVBuffer.put(bytes);
73 | }
74 | }
75 |
76 | void readPixels() {
77 | if (mPixelBuffer == null) {
78 | return;
79 | }
80 | long start = System.currentTimeMillis();
81 | mPixelBuffer.position(0);
82 | GLES30.glReadPixels(0, 0, mWidth, mHeight, GLES30.GL_RGBA, GLES30.GL_UNSIGNED_BYTE, mPixelBuffer);
83 | mRuntimeCounter.add(System.currentTimeMillis() - start);
84 | LogUtils.v(String.format("%s glReadPixels(W/H=%d/%d) takes %dms", TAG, mWidth, mHeight, System.currentTimeMillis() - start));
85 | EventDispatcher.dispatch(Events.FPS_AVAILABLE, mRuntimeCounter.getAvg());
86 | }
87 |
88 | void pixelsToBitmap() {
89 | pixelsToBitmap(mPixelBuffer);
90 | }
91 |
92 | void pixelsToBitmap(ByteBuffer pixelBuffer) {
93 | if (pixelBuffer == null) {
94 | return;
95 | }
96 |
97 | final Bitmap bmp = Bitmap.createBitmap(mHeight, mWidth, Bitmap.Config.ARGB_8888);
98 |
99 | pixelBuffer.rewind();
100 | bmp.copyPixelsFromBuffer(pixelBuffer);
101 |
102 | EventDispatcher.dispatch(Events.BITMAP_AVAILABLE, bmp);
103 | }
104 |
105 | abstract void onStart();
106 |
107 | abstract void onDrawFrame();
108 |
109 | abstract void onDestroy();
110 | }
111 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/java/com/inuker/rgbconverter/RgbConverter1.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * Created by dingjikerbo on 17/8/21.
7 | */
8 |
9 | public class RgbConverter1 extends RgbConverter {
10 |
11 | public RgbConverter1(Context context) {
12 | super(context);
13 | }
14 |
15 | @Override
16 | void onStart() {
17 |
18 | }
19 |
20 | @Override
21 | void onDrawFrame() {
22 | readPixels();
23 | pixelsToBitmap();
24 | }
25 |
26 | @Override
27 | void onDestroy() {
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/java/com/inuker/rgbconverter/RgbConverter2.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter;
2 |
3 | import android.content.Context;
4 |
5 | import com.inuker.library.program.YUVProgram;
6 |
7 | /**
8 | * Created by dingjikerbo on 17/8/21.
9 | */
10 |
11 | public class RgbConverter2 extends SingleRgbConverter {
12 |
13 | private YUVProgram mYUVProgram;
14 |
15 | public RgbConverter2(Context context) {
16 | super(context);
17 | }
18 |
19 | @Override
20 | void onSurfaceCreated() {
21 | super.onSurfaceCreated();
22 |
23 | mYUVProgram = new YUVProgram(mContext, mWidth, mHeight);
24 | }
25 |
26 | @Override
27 | void onSurfaceDestroy() {
28 | mYUVProgram.release();
29 | super.onSurfaceDestroy();
30 | }
31 |
32 | @Override
33 | void onDrawSurface() {
34 | super.onDrawSurface();
35 |
36 | synchronized (mYUVBuffer) {
37 | mYUVProgram.useProgram();
38 | mYUVProgram.draw(mYUVBuffer.array());
39 | }
40 |
41 | readPixels();
42 | pixelsToBitmap();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/java/com/inuker/rgbconverter/RgbConverter3.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter;
2 |
3 | import android.content.Context;
4 | import android.opengl.GLES30;
5 |
6 | import com.inuker.library.program.YUVProgram;
7 | import com.inuker.library.utils.GlUtil;
8 |
9 | /**
10 | * Created by dingjikerbo on 17/8/22.
11 | */
12 |
13 | public class RgbConverter3 extends SingleRgbConverter {
14 |
15 | private int mFrameBuffer;
16 |
17 | private int mOffscreenTexture;
18 |
19 | private YUVProgram mYUVProgram;
20 |
21 | public RgbConverter3(Context context) {
22 | super(context);
23 | }
24 |
25 | @Override
26 | void onSurfaceCreated() {
27 | super.onSurfaceCreated();
28 | mYUVProgram = new YUVProgram(mContext, mWidth, mHeight);
29 | prepareFramebuffer();
30 | }
31 |
32 | private void prepareFramebuffer() {
33 | int[] values = new int[1];
34 |
35 | // Create a texture object and bind it. This will be the color buffer.
36 | GLES30.glGenTextures(1, values, 0);
37 | mOffscreenTexture = values[0]; // expected > 0
38 | GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mOffscreenTexture);
39 |
40 | // Create texture storage.
41 | GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_RGBA, mWidth, mHeight, 0,
42 | GLES30.GL_RGBA, GLES30.GL_UNSIGNED_BYTE, null);
43 |
44 | // Set parameters. We're probably using non-power-of-two dimensions, so
45 | // some values may not be available for use.
46 | GLES30.glTexParameterf(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER,
47 | GLES30.GL_NEAREST);
48 | GLES30.glTexParameterf(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER,
49 | GLES30.GL_LINEAR);
50 | GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S,
51 | GLES30.GL_CLAMP_TO_EDGE);
52 | GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T,
53 | GLES30.GL_CLAMP_TO_EDGE);
54 |
55 | // Create framebuffer object and bind it.
56 | GLES30.glGenFramebuffers(1, values, 0);
57 | mFrameBuffer = values[0]; // expected > 0
58 | GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFrameBuffer);
59 |
60 | GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0,
61 | GLES30.GL_TEXTURE_2D, mOffscreenTexture, 0);
62 |
63 | // See if GLES is happy with all this.
64 | int status = GLES30.glCheckFramebufferStatus(GLES30.GL_FRAMEBUFFER);
65 | if (status != GLES30.GL_FRAMEBUFFER_COMPLETE) {
66 | throw new RuntimeException("Framebuffer not complete, status=" + status);
67 | }
68 |
69 | GlUtil.checkGlError("prepareFramebuffer done");
70 | }
71 |
72 | @Override
73 | void onDrawSurface() {
74 | super.onDrawSurface();
75 |
76 | synchronized (mYUVBuffer) {
77 | mYUVProgram.useProgram();
78 | mYUVProgram.draw(mYUVBuffer.array());
79 | }
80 |
81 | readPixels();
82 | pixelsToBitmap();
83 | }
84 |
85 | @Override
86 | void onSurfaceDestroy() {
87 | mYUVProgram.release();
88 | GLES30.glDeleteFramebuffers(1, new int[] {mFrameBuffer}, 0);
89 | GLES30.glDeleteTextures(1, new int[] {mOffscreenTexture}, 0);
90 | super.onSurfaceDestroy();
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/java/com/inuker/rgbconverter/RgbConverter5.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter;
2 |
3 | import android.content.Context;
4 | import android.opengl.GLES30;
5 |
6 | import com.inuker.library.EventDispatcher;
7 | import com.inuker.library.program.YUVProgram;
8 | import com.inuker.library.utils.GlUtil;
9 | import com.inuker.library.utils.LogUtils;
10 | import com.inuker.library.utils.NativeUtils;
11 |
12 | import java.nio.ByteBuffer;
13 |
14 | /**
15 | * Created by dingjikerbo on 17/8/22.
16 | */
17 |
18 | public class RgbConverter5 extends SingleRgbConverter {
19 |
20 | private YUVProgram mYUVProgram;
21 |
22 | private int mPBO;
23 |
24 | public RgbConverter5(Context context) {
25 | super(context);
26 | }
27 |
28 | private void preparePBOBuffer() {
29 | int[] values = new int[1];
30 | GLES30.glGenBuffers(1, values, 0);
31 | mPBO = values[0];
32 |
33 | GLES30.glBindBuffer(GLES30.GL_PIXEL_PACK_BUFFER, mPBO);
34 | GLES30.glBufferData(GLES30.GL_PIXEL_PACK_BUFFER, mWidth * mHeight * 4, null, GLES30.GL_STREAM_READ);
35 | }
36 |
37 | @Override
38 | void readPixels() {
39 | long start1 = System.currentTimeMillis();
40 |
41 | NativeUtils.glReadPixels(0, 0, mWidth, mHeight, GLES30.GL_RGBA, GLES30.GL_UNSIGNED_BYTE);
42 | GlUtil.checkGlError("glReadPixels");
43 |
44 | LogUtils.v(String.format("glReadPixels takes %dms", System.currentTimeMillis() - start1));
45 |
46 | long start2 = System.currentTimeMillis();
47 | final ByteBuffer pixelBuffer = (ByteBuffer) GLES30.glMapBufferRange(GLES30.GL_PIXEL_PACK_BUFFER, 0, mWidth * mHeight * 4, GLES30.GL_MAP_READ_BIT);
48 | LogUtils.v(String.format("glMapBuffer takes %dms", System.currentTimeMillis() - start2));
49 |
50 | mRuntimeCounter.add(System.currentTimeMillis() - start1);
51 |
52 | pixelsToBitmap(pixelBuffer);
53 |
54 | GlUtil.checkGlError("glMapBufferRange");
55 |
56 | LogUtils.v(String.format("%s readPixels takes %dms", TAG, System.currentTimeMillis() - start1));
57 | EventDispatcher.dispatch(Events.FPS_AVAILABLE, mRuntimeCounter.getAvg());
58 | }
59 |
60 | @Override
61 | void onSurfaceCreated() {
62 | super.onSurfaceCreated();
63 |
64 | mYUVProgram = new YUVProgram(mContext, mWidth, mHeight);
65 | preparePBOBuffer();
66 | }
67 |
68 | @Override
69 | void onDrawSurface() {
70 | super.onDrawSurface();
71 |
72 | synchronized (mYUVBuffer) {
73 | mYUVProgram.useProgram();
74 | mYUVProgram.draw(mYUVBuffer.array());
75 | }
76 |
77 | readPixels();
78 |
79 | GLES30.glUnmapBuffer(GLES30.GL_PIXEL_PACK_BUFFER);
80 | }
81 |
82 | @Override
83 | void onSurfaceDestroy() {
84 | mYUVProgram.release();
85 | GLES30.glDeleteBuffers(1, new int[] {mPBO}, 0);
86 | GlUtil.checkGlError("glDestroy");
87 |
88 | super.onSurfaceDestroy();
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/java/com/inuker/rgbconverter/SingleRgbConverter.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.os.HandlerThread;
6 | import android.os.Message;
7 |
8 | import com.inuker.library.EglCore;
9 | import com.inuker.library.OffscreenSurface;
10 | import com.inuker.library.utils.LogUtils;
11 |
12 | /**
13 | * Created by dingjikerbo on 17/8/22.
14 | */
15 |
16 | public class SingleRgbConverter extends RgbConverter implements Handler.Callback {
17 |
18 | private static final int MSG_SURFACE_CREATE = 1;
19 | private static final int MSG_DRAW_FRAME = 2;
20 | private static final int MSG_SURFACE_DESTROY = 3;
21 |
22 | private HandlerThread mRenderThread;
23 | private Handler mRenderHandler;
24 |
25 | protected EglCore mEglCore;
26 | protected OffscreenSurface mOffscreenSurface;
27 |
28 | public SingleRgbConverter(Context context) {
29 | super(context);
30 | }
31 |
32 | @Override
33 | void onStart() {
34 | mRenderThread = new HandlerThread(TAG);
35 | mRenderThread.start();
36 | mRenderHandler = new Handler(mRenderThread.getLooper(), this);
37 | mRenderHandler.sendEmptyMessage(MSG_SURFACE_CREATE);
38 | }
39 |
40 | @Override
41 | void onDrawFrame() {
42 | if (mRenderHandler != null) {
43 | mRenderHandler.removeMessages(MSG_DRAW_FRAME);
44 | mRenderHandler.sendEmptyMessage(MSG_DRAW_FRAME);
45 | }
46 | }
47 |
48 | @Override
49 | void onDestroy() {
50 | if (mRenderHandler != null) {
51 | mRenderHandler.sendEmptyMessage(MSG_SURFACE_DESTROY);
52 | }
53 | }
54 |
55 | @Override
56 | public boolean handleMessage(Message msg) {
57 | switch (msg.what) {
58 | case MSG_SURFACE_CREATE:
59 | onSurfaceCreated();
60 | break;
61 |
62 | case MSG_DRAW_FRAME:
63 | if (mYUVBuffer != null) {
64 | onDrawSurface();
65 | }
66 | break;
67 | case MSG_SURFACE_DESTROY:
68 | onSurfaceDestroy();
69 | break;
70 | }
71 | return false;
72 | }
73 |
74 | void onSurfaceCreated() {
75 | LogUtils.v(String.format("%s onSurfaceCreated", TAG));
76 | mEglCore = new EglCore(null, EglCore.FLAG_TRY_GLES3);
77 | mOffscreenSurface = new OffscreenSurface(mEglCore, mWidth, mHeight);
78 | mOffscreenSurface.makeCurrent();
79 | }
80 |
81 | void onDrawSurface() {
82 | LogUtils.v(String.format("%s onDrawSurface", TAG));
83 | }
84 |
85 | void onSurfaceDestroy() {
86 | LogUtils.v(String.format("%s onSurfaceDestroy", TAG));
87 |
88 | mRenderThread.quit();
89 | mRenderThread = null;
90 | mRenderHandler = null;
91 |
92 | mOffscreenSurface.release();
93 | mEglCore.makeNothingCurrent();
94 | mEglCore.release();
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
18 |
19 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/layout/launch_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/rgbconverter/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/rgbconverter/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/rgbconverter/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/rgbconverter/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/rgbconverter/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/rgbconverter/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/rgbconverter/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/rgbconverter/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/rgbconverter/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/rgbconverter/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RGBConverter1
3 |
4 |
5 |
6 | - readPixels directly from Display Surface
7 | - readPixels from PBuffer
8 | - readPixels from FBO
9 | - readPixels from FBO + PBO
10 | - readPixels from PBO
11 |
12 |
13 |
--------------------------------------------------------------------------------
/rgbconverter/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rgbconverter/src/test/java/com/inuker/rgbconverter1/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.rgbconverter1;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library', ':glsurfacepreview', ':surfacepreview', ':glsurfacepreview2', ':surfacepreview2', ':multisurfacepreview', ':rgbconverter', ':recorder1', ':recorder2', ':glsurfacepreview3'
2 |
--------------------------------------------------------------------------------
/surfacepreview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/surfacepreview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "26.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.inuker.surfaceviewpreview"
9 | minSdkVersion 18
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | ndk {
17 | abiFilters "armeabi-v7a"
18 | }
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | }
27 |
28 | dependencies {
29 | compile fileTree(dir: 'libs', include: ['*.jar'])
30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
31 | exclude group: 'com.android.support', module: 'support-annotations'
32 | })
33 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
34 | testCompile 'junit:junit:4.12'
35 | compile project(path: ':library')
36 | }
37 |
--------------------------------------------------------------------------------
/surfacepreview/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/dingjikerbo/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/surfacepreview/src/androidTest/java/com/inuker/surfaceviewpreview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.surfaceviewpreview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.assertEquals;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.inuker.surfaceviewpreview", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/surfacepreview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/surfacepreview/src/main/java/com/inuker/surfacepreview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.inuker.surfacepreview;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 |
6 | public class MainActivity extends Activity {
7 |
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 |
12 | CameraSurfaceView surfaceView = new CameraSurfaceView(this);
13 | setContentView(surfaceView);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SurfaceViewPreview
3 |
4 |
--------------------------------------------------------------------------------
/surfacepreview/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/surfacepreview/src/test/java/com/inuker/surfaceviewpreview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.surfaceviewpreview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/surfacepreview2/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/surfacepreview2/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview2/README.md
--------------------------------------------------------------------------------
/surfacepreview2/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "26.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.inuker.glsurfacepreview3"
9 | minSdkVersion 18
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | ndk {
17 | abiFilters "armeabi-v7a"
18 | }
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | }
27 |
28 | dependencies {
29 | compile fileTree(dir: 'libs', include: ['*.jar'])
30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
31 | exclude group: 'com.android.support', module: 'support-annotations'
32 | })
33 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
34 | testCompile 'junit:junit:4.12'
35 | compile project(path: ':library')
36 | }
37 |
--------------------------------------------------------------------------------
/surfacepreview2/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/dingjikerbo/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/surfacepreview2/src/androidTest/java/com/inuker/glsurfacepreview3/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.glsurfacepreview3;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.assertEquals;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.inuker.glsurfacepreview3", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/surfacepreview2/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/surfacepreview2/src/main/java/com/inuker/surfacepreview2/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.inuker.surfacepreview2;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 |
6 | public class MainActivity extends Activity {
7 |
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 |
12 | CameraSurfaceView surfaceView = new CameraSurfaceView(this);
13 | setContentView(surfaceView);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview2/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview2/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview2/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview2/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview2/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview2/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview2/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview2/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview2/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dingjikerbo/Android-Camera/aa869f65bc0f8735b3e77109283ff863088eb720/surfacepreview2/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GLSurfacePreview3
3 |
4 |
--------------------------------------------------------------------------------
/surfacepreview2/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/surfacepreview2/src/test/java/com/inuker/glsurfacepreview3/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.inuker.glsurfacepreview3;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------