xref: /aosp_15_r20/external/angle/src/feature_support_util/feature_support_util.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2018 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // feature_support_util.h: Internal-to-ANGLE header file for feature-support utilities.
8 
9 #ifndef FEATURE_SUPPORT_UTIL_H_
10 #define FEATURE_SUPPORT_UTIL_H_
11 
12 #include "export.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /**************************************************************************************************
19  *
20  * The following is the "version 2" private API for the Android EGL loader:
21  *
22  **************************************************************************************************/
23 
24 // Typedefs for handles:
25 typedef void *RulesHandle;
26 typedef void *SystemInfoHandle;
27 
28 // Callers of the ANGLE feature-support-utility API (e.g. the Android EGL loader) will call this
29 // function in order to determine what version of the API it can use (if any).
30 //
31 // The caller supplies the highest version of the API that it knows about.  If that version is
32 // supported by the feature-support-utility, true is returned and the version isn't changed.  If
33 // the supplied version is higher than supported by the feature-support-utility, true is
34 // returned and the version is changed to the highest supported by the feature-support-utility.
35 // If the supplied version is lower than supported by the feature-support-utility, false is
36 // returned.
37 //
38 // Parameters:
39 //
40 // - versionToUse (IN/OUT) - The application supplies the highest version of the interface that
41 //                           it knows about.  If successful, the output value is either
42 //                           unchanged or is the highest supported by the interface.
43 //
44 ANGLE_EXPORT bool ANGLEGetFeatureSupportUtilAPIVersion(unsigned int *versionToUse);
45 
46 // The Android EGL loader will call this function in order to parse a rules file
47 // and create a set of rules, for which a handle is returned.
48 //
49 // Parameters:
50 // - rulesString   (IN) - Rules-file contents, as a non-zero length, null-terminated char*
51 //                        string
52 // - rulesHandle  (OUT) - Handle to the rules data structure
53 // - rulesVersion (OUT) - Version of the rules data structure (potentially because of schema
54 //                        changes) that should be passed to ANGLEShouldBeUsedForApplication()
55 //
56 // Return value:
57 // - bool - true if no errors, otherwise false
58 //
59 ANGLE_EXPORT bool ANGLEAndroidParseRulesString(const char *rulesString,
60                                                RulesHandle *rulesHandle,
61                                                int *rulesVersion);
62 
63 // The Android EGL loader will call this function in order to obtain a handle to
64 // the SystemInfo struct.
65 //
66 // Parameters:
67 // - systemInfoHandle (OUT) - handle to the SystemInfo structure
68 //
69 // Return value:
70 // - bool - true if no errors, otherwise false
71 //
72 ANGLE_EXPORT bool ANGLEGetSystemInfo(SystemInfoHandle *systemInfoHandle);
73 
74 // The Android EGL loader will call this function in order to add the device's manufacturer and
75 // model to the SystemInfo struct associated with the handle returned by ANGLEGetSystemInfo.
76 //
77 // Parameters:
78 // - deviceMfr   (IN) - Device manufacturer, from the
79 //                      "ro.product.manufacturer"com.google.android" property
80 // - deviceModel (IN) - Device model, from the "ro.product.model"com.google.android" property
81 // - systemInfoHandle (IN) - handle to the SystemInfo structure
82 //
83 // Return value:
84 // - bool - true if no errors, otherwise false
85 //
86 ANGLE_EXPORT bool ANGLEAddDeviceInfoToSystemInfo(const char *deviceMfr,
87                                                  const char *deviceModel,
88                                                  SystemInfoHandle systemInfoHandle);
89 
90 // The Android EGL loader will call this function in order to determine whether
91 // to use ANGLE instead of a native OpenGL-ES (GLES) driver.
92 //
93 // Parameters:
94 // - rulesHandle      (IN) - Handle to the rules data structure
95 // - rulesVersion     (IN) - Version of the rules data structure (potentially because of schema
96 //                           changes) that was passed from AndroidParseRulesFile()
97 // - systemInfoHandle (IN) - Handle to the SystemInfo structure
98 // - appName          (IN) - Java name of the application (e.g. "com.google.android.apps.maps")
99 //
100 // Return value:
101 // - bool - true if Android should use ANGLE for appName, otherwise false (i.e. use the native
102 //          GLES driver)
103 //
104 ANGLE_EXPORT bool ANGLEShouldBeUsedForApplication(const RulesHandle rulesHandle,
105                                                   int rulesVersion,
106                                                   const SystemInfoHandle systemInfoHandle,
107                                                   const char *appName);
108 
109 // The Android EGL loader will call this function in order to free a rules handle.
110 //
111 // Parameters:
112 // - rulesHandle (IN) - Handle to the rules data structure
113 //
114 ANGLE_EXPORT void ANGLEFreeRulesHandle(const RulesHandle rulesHandle);
115 
116 // The Android EGL loader will call this function in order to free a SystemInfo handle.
117 //
118 // Parameters:
119 // - systemInfoHandle (IN) - Handle to the SystemInfo structure
120 //
121 ANGLE_EXPORT void ANGLEFreeSystemInfoHandle(const SystemInfoHandle systemInfoHandle);
122 
123 // The following are internal versions supported by the current  feature-support-utility API.
124 
125 constexpr unsigned int kFeatureVersion_LowestSupported  = 2;
126 constexpr unsigned int kFeatureVersion_HighestSupported = 2;
127 
128 #ifdef __cplusplus
129 }  // extern "C"
130 #endif
131 
132 #endif  // FEATURE_SUPPORT_UTIL_H_
133