Android: Prepare moving EglBase10/EglBase14 from to API to src

BUG=webrtc:7172

Review-Url: https://codereview.webrtc.org/2826063002
Cr-Commit-Position: refs/heads/master@{#17807}
This commit is contained in:
magjed
2017-04-21 01:34:12 -07:00
committed by Commit bot
parent 953f82c422
commit b04646f38b
2 changed files with 29 additions and 4 deletions

View File

@ -80,8 +80,11 @@ public abstract class EglBase {
}; };
// clang-format on // clang-format on
// Create a new context with the specified config attributes, sharing data with sharedContext. /**
// |sharedContext| can be null. * Create a new context with the specified config attributes, sharing data with |sharedContext|.
* If |sharedContext| is null, a root context is created. This function will try to create an EGL
* 1.4 context if possible, and an EGL 1.0 context otherwise.
*/
public static EglBase create(Context sharedContext, int[] configAttributes) { public static EglBase create(Context sharedContext, int[] configAttributes) {
return (EglBase14.isEGL14Supported() return (EglBase14.isEGL14Supported()
&& (sharedContext == null || sharedContext instanceof EglBase14.Context)) && (sharedContext == null || sharedContext instanceof EglBase14.Context))
@ -89,14 +92,36 @@ public abstract class EglBase {
: new EglBase10((EglBase10.Context) sharedContext, configAttributes); : new EglBase10((EglBase10.Context) sharedContext, configAttributes);
} }
/**
* Helper function for creating a plain root context. This function will try to create an EGL 1.4
* context if possible, and an EGL 1.0 context otherwise.
*/
public static EglBase create() { public static EglBase create() {
return create(null, CONFIG_PLAIN); return create(null /* shaderContext */, CONFIG_PLAIN);
} }
/**
* Helper function for creating a plain context, sharing data with |sharedContext|. This function
* will try to create an EGL 1.4 context if possible, and an EGL 1.0 context otherwise.
*/
public static EglBase create(Context sharedContext) { public static EglBase create(Context sharedContext) {
return create(sharedContext, CONFIG_PLAIN); return create(sharedContext, CONFIG_PLAIN);
} }
/**
* Explicitly create a root EGl 1.0 context with the specified config attributes.
*/
public static EglBase createEgl10(int[] configAttributes) {
return new EglBase10(null /* shaderContext */, configAttributes);
}
/**
* Explicitly create a root EGl 1.4 context with the specified config attributes.
*/
public static EglBase createEgl14(int[] configAttributes) {
return new EglBase14(null /* shaderContext */, configAttributes);
}
public abstract void createSurface(Surface surface); public abstract void createSurface(Surface surface);
// Create EGLSurface from the Android SurfaceTexture. // Create EGLSurface from the Android SurfaceTexture.

View File

@ -186,7 +186,7 @@ public class EglRenderer implements VideoRenderer.Callbacks {
// caused trouble on some weird devices. // caused trouble on some weird devices.
if (sharedContext == null) { if (sharedContext == null) {
logD("EglBase10.create context"); logD("EglBase10.create context");
eglBase = new EglBase10(null /* sharedContext */, configAttributes); eglBase = EglBase.createEgl10(configAttributes);
} else { } else {
logD("EglBase.create shared context"); logD("EglBase.create shared context");
eglBase = EglBase.create(sharedContext, configAttributes); eglBase = EglBase.create(sharedContext, configAttributes);