[Android] Greatly clean up the previous commits. Now here is the long list of cleaned up things:

- Spaces -> Tabs | Consistency
- Javadoc everything that was added and not documented.
- Remove duplicated code regarding the adapter that used to reside in DolphinInfoFragment.java. Now it resides in AboutActivity.java without a second duplication of it.
- Properly retrieve all of the contexts in the EGL initialization in EGLHelper.java.
- Remove the attribute EGL_RENDERABLE_TYPE from the pbuffersurface attributes in EGLHelper.java. With this present, the EGL context will always fail to reinitialize if destroyed and attempted to be recreated.
- Break the inner class Limit within GLES2InfoFragment.java, GLES3InfoFragment.java, and GLInfoFragment.java into its own single class. Greatly reduces code duplication.
- Introduce a Type enum into Limit.java (one of the wildly rare cases in Java where an enum is actually an OK solution). Removes duplicated constants from the Java files stated in the previous bullet note.
- Add a copyright comment to the top of EGLHelper.java. Forgot to do this initially, my bad.
- Add some missing override annotations to GLES2InfoFragment.java, GLES3InfoFragment.java, and GLInfoFragment.java.
- Use StringBuilders in the previously mentioned three Java files. This is better than using a String in this instance, as the String object won't have to be recreated multiple times (ala concatenation).
- Fix some constant accessors in the previously mentioned three Java files.
- Added the 'final' modifier to the above three classes and to Limit.java. These classes serve a single purpose only, and are not intended to be inherited.
This commit is contained in:
Lioncash 2014-01-22 00:41:23 -05:00
parent 7e9b8d18a7
commit 5c4d087e8f
7 changed files with 352 additions and 403 deletions

View File

@ -31,76 +31,76 @@ public final class AboutActivity extends Activity implements TabListener
private ViewPager viewPager;
private EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);
// Represents an item in the multiple About fragments.
public static final class AboutFragmentItem
{
private final String title;
private final String subtitle;
// Represents an item in the multiple About fragments.
public static final class AboutFragmentItem
{
private final String title;
private final String subtitle;
public AboutFragmentItem(String title, String subtitle)
{
this.title = title;
this.subtitle = subtitle;
}
public AboutFragmentItem(String title, String subtitle)
{
this.title = title;
this.subtitle = subtitle;
}
public String getTitle()
{
return title;
}
public String getTitle()
{
return title;
}
public String getSubTitle()
{
return subtitle;
}
}
public String getSubTitle()
{
return subtitle;
}
}
// The adapter that manages the displaying of items in multiple About fragments.
public static final class InfoFragmentAdapter extends ArrayAdapter<AboutFragmentItem>
{
private final Context ctx;
private final int id;
private final List<AboutFragmentItem> items;
// The adapter that manages the displaying of items in multiple About fragments.
public static final class InfoFragmentAdapter extends ArrayAdapter<AboutFragmentItem>
{
private final Context ctx;
private final int id;
private final List<AboutFragmentItem> items;
public InfoFragmentAdapter(Context ctx, int id, List<AboutFragmentItem> items)
{
super(ctx, id, items);
public InfoFragmentAdapter(Context ctx, int id, List<AboutFragmentItem> items)
{
super(ctx, id, items);
this.ctx = ctx;
this.id = id;
this.items = items;
}
this.ctx = ctx;
this.id = id;
this.items = items;
}
@Override
public AboutFragmentItem getItem(int index)
{
return items.get(index);
}
@Override
public AboutFragmentItem getItem(int index)
{
return items.get(index);
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater vi = LayoutInflater.from(ctx);
convertView = vi.inflate(id, parent, false);
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater vi = LayoutInflater.from(ctx);
convertView = vi.inflate(id, parent, false);
}
final AboutFragmentItem item = items.get(position);
if (item != null)
{
TextView title = (TextView) convertView.findViewById(R.id.AboutItemTitle);
TextView subtitle = (TextView) convertView.findViewById(R.id.AboutItemSubTitle);
final AboutFragmentItem item = items.get(position);
if (item != null)
{
TextView title = (TextView) convertView.findViewById(R.id.AboutItemTitle);
TextView subtitle = (TextView) convertView.findViewById(R.id.AboutItemSubTitle);
if (title != null)
title.setText(item.getTitle());
if (title != null)
title.setText(item.getTitle());
if (subtitle != null)
subtitle.setText(item.getSubTitle());
}
if (subtitle != null)
subtitle.setText(item.getSubTitle());
}
return convertView;
}
}
return convertView;
}
}
@Override
protected void onCreate(Bundle savedInstanceState)
@ -193,9 +193,9 @@ public final class AboutActivity extends Activity implements TabListener
else if (position == 3) // GLES 3 or OpenGL (depending on circumstances)
{
if (eglHelper.supportsGLES3())
return new GLES3InfoFragment(); // TODO: Return the GLES 3 fragment in this case (normal case)
return new GLES3InfoFragment();
else
return new GLInfoFragment(); // TODO: Return the OpenGL fragment in this case (GLES3 not supported case)
return new GLInfoFragment(); // GLES3 not supported, but OpenGL is.
}
else if (position == 4) // OpenGL fragment
{

View File

@ -7,20 +7,18 @@
package org.dolphinemu.dolphinemu.about;
import android.app.ListFragment;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.about.AboutActivity.AboutFragmentItem;
import org.dolphinemu.dolphinemu.about.AboutActivity.InfoFragmentAdapter;
import org.dolphinemu.dolphinemu.settings.video.VideoSettingsFragment;
/**
@ -47,75 +45,4 @@ public final class DolphinInfoFragment extends ListFragment
return rootView;
}
// Represents an item in the DolphinInfoFragment.
private static final class AboutFragmentItem
{
private final String title;
private final String subtitle;
public AboutFragmentItem(String title, String subtitle)
{
this.title = title;
this.subtitle = subtitle;
}
public String getTitle()
{
return title;
}
public String getSubTitle()
{
return subtitle;
}
}
// The adapter that manages the displaying of items in this DolphinInfoFragment.
private static final class InfoFragmentAdapter extends ArrayAdapter<AboutFragmentItem>
{
private final Context ctx;
private final int id;
private final List<AboutFragmentItem> items;
public InfoFragmentAdapter(Context ctx, int id, List<AboutFragmentItem> items)
{
super(ctx, id, items);
this.ctx = ctx;
this.id = id;
this.items = items;
}
@Override
public AboutFragmentItem getItem(int index)
{
return items.get(index);
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater vi = LayoutInflater.from(ctx);
convertView = vi.inflate(id, parent, false);
}
final AboutFragmentItem item = items.get(position);
if (item != null)
{
TextView title = (TextView) convertView.findViewById(R.id.AboutItemTitle);
TextView subtitle = (TextView) convertView.findViewById(R.id.AboutItemSubTitle);
if (title != null)
title.setText(item.getTitle());
if (subtitle != null)
subtitle.setText(item.getSubTitle());
}
return convertView;
}
}
}

View File

@ -7,9 +7,7 @@
package org.dolphinemu.dolphinemu.about;
import android.app.ListFragment;
import android.opengl.GLES10;
import android.opengl.GLES20;
import android.opengl.GLES30;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
@ -18,88 +16,67 @@ import android.view.ViewGroup;
import android.widget.ListView;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.about.Limit.Type;
import org.dolphinemu.dolphinemu.utils.EGLHelper;
import java.util.ArrayList;
import java.util.List;
import javax.microedition.khronos.opengles.GL10;
/**
* {@link ListFragment} responsible for displaying
* information relating to OpenGL ES 2.
*/
public final class GLES2InfoFragment extends ListFragment
{
private EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);
public class GLES2InfoFragment extends ListFragment {
private final Limit[] Limits = {
new Limit("Vendor", GLES20.GL_VENDOR, Type.STRING),
new Limit("Version", GLES20.GL_VERSION, Type.STRING),
new Limit("Renderer", GLES20.GL_RENDERER, Type.STRING),
new Limit("GLSL version", GLES20.GL_SHADING_LANGUAGE_VERSION, Type.STRING),
// GLES 2.0 Limits
//new Limit("Aliased Point Size", GLES20.GL_ALIASED_POINT_SIZE_RANGE, Type.INTEGER_RANGE),
//new Limit("Aliased Line Width ", GLES20.GL_ALIASED_LINE_WIDTH_RANGE, Type.INTEGER_RANGE),
new Limit("Max Texture Size", GLES20.GL_MAX_TEXTURE_SIZE, Type.INTEGER),
//new Limit("Viewport Dimensions", GLES20.GL_MAX_VIEWPORT_DIMS, Type.INTEGER_RANGE),
new Limit("Subpixel Bits", GLES20.GL_SUBPIXEL_BITS, Type.INTEGER),
new Limit("Max Vertex Attributes", GLES20.GL_MAX_VERTEX_ATTRIBS, Type.INTEGER),
new Limit("Max Vertex Uniform Vectors", GLES20.GL_MAX_VERTEX_UNIFORM_VECTORS, Type.INTEGER),
new Limit("Max Varying Vectors", GLES20.GL_MAX_VARYING_VECTORS, Type.INTEGER),
new Limit("Max Combined Texture Units", GLES20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, Type.INTEGER),
new Limit("Max Vertex Texture Units", GLES20.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, Type.INTEGER),
new Limit("Max Texture Units", GLES20.GL_MAX_TEXTURE_IMAGE_UNITS, Type.INTEGER),
new Limit("Max Fragment Uniform Vectors", GLES20.GL_MAX_FRAGMENT_UNIFORM_VECTORS, Type.INTEGER),
new Limit("Max Cubemap Texture Size", GLES20.GL_MAX_CUBE_MAP_TEXTURE_SIZE, Type.INTEGER),
new Limit("Shader Binary Formats", GLES20.GL_NUM_SHADER_BINARY_FORMATS, Type.INTEGER),
new Limit("Max Framebuffer Size", GLES20.GL_MAX_RENDERBUFFER_SIZE, Type.INTEGER),
};
private EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();
public static final int TYPE_STRING = 0;
public static final int TYPE_INTEGER = 1;
public static final int TYPE_INTEGER_RANGE = 2;
for (Limit limit : Limits)
{
Log.i("GLES2InfoFragment", "Getting enum " + limit.name);
Input.add(new AboutActivity.AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
}
class Limit
{
public final String name;
public final int glEnum;
public final int type;
// Get extensions manually
String[] extensions = eglHelper.glGetString(GLES20.GL_EXTENSIONS).split(" ");
StringBuilder extensionsBuilder = new StringBuilder();
for (String extension : extensions)
{
extensionsBuilder.append(extension).append('\n');
}
Input.add(new AboutActivity.AboutFragmentItem("OpenGL ES 2.0 Extensions", extensionsBuilder.toString()));
public Limit(String name, int glEnum, int type)
{
this.name = name;
this.glEnum = glEnum;
this.type = type;
}
public String GetValue()
{
if (type == TYPE_INTEGER)
return Integer.toString(eglHelper.glGetInteger(glEnum));
return eglHelper.glGetString(glEnum);
}
}
AboutActivity.InfoFragmentAdapter adapter = new AboutActivity.InfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
rootView.setAdapter(adapter);
private final Limit Limits[] = {
new Limit("Vendor", GL10.GL_VENDOR, TYPE_STRING),
new Limit("Version", GL10.GL_VERSION, TYPE_STRING),
new Limit("Renderer", GL10.GL_RENDERER, TYPE_STRING),
new Limit("GLSL version", GLES20.GL_SHADING_LANGUAGE_VERSION, TYPE_STRING),
// GLES 2.0 Limits
//new Limit("Aliased Point Size", GLES20.GL_ALIASED_POINT_SIZE_RANGE, TYPE_INTEGER_RANGE),
//new Limit("Aliased Line Width ", GLES20.GL_ALIASED_LINE_WIDTH_RANGE, TYPE_INTEGER_RANGE),
new Limit("Max Texture Size", GLES20.GL_MAX_TEXTURE_SIZE, TYPE_INTEGER),
//new Limit("Viewport Dimensions", GLES20.GL_MAX_VIEWPORT_DIMS, TYPE_INTEGER_RANGE),
new Limit("Subpixel Bits", GLES20.GL_SUBPIXEL_BITS, TYPE_INTEGER),
new Limit("Max Vertex Attributes", GLES20.GL_MAX_VERTEX_ATTRIBS, TYPE_INTEGER),
new Limit("Max Vertex Uniform Vectors", GLES20.GL_MAX_VERTEX_UNIFORM_VECTORS, TYPE_INTEGER),
new Limit("Max Varying Vectors", GLES20.GL_MAX_VARYING_VECTORS, TYPE_INTEGER),
new Limit("Max Combined Texture Units", GLES20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, TYPE_INTEGER),
new Limit("Max Vertex Texture Units", GLES20.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, TYPE_INTEGER),
new Limit("Max Texture Units", GLES20.GL_MAX_TEXTURE_IMAGE_UNITS, TYPE_INTEGER),
new Limit("Max Fragment Uniform Vectors", GLES20.GL_MAX_FRAGMENT_UNIFORM_VECTORS, TYPE_INTEGER),
new Limit("Max Cubemap Texture Size", GLES20.GL_MAX_CUBE_MAP_TEXTURE_SIZE, TYPE_INTEGER),
new Limit("Shader Binary Formats", GLES20.GL_NUM_SHADER_BINARY_FORMATS, TYPE_INTEGER),
new Limit("Max Framebuffer Size", GLES20.GL_MAX_RENDERBUFFER_SIZE, TYPE_INTEGER),
};
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();
for(Limit limit : Limits)
{
Log.w("Dolphinemu", "Getting enum " + limit.name);
Input.add(new AboutActivity.AboutFragmentItem(limit.name, limit.GetValue()));
}
// Get extensions manually
String ExtensionsString = eglHelper.glGetString(GLES20.GL_EXTENSIONS);
String Extensions[] = ExtensionsString.split(" ");
String FinalExtensions = "";
for (String Extension : Extensions)
FinalExtensions += Extension + "\n";
Input.add(new AboutActivity.AboutFragmentItem("OpenGL ES 2.0 Extensions", FinalExtensions));
AboutActivity.InfoFragmentAdapter adapter = new AboutActivity.InfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
rootView.setAdapter(adapter);
return rootView;
}
return rootView;
}
}

View File

@ -7,8 +7,6 @@
package org.dolphinemu.dolphinemu.about;
import android.app.ListFragment;
import android.opengl.GLES10;
import android.opengl.GLES20;
import android.opengl.GLES30;
import android.os.Bundle;
import android.util.Log;
@ -17,123 +15,100 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.about.Limit.Type;
import org.dolphinemu.dolphinemu.utils.EGLHelper;
import java.sql.Struct;
import java.util.ArrayList;
import java.util.List;
import javax.microedition.khronos.opengles.GL10;
/**
* {@link ListFragment} responsible for displaying
* information relating to OpenGL ES 3.
*/
public final class GLES3InfoFragment extends ListFragment
{
private EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES3_BIT_KHR);
public class GLES3InfoFragment extends ListFragment {
private final Limit[] Limits = {
new Limit("Vendor", GLES30.GL_VENDOR, Type.STRING),
new Limit("Version", GLES30.GL_VERSION, Type.STRING),
new Limit("Renderer", GLES30.GL_RENDERER, Type.STRING),
new Limit("GLSL version", GLES30.GL_SHADING_LANGUAGE_VERSION, Type.STRING),
// GLES 2.0 Limits
//new Limit("Aliased Point Size", GLES20.GL_ALIASED_POINT_SIZE_RANGE, Type.INTEGER_RANGE),
//new Limit("Aliased Line Width ", GLES20.GL_ALIASED_LINE_WIDTH_RANGE, Type.INTEGER_RANGE),
new Limit("Max Texture Size", GLES30.GL_MAX_TEXTURE_SIZE, Type.INTEGER),
//new Limit("Viewport Dimensions", GLES20.GL_MAX_VIEWPORT_DIMS, Type.INTEGER_RANGE),
new Limit("Subpixel Bits", GLES30.GL_SUBPIXEL_BITS, Type.INTEGER),
new Limit("Max Vertex Attributes", GLES30.GL_MAX_VERTEX_ATTRIBS, Type.INTEGER),
new Limit("Max Vertex Uniform Vectors", GLES30.GL_MAX_VERTEX_UNIFORM_VECTORS, Type.INTEGER),
new Limit("Max Varying Vectors", GLES30.GL_MAX_VARYING_VECTORS, Type.INTEGER),
new Limit("Max Combined Texture Units", GLES30.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, Type.INTEGER),
new Limit("Max Vertex Texture Units", GLES30.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, Type.INTEGER),
new Limit("Max Texture Units", GLES30.GL_MAX_TEXTURE_IMAGE_UNITS, Type.INTEGER),
new Limit("Max Fragment Uniform Vectors", GLES30.GL_MAX_FRAGMENT_UNIFORM_VECTORS, Type.INTEGER),
new Limit("Max Cubemap Texture Size", GLES30.GL_MAX_CUBE_MAP_TEXTURE_SIZE, Type.INTEGER),
new Limit("Shader Binary Formats", GLES30.GL_NUM_SHADER_BINARY_FORMATS, Type.INTEGER),
new Limit("Max Framebuffer Size", GLES30.GL_MAX_RENDERBUFFER_SIZE, Type.INTEGER),
// GLES 3.0 limits
new Limit("Max 3D Texture size", GLES30.GL_MAX_3D_TEXTURE_SIZE, Type.INTEGER),
new Limit("Max Element Vertices", GLES30.GL_MAX_ELEMENTS_VERTICES, Type.INTEGER),
new Limit("Max Element Indices", GLES30.GL_MAX_ELEMENTS_INDICES, Type.INTEGER),
new Limit("Max Draw Buffers", GLES30.GL_MAX_DRAW_BUFFERS, Type.INTEGER),
new Limit("Max Fragment Uniform Components", GLES30.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, Type.INTEGER),
new Limit("Max Vertex Uniform Components", GLES30.GL_MAX_VERTEX_UNIFORM_COMPONENTS, Type.INTEGER),
new Limit("Number of Extensions", GLES30.GL_NUM_EXTENSIONS, Type.INTEGER),
new Limit("Max Array Texture Layers", GLES30.GL_MAX_ARRAY_TEXTURE_LAYERS, Type.INTEGER),
new Limit("Min Program Texel Offset", GLES30.GL_MIN_PROGRAM_TEXEL_OFFSET, Type.INTEGER),
new Limit("Max Program Texel Offset", GLES30.GL_MAX_PROGRAM_TEXEL_OFFSET, Type.INTEGER),
new Limit("Max Varying Components", GLES30.GL_MAX_VARYING_COMPONENTS, Type.INTEGER),
new Limit("Max TF Varying Length", GLES30.GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, Type.INTEGER),
new Limit("Max TF Separate Components", GLES30.GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, Type.INTEGER),
new Limit("Max TF Interleaved Components", GLES30.GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, Type.INTEGER),
new Limit("Max TF Separate Attributes", GLES30.GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, Type.INTEGER),
new Limit("Max Color Attachments", GLES30.GL_MAX_COLOR_ATTACHMENTS, Type.INTEGER),
new Limit("Max Samples", GLES30.GL_MAX_SAMPLES, Type.INTEGER),
new Limit("Max Vertex UBOs", GLES30.GL_MAX_VERTEX_UNIFORM_BLOCKS, Type.INTEGER),
new Limit("Max Fragment UBOs", GLES30.GL_MAX_FRAGMENT_UNIFORM_BLOCKS, Type.INTEGER),
new Limit("Max Combined UBOs", GLES30.GL_MAX_COMBINED_UNIFORM_BLOCKS, Type.INTEGER),
new Limit("Max Uniform Buffer Bindings", GLES30.GL_MAX_UNIFORM_BUFFER_BINDINGS, Type.INTEGER),
new Limit("Max UBO Size", GLES30.GL_MAX_UNIFORM_BLOCK_SIZE, Type.INTEGER),
new Limit("Max Combined Vertex Uniform Components", GLES30.GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, Type.INTEGER),
new Limit("Max Combined Fragment Uniform Components", GLES30.GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, Type.INTEGER),
new Limit("UBO Alignment", GLES30.GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, Type.INTEGER),
new Limit("Max Vertex Output Components", GLES30.GL_MAX_VERTEX_OUTPUT_COMPONENTS, Type.INTEGER),
new Limit("Max Fragment Input Components", GLES30.GL_MAX_FRAGMENT_INPUT_COMPONENTS, Type.INTEGER),
new Limit("Max Server Wait Timeout", GLES30.GL_MAX_SERVER_WAIT_TIMEOUT, Type.INTEGER),
new Limit("Program Binary Formats", GLES30.GL_NUM_PROGRAM_BINARY_FORMATS, Type.INTEGER),
new Limit("Max Element Index", GLES30.GL_MAX_ELEMENT_INDEX, Type.INTEGER),
new Limit("Sample Counts", GLES30.GL_NUM_SAMPLE_COUNTS, Type.INTEGER),
};
private EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES3_BIT_KHR);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();
public static final int TYPE_STRING = 0;
public static final int TYPE_INTEGER = 1;
public static final int TYPE_INTEGER_RANGE = 2;
for (Limit limit : Limits)
{
Log.i("GLES3InfoFragment", "Getting enum " + limit.name);
Input.add(new AboutActivity.AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
}
class Limit
{
public final String name;
public final int glEnum;
public final int type;
// Get extensions manually
int numExtensions = eglHelper.glGetInteger(GLES30.GL_NUM_EXTENSIONS);
StringBuilder extensionsBuilder = new StringBuilder();
for (int i = 0; i < numExtensions; i++)
{
extensionsBuilder.append(eglHelper.glGetStringi(GLES30.GL_EXTENSIONS, i)).append('\n');
}
Input.add(new AboutActivity.AboutFragmentItem("OpenGL ES 3.0 Extensions", extensionsBuilder.toString()));
public Limit(String name, int glEnum, int type)
{
this.name = name;
this.glEnum = glEnum;
this.type = type;
}
public String GetValue()
{
if (type == TYPE_INTEGER)
return Integer.toString(eglHelper.glGetInteger(glEnum));
return eglHelper.glGetString(glEnum);
}
}
AboutActivity.InfoFragmentAdapter adapter = new AboutActivity.InfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
rootView.setAdapter(adapter);
private final Limit Limits[] = {
new Limit("Vendor", GL10.GL_VENDOR, TYPE_STRING),
new Limit("Version", GL10.GL_VERSION, TYPE_STRING),
new Limit("Renderer", GL10.GL_RENDERER, TYPE_STRING),
new Limit("GLSL version", GLES20.GL_SHADING_LANGUAGE_VERSION, TYPE_STRING),
// GLES 2.0 Limits
//new Limit("Aliased Point Size", GLES20.GL_ALIASED_POINT_SIZE_RANGE, TYPE_INTEGER_RANGE),
//new Limit("Aliased Line Width ", GLES20.GL_ALIASED_LINE_WIDTH_RANGE, TYPE_INTEGER_RANGE),
new Limit("Max Texture Size", GLES20.GL_MAX_TEXTURE_SIZE, TYPE_INTEGER),
//new Limit("Viewport Dimensions", GLES20.GL_MAX_VIEWPORT_DIMS, TYPE_INTEGER_RANGE),
new Limit("Subpixel Bits", GLES20.GL_SUBPIXEL_BITS, TYPE_INTEGER),
new Limit("Max Vertex Attributes", GLES20.GL_MAX_VERTEX_ATTRIBS, TYPE_INTEGER),
new Limit("Max Vertex Uniform Vectors", GLES20.GL_MAX_VERTEX_UNIFORM_VECTORS, TYPE_INTEGER),
new Limit("Max Varying Vectors", GLES20.GL_MAX_VARYING_VECTORS, TYPE_INTEGER),
new Limit("Max Combined Texture Units", GLES20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, TYPE_INTEGER),
new Limit("Max Vertex Texture Units", GLES20.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, TYPE_INTEGER),
new Limit("Max Texture Units", GLES20.GL_MAX_TEXTURE_IMAGE_UNITS, TYPE_INTEGER),
new Limit("Max Fragment Uniform Vectors", GLES20.GL_MAX_FRAGMENT_UNIFORM_VECTORS, TYPE_INTEGER),
new Limit("Max Cubemap Texture Size", GLES20.GL_MAX_CUBE_MAP_TEXTURE_SIZE, TYPE_INTEGER),
new Limit("Shader Binary Formats", GLES20.GL_NUM_SHADER_BINARY_FORMATS, TYPE_INTEGER),
new Limit("Max Framebuffer Size", GLES20.GL_MAX_RENDERBUFFER_SIZE, TYPE_INTEGER),
// GLES 3.0 limits
new Limit("Max 3D Texture size", GLES30.GL_MAX_3D_TEXTURE_SIZE, TYPE_INTEGER),
new Limit("Max Element Vertices", GLES30.GL_MAX_ELEMENTS_VERTICES, TYPE_INTEGER),
new Limit("Max Element Indices", GLES30.GL_MAX_ELEMENTS_INDICES, TYPE_INTEGER),
new Limit("Max Draw Buffers", GLES30.GL_MAX_DRAW_BUFFERS, TYPE_INTEGER),
new Limit("Max Fragment Uniform Components", GLES30.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, TYPE_INTEGER),
new Limit("Max Vertex Uniform Components", GLES30.GL_MAX_VERTEX_UNIFORM_COMPONENTS, TYPE_INTEGER),
new Limit("Number of Extensions", GLES30.GL_NUM_EXTENSIONS, TYPE_INTEGER),
new Limit("Max Array Texture Layers", GLES30.GL_MAX_ARRAY_TEXTURE_LAYERS, TYPE_INTEGER),
new Limit("Min Program Texel Offset", GLES30.GL_MIN_PROGRAM_TEXEL_OFFSET, TYPE_INTEGER),
new Limit("Max Program Texel Offset", GLES30.GL_MAX_PROGRAM_TEXEL_OFFSET, TYPE_INTEGER),
new Limit("Max Varying Components", GLES30.GL_MAX_VARYING_COMPONENTS, TYPE_INTEGER),
new Limit("Max TF Varying Length", GLES30.GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, TYPE_INTEGER),
new Limit("Max TF Separate Components", GLES30.GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, TYPE_INTEGER),
new Limit("Max TF Interleaved Components", GLES30.GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, TYPE_INTEGER),
new Limit("Max TF Separate Attributes", GLES30.GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, TYPE_INTEGER),
new Limit("Max Color Attachments", GLES30.GL_MAX_COLOR_ATTACHMENTS, TYPE_INTEGER),
new Limit("Max Samples", GLES30.GL_MAX_SAMPLES, TYPE_INTEGER),
new Limit("Max Vertex UBOs", GLES30.GL_MAX_VERTEX_UNIFORM_BLOCKS, TYPE_INTEGER),
new Limit("Max Fragment UBOs", GLES30.GL_MAX_FRAGMENT_UNIFORM_BLOCKS, TYPE_INTEGER),
new Limit("Max Combined UBOs", GLES30.GL_MAX_COMBINED_UNIFORM_BLOCKS, TYPE_INTEGER),
new Limit("Max Uniform Buffer Bindings", GLES30.GL_MAX_UNIFORM_BUFFER_BINDINGS, TYPE_INTEGER),
new Limit("Max UBO Size", GLES30.GL_MAX_UNIFORM_BLOCK_SIZE, TYPE_INTEGER),
new Limit("Max Combined Vertex Uniform Components", GLES30.GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, TYPE_INTEGER),
new Limit("Max Combined Fragment Uniform Components", GLES30.GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, TYPE_INTEGER),
new Limit("UBO Alignment", GLES30.GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, TYPE_INTEGER),
new Limit("Max Vertex Output Components", GLES30.GL_MAX_VERTEX_OUTPUT_COMPONENTS, TYPE_INTEGER),
new Limit("Max Fragment Input Components", GLES30.GL_MAX_FRAGMENT_INPUT_COMPONENTS, TYPE_INTEGER),
new Limit("Max Server Wait Timeout", GLES30.GL_MAX_SERVER_WAIT_TIMEOUT, TYPE_INTEGER),
new Limit("Program Binary Formats", GLES30.GL_NUM_PROGRAM_BINARY_FORMATS, TYPE_INTEGER),
new Limit("Max Element Index", GLES30.GL_MAX_ELEMENT_INDEX, TYPE_INTEGER),
new Limit("Sample Counts", GLES30.GL_NUM_SAMPLE_COUNTS, TYPE_INTEGER),
};
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();
for(Limit limit : Limits)
{
Log.w("Dolphinemu", "Getting enum " + limit.name);
Input.add(new AboutActivity.AboutFragmentItem(limit.name, limit.GetValue()));
}
// Get extensions manually
int numExtensions = eglHelper.glGetInteger(GLES30.GL_NUM_EXTENSIONS);
String ExtensionsString = "";
for (int indx = 0; indx < numExtensions; ++indx)
ExtensionsString += eglHelper.glGetStringi(GLES10.GL_EXTENSIONS, indx) + "\n";
Input.add(new AboutActivity.AboutFragmentItem("OpenGL ES 3.0 Extensions", ExtensionsString));
AboutActivity.InfoFragmentAdapter adapter = new AboutActivity.InfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
rootView.setAdapter(adapter);
return rootView;
}
return rootView;
}
}

View File

@ -7,7 +7,6 @@
package org.dolphinemu.dolphinemu.about;
import android.app.ListFragment;
import android.opengl.GLES10;
import android.opengl.GLES20;
import android.opengl.GLES30;
import android.os.Bundle;
@ -18,6 +17,7 @@ import android.view.ViewGroup;
import android.widget.ListView;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.about.Limit.Type;
import org.dolphinemu.dolphinemu.utils.EGLHelper;
import java.util.ArrayList;
@ -25,64 +25,46 @@ import java.util.List;
import javax.microedition.khronos.opengles.GL10;
public class GLInfoFragment extends ListFragment {
/**
* {@link ListFragment} responsible for displaying
* information relating to OpenGL.
*/
public final class GLInfoFragment extends ListFragment
{
private EGLHelper eglHelper;
private EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_BIT);
private final Limit[] Limits = {
new Limit("Vendor", GL10.GL_VENDOR, Type.STRING),
new Limit("Version", GL10.GL_VERSION, Type.STRING),
new Limit("Renderer", GL10.GL_RENDERER, Type.STRING),
new Limit("GLSL version", GLES20.GL_SHADING_LANGUAGE_VERSION, Type.STRING),
};
public static final int TYPE_STRING = 0;
public static final int TYPE_INTEGER = 1;
public static final int TYPE_INTEGER_RANGE = 2;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_BIT);
ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();
class Limit
{
public final String name;
public final int glEnum;
public final int type;
for (Limit limit : Limits)
{
Log.i("GLInfoFragment", "Getting enum " + limit.name);
Input.add(new AboutActivity.AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
}
public Limit(String name, int glEnum, int type)
{
this.name = name;
this.glEnum = glEnum;
this.type = type;
}
public String GetValue()
{
if (type == TYPE_INTEGER)
return Integer.toString(eglHelper.glGetInteger(glEnum));
return eglHelper.glGetString(glEnum);
}
}
// Get extensions manually
int numExtensions = eglHelper.glGetInteger(GLES30.GL_NUM_EXTENSIONS);
StringBuilder extensionsBuilder = new StringBuilder();
for (int i = 0; i < numExtensions; i++)
{
extensionsBuilder.append(eglHelper.glGetStringi(GL10.GL_EXTENSIONS, i)).append('\n');
}
Input.add(new AboutActivity.AboutFragmentItem("OpenGL Extensions", extensionsBuilder.toString()));
private final Limit Limits[] = {
new Limit("Vendor", GL10.GL_VENDOR, TYPE_STRING),
new Limit("Version", GL10.GL_VERSION, TYPE_STRING),
new Limit("Renderer", GL10.GL_RENDERER, TYPE_STRING),
new Limit("GLSL version", GLES20.GL_SHADING_LANGUAGE_VERSION, TYPE_STRING),
};
AboutActivity.InfoFragmentAdapter adapter = new AboutActivity.InfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
rootView.setAdapter(adapter);
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();
for(Limit limit : Limits)
{
Log.w("Dolphinemu", "Getting enum " + limit.name);
Input.add(new AboutActivity.AboutFragmentItem(limit.name, limit.GetValue()));
}
// Get extensions manually
int numExtensions = eglHelper.glGetInteger(GLES30.GL_NUM_EXTENSIONS);
String ExtensionsString = "";
for (int indx = 0; indx < numExtensions; ++indx)
ExtensionsString += eglHelper.glGetStringi(GLES10.GL_EXTENSIONS, indx) + "\n";
Input.add(new AboutActivity.AboutFragmentItem("OpenGL Extensions", ExtensionsString));
AboutActivity.InfoFragmentAdapter adapter = new AboutActivity.InfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
rootView.setAdapter(adapter);
return rootView;
}
return rootView;
}
}

View File

@ -0,0 +1,56 @@
package org.dolphinemu.dolphinemu.about;
import org.dolphinemu.dolphinemu.utils.EGLHelper;
final class Limit
{
/**
* Possible types a Limit can be.
*/
enum Type
{
/** Generic string */
STRING,
/** Integer constant */
INTEGER,
/** Range of integers */
INTEGER_RANGE,
}
/** Name of this limit */
public final String name;
/** The GL constant that represents this limit.*/
public final int glEnum;
/** The {@link Type} of this limit. */
public final Type type;
/**
* Constructor
*
* @param name Name of the limit.
* @param glEnum The GL constant that represents this limit.
* @param type The {@link Type} of this limit.
*/
public Limit(String name, int glEnum, Type type)
{
this.name = name;
this.glEnum = glEnum;
this.type = type;
}
/**
* Retrieves the information represented by this limit.
*
* @param context {@link EGLHelper} context to retrieve the limit with.
*
* @return the information represented by this limit.
*/
public String GetValue(EGLHelper context)
{
if (type == Type.INTEGER)
return Integer.toString(context.glGetInteger(glEnum));
return context.glGetString(glEnum);
}
}

View File

@ -1,3 +1,9 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.utils;
import javax.microedition.khronos.egl.EGL10;
@ -216,17 +222,9 @@ public final class EGLHelper
// Detects the specific kind of GL modes that are supported
private boolean detect()
{
// Attributes for a visual in RGBA format with at least 8 bits per color.
int[] attribs = {
EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_NONE
};
// Get total number of configs available.
int[] numConfigs = new int[1];
if (!mEGL.eglChooseConfig(mDisplay, attribs, null, 0, numConfigs))
if (!mEGL.eglGetConfigs(mDisplay, null, 0, numConfigs))
{
Log.e("EGLHelper", "Error retrieving number of EGL configs available.");
return false;
@ -234,7 +232,7 @@ public final class EGLHelper
// Now get all the configurations
mEGLConfigs = new EGLConfig[numConfigs[0]];
if (!mEGL.eglChooseConfig(mDisplay, attribs, mEGLConfigs, mEGLConfigs.length, numConfigs))
if (!mEGL.eglGetConfigs(mDisplay, mEGLConfigs, mEGLConfigs.length, numConfigs))
{
Log.e("EGLHelper", "Error retrieving all EGL configs.");
return false;
@ -266,7 +264,6 @@ public final class EGLHelper
int[] attribs = {
EGL10.EGL_WIDTH, width,
EGL10.EGL_HEIGHT, height,
EGL10.EGL_RENDERABLE_TYPE, renderableType,
EGL10.EGL_NONE
};
@ -282,23 +279,19 @@ public final class EGLHelper
switch (renderableType)
{
case EGL_OPENGL_ES_BIT:
attribs[5] = EGL_OPENGL_ES_BIT;
ctx_attribs[1] = 1;
break;
case EGL_OPENGL_BIT:
attribs[5] = EGL_OPENGL_BIT;
ctx_attribs[0] = EGL10.EGL_NONE;
break;
case EGL_OPENGL_ES3_BIT_KHR:
attribs[5] = EGL_OPENGL_ES3_BIT_KHR;
ctx_attribs[1] = 3;
break;
case EGL_OPENGL_ES2_BIT:
default: // Fall-back to GLES 2.
attribs[5] = EGL_OPENGL_ES2_BIT;
ctx_attribs[1] = 2;
break;
}
@ -309,20 +302,59 @@ public final class EGLHelper
mGL = (GL10) mEGLContext.getGL();
}
public String glGetString(int glEnum)
{
return mGL.glGetString(glEnum);
}
/**
* Simplified call to {@link GL10#glGetString(int)}
* <p>
* Accepts the following constants:
* <ul>
* <li>GL_VENDOR - Company responsible for the GL implementation.</li>
* <li>GL_VERSION - Version or release number.</li>
* <li>GL_RENDERER - Name of the renderer</li>
* <li>GL_SHADING_LANGUAGE_VERSION - Version or release number of the shading language </li>
* </ul>
*
* @param glEnum A symbolic constant within {@link GL10}.
*
* @return the string information represented by {@code glEnum}.
*/
public String glGetString(int glEnum)
{
return mGL.glGetString(glEnum);
}
public String glGetStringi(int glEnum, int index)
{
return GLES30.glGetStringi(glEnum, index);
}
/**
* Simplified call to {@link GLES30#glGetStringi(int, int)}
* <p>
* Accepts the following constants:
* <ul>
* <li>GL_VENDOR - Company responsible for the GL implementation.</li>
* <li>GL_VERSION - Version or release number.</li>
* <li>GL_RENDERER - Name of the renderer</li>
* <li>GL_SHADING_LANGUAGE_VERSION - Version or release number of the shading language </li>
* <li>GL_EXTENSIONS - Extension string supported by the implementation at {@code index}.</li>
* </ul>
*
* @param glEnum A symbolic GL constant
* @param index The index of the string to return.
*
* @return the string information represented by {@code glEnum} and {@code index}.
*/
public String glGetStringi(int glEnum, int index)
{
return GLES30.glGetStringi(glEnum, index);
}
public int glGetInteger(int glEnum)
{
int[] val = new int[1];
mGL.glGetIntegerv(glEnum, val, 0);
return val[0];
}
/**
* Simplified call to {@link GL10#glGetIntegerv(int, int[], int)
*
* @param glEnum A symbolic GL constant.
*
* @return the integer information represented by {@code glEnum}.
*/
public int glGetInteger(int glEnum)
{
int[] val = new int[1];
mGL.glGetIntegerv(glEnum, val, 0);
return val[0];
}
}