├── Camera
├── CameraV1
│ ├── .gitignore
│ ├── README.md
│ ├── app
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── lb377463323
│ │ │ │ └── camera1
│ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ ├── layout
│ │ │ └── activity_main.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── ids.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
└── CameraV2
│ ├── .gitignore
│ ├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── lb377463323
│ │ │ └── camera2
│ │ │ └── MainActivity.java
│ │ └── res
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── gallery_imageview.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── Filter
├── .gitignore
├── .idea
│ ├── gradle.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── runConfigurations.xml
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── liubing
│ │ │ └── filtertestbed
│ │ │ ├── CameraV1.java
│ │ │ ├── CameraV1GLSurfaceView
│ │ │ ├── CameraV1GLSurfaceView.java
│ │ │ ├── CameraV1GLSurfaceViewActivity.java
│ │ │ └── CameraV1Renderer.java
│ │ │ ├── CameraV1TextureView
│ │ │ ├── CameraV1GLRenderer.java
│ │ │ └── CameraV1TextureViewActivity.java
│ │ │ ├── CameraV2.java
│ │ │ ├── CameraV2GLSurfaceView
│ │ │ ├── CameraV2GLSurfaceView.java
│ │ │ ├── CameraV2GLSurfaceViewActivity.java
│ │ │ └── CameraV2Renderer.java
│ │ │ ├── FilterEngine.java
│ │ │ └── Utils.java
│ │ └── res
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── raw
│ │ ├── base_fragment_shader.glsl
│ │ └── base_vertex_shader.glsl
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── JNIDemo
├── .gitignore
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── lb6905
│ │ │ └── jnidemo
│ │ │ ├── MainActivity.java
│ │ │ └── TestClass.java
│ │ ├── jni
│ │ ├── Android.mk
│ │ └── hello-jni.c
│ │ ├── libs
│ │ ├── arm64-v8a
│ │ │ └── libhello-jni.so
│ │ ├── armeabi-v7a
│ │ │ └── libhello-jni.so
│ │ ├── armeabi
│ │ │ └── libhello-jni.so
│ │ ├── mips
│ │ │ └── libhello-jni.so
│ │ ├── mips64
│ │ │ └── libhello-jni.so
│ │ ├── x86
│ │ │ └── libhello-jni.so
│ │ └── x86_64
│ │ │ └── libhello-jni.so
│ │ ├── obj
│ │ └── local
│ │ │ ├── arm64-v8a
│ │ │ ├── libhello-jni.so
│ │ │ └── objs
│ │ │ │ └── hello-jni
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ ├── armeabi-v7a
│ │ │ ├── libhello-jni.so
│ │ │ └── objs
│ │ │ │ └── hello-jni
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ ├── armeabi
│ │ │ ├── libhello-jni.so
│ │ │ └── objs
│ │ │ │ └── hello-jni
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ ├── mips
│ │ │ ├── libhello-jni.so
│ │ │ └── objs
│ │ │ │ └── hello-jni
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ ├── mips64
│ │ │ ├── libhello-jni.so
│ │ │ └── objs
│ │ │ │ └── hello-jni
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ ├── x86
│ │ │ ├── libhello-jni.so
│ │ │ └── objs
│ │ │ │ └── hello-jni
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ └── x86_64
│ │ │ ├── libhello-jni.so
│ │ │ └── objs
│ │ │ └── hello-jni
│ │ │ ├── hello-jni.o
│ │ │ └── hello-jni.o.d
│ │ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── OpenGLES
├── .gitignore
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── lb377463323
│ │ │ └── opengles
│ │ │ ├── GLActivity.java
│ │ │ ├── GLRenderer.java
│ │ │ └── Triangle.java
│ │ └── res
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
└── README.md
/Camera/CameraV1/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/Camera/CameraV1/README.md:
--------------------------------------------------------------------------------
1 | This is a CameraV1 Demo,it has preview、switch camera、take picture function.
2 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.lb377463323.camera1"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | compile 'com.android.support:appcompat-v7:25.1.1'
25 | }
26 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/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 /home/liubing/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 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/java/com/lb377463323/camera1/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.lb377463323.camera1;
2 |
3 | import android.content.Context;
4 | import android.content.pm.PackageManager;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapFactory;
7 | import android.graphics.Color;
8 | import android.graphics.Matrix;
9 | import android.graphics.SurfaceTexture;
10 | import android.hardware.Camera;
11 | import android.os.Bundle;
12 | import android.os.Environment;
13 | import android.os.Process;
14 | import android.support.v7.app.AppCompatActivity;
15 | import android.util.Log;
16 | import android.view.Gravity;
17 | import android.view.TextureView;
18 | import android.view.View;
19 | import android.view.ViewGroup;
20 | import android.widget.AdapterView;
21 | import android.widget.BaseAdapter;
22 | import android.widget.Button;
23 | import android.widget.ListView;
24 | import android.widget.PopupWindow;
25 | import android.widget.TextView;
26 |
27 | import java.io.BufferedOutputStream;
28 | import java.io.File;
29 | import java.io.FileNotFoundException;
30 | import java.io.FileOutputStream;
31 | import java.io.IOException;
32 | import java.text.SimpleDateFormat;
33 | import java.util.ArrayList;
34 | import java.util.Date;
35 | import java.util.List;
36 |
37 | public class MainActivity extends AppCompatActivity implements TextureView.SurfaceTextureListener, View.OnClickListener, AdapterView.OnItemClickListener{
38 | private String TAG = "MainActivity";
39 | public static final String STORAGE_PATH = Environment.getExternalStorageDirectory().toString();
40 |
41 | private Camera mCamera;
42 | private TextureView mTextureView;
43 | private int mCameraId;
44 | private int mCameraNum;
45 | private Button mCaptureButton;
46 | private Button mSwitchCamButton;
47 | private Button mPictureSizeButton;
48 | private PopupWindow mPreviewPopupWindow;
49 | private PopupWindow mPicturePopupWindow;
50 | private Camera.Parameters mParameters;
51 | private List mSupportedPreSizeList;
52 | private List mSupportedPicSizeList;
53 | private List mPreviewSizeList;
54 | private List mPictureSizeList;
55 | private ListView mPictureListView;
56 | private MyAdapter mPictureAdapter;
57 | private int mCaptureWidth;
58 | private int mCaptureHeight;
59 |
60 | @Override
61 | protected void onCreate(Bundle savedInstanceState) {
62 | super.onCreate(savedInstanceState);
63 | setContentView(R.layout.activity_main);
64 | mTextureView = (TextureView) findViewById(R.id.camera_preview);
65 | mCaptureButton = (Button) findViewById(R.id.btn_capture);
66 | mSwitchCamButton = (Button) findViewById(R.id.btn_switchCam);
67 | mPictureSizeButton = (Button) findViewById(R.id.btn_pictureSize);
68 | mCaptureButton.setOnClickListener(this);
69 | mSwitchCamButton.setOnClickListener(this);
70 | mPictureSizeButton.setOnClickListener(this);
71 |
72 | if(checkCameraHardware(this)){
73 | mCameraNum = Camera.getNumberOfCameras();
74 | Log.i(TAG, "Camera Number: " + mCameraNum);
75 | mTextureView.setSurfaceTextureListener(this);
76 | }else {
77 | Log.i(TAG, "Has not Camera!");
78 | }
79 | }
80 |
81 | @Override
82 | protected void onResume() {
83 | super.onResume();
84 | requestCamera(mCameraId);
85 | initSizeList();
86 | initParameters();
87 | initPopupWindow();
88 | }
89 |
90 | //Check whether the device has a camera
91 | private boolean checkCameraHardware(Context context){
92 | if(context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)){
93 | return true;//has Camera
94 | }else {
95 | return false;// has not Camera
96 | }
97 | }
98 |
99 | private void setPreviewTexture(SurfaceTexture surfaceTexture) {
100 | if (mCamera != null) {
101 | try {
102 | mCamera.setPreviewTexture(surfaceTexture);
103 | } catch (IOException e) {
104 | e.printStackTrace();
105 | }
106 | }
107 | }
108 |
109 | @Override
110 | public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
111 | setPreviewTexture(surface);
112 | setDisplayOrientation(90);
113 | startPreview();
114 | Log.i(TAG, "onSurfaceTextureAvailable: size:" + width +"," + height);
115 | }
116 |
117 | @Override
118 | public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
119 |
120 | }
121 |
122 | @Override
123 | public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
124 | return false;
125 | }
126 |
127 | @Override
128 | public void onSurfaceTextureUpdated(SurfaceTexture surface) {
129 |
130 | }
131 |
132 | @Override
133 | public void onClick(View v) {
134 | switch (v.getId()){
135 | case R.id.btn_capture:
136 | takePicture();
137 | break;
138 | case R.id.btn_switchCam:
139 | switchCamera();
140 | break;
141 | case R.id.btn_pictureSize:
142 | showPopupWindow(mPicturePopupWindow, mPictureSizeButton);
143 | break;
144 | default:
145 | break;
146 | }
147 | }
148 |
149 | public void takePicture(){
150 | if (mCamera != null){
151 | mCamera.takePicture(null, null, mPictureCallback);
152 | }
153 | }
154 |
155 | public void switchCamera(){
156 | if (mCameraNum > 1){
157 | mCameraId = mCameraId == Camera.CameraInfo.CAMERA_FACING_BACK ?
158 | Camera.CameraInfo.CAMERA_FACING_FRONT : Camera.CameraInfo.CAMERA_FACING_BACK;
159 | stopPreview();
160 | closeCamera();
161 |
162 | requestCamera(mCameraId);
163 | initSizeList();
164 | for (int i = 0; i < mPreviewSizeList.size(); i++) {
165 | Log.i(TAG, "preview size " + i + " :" + mPreviewSizeList.get(i));
166 | }
167 |
168 | for (int j = 0; j < mPictureSizeList.size(); j++) {
169 | Log.i(TAG, "picture size " + j + " :" + mPictureSizeList.get(j));
170 | }
171 | initParameters();
172 | mPictureAdapter.notifyDataSetChanged();
173 | setDisplayOrientation(90);
174 | setPreviewTexture(mTextureView.getSurfaceTexture());
175 | startPreview();
176 | Log.i(TAG, "Camera has switched!");
177 | }else {
178 | Log.i(TAG, "This device does not support switch camera");
179 | }
180 | }
181 |
182 | private Camera.ErrorCallback mErrorCallback = new Camera.ErrorCallback() {
183 | @Override
184 | public void onError(int error, Camera camera) {
185 | Log.e(TAG, "onError: got camera error callback: " + error);
186 | if (error == Camera.CAMERA_ERROR_SERVER_DIED) {
187 | android.os.Process.killProcess(Process.myPid());
188 | }
189 | }
190 | };
191 |
192 | private Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
193 | @Override
194 | public void onPictureTaken(final byte[] data, Camera camera) {
195 | new Thread(new Runnable() {
196 | @Override
197 | public void run() {
198 | String path = STORAGE_PATH + "/DCIM" + "/CameraV1";
199 | writeFile(path, data);
200 | }
201 | }, "captureThread").start();
202 | startPreview();
203 | }
204 | };
205 |
206 | public void writeFile(String path, byte[] data) {
207 | Bitmap bitmap = null;
208 | if (data != null){
209 | bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
210 | }
211 |
212 | if (bitmap != null){
213 | Matrix matrix = new Matrix();
214 | if (mCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
215 | matrix.postRotate(90);
216 | }else if (mCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT){
217 | matrix.postRotate(90);
218 | matrix.postScale(1, -1);
219 | }
220 | Bitmap rotateBmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
221 | bitmap.getHeight(), matrix,false);
222 | saveBmp2SD(path, rotateBmp);
223 | rotateBmp.recycle();
224 | }
225 | }
226 |
227 | private void saveBmp2SD(String path, Bitmap bitmap){
228 | File file = new File(path);
229 | if (!file.exists()){
230 | file.mkdir();
231 | }
232 | String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
233 | String fileName = path + "/" + "IMG_" + timeStamp + ".jpg";
234 | try {
235 | FileOutputStream fos = new FileOutputStream(fileName);
236 | BufferedOutputStream bos = new BufferedOutputStream(fos);
237 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
238 | bos.flush();
239 | bos.close();
240 | Log.i(TAG, "Take picture success!");
241 | } catch (FileNotFoundException e) {
242 | e.printStackTrace();
243 | Log.e(TAG, "The save file for take picture is not exists!");
244 | } catch (IOException e) {
245 | e.printStackTrace();
246 | Log.e(TAG, "Take picture fail!");
247 | }
248 | }
249 |
250 | private void setDisplayOrientation(int degree){
251 | if (mCamera != null) {
252 | mCamera.setDisplayOrientation(degree);
253 | }
254 | Log.i(TAG, "Set display orientation is : " + degree);
255 | }
256 |
257 | private void requestCamera(int mCameraId) {
258 | openCamera(mCameraId);
259 | }
260 |
261 | private void openCamera(int cameraId){
262 | try{
263 | if (mCamera == null) {
264 | mCamera = Camera.open(cameraId);
265 | Log.i(TAG, "Camera has opened, cameraId is " + cameraId);
266 | }
267 | }catch (Exception e){
268 | Log.e(TAG, "Open Camera has exception!");
269 | }
270 | }
271 |
272 | private void startPreview(){
273 | if (mCamera != null) {
274 | mCamera.setErrorCallback(mErrorCallback);
275 | mCamera.startPreview();
276 | Log.i(TAG, "Camera Preview has started!");
277 | }
278 | }
279 |
280 | private void stopPreview() {
281 | if (mCamera != null){
282 | mCamera.stopPreview();
283 | Log.i(TAG, "Camera Preview has stopped!");
284 | }
285 | }
286 |
287 | private void closeCamera() {
288 | if (mCamera != null){
289 | mCamera.setErrorCallback(null);
290 | mCamera.release();
291 | mCamera = null;
292 | Log.i(TAG, "Camera has closed!");
293 | }
294 | }
295 |
296 | @Override
297 | protected void onPause() {
298 | super.onPause();
299 | stopPreview();
300 | closeCamera();
301 | }
302 |
303 | private void initSizeList() {
304 | mParameters = getParameters();
305 | mSupportedPreSizeList = getSupportedPreviewSizes(mParameters);
306 | mSupportedPicSizeList = getSupportedPictureSizes(mParameters);
307 | }
308 |
309 | private void initParameters() {
310 | if (mSupportedPreSizeList != null && mSupportedPicSizeList != null) {
311 | mParameters.setPreviewSize(mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).width,
312 | mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).height);
313 | Log.i(TAG, "initParameters: previewSize: " + mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).width +
314 | "," + mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).height);
315 | mCaptureWidth = mSupportedPicSizeList.get(mSupportedPicSizeList.size() - 1).width;
316 | mCaptureHeight = mSupportedPicSizeList.get(mSupportedPicSizeList.size() - 1).height;
317 | mParameters.setPictureSize(mCaptureWidth, mCaptureHeight);
318 | Log.i(TAG, "initParameters: pictureSize: " + mCaptureWidth + "," + mCaptureHeight);
319 | setParameters();
320 | }
321 | }
322 |
323 | private void initPopupWindow() {
324 | initPicturePopupWindow();
325 | }
326 |
327 | private void initPicturePopupWindow() {
328 | mPictureAdapter = new MyAdapter(mPictureSizeList);
329 | mPictureListView = new ListView(this);
330 | mPictureListView.setId(R.id.pictureId);
331 | mPictureListView.setAdapter(mPictureAdapter);
332 | if (mPicturePopupWindow == null) {
333 | mPicturePopupWindow = new PopupWindow(mPictureListView, 320, 320,true);
334 | }
335 | mPictureListView.setOnItemClickListener(this);
336 | }
337 |
338 | private void showPopupWindow(PopupWindow popupWindow, View view) {
339 | if (popupWindow != null && view != null && !popupWindow.isShowing()) {
340 | int[] location = new int[2];
341 | view.getLocationOnScreen(location);
342 | popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, location[0], location[1] - popupWindow.getHeight());
343 | } else {
344 | if (popupWindow != null) {
345 | popupWindow.dismiss();
346 | }
347 | }
348 | }
349 |
350 | class MyAdapter extends BaseAdapter {
351 | List sizeList = new ArrayList<>();
352 |
353 | public MyAdapter(List list) {
354 | this.sizeList = list;
355 | }
356 |
357 | @Override
358 | public int getCount() {
359 | return sizeList.size();
360 | }
361 |
362 | @Override
363 | public Object getItem(int position) {
364 | return sizeList.get(position);
365 | }
366 |
367 | @Override
368 | public long getItemId(int position) {
369 | return position;
370 | }
371 |
372 | @Override
373 | public View getView(int position, View convertView, ViewGroup parent) {
374 | TextView textView = new TextView(MainActivity.this);
375 | textView.setTextSize(18);
376 | textView.setTextColor(Color.rgb(255, 255, 0));
377 | textView.setText(sizeList.get(position));
378 | return textView;
379 | }
380 | }
381 |
382 | private Camera.Parameters getParameters() {
383 | if (mCamera != null) {
384 | return mCamera.getParameters();
385 | }
386 | return null;
387 | }
388 |
389 | private void setParameters() {
390 | if(mCamera != null && mParameters != null) {
391 | mCamera.setParameters(mParameters);
392 | }
393 | }
394 |
395 | private List getSupportedPreviewSizes(Camera.Parameters parameters) {
396 | if (parameters == null) {
397 | return null;
398 | }
399 | if (mPreviewSizeList == null) {
400 | mPreviewSizeList = new ArrayList<>();
401 | } else {
402 | mPreviewSizeList.clear();
403 | }
404 | mSupportedPreSizeList = new ArrayList<>();
405 | for (Camera.Size size : parameters.getSupportedPreviewSizes()) {
406 | if (equalsRate(size, 1.777f)) {
407 | mSupportedPreSizeList.add(size);
408 | }
409 | }
410 | for (Camera.Size size : mSupportedPreSizeList) {
411 | mPreviewSizeList.add(size.width + "×" + size.height);
412 | }
413 | return mSupportedPreSizeList;
414 | }
415 |
416 |
417 | private List getSupportedPictureSizes(Camera.Parameters parameters) {
418 | if (parameters == null) {
419 | return null;
420 | }
421 | if (mPictureSizeList == null) {
422 | mPictureSizeList = new ArrayList<>();
423 | } else {
424 | mPictureSizeList.clear();
425 | }
426 | mSupportedPicSizeList = new ArrayList<>();
427 | for (Camera.Size size : parameters.getSupportedPictureSizes()) {
428 | if(equalsRate(size, 1.777f)) {
429 | mSupportedPicSizeList.add(size);
430 | }
431 | }
432 | for (Camera.Size size : mSupportedPicSizeList) {
433 | mPictureSizeList.add(size.width + "×" + size.height);
434 | }
435 | return mSupportedPicSizeList;
436 | }
437 |
438 | @Override
439 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
440 | switch (parent.getId()) {
441 | case R.id.pictureId:
442 | Log.i(TAG, "onItemClick: PictureSize: " + mPictureSizeList.get(position));
443 | setCaptureSize(mSupportedPicSizeList.get(position).width,
444 | mSupportedPicSizeList.get(position).height);
445 | mPicturePopupWindow.dismiss();
446 | break;
447 | default:
448 | break;
449 | }
450 | }
451 |
452 | private void setPreviewSize(float rate) {
453 | if (!equalsRate(mParameters.getPreviewSize(), rate)) {
454 | mParameters.setPreviewSize(mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).width,
455 | mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).height);
456 | Log.i(TAG, "setPreviewSize: changed: " + mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).width +
457 | "×" + mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).height);
458 | setParameters();
459 | stopPreview();
460 | startPreview();
461 | } else {
462 | return;
463 | }
464 | }
465 |
466 | private void setCaptureSize(int captureWidth, int captureHeight) {
467 | this.mCaptureWidth = captureWidth;
468 | this.mCaptureHeight = captureHeight;
469 | mParameters.setPictureSize(mCaptureWidth, mCaptureHeight);
470 | if (mCamera != null) {
471 | setParameters();
472 | }
473 | setPreviewSize((float) captureWidth / (float) captureHeight);
474 | }
475 |
476 | private boolean equalsRate(Camera.Size size, float rate){
477 | float f = (float)size.width / (float) size.height;
478 | if (Math.abs(f - rate) <= 0.1f) {
479 | return true;
480 | } else {
481 | return false;
482 | }
483 | }
484 | }
485 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
21 |
27 |
33 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV1/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV1/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV1/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV1/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV1/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CameraV1
3 |
4 |
--------------------------------------------------------------------------------
/Camera/CameraV1/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Camera/CameraV1/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/Camera/CameraV1/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/Camera/CameraV1/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV1/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Camera/CameraV1/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
7 |
--------------------------------------------------------------------------------
/Camera/CameraV1/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Camera/CameraV1/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/Camera/CameraV1/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/Camera/CameraV2/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.lb377463323.camera2"
9 | minSdkVersion 21
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | compile 'com.android.support:appcompat-v7:25.1.1'
25 | compile 'com.android.support:recyclerview-v7:25.1.1'
26 | }
27 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/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 E:\AndroidSdk/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 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/java/com/lb377463323/camera2/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.lb377463323.camera2;
2 |
3 | import android.Manifest;
4 | import android.app.Activity;
5 | import android.content.Context;
6 | import android.content.pm.PackageManager;
7 | import android.graphics.ImageFormat;
8 | import android.graphics.SurfaceTexture;
9 | import android.hardware.camera2.CameraAccessException;
10 | import android.hardware.camera2.CameraCaptureSession;
11 | import android.hardware.camera2.CameraCharacteristics;
12 | import android.hardware.camera2.CameraDevice;
13 | import android.hardware.camera2.CameraManager;
14 | import android.hardware.camera2.CameraMetadata;
15 | import android.hardware.camera2.CaptureRequest;
16 | import android.hardware.camera2.CaptureResult;
17 | import android.hardware.camera2.TotalCaptureResult;
18 | import android.hardware.camera2.params.StreamConfigurationMap;
19 | import android.media.Image;
20 | import android.media.ImageReader;
21 | import android.os.Bundle;
22 | import android.os.Environment;
23 | import android.os.Handler;
24 | import android.os.HandlerThread;
25 | import android.support.v4.app.ActivityCompat;
26 | import android.util.Size;
27 | import android.util.SparseIntArray;
28 | import android.view.Surface;
29 | import android.view.TextureView;
30 | import android.view.View;
31 | import android.view.Window;
32 | import android.view.WindowManager;
33 | import android.widget.Toast;
34 |
35 | import java.io.File;
36 | import java.io.FileOutputStream;
37 | import java.io.IOException;
38 | import java.nio.ByteBuffer;
39 | import java.text.SimpleDateFormat;
40 | import java.util.ArrayList;
41 | import java.util.Arrays;
42 | import java.util.Collections;
43 | import java.util.Comparator;
44 | import java.util.Date;
45 | import java.util.List;
46 |
47 | public class MainActivity extends Activity {
48 | private static final SparseIntArray ORIENTATION = new SparseIntArray();
49 |
50 | static {
51 | ORIENTATION.append(Surface.ROTATION_0, 90);
52 | ORIENTATION.append(Surface.ROTATION_90, 0);
53 | ORIENTATION.append(Surface.ROTATION_180, 270);
54 | ORIENTATION.append(Surface.ROTATION_270, 180);
55 | }
56 |
57 | private String mCameraId;
58 | private Size mPreviewSize;
59 | private Size mCaptureSize;
60 | private HandlerThread mCameraThread;
61 | private Handler mCameraHandler;
62 | private CameraDevice mCameraDevice;
63 | private TextureView mTextureView;
64 | private ImageReader mImageReader;
65 | private CaptureRequest.Builder mCaptureRequestBuilder;
66 | private CaptureRequest mCaptureRequest;
67 | private CameraCaptureSession mCameraCaptureSession;
68 |
69 | @Override
70 | protected void onCreate(Bundle savedInstanceState) {
71 | super.onCreate(savedInstanceState);
72 |
73 | //全屏无状态栏
74 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
75 | requestWindowFeature(Window.FEATURE_NO_TITLE);
76 |
77 | setContentView(R.layout.activity_main);
78 | mTextureView = (TextureView) findViewById(R.id.textureView);
79 | }
80 |
81 | @Override
82 | protected void onResume() {
83 | super.onResume();
84 | startCameraThread();
85 | if (!mTextureView.isAvailable()) {
86 | mTextureView.setSurfaceTextureListener(mTextureListener);
87 | } else {
88 | startPreview();
89 | }
90 | }
91 |
92 | private void startCameraThread() {
93 | mCameraThread = new HandlerThread("CameraThread");
94 | mCameraThread.start();
95 | mCameraHandler = new Handler(mCameraThread.getLooper());
96 | }
97 |
98 | private TextureView.SurfaceTextureListener mTextureListener = new TextureView.SurfaceTextureListener() {
99 | @Override
100 | public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
101 | //当SurefaceTexture可用的时候,设置相机参数并打开相机
102 | setupCamera(width, height);
103 | openCamera();
104 | }
105 |
106 | @Override
107 | public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
108 |
109 | }
110 |
111 | @Override
112 | public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
113 | return false;
114 | }
115 |
116 | @Override
117 | public void onSurfaceTextureUpdated(SurfaceTexture surface) {
118 |
119 | }
120 | };
121 |
122 | private void setupCamera(int width, int height) {
123 | //获取摄像头的管理者CameraManager
124 | CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
125 | try {
126 | //遍历所有摄像头
127 | for (String cameraId : manager.getCameraIdList()) {
128 | CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
129 | Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);
130 | //此处默认打开后置摄像头
131 | if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT)
132 | continue;
133 | //获取StreamConfigurationMap,它是管理摄像头支持的所有输出格式和尺寸
134 | StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
135 | assert map != null;
136 | //根据TextureView的尺寸设置预览尺寸
137 | mPreviewSize = getOptimalSize(map.getOutputSizes(SurfaceTexture.class), width, height);
138 | //获取相机支持的最大拍照尺寸
139 | mCaptureSize = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), new Comparator() {
140 | @Override
141 | public int compare(Size lhs, Size rhs) {
142 | return Long.signum(lhs.getWidth() * lhs.getHeight() - rhs.getHeight() * rhs.getWidth());
143 | }
144 | });
145 | //此ImageReader用于拍照所需
146 | setupImageReader();
147 | mCameraId = cameraId;
148 | break;
149 | }
150 | } catch (CameraAccessException e) {
151 | e.printStackTrace();
152 | }
153 | }
154 |
155 | //选择sizeMap中大于并且最接近width和height的size
156 | private Size getOptimalSize(Size[] sizeMap, int width, int height) {
157 | List sizeList = new ArrayList<>();
158 | for (Size option : sizeMap) {
159 | if (width > height) {
160 | if (option.getWidth() > width && option.getHeight() > height) {
161 | sizeList.add(option);
162 | }
163 | } else {
164 | if (option.getWidth() > height && option.getHeight() > width) {
165 | sizeList.add(option);
166 | }
167 | }
168 | }
169 | if (sizeList.size() > 0) {
170 | return Collections.min(sizeList, new Comparator() {
171 | @Override
172 | public int compare(Size lhs, Size rhs) {
173 | return Long.signum(lhs.getWidth() * lhs.getHeight() - rhs.getWidth() * rhs.getHeight());
174 | }
175 | });
176 | }
177 | return sizeMap[0];
178 | }
179 |
180 |
181 | private void openCamera() {
182 | CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
183 | try {
184 | if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
185 | return;
186 | }
187 | manager.openCamera(mCameraId, mStateCallback, mCameraHandler);
188 | } catch (CameraAccessException e) {
189 | e.printStackTrace();
190 | }
191 | }
192 |
193 | private CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() {
194 | @Override
195 | public void onOpened(CameraDevice camera) {
196 | mCameraDevice = camera;
197 | startPreview();
198 | }
199 |
200 | @Override
201 | public void onDisconnected(CameraDevice camera) {
202 | camera.close();
203 | mCameraDevice = null;
204 | }
205 |
206 | @Override
207 | public void onError(CameraDevice camera, int error) {
208 | camera.close();
209 | mCameraDevice = null;
210 | }
211 | };
212 |
213 | private void startPreview() {
214 | SurfaceTexture mSurfaceTexture = mTextureView.getSurfaceTexture();
215 | mSurfaceTexture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
216 | Surface previewSurface = new Surface(mSurfaceTexture);
217 | try {
218 | mCaptureRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
219 | mCaptureRequestBuilder.addTarget(previewSurface);
220 | mCameraDevice.createCaptureSession(Arrays.asList(previewSurface, mImageReader.getSurface()), new CameraCaptureSession.StateCallback() {
221 | @Override
222 | public void onConfigured(CameraCaptureSession session) {
223 | try {
224 | mCaptureRequest = mCaptureRequestBuilder.build();
225 | mCameraCaptureSession = session;
226 | mCameraCaptureSession.setRepeatingRequest(mCaptureRequest, null, mCameraHandler);
227 | } catch (CameraAccessException e) {
228 | e.printStackTrace();
229 | }
230 | }
231 |
232 | @Override
233 | public void onConfigureFailed(CameraCaptureSession session) {
234 |
235 | }
236 | }, mCameraHandler);
237 | } catch (CameraAccessException e) {
238 | e.printStackTrace();
239 | }
240 | }
241 |
242 | public void takePicture(View view) {
243 | lockFocus();
244 | }
245 |
246 | private void lockFocus() {
247 | try {
248 | mCaptureRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START);
249 | mCameraCaptureSession.capture(mCaptureRequestBuilder.build(), mCaptureCallback, mCameraHandler);
250 | } catch (CameraAccessException e) {
251 | e.printStackTrace();
252 | }
253 | }
254 |
255 | private CameraCaptureSession.CaptureCallback mCaptureCallback = new CameraCaptureSession.CaptureCallback() {
256 | @Override
257 | public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request, CaptureResult partialResult) {
258 | }
259 |
260 | @Override
261 | public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) {
262 | capture();
263 | }
264 | };
265 |
266 | private void capture() {
267 | try {
268 | final CaptureRequest.Builder mCaptureBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
269 | int rotation = getWindowManager().getDefaultDisplay().getRotation();
270 | mCaptureBuilder.addTarget(mImageReader.getSurface());
271 | mCaptureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATION.get(rotation));
272 | CameraCaptureSession.CaptureCallback CaptureCallback = new CameraCaptureSession.CaptureCallback() {
273 | @Override
274 | public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) {
275 | Toast.makeText(getApplicationContext(), "Image Saved!", Toast.LENGTH_SHORT).show();
276 | unLockFocus();
277 | }
278 | };
279 | mCameraCaptureSession.stopRepeating();
280 | mCameraCaptureSession.capture(mCaptureBuilder.build(), CaptureCallback, null);
281 | } catch (CameraAccessException e) {
282 | e.printStackTrace();
283 | }
284 | }
285 |
286 | private void unLockFocus() {
287 | try {
288 | mCaptureRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
289 | //mCameraCaptureSession.capture(mCaptureRequestBuilder.build(), null, mCameraHandler);
290 | mCameraCaptureSession.setRepeatingRequest(mCaptureRequest, null, mCameraHandler);
291 | } catch (CameraAccessException e) {
292 | e.printStackTrace();
293 | }
294 | }
295 |
296 | @Override
297 | protected void onPause() {
298 | super.onPause();
299 | if (mCameraCaptureSession != null) {
300 | mCameraCaptureSession.close();
301 | mCameraCaptureSession = null;
302 | }
303 |
304 | if (mCameraDevice != null) {
305 | mCameraDevice.close();
306 | mCameraDevice = null;
307 | }
308 |
309 | if (mImageReader != null) {
310 | mImageReader.close();
311 | mImageReader = null;
312 | }
313 | }
314 |
315 | private void setupImageReader() {
316 | //2代表ImageReader中最多可以获取两帧图像流
317 | mImageReader = ImageReader.newInstance(mCaptureSize.getWidth(), mCaptureSize.getHeight(),
318 | ImageFormat.JPEG, 2);
319 | mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
320 | @Override
321 | public void onImageAvailable(ImageReader reader) {
322 | mCameraHandler.post(new imageSaver(reader.acquireNextImage()));
323 | }
324 | }, mCameraHandler);
325 | }
326 |
327 | public static class imageSaver implements Runnable {
328 |
329 | private Image mImage;
330 |
331 | public imageSaver(Image image) {
332 | mImage = image;
333 | }
334 |
335 | @Override
336 | public void run() {
337 | ByteBuffer buffer = mImage.getPlanes()[0].getBuffer();
338 | byte[] data = new byte[buffer.remaining()];
339 | buffer.get(data);
340 | String path = Environment.getExternalStorageDirectory() + "/DCIM/CameraV2/";
341 | File mImageFile = new File(path);
342 | if (!mImageFile.exists()) {
343 | mImageFile.mkdir();
344 | }
345 | String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
346 | String fileName = path + "IMG_" + timeStamp + ".jpg";
347 | FileOutputStream fos = null;
348 | try {
349 | fos = new FileOutputStream(fileName);
350 | fos.write(data, 0, data.length);
351 | } catch (IOException e) {
352 | e.printStackTrace();
353 | } finally {
354 | if (fos != null) {
355 | try {
356 | fos.close();
357 | } catch (IOException e) {
358 | e.printStackTrace();
359 | }
360 | }
361 | }
362 | }
363 | }
364 | }
365 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/layout/gallery_imageview.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
11 |
12 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV2/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV2/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV2/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV2/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV2/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CameraV2
3 |
4 |
--------------------------------------------------------------------------------
/Camera/CameraV2/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Camera/CameraV2/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/Camera/CameraV2/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/Camera/CameraV2/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Camera/CameraV2/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Camera/CameraV2/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
7 |
--------------------------------------------------------------------------------
/Camera/CameraV2/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Camera/CameraV2/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/Camera/CameraV2/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/Filter/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/Filter/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/Filter/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Filter/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Filter/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Filter/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Filter/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.liubing.filtertestbed"
9 | minSdkVersion 21
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | compile 'com.android.support:appcompat-v7:25.3.1'
25 | }
26 |
--------------------------------------------------------------------------------
/Filter/app/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 E:\AndroidSdk/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 |
--------------------------------------------------------------------------------
/Filter/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
17 |
26 |
27 |
36 |
37 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed;
2 |
3 | import android.app.Activity;
4 | import android.graphics.SurfaceTexture;
5 | import android.hardware.Camera;
6 | import android.util.Log;
7 | import android.view.Surface;
8 |
9 | import java.io.IOException;
10 |
11 | /**
12 | * Created by lb6905 on 2017/6/27.
13 | */
14 |
15 | public class CameraV1 {
16 | private Activity mActivity;
17 | private int mCameraId;
18 | private Camera mCamera;
19 |
20 | public CameraV1(Activity activity) {
21 | mActivity = activity;
22 | }
23 |
24 | public boolean openCamera(int screenWidth, int screenHeight, int cameraId) {
25 | try {
26 | mCameraId = cameraId;
27 | mCamera = Camera.open(mCameraId);
28 | Camera.Parameters parameters = mCamera.getParameters();
29 | parameters.set("orientation", "portrait");
30 | parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
31 | parameters.setPreviewSize(1280, 720);
32 | setCameraDisplayOrientation(mActivity, mCameraId, mCamera);
33 | mCamera.setParameters(parameters);
34 | Log.i("lb6905", "open camera");
35 | } catch (Exception e) {
36 | e.printStackTrace();
37 | return false;
38 | }
39 | return true;
40 | }
41 |
42 | public static void setCameraDisplayOrientation(Activity activity,
43 | int cameraId, android.hardware.Camera camera) {
44 | android.hardware.Camera.CameraInfo info =
45 | new android.hardware.Camera.CameraInfo();
46 | android.hardware.Camera.getCameraInfo(cameraId, info);
47 | int rotation = activity.getWindowManager().getDefaultDisplay()
48 | .getRotation();
49 | int degrees = 0;
50 | switch (rotation) {
51 | case Surface.ROTATION_0: degrees = 0; break;
52 | case Surface.ROTATION_90: degrees = 90; break;
53 | case Surface.ROTATION_180: degrees = 180; break;
54 | case Surface.ROTATION_270: degrees = 270; break;
55 | }
56 |
57 | int result;
58 | if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
59 | result = (info.orientation + degrees) % 360;
60 | result = (360 - result) % 360; // compensate the mirror
61 | } else { // back-facing
62 | result = (info.orientation - degrees + 360) % 360;
63 | }
64 | camera.setDisplayOrientation(result);
65 | }
66 |
67 | public void startPreview() {
68 | if (mCamera != null) {
69 | mCamera.startPreview();
70 | }
71 | }
72 |
73 | public void stopPreview() {
74 | if (mCamera != null) {
75 | mCamera.stopPreview();
76 | }
77 | }
78 |
79 | public void setPreviewTexture(SurfaceTexture surfaceTexture) {
80 | if (mCamera != null) {
81 | try {
82 | mCamera.setPreviewTexture(surfaceTexture);
83 | } catch (IOException e) {
84 | e.printStackTrace();
85 | }
86 | }
87 | }
88 |
89 | public void releaseCamera() {
90 | if (mCamera != null) {
91 | mCamera.release();
92 | mCamera = null;
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1GLSurfaceView.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed.CameraV1GLSurfaceView;
2 |
3 | import android.content.Context;
4 | import android.opengl.GLSurfaceView;
5 |
6 | import com.liubing.filtertestbed.CameraV1;
7 |
8 | /**
9 | * Created by lb6905 on 2017/6/12.
10 | */
11 |
12 | public class CameraV1GLSurfaceView extends GLSurfaceView {
13 |
14 | private CameraV1Renderer mRenderer;
15 | private int textureId = -1;
16 |
17 | public CameraV1GLSurfaceView(Context context) {
18 | super(context);
19 | }
20 |
21 | public void init(CameraV1 camera, boolean isPreviewStarted, Context context) {
22 | setEGLContextClientVersion(2);
23 | mRenderer = new CameraV1Renderer();
24 | mRenderer.init(this, camera, isPreviewStarted, context);
25 | setRenderer(mRenderer);
26 | }
27 |
28 | public void deinit() {
29 | if (mRenderer != null) {
30 | mRenderer.deinit();
31 | mRenderer = null;
32 | textureId = -1;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1GLSurfaceViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed.CameraV1GLSurfaceView;
2 |
3 | import android.app.Activity;
4 | import android.content.pm.ActivityInfo;
5 | import android.hardware.Camera;
6 | import android.os.Bundle;
7 | import android.util.DisplayMetrics;
8 | import android.view.Window;
9 | import android.view.WindowManager;
10 |
11 | import com.liubing.filtertestbed.CameraV1;
12 |
13 | public class CameraV1GLSurfaceViewActivity extends Activity {
14 | private CameraV1GLSurfaceView mGLSurfaceView;
15 | private int mCameraId;
16 | private CameraV1 mCamera;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 |
22 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
23 | requestWindowFeature(Window.FEATURE_NO_TITLE);
24 | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
25 |
26 | mGLSurfaceView = new CameraV1GLSurfaceView(this);
27 | mCameraId = Camera.CameraInfo.CAMERA_FACING_BACK;
28 | DisplayMetrics dm = new DisplayMetrics();
29 | mCamera = new CameraV1(this);
30 | if (!mCamera.openCamera(dm.widthPixels, dm.heightPixels, mCameraId)) {
31 | return;
32 | }
33 | mGLSurfaceView.init(mCamera, false, CameraV1GLSurfaceViewActivity.this);
34 | setContentView(mGLSurfaceView);
35 | }
36 |
37 | @Override
38 | protected void onPause() {
39 | super.onPause();
40 | if (mGLSurfaceView != null) {
41 | mGLSurfaceView.onPause();
42 | mGLSurfaceView.deinit();
43 | mGLSurfaceView = null;
44 | }
45 |
46 | if (mCamera != null) {
47 | mCamera.stopPreview();
48 | mCamera.releaseCamera();
49 | mCamera = null;
50 | }
51 | }
52 |
53 | @Override
54 | protected void onDestroy() {
55 | super.onDestroy();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1Renderer.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed.CameraV1GLSurfaceView;
2 |
3 | import android.content.Context;
4 | import android.graphics.SurfaceTexture;
5 | import android.opengl.GLES11Ext;
6 | import android.opengl.GLES20;
7 | import android.opengl.GLSurfaceView;
8 | import android.util.Log;
9 |
10 | import com.liubing.filtertestbed.FilterEngine;
11 | import com.liubing.filtertestbed.CameraV1;
12 | import com.liubing.filtertestbed.Utils;
13 |
14 | import java.nio.FloatBuffer;
15 |
16 | import javax.microedition.khronos.egl.EGLConfig;
17 | import javax.microedition.khronos.opengles.GL10;
18 |
19 | import static android.opengl.GLES11Ext.GL_TEXTURE_EXTERNAL_OES;
20 | import static android.opengl.GLES20.GL_FLOAT;
21 | import static android.opengl.GLES20.GL_FRAMEBUFFER;
22 | import static android.opengl.GLES20.GL_TRIANGLES;
23 | import static android.opengl.GLES20.glActiveTexture;
24 | import static android.opengl.GLES20.glBindFramebuffer;
25 | import static android.opengl.GLES20.glBindTexture;
26 | import static android.opengl.GLES20.glClearColor;
27 | import static android.opengl.GLES20.glDrawArrays;
28 | import static android.opengl.GLES20.glEnableVertexAttribArray;
29 | import static android.opengl.GLES20.glGenFramebuffers;
30 | import static android.opengl.GLES20.glGetAttribLocation;
31 | import static android.opengl.GLES20.glGetUniformLocation;
32 | import static android.opengl.GLES20.glUniform1i;
33 | import static android.opengl.GLES20.glUniformMatrix4fv;
34 | import static android.opengl.GLES20.glVertexAttribPointer;
35 | import static android.opengl.GLES20.glViewport;
36 |
37 | /**
38 | * Created by lb6905 on 2017/6/12.
39 | */
40 |
41 | public class CameraV1Renderer implements GLSurfaceView.Renderer {
42 |
43 | private static final String TAG = "Filter_MyRenderer";
44 | private Context mContext;
45 | private int mOESTextureId = -1;
46 | private SurfaceTexture mSurfaceTexture;
47 | private float[] transformMatrix = new float[16];
48 | private CameraV1GLSurfaceView mGLSurfaceView;
49 | private CameraV1 mCamera;
50 | private boolean bIsPreviewStarted;
51 | private FilterEngine mFilterEngine;
52 | private FloatBuffer mDataBuffer;
53 | private int mShaderProgram = -1;
54 | private int aPositionLocation = -1;
55 | private int aTextureCoordLocation = -1;
56 | private int uTextureMatrixLocation = -1;
57 | private int uTextureSamplerLocation = -1;
58 | private int[] mFBOIds = new int[1];
59 |
60 | public void init(CameraV1GLSurfaceView glSurfaceView, CameraV1 camera, boolean isPreviewStarted, Context context) {
61 | mContext = context;
62 | mGLSurfaceView = glSurfaceView;
63 | mCamera = camera;
64 | bIsPreviewStarted = isPreviewStarted;
65 | }
66 |
67 | @Override
68 | public void onSurfaceCreated(GL10 gl, EGLConfig config) {
69 | mOESTextureId = Utils.createOESTextureObject();
70 | mFilterEngine = new FilterEngine(mOESTextureId, mContext);
71 | mDataBuffer = mFilterEngine.getBuffer();
72 | mShaderProgram = mFilterEngine.getShaderProgram();
73 | glGenFramebuffers(1, mFBOIds, 0);
74 | glBindFramebuffer(GL_FRAMEBUFFER, mFBOIds[0]);
75 | Log.i("lb6905", "onSurfaceCreated: mFBOId: " + mFBOIds[0]);
76 | }
77 |
78 | @Override
79 | public void onSurfaceChanged(GL10 gl, int width, int height) {
80 | glViewport(0, 0, width, height);
81 | }
82 |
83 | @Override
84 | public void onDrawFrame(GL10 gl) {
85 | Long t1 = System.currentTimeMillis();
86 | if (mSurfaceTexture != null) {
87 | mSurfaceTexture.updateTexImage();
88 | mSurfaceTexture.getTransformMatrix(transformMatrix);
89 | }
90 |
91 | if (!bIsPreviewStarted) {
92 | bIsPreviewStarted = initSurfaceTexture();
93 | bIsPreviewStarted = true;
94 | return;
95 | }
96 |
97 | //glClear(GL_COLOR_BUFFER_BIT);
98 | glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
99 |
100 | aPositionLocation = glGetAttribLocation(mShaderProgram, FilterEngine.POSITION_ATTRIBUTE);
101 | aTextureCoordLocation = glGetAttribLocation(mShaderProgram, FilterEngine.TEXTURE_COORD_ATTRIBUTE);
102 | uTextureMatrixLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_MATRIX_UNIFORM);
103 | uTextureSamplerLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_SAMPLER_UNIFORM);
104 |
105 | glActiveTexture(GLES20.GL_TEXTURE0);
106 | glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mOESTextureId);
107 | glUniform1i(uTextureSamplerLocation, 0);
108 | glUniformMatrix4fv(uTextureMatrixLocation, 1, false, transformMatrix, 0);
109 |
110 | if (mDataBuffer != null) {
111 | mDataBuffer.position(0);
112 | glEnableVertexAttribArray(aPositionLocation);
113 | glVertexAttribPointer(aPositionLocation, 2, GL_FLOAT, false, 16, mDataBuffer);
114 |
115 | mDataBuffer.position(2);
116 | glEnableVertexAttribArray(aTextureCoordLocation);
117 | glVertexAttribPointer(aTextureCoordLocation, 2, GL_FLOAT, false, 16, mDataBuffer);
118 | }
119 |
120 | //glDrawElements(GL_TRIANGLE_FAN, 6,GL_UNSIGNED_INT, 0);
121 | //glDrawArrays(GL_TRIANGLE_FAN, 0 , 6);
122 | glDrawArrays(GL_TRIANGLES, 0, 6);
123 | //glDrawArrays(GL_TRIANGLES, 3, 3);
124 | glBindFramebuffer(GL_FRAMEBUFFER, 0);
125 | long t2 = System.currentTimeMillis();
126 | long t = t2 - t1;
127 | Log.i("lb6905", "onDrawFrame: time: " + t);
128 | }
129 |
130 | public boolean initSurfaceTexture() {
131 | if (mCamera == null || mGLSurfaceView == null) {
132 | Log.i(TAG, "mCamera or mGLSurfaceView is null!");
133 | return false;
134 | }
135 | mSurfaceTexture = new SurfaceTexture(mOESTextureId);
136 | mSurfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
137 | @Override
138 | public void onFrameAvailable(SurfaceTexture surfaceTexture) {
139 | mGLSurfaceView.requestRender();
140 | }
141 | });
142 | mCamera.setPreviewTexture(mSurfaceTexture);
143 | mCamera.startPreview();
144 | return true;
145 | }
146 |
147 | public void deinit() {
148 | if (mFilterEngine != null) {
149 | mFilterEngine = null;
150 | }
151 | mDataBuffer = null;
152 | if (mSurfaceTexture != null) {
153 | mSurfaceTexture.release();
154 | mSurfaceTexture = null;
155 | }
156 | mCamera = null;
157 | mOESTextureId = -1;
158 | bIsPreviewStarted = false;
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1TextureView/CameraV1GLRenderer.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed.CameraV1TextureView;
2 |
3 | import android.content.Context;
4 | import android.graphics.SurfaceTexture;
5 | import android.opengl.EGL14;
6 | import android.opengl.GLES20;
7 | import android.os.Handler;
8 | import android.os.HandlerThread;
9 | import android.os.Message;
10 | import android.util.Log;
11 | import android.view.TextureView;
12 |
13 | import com.liubing.filtertestbed.FilterEngine;
14 |
15 | import java.nio.FloatBuffer;
16 |
17 | import javax.microedition.khronos.egl.EGL10;
18 | import javax.microedition.khronos.egl.EGLConfig;
19 | import javax.microedition.khronos.egl.EGLContext;
20 | import javax.microedition.khronos.egl.EGLDisplay;
21 | import javax.microedition.khronos.egl.EGLSurface;
22 |
23 | /**
24 | * Created by lb6905 on 2017/6/28.
25 | */
26 |
27 | public class CameraV1GLRenderer implements SurfaceTexture.OnFrameAvailableListener {
28 | private static final String TAG = "Filter_GLRenderer";
29 | private Context mContext;
30 | private HandlerThread mHandlerThread;
31 | private Handler mHandler;
32 | private TextureView mTextureView;
33 | private int mOESTextureId;
34 | private FilterEngine mFilterEngine;
35 | private FloatBuffer mDataBuffer;
36 | private int mShaderProgram = -1;
37 | private float[] transformMatrix = new float[16];
38 |
39 | private EGL10 mEgl = null;
40 | private EGLDisplay mEGLDisplay = EGL10.EGL_NO_DISPLAY;
41 | private EGLContext mEGLContext = EGL10.EGL_NO_CONTEXT;
42 | private EGLConfig[] mEGLConfig = new EGLConfig[1];
43 | private EGLSurface mEglSurface;
44 |
45 | private static final int MSG_INIT = 1;
46 | private static final int MSG_RENDER = 2;
47 | private static final int MSG_DEINIT = 3;
48 | private SurfaceTexture mOESSurfaceTexture;
49 |
50 | public void init(TextureView textureView, int oesTextureId, Context context) {
51 | mContext = context;
52 | mTextureView = textureView;
53 | mOESTextureId = oesTextureId;
54 | mHandlerThread = new HandlerThread("Renderer Thread");
55 | mHandlerThread.start();
56 | mHandler = new Handler(mHandlerThread.getLooper()){
57 | @Override
58 | public void handleMessage(Message msg) {
59 | switch (msg.what) {
60 | case MSG_INIT:
61 | initEGL();
62 | return;
63 | case MSG_RENDER:
64 | drawFrame();
65 | return;
66 | case MSG_DEINIT:
67 | return;
68 | default:
69 | return;
70 | }
71 | }
72 | };
73 | mHandler.sendEmptyMessage(MSG_INIT);
74 | }
75 |
76 | private void initEGL() {
77 | mEgl = (EGL10) EGLContext.getEGL();
78 |
79 | //获取显示设备
80 | mEGLDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
81 | if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) {
82 | throw new RuntimeException("eglGetDisplay failed! " + mEgl.eglGetError());
83 | }
84 |
85 | //version中存放EGL版本号
86 | int[] version = new int[2];
87 |
88 | //初始化EGL
89 | if (!mEgl.eglInitialize(mEGLDisplay, version)) {
90 | throw new RuntimeException("eglInitialize failed! " + mEgl.eglGetError());
91 | }
92 |
93 | //构造需要的配置列表
94 | int[] attributes = {
95 | EGL10.EGL_RED_SIZE, 8,
96 | EGL10.EGL_GREEN_SIZE,8,
97 | EGL10.EGL_BLUE_SIZE, 8,
98 | EGL10.EGL_ALPHA_SIZE, 8,
99 | EGL10.EGL_BUFFER_SIZE, 32,
100 | EGL10.EGL_RENDERABLE_TYPE, 4,
101 | EGL10.EGL_SURFACE_TYPE, EGL10.EGL_WINDOW_BIT,
102 | EGL10.EGL_NONE
103 | };
104 | int[] configsNum = new int[1];
105 |
106 | //EGL选择配置
107 | if (!mEgl.eglChooseConfig(mEGLDisplay, attributes, mEGLConfig, 1, configsNum)) {
108 | throw new RuntimeException("eglChooseConfig failed! " + mEgl.eglGetError());
109 | }
110 | SurfaceTexture surfaceTexture = mTextureView.getSurfaceTexture();
111 | if (surfaceTexture == null)
112 | return;
113 |
114 | //创建EGL显示窗口
115 | mEglSurface = mEgl.eglCreateWindowSurface(mEGLDisplay, mEGLConfig[0], surfaceTexture, null);
116 |
117 | //创建上下文
118 | int[] contextAttribs = {
119 | EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
120 | EGL10.EGL_NONE
121 | };
122 | mEGLContext = mEgl.eglCreateContext(mEGLDisplay, mEGLConfig[0], EGL10.EGL_NO_CONTEXT, contextAttribs);
123 |
124 | if (mEGLDisplay == EGL10.EGL_NO_DISPLAY || mEGLContext == EGL10.EGL_NO_CONTEXT){
125 | throw new RuntimeException("eglCreateContext fail failed! " + mEgl.eglGetError());
126 | }
127 |
128 | if (!mEgl.eglMakeCurrent(mEGLDisplay,mEglSurface, mEglSurface, mEGLContext)) {
129 | throw new RuntimeException("eglMakeCurrent failed! " + mEgl.eglGetError());
130 | }
131 |
132 | mFilterEngine = new FilterEngine(mOESTextureId, mContext);
133 | mDataBuffer = mFilterEngine.getBuffer();
134 | mShaderProgram = mFilterEngine.getShaderProgram();
135 | }
136 |
137 | private void drawFrame() {
138 | long t1, t2;
139 | t1 = System.currentTimeMillis();
140 | if (mOESSurfaceTexture != null) {
141 | mOESSurfaceTexture.updateTexImage();
142 | mOESSurfaceTexture.getTransformMatrix(transformMatrix);
143 | }
144 | mEgl.eglMakeCurrent(mEGLDisplay, mEglSurface, mEglSurface, mEGLContext);
145 | GLES20.glViewport(0,0,mTextureView.getWidth(),mTextureView.getHeight());
146 | GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
147 | GLES20.glClearColor(1f, 1f, 0f, 0f);
148 | mFilterEngine.drawTexture(transformMatrix);
149 | mEgl.eglSwapBuffers(mEGLDisplay, mEglSurface);
150 | t2 = System.currentTimeMillis();
151 | Log.i(TAG, "drawFrame: time = " + (t2 - t1));
152 | }
153 |
154 | @Override
155 | public void onFrameAvailable(SurfaceTexture surfaceTexture) {
156 | if (mHandler != null) {
157 | mHandler.sendEmptyMessage(MSG_RENDER);
158 | }
159 | }
160 |
161 | public SurfaceTexture initOESTexture() {
162 | mOESSurfaceTexture = new SurfaceTexture(mOESTextureId);
163 | mOESSurfaceTexture.setOnFrameAvailableListener(this);
164 | return mOESSurfaceTexture;
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1TextureView/CameraV1TextureViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed.CameraV1TextureView;
2 |
3 | import android.app.Activity;
4 | import android.content.pm.ActivityInfo;
5 | import android.graphics.SurfaceTexture;
6 | import android.hardware.Camera;
7 | import android.os.Bundle;
8 | import android.support.annotation.Nullable;
9 | import android.util.DisplayMetrics;
10 | import android.view.TextureView;
11 | import android.view.Window;
12 | import android.view.WindowManager;
13 |
14 | import com.liubing.filtertestbed.CameraV1;
15 | import com.liubing.filtertestbed.Utils;
16 |
17 | /**
18 | * Created by lb6905 on 2017/6/28.
19 | */
20 |
21 | public class CameraV1TextureViewActivity extends Activity {
22 | private static final String TAG = "Filter_TVActivity";
23 | private TextureView mTextureView;
24 | private int mCameraId;
25 | private CameraV1 mCamera;
26 | private SurfaceTexture mOESSurfaceTexture;
27 | private int mOESTextureId = -1;
28 | private CameraV1GLRenderer mRenderer;
29 |
30 | @Override
31 | protected void onCreate(@Nullable Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 |
34 | //设置全屏无状态栏,并竖屏显示
35 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
36 | requestWindowFeature(Window.FEATURE_NO_TITLE);
37 | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
38 |
39 | mTextureView = new TextureView(this);
40 | mTextureView.setSurfaceTextureListener(mTextureListener);
41 | //设置隐藏虚拟按键
42 | //mTextureView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
43 | mRenderer = new CameraV1GLRenderer();
44 | setContentView(mTextureView);
45 | }
46 |
47 | public TextureView.SurfaceTextureListener mTextureListener = new TextureView.SurfaceTextureListener() {
48 | @Override
49 | public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
50 | mOESTextureId = Utils.createOESTextureObject();
51 | mRenderer.init(mTextureView, mOESTextureId, CameraV1TextureViewActivity.this);
52 | mOESSurfaceTexture = mRenderer.initOESTexture();
53 |
54 | mCameraId = Camera.CameraInfo.CAMERA_FACING_BACK;
55 | DisplayMetrics dm = new DisplayMetrics();
56 | mCamera = new CameraV1(CameraV1TextureViewActivity.this);
57 | if (!mCamera.openCamera(dm.widthPixels, dm.heightPixels, mCameraId)) {
58 | return;
59 | }
60 |
61 | mCamera.setPreviewTexture(mOESSurfaceTexture);
62 | mCamera.startPreview();
63 | }
64 |
65 | @Override
66 | public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
67 | }
68 |
69 | @Override
70 | public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
71 | if (mCamera != null) {
72 | mCamera.stopPreview();
73 | mCamera.releaseCamera();
74 | mCamera = null;
75 | }
76 | return true;
77 | }
78 |
79 | @Override
80 | public void onSurfaceTextureUpdated(SurfaceTexture surface) {
81 | }
82 | };
83 |
84 | @Override
85 | protected void onPause() {
86 | super.onPause();
87 | if (mCamera != null) {
88 | mCamera.stopPreview();
89 | mCamera.releaseCamera();
90 | mCamera = null;
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed;
2 |
3 | import android.Manifest;
4 | import android.app.Activity;
5 | import android.content.Context;
6 | import android.content.pm.PackageManager;
7 | import android.graphics.SurfaceTexture;
8 | import android.hardware.camera2.CameraAccessException;
9 | import android.hardware.camera2.CameraCaptureSession;
10 | import android.hardware.camera2.CameraCharacteristics;
11 | import android.hardware.camera2.CameraDevice;
12 | import android.hardware.camera2.CameraManager;
13 | import android.hardware.camera2.CaptureRequest;
14 | import android.hardware.camera2.params.StreamConfigurationMap;
15 | import android.os.Handler;
16 | import android.os.HandlerThread;
17 | import android.support.annotation.NonNull;
18 | import android.support.v4.app.ActivityCompat;
19 | import android.util.Log;
20 | import android.util.Size;
21 | import android.view.Surface;
22 |
23 | import java.util.ArrayList;
24 | import java.util.Arrays;
25 | import java.util.Collections;
26 | import java.util.Comparator;
27 | import java.util.List;
28 |
29 | /**
30 | * Created by lb6905 on 2017/7/20.
31 | */
32 |
33 | public class CameraV2 {
34 |
35 | public static final String TAG = "Filter_CameraV2";
36 |
37 | private Activity mActivity;
38 | private CameraDevice mCameraDevice;
39 | private String mCameraId;
40 | private Size mPreviewSize;
41 | private HandlerThread mCameraThread;
42 | private Handler mCameraHandler;
43 | private SurfaceTexture mSurfaceTexture;
44 | private CaptureRequest.Builder mCaptureRequestBuilder;
45 | private CaptureRequest mCaptureRequest;
46 | private CameraCaptureSession mCameraCaptureSession;
47 |
48 | public CameraV2(Activity activity) {
49 | mActivity = activity;
50 | startCameraThread();
51 | }
52 |
53 | public String setupCamera(int width, int height) {
54 | CameraManager cameraManager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
55 | try {
56 | for (String id : cameraManager.getCameraIdList()) {
57 | CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(id);
58 | if (characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT) {
59 | continue;
60 | }
61 | StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
62 | mPreviewSize = getOptimalSize(map.getOutputSizes(SurfaceTexture.class), width, height);
63 | mCameraId = id;
64 | Log.i(TAG, "preview width = " + mPreviewSize.getWidth() + ", height = " + mPreviewSize.getHeight() + ", cameraId = " + mCameraId);
65 | }
66 | } catch (CameraAccessException e) {
67 | e.printStackTrace();
68 | }
69 | return mCameraId;
70 | }
71 |
72 | public void startCameraThread() {
73 | mCameraThread = new HandlerThread("CameraThread");
74 | mCameraThread.start();
75 | mCameraHandler = new Handler(mCameraThread.getLooper());
76 | }
77 |
78 | public boolean openCamera() {
79 | CameraManager cameraManager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
80 | try {
81 | if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
82 | return false;
83 | }
84 | cameraManager.openCamera(mCameraId, mStateCallback, mCameraHandler);
85 | } catch (CameraAccessException e) {
86 | e.printStackTrace();
87 | return false;
88 | }
89 | return true;
90 | }
91 |
92 | public CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() {
93 | @Override
94 | public void onOpened(@NonNull CameraDevice camera) {
95 | mCameraDevice = camera;
96 | }
97 |
98 | @Override
99 | public void onDisconnected(@NonNull CameraDevice camera) {
100 | camera.close();
101 | mCameraDevice = null;
102 | }
103 |
104 | @Override
105 | public void onError(@NonNull CameraDevice camera, int error) {
106 | camera.close();
107 | mCameraDevice = null;
108 | }
109 | };
110 |
111 | private Size getOptimalSize(Size[] sizeMap, int width, int height) {
112 | List sizeList = new ArrayList<>();
113 | for (Size option : sizeMap) {
114 | if (width > height) {
115 | if (option.getWidth() > width && option.getHeight() > height) {
116 | sizeList.add(option);
117 | }
118 | } else {
119 | if (option.getWidth() > height && option.getHeight() > width) {
120 | sizeList.add(option);
121 | }
122 | }
123 | }
124 | if (sizeList.size() > 0) {
125 | return Collections.min(sizeList, new Comparator() {
126 | @Override
127 | public int compare(Size lhs, Size rhs) {
128 | return Long.signum(lhs.getWidth() * lhs.getHeight() - rhs.getWidth() * rhs.getHeight());
129 | }
130 | });
131 | }
132 | return sizeMap[0];
133 | }
134 |
135 | public void setPreviewTexture(SurfaceTexture surfaceTexture) {
136 | mSurfaceTexture = surfaceTexture;
137 | }
138 |
139 | public void startPreview() {
140 | mSurfaceTexture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
141 | Surface surface = new Surface(mSurfaceTexture);
142 | try {
143 | mCaptureRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
144 | mCaptureRequestBuilder.addTarget(surface);
145 | mCameraDevice.createCaptureSession(Arrays.asList(surface), new CameraCaptureSession.StateCallback() {
146 | @Override
147 | public void onConfigured(@NonNull CameraCaptureSession session) {
148 | try {
149 | mCaptureRequest = mCaptureRequestBuilder.build();
150 | mCameraCaptureSession = session;
151 | mCameraCaptureSession.setRepeatingRequest(mCaptureRequest, null, mCameraHandler);
152 | } catch (CameraAccessException e) {
153 | e.printStackTrace();
154 | }
155 | }
156 |
157 | @Override
158 | public void onConfigureFailed(@NonNull CameraCaptureSession session) {
159 |
160 | }
161 | }, mCameraHandler);
162 | } catch (CameraAccessException e) {
163 | e.printStackTrace();
164 | }
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2GLSurfaceView.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed.CameraV2GLSurfaceView;
2 |
3 | import android.content.Context;
4 | import android.opengl.GLSurfaceView;
5 |
6 | import com.liubing.filtertestbed.CameraV1;
7 | import com.liubing.filtertestbed.CameraV2;
8 |
9 | /**
10 | * Created by lb6905 on 2017/7/19.
11 | */
12 |
13 | public class CameraV2GLSurfaceView extends GLSurfaceView {
14 | public static final String TAG = "Filter_CameraV2GLSurfaceView";
15 | private CameraV2Renderer mCameraV2Renderer;
16 |
17 | public void init(CameraV2 camera, boolean isPreviewStarted, Context context) {
18 | setEGLContextClientVersion(2);
19 |
20 | mCameraV2Renderer = new CameraV2Renderer();
21 | mCameraV2Renderer.init(this, camera, isPreviewStarted, context);
22 |
23 | setRenderer(mCameraV2Renderer);
24 | }
25 |
26 | public CameraV2GLSurfaceView(Context context) {
27 | super(context);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2GLSurfaceViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed.CameraV2GLSurfaceView;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.util.DisplayMetrics;
7 |
8 | import com.liubing.filtertestbed.CameraV2;
9 |
10 | /**
11 | * Created by lb6905 on 2017/7/19.
12 | */
13 |
14 | public class CameraV2GLSurfaceViewActivity extends Activity {
15 | private CameraV2GLSurfaceView mCameraV2GLSurfaceView;
16 | private CameraV2 mCamera;
17 |
18 | @Override
19 | protected void onCreate(@Nullable Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 |
22 | mCameraV2GLSurfaceView = new CameraV2GLSurfaceView(this);
23 | DisplayMetrics dm = new DisplayMetrics();
24 | getWindowManager().getDefaultDisplay().getMetrics(dm);
25 | mCamera = new CameraV2(this);
26 | mCamera.setupCamera(dm.widthPixels, dm.heightPixels);
27 | if (!mCamera.openCamera()) {
28 | return;
29 | }
30 | mCameraV2GLSurfaceView.init(mCamera, false, CameraV2GLSurfaceViewActivity.this);
31 | setContentView(mCameraV2GLSurfaceView);
32 | }
33 |
34 | @Override
35 | protected void onResume() {
36 | super.onResume();
37 | }
38 |
39 | @Override
40 | protected void onDestroy() {
41 | super.onDestroy();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2Renderer.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed.CameraV2GLSurfaceView;
2 |
3 | import android.content.Context;
4 | import android.graphics.SurfaceTexture;
5 | import android.opengl.GLES11Ext;
6 | import android.opengl.GLSurfaceView;
7 | import android.util.Log;
8 |
9 | import com.liubing.filtertestbed.CameraV2;
10 | import com.liubing.filtertestbed.FilterEngine;
11 | import com.liubing.filtertestbed.Utils;
12 |
13 | import java.nio.FloatBuffer;
14 |
15 | import javax.microedition.khronos.egl.EGLConfig;
16 | import javax.microedition.khronos.opengles.GL10;
17 |
18 | import static android.opengl.GLES11Ext.GL_TEXTURE_EXTERNAL_OES;
19 | import static android.opengl.GLES20.GL_FLOAT;
20 | import static android.opengl.GLES20.GL_FRAMEBUFFER;
21 | import static android.opengl.GLES20.GL_TRIANGLES;
22 | import static android.opengl.GLES20.glActiveTexture;
23 | import static android.opengl.GLES20.glBindFramebuffer;
24 | import static android.opengl.GLES20.glBindTexture;
25 | import static android.opengl.GLES20.glClearColor;
26 | import static android.opengl.GLES20.glDrawArrays;
27 | import static android.opengl.GLES20.glEnableVertexAttribArray;
28 | import static android.opengl.GLES20.glGenFramebuffers;
29 | import static android.opengl.GLES20.glGetAttribLocation;
30 | import static android.opengl.GLES20.glGetUniformLocation;
31 | import static android.opengl.GLES20.glUniform1i;
32 | import static android.opengl.GLES20.glUniformMatrix4fv;
33 | import static android.opengl.GLES20.glVertexAttribPointer;
34 | import static android.opengl.GLES20.glViewport;
35 |
36 | /**
37 | * Created by lb6905 on 2017/7/19.
38 | */
39 |
40 | public class CameraV2Renderer implements GLSurfaceView.Renderer {
41 |
42 | public static final String TAG = "Filter_CameraV2Renderer";
43 | private Context mContext;
44 | CameraV2GLSurfaceView mCameraV2GLSurfaceView;
45 | CameraV2 mCamera;
46 | boolean bIsPreviewStarted;
47 | private int mOESTextureId = -1;
48 | private SurfaceTexture mSurfaceTexture;
49 | private float[] transformMatrix = new float[16];
50 | private FilterEngine mFilterEngine;
51 | private FloatBuffer mDataBuffer;
52 | private int mShaderProgram = -1;
53 | private int aPositionLocation = -1;
54 | private int aTextureCoordLocation = -1;
55 | private int uTextureMatrixLocation = -1;
56 | private int uTextureSamplerLocation = -1;
57 | private int[] mFBOIds = new int[1];
58 |
59 | public void init(CameraV2GLSurfaceView surfaceView, CameraV2 camera, boolean isPreviewStarted, Context context) {
60 | mContext = context;
61 | mCameraV2GLSurfaceView = surfaceView;
62 | mCamera = camera;
63 | bIsPreviewStarted = isPreviewStarted;
64 | }
65 |
66 | @Override
67 | public void onSurfaceCreated(GL10 gl, EGLConfig config) {
68 | mOESTextureId = Utils.createOESTextureObject();
69 | mFilterEngine = new FilterEngine(mOESTextureId, mContext);
70 | mDataBuffer = mFilterEngine.getBuffer();
71 | mShaderProgram = mFilterEngine.getShaderProgram();
72 | glGenFramebuffers(1, mFBOIds, 0);
73 | glBindFramebuffer(GL_FRAMEBUFFER, mFBOIds[0]);
74 | Log.i(TAG, "onSurfaceCreated: mFBOId: " + mFBOIds[0]);
75 | }
76 |
77 | @Override
78 | public void onSurfaceChanged(GL10 gl, int width, int height) {
79 | glViewport(0, 0, width, height);
80 | Log.i(TAG, "onSurfaceChanged: " + width + ", " + height);
81 | }
82 |
83 | @Override
84 | public void onDrawFrame(GL10 gl) {
85 | Long t1 = System.currentTimeMillis();
86 | if (mSurfaceTexture != null) {
87 | mSurfaceTexture.updateTexImage();
88 | mSurfaceTexture.getTransformMatrix(transformMatrix);
89 | }
90 |
91 | if (!bIsPreviewStarted) {
92 | bIsPreviewStarted = initSurfaceTexture();
93 | bIsPreviewStarted = true;
94 | return;
95 | }
96 |
97 | //glClear(GL_COLOR_BUFFER_BIT);
98 | glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
99 |
100 | aPositionLocation = glGetAttribLocation(mShaderProgram, FilterEngine.POSITION_ATTRIBUTE);
101 | aTextureCoordLocation = glGetAttribLocation(mShaderProgram, FilterEngine.TEXTURE_COORD_ATTRIBUTE);
102 | uTextureMatrixLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_MATRIX_UNIFORM);
103 | uTextureSamplerLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_SAMPLER_UNIFORM);
104 |
105 | glActiveTexture(GL_TEXTURE_EXTERNAL_OES);
106 | glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mOESTextureId);
107 | glUniform1i(uTextureSamplerLocation, 0);
108 | glUniformMatrix4fv(uTextureMatrixLocation, 1, false, transformMatrix, 0);
109 |
110 | if (mDataBuffer != null) {
111 | mDataBuffer.position(0);
112 | glEnableVertexAttribArray(aPositionLocation);
113 | glVertexAttribPointer(aPositionLocation, 2, GL_FLOAT, false, 16, mDataBuffer);
114 |
115 | mDataBuffer.position(2);
116 | glEnableVertexAttribArray(aTextureCoordLocation);
117 | glVertexAttribPointer(aTextureCoordLocation, 2, GL_FLOAT, false, 16, mDataBuffer);
118 | }
119 |
120 | //glDrawElements(GL_TRIANGLE_FAN, 6,GL_UNSIGNED_INT, 0);
121 | //glDrawArrays(GL_TRIANGLE_FAN, 0 , 6);
122 | glDrawArrays(GL_TRIANGLES, 0, 6);
123 | //glDrawArrays(GL_TRIANGLES, 3, 3);
124 | glBindFramebuffer(GL_FRAMEBUFFER, 0);
125 | long t2 = System.currentTimeMillis();
126 | long t = t2 - t1;
127 | Log.i(TAG, "onDrawFrame: time: " + t);
128 | }
129 |
130 | public boolean initSurfaceTexture() {
131 | if (mCamera == null || mCameraV2GLSurfaceView == null) {
132 | Log.i(TAG, "mCamera or mGLSurfaceView is null!");
133 | return false;
134 | }
135 | mSurfaceTexture = new SurfaceTexture(mOESTextureId);
136 | mSurfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
137 | @Override
138 | public void onFrameAvailable(SurfaceTexture surfaceTexture) {
139 | mCameraV2GLSurfaceView.requestRender();
140 | }
141 | });
142 | mCamera.setPreviewTexture(mSurfaceTexture);
143 | mCamera.startPreview();
144 | return true;
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/FilterEngine.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed;
2 |
3 | import android.content.Context;
4 | import android.opengl.GLES11Ext;
5 |
6 | import java.nio.ByteBuffer;
7 | import java.nio.ByteOrder;
8 | import java.nio.FloatBuffer;
9 |
10 | import static android.opengl.GLES11Ext.GL_TEXTURE_EXTERNAL_OES;
11 | import static android.opengl.GLES20.GL_FLOAT;
12 | import static android.opengl.GLES20.GL_FRAGMENT_SHADER;
13 | import static android.opengl.GLES20.GL_TRIANGLES;
14 | import static android.opengl.GLES20.GL_VERTEX_SHADER;
15 | import static android.opengl.GLES20.glActiveTexture;
16 | import static android.opengl.GLES20.glAttachShader;
17 | import static android.opengl.GLES20.glBindTexture;
18 | import static android.opengl.GLES20.glCompileShader;
19 | import static android.opengl.GLES20.glCreateProgram;
20 | import static android.opengl.GLES20.glCreateShader;
21 | import static android.opengl.GLES20.glDrawArrays;
22 | import static android.opengl.GLES20.glEnableVertexAttribArray;
23 | import static android.opengl.GLES20.glGetAttribLocation;
24 | import static android.opengl.GLES20.glGetError;
25 | import static android.opengl.GLES20.glGetUniformLocation;
26 | import static android.opengl.GLES20.glLinkProgram;
27 | import static android.opengl.GLES20.glShaderSource;
28 | import static android.opengl.GLES20.glUniform1i;
29 | import static android.opengl.GLES20.glUniformMatrix4fv;
30 | import static android.opengl.GLES20.glUseProgram;
31 | import static android.opengl.GLES20.glVertexAttribPointer;
32 |
33 | /**
34 | * Created by lb6905 on 2017/6/12.
35 | */
36 |
37 | public class FilterEngine {
38 |
39 | private static FilterEngine filterEngine = null;
40 |
41 | private Context mContext;
42 | private FloatBuffer mBuffer;
43 | private int mOESTextureId = -1;
44 | private int vertexShader = -1;
45 | private int fragmentShader = -1;
46 |
47 | private int mShaderProgram = -1;
48 |
49 | private int aPositionLocation = -1;
50 | private int aTextureCoordLocation = -1;
51 | private int uTextureMatrixLocation = -1;
52 | private int uTextureSamplerLocation = -1;
53 |
54 | public FilterEngine(int OESTextureId, Context context) {
55 | mContext = context;
56 | mOESTextureId = OESTextureId;
57 | mBuffer = createBuffer(vertexData);
58 | vertexShader = loadShader(GL_VERTEX_SHADER, Utils.readShaderFromResource(mContext, R.raw.base_vertex_shader));
59 | fragmentShader = loadShader(GL_FRAGMENT_SHADER, Utils.readShaderFromResource(mContext, R.raw.base_fragment_shader));
60 | mShaderProgram = linkProgram(vertexShader, fragmentShader);
61 | }
62 |
63 | /*public static FilterEngine getInstance() {
64 | if (filterEngine == null) {
65 | synchronized (FilterEngine.class) {
66 | if (filterEngine == null)
67 | filterEngine = new FilterEngine();
68 | }
69 | }
70 | return filterEngine;
71 | }*/
72 |
73 | private static final float[] vertexData = {
74 | 1f, 1f, 1f, 1f,
75 | -1f, 1f, 0f, 1f,
76 | -1f, -1f, 0f, 0f,
77 | 1f, 1f, 1f, 1f,
78 | -1f, -1f, 0f, 0f,
79 | 1f, -1f, 1f, 0f
80 | };
81 |
82 | public static final String POSITION_ATTRIBUTE = "aPosition";
83 | public static final String TEXTURE_COORD_ATTRIBUTE = "aTextureCoordinate";
84 | public static final String TEXTURE_MATRIX_UNIFORM = "uTextureMatrix";
85 | public static final String TEXTURE_SAMPLER_UNIFORM = "uTextureSampler";
86 |
87 | public FloatBuffer createBuffer(float[] vertexData) {
88 | FloatBuffer buffer = ByteBuffer.allocateDirect(vertexData.length * 4)
89 | .order(ByteOrder.nativeOrder())
90 | .asFloatBuffer();
91 | buffer.put(vertexData, 0, vertexData.length).position(0);
92 | return buffer;
93 | }
94 |
95 | public int loadShader(int type, String shaderSource) {
96 | int shader = glCreateShader(type);
97 | if (shader == 0) {
98 | throw new RuntimeException("Create Shader Failed!" + glGetError());
99 | }
100 | glShaderSource(shader, shaderSource);
101 | glCompileShader(shader);
102 | return shader;
103 | }
104 |
105 | public int linkProgram(int verShader, int fragShader) {
106 | int program = glCreateProgram();
107 | if (program == 0) {
108 | throw new RuntimeException("Create Program Failed!" + glGetError());
109 | }
110 | glAttachShader(program, verShader);
111 | glAttachShader(program, fragShader);
112 | glLinkProgram(program);
113 |
114 | glUseProgram(program);
115 | return program;
116 | }
117 |
118 | public void drawTexture(float[] transformMatrix) {
119 | aPositionLocation = glGetAttribLocation(mShaderProgram, FilterEngine.POSITION_ATTRIBUTE);
120 | aTextureCoordLocation = glGetAttribLocation(mShaderProgram, FilterEngine.TEXTURE_COORD_ATTRIBUTE);
121 | uTextureMatrixLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_MATRIX_UNIFORM);
122 | uTextureSamplerLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_SAMPLER_UNIFORM);
123 |
124 | glActiveTexture(GLES20.GL_TEXTURE0);
125 | glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mOESTextureId);
126 | glUniform1i(uTextureSamplerLocation, 0);
127 | glUniformMatrix4fv(uTextureMatrixLocation, 1, false, transformMatrix, 0);
128 |
129 | if (mBuffer != null) {
130 | mBuffer.position(0);
131 | glEnableVertexAttribArray(aPositionLocation);
132 | glVertexAttribPointer(aPositionLocation, 2, GL_FLOAT, false, 16, mBuffer);
133 |
134 | mBuffer.position(2);
135 | glEnableVertexAttribArray(aTextureCoordLocation);
136 | glVertexAttribPointer(aTextureCoordLocation, 2, GL_FLOAT, false, 16, mBuffer);
137 |
138 | glDrawArrays(GL_TRIANGLES, 0, 6);
139 | }
140 | }
141 |
142 | public int getShaderProgram() {
143 | return mShaderProgram;
144 | }
145 |
146 | public FloatBuffer getBuffer() {
147 | return mBuffer;
148 | }
149 |
150 | public int getOESTextureId() {
151 | return mOESTextureId;
152 | }
153 |
154 | public void setOESTextureId(int OESTextureId) {
155 | mOESTextureId = OESTextureId;
156 | }
157 | }
158 |
159 |
--------------------------------------------------------------------------------
/Filter/app/src/main/java/com/liubing/filtertestbed/Utils.java:
--------------------------------------------------------------------------------
1 | package com.liubing.filtertestbed;
2 |
3 | import android.content.Context;
4 | import android.opengl.GLES11Ext;
5 | import android.opengl.GLES20;
6 |
7 | import java.io.BufferedReader;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 | import java.io.InputStreamReader;
11 |
12 | import javax.microedition.khronos.opengles.GL10;
13 |
14 | /**
15 | * Created by lb6905 on 2017/6/28.
16 | */
17 |
18 | public class Utils {
19 |
20 | public static int createOESTextureObject() {
21 | int[] tex = new int[1];
22 | GLES20.glGenTextures(1, tex, 0);
23 | GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, tex[0]);
24 | GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
25 | GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
26 | GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
27 | GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
28 | GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
29 | GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
30 | GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
31 | GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
32 | GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);
33 | return tex[0];
34 | }
35 |
36 | public static String readShaderFromResource(Context context, int resourceId) {
37 | StringBuilder builder = new StringBuilder();
38 | InputStream is = null;
39 | InputStreamReader isr = null;
40 | BufferedReader br = null;
41 | try {
42 | is = context.getResources().openRawResource(resourceId);
43 | isr = new InputStreamReader(is);
44 | br = new BufferedReader(isr);
45 | String line;
46 | while ((line = br.readLine()) != null) {
47 | builder.append(line + "\n");
48 | }
49 | } catch (IOException e) {
50 | e.printStackTrace();
51 | } finally {
52 | try {
53 | if (is != null) {
54 | is.close();
55 | is = null;
56 | }
57 | if (isr != null) {
58 | isr.close();
59 | isr = null;
60 | }
61 | if (br != null) {
62 | br.close();
63 | br = null;
64 | }
65 | } catch (IOException e) {
66 | e.printStackTrace();
67 | }
68 | }
69 | return builder.toString();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Filter/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Filter/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Filter/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Filter/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Filter/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Filter/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Filter/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Filter/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Filter/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Filter/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Filter/app/src/main/res/raw/base_fragment_shader.glsl:
--------------------------------------------------------------------------------
1 | #extension GL_OES_EGL_image_external : require
2 | precision mediump float;
3 | uniform samplerExternalOES uTextureSampler;
4 | varying vec2 vTextureCoord;
5 | void main()
6 | {
7 | vec4 vCameraColor = texture2D(uTextureSampler, vTextureCoord);
8 | float fGrayColor = (0.3*vCameraColor.r + 0.59*vCameraColor.g + 0.11*vCameraColor.b);
9 | gl_FragColor = vec4(fGrayColor, fGrayColor, fGrayColor, 1.0);
10 | }
11 |
--------------------------------------------------------------------------------
/Filter/app/src/main/res/raw/base_vertex_shader.glsl:
--------------------------------------------------------------------------------
1 | attribute vec4 aPosition;
2 | uniform mat4 uTextureMatrix;
3 | attribute vec4 aTextureCoordinate;
4 | varying vec2 vTextureCoord;
5 | void main()
6 | {
7 | vTextureCoord = (uTextureMatrix * aTextureCoordinate).xy;
8 | gl_Position = aPosition;
9 | }
--------------------------------------------------------------------------------
/Filter/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/Filter/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Filter/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/Filter/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FilterTestBed
3 |
4 |
--------------------------------------------------------------------------------
/Filter/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Filter/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/Filter/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/Filter/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/Filter/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Filter/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
7 |
--------------------------------------------------------------------------------
/Filter/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Filter/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/Filter/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/JNIDemo/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/JNIDemo/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/JNIDemo/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.lb6905.jnidemo"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | sourceSets.main {
15 | jniLibs.srcDir 'src/main/libs'
16 | jni.srcDirs = []
17 | }
18 | }
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | }
26 |
27 | dependencies {
28 | compile fileTree(dir: 'libs', include: ['*.jar'])
29 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
30 | exclude group: 'com.android.support', module: 'support-annotations'
31 | })
32 | compile 'com.android.support:appcompat-v7:25.3.1'
33 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
34 | testCompile 'junit:junit:4.12'
35 | }
36 |
--------------------------------------------------------------------------------
/JNIDemo/app/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 E:\ProgramFiles\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 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/java/com/lb6905/jnidemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.lb6905.jnidemo;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.widget.TextView;
6 |
7 | public class MainActivity extends AppCompatActivity {
8 | private TextView mTextView;
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 | mTextView = (TextView) findViewById(R.id.tv_jni);
15 | int[] arr = getArray();
16 | mTextView.setText(stringFromJNI());
17 | JNIReflect();
18 | }
19 |
20 | public native String stringFromJNI();
21 | public native void setArray(int[] array);
22 | public native int[] getArray();
23 | public native void JNIReflect();
24 |
25 | static {
26 | System.loadLibrary("hello-jni");
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/java/com/lb6905/jnidemo/TestClass.java:
--------------------------------------------------------------------------------
1 | package com.lb6905.jnidemo;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * Created by lb6905 on 2017/7/18.
7 | */
8 |
9 | public class TestClass {
10 | private final static String TAG = "TestClass";
11 |
12 | public TestClass(){
13 | Log.i(TAG, "TestClass");
14 | }
15 |
16 | public void test(int index) {
17 | Log.i(TAG, "test : " + index);
18 | }
19 |
20 | public static void testStatic(String str) {
21 | Log.i(TAG, "testStatic : " + str);
22 | }
23 |
24 | public static class InnerClass {
25 | private int num;
26 | public InnerClass() {
27 | Log.i(TAG, "InnerClass");
28 | }
29 |
30 | public void setInt(int n) {
31 | num = n;
32 | Log.i(TAG, "setInt: num = " + num);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/jni/Android.mk:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2009 The Android Open Source Project
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | #
15 | LOCAL_PATH := $(call my-dir)
16 |
17 | include $(CLEAR_VARS)
18 |
19 | LOCAL_MODULE := hello-jni
20 | LOCAL_SRC_FILES := hello-jni.c
21 |
22 | include $(BUILD_SHARED_LIBRARY)
23 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/jni/hello-jni.c:
--------------------------------------------------------------------------------
1 | //
2 | // Created by lb6905 on 2017/6/21.
3 | //
4 | #include
5 | #include
6 |
7 | #ifndef _Included_com_lb6905_jnidemo_MainActivity
8 | #define _Included_com_lb6905_jnidemo_MainActivity
9 |
10 | int lutData[5] = {0,10,12,3,4};
11 |
12 | jstring
13 | Java_com_lb6905_jnidemo_MainActivity_stringFromJNI( JNIEnv* env,
14 | jobject thiz )
15 | {
16 | return (*env)->NewStringUTF(env, "Hello from JNI !");
17 | }
18 |
19 | /*
20 | * Class: com_lb6905_jnidemo_MainActivity
21 | * Method: setArray
22 | * Signature: ([I)V
23 | */
24 | JNIEXPORT void JNICALL Java_com_lb6905_jnidemo_MainActivity_setArray
25 | (JNIEnv *env, jobject thiz, jintArray array)
26 | {
27 |
28 | }
29 |
30 | /*
31 | * Class: com_lb6905_jnidemo_MainActivity
32 | * Method: getArray
33 | * Signature: ()[I
34 | */
35 | JNIEXPORT jintArray JNICALL Java_com_lb6905_jnidemo_MainActivity_getArray
36 | (JNIEnv *env, jobject thiz)
37 | {
38 | jintArray array = (*env)->NewIntArray(env, 5);
39 | (*env)->SetIntArrayRegion(env, array, 0, 5, lutData);
40 | return array;
41 | }
42 |
43 | JNIEXPORT void JNICALL Java_com_lb6905_jnidemo_MainActivity_JNIReflect
44 | (JNIEnv *env, jobject thiz)
45 | {
46 | //实例化Test类
47 | jclass testclass = (*env)->FindClass(env, "com/lb6905/jnidemo/TestClass");
48 | jmethodID testcontruct = (*env)->GetMethodID(env, testclass, "", "()V");
49 | jobject testobject = (*env)->NewObject(env, testclass, testcontruct);
50 |
51 | //调用成员方法
52 | jmethodID test = (*env)->GetMethodID(env, testclass, "test", "(I)V");
53 | (*env)->CallVoidMethod(env, testobject, test, 1);
54 |
55 | //调用静态方法
56 | jmethodID testStatic = (*env)->GetStaticMethodID(env, testclass, "testStatic", "(Ljava/lang/String;)V");
57 | jstring str = (*env)->NewStringUTF(env, "hello world!");
58 | (*env)->CallStaticVoidMethod(env, testclass, testStatic, str);
59 |
60 | //实例化InnerClass子类
61 | jclass innerclass = (*env)->FindClass(env, "com/lb6905/jnidemo/TestClass$InnerClass");
62 | jmethodID innercontruct = (*env)->GetMethodID(env, innerclass, "", "()V");
63 | jobject innerobject = (*env)->NewObject(env, innerclass, innercontruct);
64 |
65 | jmethodID setInt = (*env)->GetMethodID(env, innerclass, "setInt", "(I)V");
66 | (*env)->CallVoidMethod(env, innerobject, setInt, 2);
67 | }
68 | #endif
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/libs/arm64-v8a/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/libs/arm64-v8a/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/libs/armeabi-v7a/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/libs/armeabi-v7a/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/libs/armeabi/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/libs/armeabi/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/libs/mips/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/libs/mips/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/libs/mips64/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/libs/mips64/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/libs/x86/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/libs/x86/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/libs/x86_64/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/libs/x86_64/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/arm64-v8a/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/arm64-v8a/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/arm64-v8a/objs/hello-jni/hello-jni.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/arm64-v8a/objs/hello-jni/hello-jni.o
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/arm64-v8a/objs/hello-jni/hello-jni.o.d:
--------------------------------------------------------------------------------
1 | F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/arm64-v8a/objs/hello-jni/hello-jni.o: \
2 | F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
3 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/armeabi-v7a/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/armeabi-v7a/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o.d:
--------------------------------------------------------------------------------
1 | F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o: \
2 | F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
3 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/armeabi/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/armeabi/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/armeabi/objs/hello-jni/hello-jni.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/armeabi/objs/hello-jni/hello-jni.o
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/armeabi/objs/hello-jni/hello-jni.o.d:
--------------------------------------------------------------------------------
1 | F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/armeabi/objs/hello-jni/hello-jni.o: \
2 | F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
3 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/mips/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/mips/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/mips/objs/hello-jni/hello-jni.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/mips/objs/hello-jni/hello-jni.o
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/mips/objs/hello-jni/hello-jni.o.d:
--------------------------------------------------------------------------------
1 | F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/mips/objs/hello-jni/hello-jni.o: \
2 | F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
3 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/mips64/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/mips64/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/mips64/objs/hello-jni/hello-jni.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/mips64/objs/hello-jni/hello-jni.o
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/mips64/objs/hello-jni/hello-jni.o.d:
--------------------------------------------------------------------------------
1 | F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/mips64/objs/hello-jni/hello-jni.o: \
2 | F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
3 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/x86/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/x86/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/x86/objs/hello-jni/hello-jni.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/x86/objs/hello-jni/hello-jni.o
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/x86/objs/hello-jni/hello-jni.o.d:
--------------------------------------------------------------------------------
1 | F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/x86/objs/hello-jni/hello-jni.o: \
2 | F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
3 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/x86_64/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/x86_64/libhello-jni.so
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/x86_64/objs/hello-jni/hello-jni.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/obj/local/x86_64/objs/hello-jni/hello-jni.o
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/obj/local/x86_64/objs/hello-jni/hello-jni.o.d:
--------------------------------------------------------------------------------
1 | F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/x86_64/objs/hello-jni/hello-jni.o: \
2 | F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
3 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | JNIDemo
3 |
4 |
--------------------------------------------------------------------------------
/JNIDemo/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/JNIDemo/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/JNIDemo/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 | android.useDeprecatedNDK=true
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
--------------------------------------------------------------------------------
/JNIDemo/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/JNIDemo/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/JNIDemo/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jun 21 09:31:24 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
7 |
--------------------------------------------------------------------------------
/JNIDemo/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/JNIDemo/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/JNIDemo/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/OpenGLES/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/OpenGLES/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/OpenGLES/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.lb377463323.opengles"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | compile 'com.android.support:appcompat-v7:25.3.1'
24 | }
25 |
--------------------------------------------------------------------------------
/OpenGLES/app/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 E:\ProgramFiles\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 |
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/java/com/lb377463323/opengles/GLActivity.java:
--------------------------------------------------------------------------------
1 | package com.lb377463323.opengles;
2 |
3 | import android.content.pm.ActivityInfo;
4 | import android.opengl.GLSurfaceView;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.Window;
8 | import android.view.WindowManager;
9 |
10 | public class GLActivity extends AppCompatActivity {
11 | private GLSurfaceView mGLSurfaceView;
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 |
17 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
18 | requestWindowFeature(Window.FEATURE_NO_TITLE);
19 | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
20 |
21 | mGLSurfaceView = new GLSurfaceView(this);
22 | mGLSurfaceView.setEGLContextClientVersion(2);
23 | mGLSurfaceView.setRenderer(new GLRenderer());
24 | setContentView(mGLSurfaceView);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/java/com/lb377463323/opengles/GLRenderer.java:
--------------------------------------------------------------------------------
1 | package com.lb377463323.opengles;
2 |
3 | import android.opengl.GLES20;
4 | import android.opengl.GLSurfaceView;
5 | import android.opengl.Matrix;
6 |
7 | import javax.microedition.khronos.egl.EGLConfig;
8 | import javax.microedition.khronos.opengles.GL10;
9 |
10 | /**
11 | * Created by lb6905 on 2017/6/30.
12 | */
13 |
14 | public class GLRenderer implements GLSurfaceView.Renderer {
15 | private Triangle mTriangle;
16 | private float[] mMVPMatrix = new float[16];
17 | private float[] mProjectMatrix = new float[16];
18 | private float[] mViewMatrix = new float[16];
19 |
20 | @Override
21 | public void onSurfaceCreated(GL10 gl, EGLConfig config) {
22 | GLES20.glClearColor(0, 0, 0, 1);
23 | mTriangle = new Triangle();
24 |
25 | //设置相机位置
26 | Matrix.setLookAtM(mViewMatrix, 0, 0, 0, 3.0f, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
27 | }
28 |
29 | @Override
30 | public void onSurfaceChanged(GL10 gl, int width, int height) {
31 | GLES20.glViewport(0, 0, width, height);
32 | //计算宽高比
33 | float ratio = (float) height / width;
34 | //设置透视投影
35 | Matrix.frustumM(mProjectMatrix, 0, -1, 1, -ratio, ratio, 3, 7);
36 |
37 | //计算变换矩阵
38 | Matrix.multiplyMM(mMVPMatrix, 0, mProjectMatrix, 0, mViewMatrix, 0);
39 | }
40 |
41 | @Override
42 | public void onDrawFrame(GL10 gl) {
43 | GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
44 | mTriangle.draw(mMVPMatrix);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/java/com/lb377463323/opengles/Triangle.java:
--------------------------------------------------------------------------------
1 | package com.lb377463323.opengles;
2 |
3 | import android.opengl.GLES20;
4 |
5 | import java.nio.ByteBuffer;
6 | import java.nio.ByteOrder;
7 | import java.nio.FloatBuffer;
8 |
9 | import static android.opengl.GLES20.GL_FLOAT;
10 |
11 | /**
12 | * Created by lb6905 on 2017/6/30.
13 | */
14 |
15 | public class Triangle {
16 | private FloatBuffer vertexBuffer;
17 |
18 | static final int COORDS_PER_VERTEX = 3;
19 | private final int mProgram;
20 |
21 | private int mPositionHandle;
22 | private int mColorHandle;
23 | private int mMVPMatrixHandle;
24 |
25 | private final int vertexCount = triangleCoords.length;
26 | private final int vertexStride = COORDS_PER_VERTEX * 4;
27 |
28 | /*private final String vertexShaderCode =
29 | "attribute vec4 vPosition;" +
30 | "void main() {" +
31 | " gl_Position = vPosition;" +
32 | "}";*/
33 |
34 | private final String vertexShaderCode =
35 | "uniform mat4 uMVPMatrix;" +
36 | "attribute vec4 vPosition;" +
37 | "void main() {" +
38 | " gl_Position = uMVPMatrix * vPosition;" +
39 | "}";
40 |
41 | private final String fragmentShaderCode =
42 | "precision mediump float;"
43 | + "uniform vec4 vColor;"
44 | + "void main() {"
45 | + " gl_FragColor = vColor;"
46 | + "}";
47 |
48 | static float[] triangleCoords = {
49 | 0.0f, 1.0f, 0.0f,
50 | 0.0f, 0.0f, 0.0f,
51 | 1.0f, 0.0f, 0.0f
52 | };
53 |
54 | float[] color = {0.0f, 1f, 0f, 1.0f};
55 |
56 |
57 | public Triangle() {
58 | ByteBuffer bb = ByteBuffer.allocateDirect(triangleCoords.length * 4);
59 | bb.order(ByteOrder.nativeOrder());
60 |
61 | vertexBuffer = bb.asFloatBuffer();
62 | vertexBuffer.put(triangleCoords);
63 | vertexBuffer.position(0);
64 |
65 | int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode);
66 | int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode);
67 |
68 | mProgram = GLES20.glCreateProgram();
69 | GLES20.glAttachShader(mProgram, vertexShader);
70 | GLES20.glAttachShader(mProgram, fragmentShader);
71 |
72 | GLES20.glLinkProgram(mProgram);
73 | }
74 |
75 | public void draw(float[] mvpMatrix) {
76 | GLES20.glUseProgram(mProgram);
77 |
78 | mPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");
79 |
80 | GLES20.glEnableVertexAttribArray(mPositionHandle);
81 |
82 | GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX,
83 | GL_FLOAT, false, vertexStride, vertexBuffer);
84 |
85 | mColorHandle = GLES20.glGetUniformLocation(mProgram, "vColor");//此方法名若写错,则绘制出来的图形颜色全是默认黑色
86 | GLES20.glUniform4fv(mColorHandle, 1, color, 0);
87 |
88 | mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
89 | GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);
90 |
91 | GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
92 |
93 | GLES20.glDisableVertexAttribArray(mPositionHandle);
94 | }
95 |
96 | public static int loadShader(int type, String shaderCode) {
97 | int shader = GLES20.glCreateShader(type);
98 |
99 | GLES20.glShaderSource(shader, shaderCode);
100 | GLES20.glCompileShader(shader);
101 |
102 | return shader;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/OpenGLES/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/OpenGLES/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/OpenGLES/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/OpenGLES/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/OpenGLES/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/OpenGLES/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/OpenGLES/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/OpenGLES/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/OpenGLES/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/OpenGLES/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | OpenGLES
3 |
4 |
--------------------------------------------------------------------------------
/OpenGLES/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/OpenGLES/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/OpenGLES/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/OpenGLES/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lb377463323/GraphicsTestBed/d938435125c0524673621474b3f026c4c56470b7/OpenGLES/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/OpenGLES/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jul 17 15:58:28 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
7 |
--------------------------------------------------------------------------------
/OpenGLES/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/OpenGLES/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/OpenGLES/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GraphicsTestBed
2 |
3 | 此项目为学习Android Graphics时写的各种Demo,根据目录排放如下,后面整理好会添加一些滤镜处理和OpenGLES进阶Demo。也欢迎大家有合适的Graphic Demo提交进来,最好带有博客讲解。
4 |
5 | - Camera
6 | - CameraV1: 根据Camera第一版API写的
7 | - CameraV2: 根据Camera第二版API写的([Android Camera2教程之打开相机、开启预览、实现PreviewCallback、拍照](http://blog.csdn.net/lb377463323/article/details/52740411))
8 | - JNIDemo
9 | - [Android JNI开发流程](http://blog.csdn.net/lb377463323/article/details/75112049)
10 | - [Android JNI反射调用Java构造方法、成员方法和静态方法](http://blog.csdn.net/lb377463323/article/details/75303125)
11 | - OpenGLES
12 | - [OpenGL ES2.0入门之Android篇(一)——绘制三角形](http://blog.csdn.net/lb377463323/article/details/52136518)
13 | - Filter(此代码包含三个包如下:有三个对应的Activity,在AndroidManifest中取消注释即可运行)
14 | - CameraV1GLSurfaceView:对应博客为 - [Android Camera使用OpenGL ES 2.0和GLSurfaceView对预览进行实时处理(黑白滤镜)](http://blog.csdn.net/lb377463323/article/details/77071054)
15 | - CameraV1TextureView:对应博客为 - [Android Camera使用OpenGL ES 2.0和TextureView对预览进行实时处理(黑白滤镜)](http://blog.csdn.net/lb377463323/article/details/77096652)
16 | - CameraV2GLSurfaceView:对应博客为 - [Android Camera2使用OpenGL ES 2.0和GLSurfaceView对预览进行实时处理(黑白滤镜)](http://blog.csdn.net/lb377463323/article/details/78054892)
17 |
--------------------------------------------------------------------------------