diff options
author | Jorim Jaggi <jjaggi@google.com> | 2016-07-20 15:46:59 +0200 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2016-07-21 13:02:53 +0200 |
commit | ee129dc3b72eea30b620b791a58071af1b0eb0da (patch) | |
tree | 846f604a4003bba7c7f9f3f7c80e497462d98ed9 | |
parent | a3ad146034936de84cf5792d466eedbf6808ae43 (diff) | |
download | libgdx-ee129dc3b72eea30b620b791a58071af1b0eb0da.tar.gz |
Put GPU priority to low for all rendering contexts
Our live wallpapers that use libgdx need to have lower GPU priority
so they don't preempt GPU tasks from the foreground windows. Ideally,
we'd add an option for this but since libgdx is exclusively used for
live wallpapers, we can just set the option statically.
Bug: 29639773
Change-Id: I0f5fae4af7d45267c69e22e31a23e58d0d771bc2
3 files changed, 12 insertions, 3 deletions
diff --git a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceView20.java b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceView20.java index 32ba11f95..ce924e289 100644 --- a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceView20.java +++ b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceView20.java @@ -44,6 +44,9 @@ public class GLSurfaceView20 extends GLSurfaceView { static String TAG = "GL2JNIView";
private static final boolean DEBUG = false;
+ final static int EGL_CONTEXT_PRIORITY_LEVEL_IMG = 0x3100;
+ final static int EGL_CONTEXT_PRIORITY_LOW_IMG = 0x3103;
+
final ResolutionStrategy resolutionStrategy;
static int targetGLESVersion;
@@ -140,7 +143,8 @@ public class GLSurfaceView20 extends GLSurfaceView { public EGLContext createContext (EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
Log.w(TAG, "creating OpenGL ES " + GLSurfaceView20.targetGLESVersion + ".0 context");
checkEglError("Before eglCreateContext "+targetGLESVersion, egl);
- int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, GLSurfaceView20.targetGLESVersion, EGL10.EGL_NONE};
+ int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, GLSurfaceView20.targetGLESVersion,
+ EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_LOW_IMG, EGL10.EGL_NONE};
EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
boolean success = checkEglError("After eglCreateContext "+targetGLESVersion, egl);
diff --git a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceView20API18.java b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceView20API18.java index b1239cea8..84a456a2b 100644 --- a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceView20API18.java +++ b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceView20API18.java @@ -135,7 +135,9 @@ public class GLSurfaceView20API18 extends GLSurfaceViewAPI18 { public EGLContext createContext (EGL10 egl, EGLDisplay display, EGLConfig eglConfig) { Log.w(TAG, "creating OpenGL ES 2.0 context"); checkEglError("Before eglCreateContext", egl); - int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE}; + int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, + GLSurfaceView20.EGL_CONTEXT_PRIORITY_LEVEL_IMG, GLSurfaceView20.EGL_CONTEXT_PRIORITY_LOW_IMG, + EGL10.EGL_NONE}; EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list); checkEglError("After eglCreateContext", egl); return context; diff --git a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceViewAPI18.java b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceViewAPI18.java index dfac62a15..58d130bd6 100644 --- a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceViewAPI18.java +++ b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceViewAPI18.java @@ -778,8 +778,11 @@ public class GLSurfaceViewAPI18 extends SurfaceView implements SurfaceHolder.Cal private int EGL_CONTEXT_CLIENT_VERSION = 0x3098; public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig config) { + final int EGL_CONTEXT_PRIORITY_LEVEL_IMG = 0x3100; + final int EGL_CONTEXT_PRIORITY_LOW_IMG = 0x3103; int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, mEGLContextClientVersion, - EGL10.EGL_NONE }; + GLSurfaceView20.EGL_CONTEXT_PRIORITY_LEVEL_IMG, GLSurfaceView20.EGL_CONTEXT_PRIORITY_LOW_IMG, + EGL10.EGL_NONE}; return egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, mEGLContextClientVersion != 0 ? attrib_list : null); |