Skip to content

Commit a3a0f2f

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "Add another pragma to disable another bunch of warnings." into main
2 parents f44d068 + 5362e82 commit a3a0f2f

17 files changed

Lines changed: 73 additions & 62 deletions

opengl/tools/glgen/gen

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ mkdir out
2222

2323
mkdir -p out/javax/microedition/khronos/opengles
2424
mkdir -p out/com/google/android/gles_jni
25+
mkdir -p out/android/annotation
2526
mkdir -p out/android/app
2627
mkdir -p out/android/graphics
28+
mkdir -p out/android/hardware
2729
mkdir -p out/android/view
2830
mkdir -p out/android/opengl
2931
mkdir -p out/android/content
@@ -34,18 +36,20 @@ mkdir -p out/android/util
3436
echo "package android.graphics;" > out/android/graphics/Canvas.java
3537
echo "public interface Canvas {}" >> out/android/graphics/Canvas.java
3638

39+
echo "package android.annotation; public @interface NonNull {}" > out/android/annotation/NonNull.java
3740
echo "package android.app; import android.content.pm.IPackageManager; public class AppGlobals { public static IPackageManager getPackageManager() { return null;} }" > out/android/app/AppGlobals.java
3841
# echo "package android.content; import android.content.pm.PackageManager; public interface Context { public PackageManager getPackageManager(); }" > out/android/content/Context.java
3942
echo "package android.content.pm; public class ApplicationInfo {public int targetSdkVersion;}" > out/android/content/pm/ApplicationInfo.java
4043
echo "package android.content.pm; public interface IPackageManager {ApplicationInfo getApplicationInfo(java.lang.String packageName, int flags, java.lang.String userId) throws android.os.RemoteException;}" > out/android/content/pm/IPackageManager.java
41-
echo "package android.os; public class Build {public static class VERSION_CODES { public static final int CUPCAKE = 3;}; }" > out/android/os/Build.java
44+
echo "package android.hardware; import android.os.ParcelFileDescriptor; public class SyncFence { public static SyncFence create(ParcelFileDescriptor w) { return null; } public static SyncFence createEmpty() { return null; } }" > out/android/hardware/SyncFence.java
45+
echo "package android.os; public class Build {public static class VERSION_CODES { public static final int CUPCAKE = 0; public static final int R = 0; }; }" > out/android/os/Build.java
46+
echo "package android.os; public class ParcelFileDescriptor { public static ParcelFileDescriptor adoptFd(int fd) { return null; } }" > out/android/os/ParcelFileDescriptor.java
4247
echo "package android.os; public class UserHandle {public static String myUserId() { return \"\"; } }" > out/android/os/UserHandle.java
4348
echo "package android.os; public class RemoteException extends Exception {}" > out/android/os/RemoteException.java
44-
echo "package android.util; public class Log {public static void w(String a, String b) {} public static void e(String a, String b) {}}" > out/android/util/Log.java
49+
echo "package android.util; public class Log {public static void d(String a, String b) {} public static void w(String a, String b) {} public static void e(String a, String b) {}}" > out/android/util/Log.java
4550

4651
echo "package android.opengl; public abstract class EGLObjectHandle { public int getHandle() { return 0; } }" > out/android/opengl/EGLObjectHandle.java
4752

48-
4953
echo "package android.graphics;" > out/android/graphics/SurfaceTexture.java
5054
echo "public interface SurfaceTexture {}" >> out/android/graphics/SurfaceTexture.java
5155
echo "package android.view;" > out/android/view/SurfaceView.java

opengl/tools/glgen/stubs/egl/EGL14Header.java-if

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package android.opengl;
2020

2121
import android.compat.annotation.UnsupportedAppUsage;
2222
import android.graphics.SurfaceTexture;
23+
import android.os.Build;
2324
import android.view.Surface;
2425
import android.view.SurfaceHolder;
2526
import android.view.SurfaceView;

opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// This source file is automatically generated
1818

1919
#pragma GCC diagnostic ignored "-Wunused-variable"
20+
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
2021
#pragma GCC diagnostic ignored "-Wunused-function"
2122

2223
#include "jni.h"

opengl/tools/glgen/stubs/egl/EGL15cHeader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// This source file is automatically generated
1818

1919
#pragma GCC diagnostic ignored "-Wunused-variable"
20+
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
2021
#pragma GCC diagnostic ignored "-Wunused-function"
2122

2223
#include "jni.h"

opengl/tools/glgen/stubs/egl/EGLExtHeader.java-if

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
package android.opengl;
2020

21+
import android.annotation.NonNull;
22+
import android.hardware.SyncFence;
23+
import android.os.ParcelFileDescriptor;
24+
import android.util.Log;
25+
2126
/**
2227
* EGL Extensions
2328
*/
@@ -30,8 +35,44 @@ public class EGLExt {
3035
public static final int EGL_OPENGL_ES3_BIT_KHR = 0x0040;
3136
public static final int EGL_RECORDABLE_ANDROID = 0x3142;
3237

38+
// EGL_ANDROID_native_fence_sync
39+
public static final int EGL_SYNC_NATIVE_FENCE_ANDROID = 0x3144;
40+
public static final int EGL_SYNC_NATIVE_FENCE_FD_ANDROID = 0x3145;
41+
public static final int EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID = 0x3146;
42+
public static final int EGL_NO_NATIVE_FENCE_FD_ANDROID = -1;
43+
3344
native private static void _nativeClassInit();
3445
static {
3546
_nativeClassInit();
3647
}
3748

49+
/**
50+
* Retrieves the SyncFence for an EGLSync created with EGL_SYNC_NATIVE_FENCE_ANDROID
51+
*
52+
* See <a href="https://www.khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_native_fence_sync.txt">
53+
* EGL_ANDROID_native_fence_sync</a> extension for more details
54+
* @param display The EGLDisplay connection
55+
* @param sync The EGLSync to fetch the SyncFence from
56+
* @return A SyncFence representing the native fence.
57+
* * If <sync> is not a valid sync object for <display>,
58+
* an {@link SyncFence#isValid() invalid} SyncFence is returned and an EGL_BAD_PARAMETER
59+
* error is generated.
60+
* * If the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute of <sync> is
61+
* EGL_NO_NATIVE_FENCE_FD_ANDROID, an {@link SyncFence#isValid() invalid} SyncFence is
62+
* returned and an EGL_BAD_PARAMETER error is generated.
63+
* * If <display> does not match the display passed to eglCreateSync
64+
* when <sync> was created, the behaviour is undefined.
65+
*/
66+
public static @NonNull SyncFence eglDupNativeFenceFDANDROID(@NonNull EGLDisplay display,
67+
@NonNull EGLSync sync) {
68+
int fd = eglDupNativeFenceFDANDROIDImpl(display, sync);
69+
Log.d("EGL", "eglDupNativeFence returned " + fd);
70+
if (fd >= 0) {
71+
return SyncFence.create(ParcelFileDescriptor.adoptFd(fd));
72+
} else {
73+
return SyncFence.createEmpty();
74+
}
75+
}
76+
77+
private static native int eglDupNativeFenceFDANDROIDImpl(EGLDisplay display, EGLSync sync);
78+

opengl/tools/glgen/stubs/egl/EGLExtcHeader.cpp

Lines changed: 11 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// This source file is automatically generated
1818

1919
#pragma GCC diagnostic ignored "-Wunused-variable"
20+
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
2021
#pragma GCC diagnostic ignored "-Wunused-function"
2122

2223
#include "jni.h"
@@ -37,25 +38,12 @@
3738
#include <ui/ANativeObjectBase.h>
3839

3940
static jclass egldisplayClass;
40-
static jclass eglcontextClass;
4141
static jclass eglsurfaceClass;
42-
static jclass eglconfigClass;
42+
static jclass eglsyncClass;
4343

4444
static jmethodID egldisplayGetHandleID;
45-
static jmethodID eglcontextGetHandleID;
4645
static jmethodID eglsurfaceGetHandleID;
47-
static jmethodID eglconfigGetHandleID;
48-
49-
static jmethodID egldisplayConstructor;
50-
static jmethodID eglcontextConstructor;
51-
static jmethodID eglsurfaceConstructor;
52-
static jmethodID eglconfigConstructor;
53-
54-
static jobject eglNoContextObject;
55-
static jobject eglNoDisplayObject;
56-
static jobject eglNoSurfaceObject;
57-
58-
46+
static jmethodID eglsyncGetHandleID;
5947

6048
/* Cache method IDs each time the class is loaded. */
6149

@@ -64,37 +52,14 @@ nativeClassInit(JNIEnv *_env, jclass glImplClass)
6452
{
6553
jclass egldisplayClassLocal = _env->FindClass("android/opengl/EGLDisplay");
6654
egldisplayClass = (jclass) _env->NewGlobalRef(egldisplayClassLocal);
67-
jclass eglcontextClassLocal = _env->FindClass("android/opengl/EGLContext");
68-
eglcontextClass = (jclass) _env->NewGlobalRef(eglcontextClassLocal);
6955
jclass eglsurfaceClassLocal = _env->FindClass("android/opengl/EGLSurface");
7056
eglsurfaceClass = (jclass) _env->NewGlobalRef(eglsurfaceClassLocal);
71-
jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig");
72-
eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal);
57+
jclass eglsyncClassLocal = _env->FindClass("android/opengl/EGLSync");
58+
eglsyncClass = (jclass) _env->NewGlobalRef(eglsyncClassLocal);
7359

7460
egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getNativeHandle", "()J");
75-
eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getNativeHandle", "()J");
7661
eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getNativeHandle", "()J");
77-
eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getNativeHandle", "()J");
78-
79-
80-
egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(J)V");
81-
eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(J)V");
82-
eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(J)V");
83-
eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(J)V");
84-
85-
86-
jclass eglClass = _env->FindClass("android/opengl/EGL14");
87-
jfieldID noContextFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_CONTEXT", "Landroid/opengl/EGLContext;");
88-
jobject localeglNoContextObject = _env->GetStaticObjectField(eglClass, noContextFieldID);
89-
eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
90-
91-
jfieldID noDisplayFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_DISPLAY", "Landroid/opengl/EGLDisplay;");
92-
jobject localeglNoDisplayObject = _env->GetStaticObjectField(eglClass, noDisplayFieldID);
93-
eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
94-
95-
jfieldID noSurfaceFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_SURFACE", "Landroid/opengl/EGLSurface;");
96-
jobject localeglNoSurfaceObject = _env->GetStaticObjectField(eglClass, noSurfaceFieldID);
97-
eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
62+
eglsyncGetHandleID = _env->GetMethodID(eglsyncClass, "getNativeHandle", "()J");
9863
}
9964

10065
static void *
@@ -108,24 +73,12 @@ fromEGLHandle(JNIEnv *_env, jmethodID mid, jobject obj) {
10873
return reinterpret_cast<void*>(_env->CallLongMethod(obj, mid));
10974
}
11075

111-
static jobject
112-
toEGLHandle(JNIEnv *_env, jclass cls, jmethodID con, void * handle) {
113-
if (cls == eglcontextClass &&
114-
(EGLContext)handle == EGL_NO_CONTEXT) {
115-
return eglNoContextObject;
116-
}
117-
118-
if (cls == egldisplayClass &&
119-
(EGLDisplay)handle == EGL_NO_DISPLAY) {
120-
return eglNoDisplayObject;
121-
}
122-
123-
if (cls == eglsurfaceClass &&
124-
(EGLSurface)handle == EGL_NO_SURFACE) {
125-
return eglNoSurfaceObject;
126-
}
76+
// TODO: this should be generated from the .spec file, but needs to be renamed and made private
77+
static jint android_eglDupNativeFenceFDANDROID(JNIEnv *env, jobject, jobject dpy, jobject sync) {
78+
EGLDisplay dpy_native = (EGLDisplay)fromEGLHandle(env, egldisplayGetHandleID, dpy);
79+
EGLSync sync_native = (EGLSync)fromEGLHandle(env, eglsyncGetHandleID, sync);
12780

128-
return _env->NewObject(cls, con, reinterpret_cast<jlong>(handle));
81+
return eglDupNativeFenceFDANDROID(dpy_native, sync_native);
12982
}
13083

13184
// --------------------------------------------------------------------------

opengl/tools/glgen/stubs/egl/eglGetDisplay.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public static native EGLDisplay eglGetDisplay(
77
/**
88
* {@hide}
99
*/
10-
@UnsupportedAppUsage
10+
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
1111
public static native EGLDisplay eglGetDisplay(
1212
long display_id
1313
);

opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// This source file is automatically generated
1919

2020
#pragma GCC diagnostic ignored "-Wunused-variable"
21+
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
2122
#pragma GCC diagnostic ignored "-Wunused-function"
2223

2324
#include <GLES/gl.h>

opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// This source file is automatically generated
1919

2020
#pragma GCC diagnostic ignored "-Wunused-variable"
21+
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
2122
#pragma GCC diagnostic ignored "-Wunused-function"
2223

2324
#include <GLES/gl.h>

opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// This source file is automatically generated
1919

2020
#pragma GCC diagnostic ignored "-Wunused-variable"
21+
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
2122
#pragma GCC diagnostic ignored "-Wunused-function"
2223

2324
#include <GLES/gl.h>

0 commit comments

Comments
 (0)