You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
src/api-impl: fix up code style, mainly for code imported from AOSP
used the following (plus manual edits):
`clang-format --style="{BasedOnStyle: LLVM, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: true, ColumnLimit: 0}`
This commit is contained in:
@@ -22,16 +22,18 @@ package android.opengl;
|
||||
*
|
||||
*/
|
||||
public class EGLConfig extends EGLObjectHandle {
|
||||
private EGLConfig(int handle) {
|
||||
super(handle);
|
||||
}
|
||||
private EGLConfig(int handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof EGLConfig)) return false;
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof EGLConfig))
|
||||
return false;
|
||||
|
||||
EGLConfig that = (EGLConfig) o;
|
||||
return getHandle() == that.getHandle();
|
||||
}
|
||||
EGLConfig that = (EGLConfig)o;
|
||||
return getHandle() == that.getHandle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,26 +22,26 @@ package android.opengl;
|
||||
*
|
||||
*/
|
||||
public abstract class EGLObjectHandle {
|
||||
private final int mHandle;
|
||||
private final int mHandle;
|
||||
|
||||
protected EGLObjectHandle(int handle) {
|
||||
mHandle = handle;
|
||||
}
|
||||
protected EGLObjectHandle(int handle) {
|
||||
mHandle = handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the native handle of the wrapped EGL object. This handle can be
|
||||
* cast to the corresponding native type on the native side.
|
||||
*
|
||||
* For example, EGLDisplay dpy = (EGLDisplay)handle;
|
||||
*
|
||||
* @return the native handle of the wrapped EGL object.
|
||||
*/
|
||||
public int getHandle() {
|
||||
return mHandle;
|
||||
}
|
||||
/**
|
||||
* Returns the native handle of the wrapped EGL object. This handle can be
|
||||
* cast to the corresponding native type on the native side.
|
||||
*
|
||||
* For example, EGLDisplay dpy = (EGLDisplay)handle;
|
||||
*
|
||||
* @return the native handle of the wrapped EGL object.
|
||||
*/
|
||||
public int getHandle() {
|
||||
return mHandle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getHandle();
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getHandle();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,25 +1,19 @@
|
||||
package android.opengl;
|
||||
|
||||
import android.util.AttributeSet;
|
||||
import android.content.Context;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLContext;
|
||||
import javax.microedition.khronos.egl.EGL10;
|
||||
import javax.microedition.khronos.egl.EGLDisplay;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import com.google.android.gles_jni.EGLImpl;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import android.view.SurfaceHolder;
|
||||
|
||||
import android.view.Surface;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.View;
|
||||
import com.google.android.gles_jni.EGLImpl;
|
||||
import javax.microedition.khronos.egl.EGL10;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.egl.EGLContext;
|
||||
import javax.microedition.khronos.egl.EGLDisplay;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
public class GLSurfaceView extends View implements SurfaceHolder.Callback { // TODO: have this extend SurfaceView?
|
||||
EGLContextFactory context_factory = new default_ContextFactory();
|
||||
@@ -56,7 +50,7 @@ public class GLSurfaceView extends View implements SurfaceHolder.Callback { // T
|
||||
// TODO: make use of this
|
||||
public void onResume() {}
|
||||
|
||||
public boolean onTouchEvent (MotionEvent event) {
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -64,14 +58,14 @@ public class GLSurfaceView extends View implements SurfaceHolder.Callback { // T
|
||||
config_chooser = chooser;
|
||||
}
|
||||
|
||||
public void setEGLConfigChooser (boolean needDepth) {
|
||||
public void setEGLConfigChooser(boolean needDepth) {
|
||||
config_chooser = new boolean_ConfigChooser(needDepth);
|
||||
}
|
||||
|
||||
public void setEGLConfigChooser(int redSize, int greenSize, int blueSize,
|
||||
int alphaSize, int depthSize, int stencilSize) {
|
||||
// setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize,
|
||||
// blueSize, alphaSize, depthSize, stencilSize));
|
||||
int alphaSize, int depthSize, int stencilSize) {
|
||||
// setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize,
|
||||
// blueSize, alphaSize, depthSize, stencilSize));
|
||||
}
|
||||
|
||||
public void setEGLContextFactory(EGLContextFactory factory) {
|
||||
@@ -91,32 +85,32 @@ public class GLSurfaceView extends View implements SurfaceHolder.Callback { // T
|
||||
private native void native_set_renderer(Renderer renderer, boolean implements_onTouchEvent);
|
||||
|
||||
public void setRenderer(Renderer renderer) {
|
||||
System.out.println("setRenderer("+renderer+") called");
|
||||
System.out.println("setRenderer(" + renderer + ") called");
|
||||
|
||||
boolean implements_onTouchEvent;
|
||||
|
||||
try {
|
||||
Class[] cArg = new Class[1];
|
||||
cArg[0] = MotionEvent.class;
|
||||
implements_onTouchEvent = !( this.getClass().getMethod("onTouchEvent", cArg).getDeclaringClass() == View.class );
|
||||
implements_onTouchEvent = !(this.getClass().getMethod("onTouchEvent", cArg).getDeclaringClass() == View.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
implements_onTouchEvent = false;
|
||||
}
|
||||
|
||||
native_set_renderer(renderer, implements_onTouchEvent);
|
||||
/* checkRenderThreadState();
|
||||
if (mEGLConfigChooser == null) {
|
||||
mEGLConfigChooser = new SimpleEGLConfigChooser(true);
|
||||
}
|
||||
if (mEGLContextFactory == null) {
|
||||
mEGLContextFactory = new DefaultContextFactory();
|
||||
}
|
||||
if (mEGLWindowSurfaceFactory == null) {
|
||||
mEGLWindowSurfaceFactory = new DefaultWindowSurfaceFactory();
|
||||
}
|
||||
mRenderer = renderer;
|
||||
mGLThread = new GLThread(mThisWeakRef);
|
||||
mGLThread.start();*/
|
||||
/* checkRenderThreadState();
|
||||
if (mEGLConfigChooser == null) {
|
||||
mEGLConfigChooser = new SimpleEGLConfigChooser(true);
|
||||
}
|
||||
if (mEGLContextFactory == null) {
|
||||
mEGLContextFactory = new DefaultContextFactory();
|
||||
}
|
||||
if (mEGLWindowSurfaceFactory == null) {
|
||||
mEGLWindowSurfaceFactory = new DefaultWindowSurfaceFactory();
|
||||
}
|
||||
mRenderer = renderer;
|
||||
mGLThread = new GLThread(mThisWeakRef);
|
||||
mGLThread.start();*/
|
||||
}
|
||||
|
||||
public interface Renderer {
|
||||
@@ -126,21 +120,19 @@ public class GLSurfaceView extends View implements SurfaceHolder.Callback { // T
|
||||
}
|
||||
|
||||
private long wrap_EGLConfigChooser_chooseConfig(long egl_display) {
|
||||
if(config_chooser != null) {
|
||||
if (config_chooser != null) {
|
||||
EGLConfig egl_config = config_chooser.chooseConfig(java_egl_wrapper, new EGLDisplay(egl_display));
|
||||
return egl_config.native_egl_config;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new java.lang.NullPointerException("FIXME: EGLConfigChooser is NULL (time to provide a default implementation?)");
|
||||
}
|
||||
}
|
||||
|
||||
private long wrap_EGLContextFactory_createContext(long egl_display, long egl_config) {
|
||||
if(context_factory != null) {
|
||||
if (context_factory != null) {
|
||||
EGLContext egl_context = context_factory.createContext(java_egl_wrapper, new EGLDisplay(egl_display), new EGLConfig(egl_config));
|
||||
return egl_context.native_egl_context;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new java.lang.NullPointerException("FIXME: EGLContextFactory is NULL (time to provide a default implementation?)");
|
||||
}
|
||||
}
|
||||
@@ -153,27 +145,27 @@ public class GLSurfaceView extends View implements SurfaceHolder.Callback { // T
|
||||
private class DummySurfaceHolder implements SurfaceHolder {
|
||||
public void addCallback(Callback callback) {}
|
||||
public void removeCallback(Callback callback) {}
|
||||
public boolean isCreating() {return false;}
|
||||
public boolean isCreating() { return false; }
|
||||
public void setType(int type) {}
|
||||
public void setFixedSize(int width, int height) {}
|
||||
public void setSizeFromLayout() {}
|
||||
public void setFormat(int format) {}
|
||||
public void setKeepScreenOn(boolean screenOn) {}
|
||||
public Canvas lockCanvas() {return null;}
|
||||
public Canvas lockCanvas(Rect dirty) {return null;}
|
||||
public Canvas lockCanvas() { return null; }
|
||||
public Canvas lockCanvas(Rect dirty) { return null; }
|
||||
public void unlockCanvasAndPost(Canvas canvas) {}
|
||||
public Rect getSurfaceFrame() {return null;}
|
||||
public Surface getSurface() {return null;}
|
||||
public Rect getSurfaceFrame() { return null; }
|
||||
public Surface getSurface() { return null; }
|
||||
}
|
||||
|
||||
public SurfaceHolder getHolder() {
|
||||
return (SurfaceHolder) new DummySurfaceHolder();
|
||||
}
|
||||
|
||||
private static class boolean_ConfigChooser implements GLSurfaceView.EGLConfigChooser {
|
||||
private static class boolean_ConfigChooser implements GLSurfaceView.EGLConfigChooser {
|
||||
// TODO - what happens if we actually allow for 16 bits per color?
|
||||
private static int[] config_attribs_no_depth = {EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 0, EGL10.EGL_DEPTH_SIZE, 0, EGL10.EGL_STENCIL_SIZE, 0, EGL10.EGL_NONE};
|
||||
private static int[] config_attribs_depth = {EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 0, EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_STENCIL_SIZE, 0, EGL10.EGL_NONE};
|
||||
private static int[] config_attribs_no_depth = {EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 0, EGL10.EGL_DEPTH_SIZE, 0, EGL10.EGL_STENCIL_SIZE, 0, EGL10.EGL_NONE};
|
||||
private static int[] config_attribs_depth = {EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 0, EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_STENCIL_SIZE, 0, EGL10.EGL_NONE};
|
||||
|
||||
private boolean want_depth;
|
||||
|
||||
@@ -181,28 +173,28 @@ public class GLSurfaceView extends View implements SurfaceHolder.Callback { // T
|
||||
want_depth = depth;
|
||||
}
|
||||
|
||||
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
|
||||
int[] num_config = new int[1];
|
||||
egl.eglChooseConfig(display, want_depth ? config_attribs_depth : config_attribs_no_depth, null, 0, num_config);
|
||||
int numConfigs = num_config[0];
|
||||
if (numConfigs <= 0) {
|
||||
throw new IllegalArgumentException("boolean_ConfigChooser: no configs match");
|
||||
}
|
||||
EGLConfig[] configs = new EGLConfig[numConfigs];
|
||||
egl.eglChooseConfig(display, want_depth ? config_attribs_depth : config_attribs_no_depth, configs, numConfigs, num_config);
|
||||
return configs[0]; // TODO - something smarter here?
|
||||
}
|
||||
}
|
||||
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
|
||||
int[] num_config = new int[1];
|
||||
egl.eglChooseConfig(display, want_depth ? config_attribs_depth : config_attribs_no_depth, null, 0, num_config);
|
||||
int numConfigs = num_config[0];
|
||||
if (numConfigs <= 0) {
|
||||
throw new IllegalArgumentException("boolean_ConfigChooser: no configs match");
|
||||
}
|
||||
EGLConfig[] configs = new EGLConfig[numConfigs];
|
||||
egl.eglChooseConfig(display, want_depth ? config_attribs_depth : config_attribs_no_depth, configs, numConfigs, num_config);
|
||||
return configs[0]; // TODO - something smarter here?
|
||||
}
|
||||
}
|
||||
|
||||
private static class default_ContextFactory implements GLSurfaceView.EGLContextFactory {
|
||||
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
|
||||
return egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, new int[]{EGL10.EGL_CONTEXT_CLIENT_VERSION, 2/*opengl_version*/, EGL10.EGL_NONE});
|
||||
}
|
||||
private static class default_ContextFactory implements GLSurfaceView.EGLContextFactory {
|
||||
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
|
||||
return egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, new int[] {EGL10.EGL_CONTEXT_CLIENT_VERSION, 2 /*opengl_version*/, EGL10.EGL_NONE});
|
||||
}
|
||||
|
||||
public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
|
||||
egl.eglDestroyContext(display, context);
|
||||
}
|
||||
}
|
||||
public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
|
||||
egl.eglDestroyContext(display, context);
|
||||
}
|
||||
}
|
||||
|
||||
// interfaces
|
||||
|
||||
@@ -212,6 +204,6 @@ public class GLSurfaceView extends View implements SurfaceHolder.Callback { // T
|
||||
|
||||
public interface EGLContextFactory {
|
||||
EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig);
|
||||
// void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context);
|
||||
// void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user