blob: 792a5f2e87d6479ce8a3720c0eeb1fc990648c31 [file] [log] [blame]
Keun young Park88e5d1f2011-12-14 14:01:01 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.tests.getinfo;
18
19import android.content.Context;
20import android.opengl.GLES20;
21import android.opengl.GLSurfaceView;
22import android.util.Log;
23
24import java.util.Scanner;
25import java.util.concurrent.CountDownLatch;
26
27import javax.microedition.khronos.egl.EGLConfig;
28import javax.microedition.khronos.opengles.GL10;
29
30class GLESSurfaceView extends GLSurfaceView {
31 private static final String TAG = "GLESSurfaceView";
32
33 private boolean mUseGL20;
34 CountDownLatch mDone;
35
36 /**
37 *
38 * @param context
39 * @param useGL20 whether to use GLES2.0 API or not inside the view
40 * @param done to notify the completion of the task
41 */
42 public GLESSurfaceView(Context context, boolean useGL20, CountDownLatch done){
43 super(context);
44
45 mUseGL20 = useGL20;
46 mDone = done;
47 if (mUseGL20) {
48 setEGLContextClientVersion(2);
49 }
50 setRenderer(new OpenGLESRenderer());
51 }
52
53 public class OpenGLESRenderer implements GLSurfaceView.Renderer {
54
55 @Override
56 public void onSurfaceCreated(GL10 gl, EGLConfig config) {
57 String extensions;
Nicholas Sauera0de8fd2014-02-19 09:47:08 -080058 String vendor;
59 String renderer;
Keun young Park88e5d1f2011-12-14 14:01:01 -080060 if (mUseGL20) {
61 extensions = GLES20.glGetString(GLES20.GL_EXTENSIONS);
Nicholas Sauera0de8fd2014-02-19 09:47:08 -080062 vendor = GLES20.glGetString(GLES20.GL_VENDOR);
63 renderer = GLES20.glGetString(GLES20.GL_RENDERER);
Keun young Park88e5d1f2011-12-14 14:01:01 -080064 } else {
65 extensions = gl.glGetString(GL10.GL_EXTENSIONS);
Nicholas Sauera0de8fd2014-02-19 09:47:08 -080066 vendor = gl.glGetString(GL10.GL_VENDOR);
67 renderer = gl.glGetString(GL10.GL_RENDERER);
Keun young Park88e5d1f2011-12-14 14:01:01 -080068 }
69 Log.i(TAG, "extensions : " + extensions);
Nicholas Sauera0de8fd2014-02-19 09:47:08 -080070 Log.i(TAG, "vendor : " + vendor);
71 Log.i(TAG, "renderer : " + renderer);
Keun young Park88e5d1f2011-12-14 14:01:01 -080072 Scanner scanner = new Scanner(extensions);
73 scanner.useDelimiter(" ");
Nicholas Sauera0de8fd2014-02-19 09:47:08 -080074 StringBuilder extensionsBuilder = new StringBuilder();
Keun young Park88e5d1f2011-12-14 14:01:01 -080075 StringBuilder builder = new StringBuilder();
76 while (scanner.hasNext()) {
77 String ext = scanner.next();
Nicholas Sauera0de8fd2014-02-19 09:47:08 -080078 extensionsBuilder.append(ext).append(";");
Keun young Park88e5d1f2011-12-14 14:01:01 -080079 if (ext.contains("texture")) {
80 if (ext.contains("compression") || ext.contains("compressed")) {
81 Log.i(TAG, "Compression supported: " + ext);
82 builder.append(ext);
83 builder.append(";");
84 }
85 }
86 }
87
88 DeviceInfoInstrument.addResult(
89 DeviceInfoConstants.OPEN_GL_COMPRESSED_TEXTURE_FORMATS,
90 builder.toString());
Nicholas Sauera0de8fd2014-02-19 09:47:08 -080091 DeviceInfoInstrument.addResult(
92 DeviceInfoConstants.OPEN_GL_EXTENSIONS,
93 extensionsBuilder.toString());
94 DeviceInfoInstrument.addResult(
95 DeviceInfoConstants.GRAPHICS_VENDOR,
96 vendor);
97 DeviceInfoInstrument.addResult(
98 DeviceInfoConstants.GRAPHICS_RENDERER,
99 renderer);
Keun young Park88e5d1f2011-12-14 14:01:01 -0800100
101 mDone.countDown();
102 }
103
104 @Override
105 public void onSurfaceChanged(GL10 gl, int width, int height) {
106
107 }
108
109 @Override
110 public void onDrawFrame(GL10 gl) {
111
112 }
113
114 }
Nicholas Sauera0de8fd2014-02-19 09:47:08 -0800115}