M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions

View File

@ -0,0 +1,289 @@
/*
** Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <dlfcn.h>
#include <limits.h>
#include <cutils/log.h>
#include <EGL/egl.h>
#include "hooks.h"
#include "egl_impl.h"
#include "Loader.h"
// ----------------------------------------------------------------------------
namespace android {
// ----------------------------------------------------------------------------
/*
* EGL drivers are called
*
* /system/lib/egl/lib{[EGL|GLESv1_CM|GLESv2] | GLES}_$TAG.so
*
*/
ANDROID_SINGLETON_STATIC_INSTANCE( Loader )
// ----------------------------------------------------------------------------
Loader::driver_t::driver_t(void* gles)
{
dso[0] = gles;
for (size_t i=1 ; i<NELEM(dso) ; i++)
dso[i] = 0;
}
Loader::driver_t::~driver_t()
{
for (size_t i=0 ; i<NELEM(dso) ; i++) {
if (dso[i]) {
dlclose(dso[i]);
dso[i] = 0;
}
}
}
status_t Loader::driver_t::set(void* hnd, int32_t api)
{
switch (api) {
case EGL:
dso[0] = hnd;
break;
case GLESv1_CM:
dso[1] = hnd;
break;
case GLESv2:
dso[2] = hnd;
break;
default:
return BAD_INDEX;
}
return NO_ERROR;
}
// ----------------------------------------------------------------------------
Loader::entry_t::entry_t(int dpy, int impl, const char* tag)
: dpy(dpy), impl(impl), tag(tag) {
}
// ----------------------------------------------------------------------------
Loader::Loader()
{
char line[256];
char tag[256];
FILE* cfg = fopen("/system/lib/egl/egl.cfg", "r");
if (cfg == NULL) {
// default config
LOGD("egl.cfg not found, using default config");
gConfig.add( entry_t(0, 0, "android") );
} else {
while (fgets(line, 256, cfg)) {
int dpy;
int impl;
if (sscanf(line, "%u %u %s", &dpy, &impl, tag) == 3) {
//LOGD(">>> %u %u %s", dpy, impl, tag);
gConfig.add( entry_t(dpy, impl, tag) );
}
}
fclose(cfg);
}
}
Loader::~Loader()
{
}
const char* Loader::getTag(int dpy, int impl)
{
const Vector<entry_t>& cfgs(gConfig);
const size_t c = cfgs.size();
for (size_t i=0 ; i<c ; i++) {
if (dpy == cfgs[i].dpy)
if (impl == cfgs[i].impl)
return cfgs[i].tag.string();
}
return 0;
}
void* Loader::open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx)
{
/*
* TODO: if we don't find display/0, then use 0/0
* (0/0 should always work)
*/
void* dso;
int index = int(display);
driver_t* hnd = 0;
char const* tag = getTag(index, impl);
if (tag) {
dso = load_driver("GLES", tag, cnx, EGL | GLESv1_CM | GLESv2);
if (dso) {
hnd = new driver_t(dso);
} else {
// Always load EGL first
dso = load_driver("EGL", tag, cnx, EGL);
if (dso) {
hnd = new driver_t(dso);
// TODO: make this more automated
hnd->set( load_driver("GLESv1_CM", tag, cnx, GLESv1_CM), GLESv1_CM );
hnd->set( load_driver("GLESv2", tag, cnx, GLESv2), GLESv2 );
}
}
}
LOG_FATAL_IF(!index && !impl && !hnd,
"couldn't find the default OpenGL ES implementation "
"for default display");
return (void*)hnd;
}
status_t Loader::close(void* driver)
{
driver_t* hnd = (driver_t*)driver;
delete hnd;
return NO_ERROR;
}
void Loader::init_api(void* dso,
char const * const * api,
__eglMustCastToProperFunctionPointerType* curr,
getProcAddressType getProcAddress)
{
char scrap[256];
while (*api) {
char const * name = *api;
__eglMustCastToProperFunctionPointerType f =
(__eglMustCastToProperFunctionPointerType)dlsym(dso, name);
if (f == NULL) {
// couldn't find the entry-point, use eglGetProcAddress()
f = getProcAddress(name);
}
if (f == NULL) {
// Try without the OES postfix
ssize_t index = ssize_t(strlen(name)) - 3;
if ((index>0 && (index<255)) && (!strcmp(name+index, "OES"))) {
strncpy(scrap, name, index);
scrap[index] = 0;
f = (__eglMustCastToProperFunctionPointerType)dlsym(dso, scrap);
//LOGD_IF(f, "found <%s> instead", scrap);
}
}
if (f == NULL) {
// Try with the OES postfix
ssize_t index = ssize_t(strlen(name)) - 3;
if ((index>0 && (index<252)) && (strcmp(name+index, "OES"))) {
strncpy(scrap, name, index);
scrap[index] = 0;
strcat(scrap, "OES");
f = (__eglMustCastToProperFunctionPointerType)dlsym(dso, scrap);
//LOGD_IF(f, "found <%s> instead", scrap);
}
}
if (f == NULL) {
//LOGD("%s", name);
f = (__eglMustCastToProperFunctionPointerType)gl_unimplemented;
}
*curr++ = f;
api++;
}
}
void *Loader::load_driver(const char* kind, const char *tag,
egl_connection_t* cnx, uint32_t mask)
{
char driver_absolute_path[PATH_MAX];
const char* const search1 = "/vendor/lib/egl/lib%s_%s.so";
const char* const search2 = "/system/lib/egl/lib%s_%s.so";
snprintf(driver_absolute_path, PATH_MAX, search1, kind, tag);
if (access(driver_absolute_path, R_OK)) {
snprintf(driver_absolute_path, PATH_MAX, search2, kind, tag);
if (access(driver_absolute_path, R_OK)) {
// this happens often, we don't want to log an error
return 0;
}
}
void* dso = dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL);
if (dso == 0) {
const char* err = dlerror();
LOGE("load_driver(%s): %s", driver_absolute_path, err?err:"unknown");
return 0;
}
LOGD("loaded %s", driver_absolute_path);
if (mask & EGL) {
getProcAddress = (getProcAddressType)dlsym(dso, "eglGetProcAddress");
LOGE_IF(!getProcAddress,
"can't find eglGetProcAddress() in %s", driver_absolute_path);
egl_t* egl = &cnx->egl;
__eglMustCastToProperFunctionPointerType* curr =
(__eglMustCastToProperFunctionPointerType*)egl;
char const * const * api = egl_names;
while (*api) {
char const * name = *api;
__eglMustCastToProperFunctionPointerType f =
(__eglMustCastToProperFunctionPointerType)dlsym(dso, name);
if (f == NULL) {
// couldn't find the entry-point, use eglGetProcAddress()
f = getProcAddress(name);
if (f == NULL) {
f = (__eglMustCastToProperFunctionPointerType)0;
}
}
*curr++ = f;
api++;
}
}
if (mask & GLESv1_CM) {
init_api(dso, gl_names,
(__eglMustCastToProperFunctionPointerType*)
&cnx->hooks[GLESv1_INDEX]->gl,
getProcAddress);
}
if (mask & GLESv2) {
init_api(dso, gl_names,
(__eglMustCastToProperFunctionPointerType*)
&cnx->hooks[GLESv2_INDEX]->gl,
getProcAddress);
}
return dso;
}
// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------

View File

@ -0,0 +1,90 @@
/*
** Copyright 2009, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#ifndef ANDROID_EGL_LOADER_H
#define ANDROID_EGL_LOADER_H
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <utils/Errors.h>
#include <utils/Singleton.h>
#include <utils/String8.h>
#include <utils/Vector.h>
#include <EGL/egl.h>
// ----------------------------------------------------------------------------
namespace android {
// ----------------------------------------------------------------------------
struct egl_connection_t;
class Loader : public Singleton<Loader>
{
friend class Singleton<Loader>;
typedef __eglMustCastToProperFunctionPointerType (*getProcAddressType)(
const char*);
enum {
EGL = 0x01,
GLESv1_CM = 0x02,
GLESv2 = 0x04
};
struct driver_t {
driver_t(void* gles);
~driver_t();
status_t set(void* hnd, int32_t api);
void* dso[3];
};
struct entry_t {
entry_t() { }
entry_t(int dpy, int impl, const char* tag);
int dpy;
int impl;
String8 tag;
};
Vector<entry_t> gConfig;
getProcAddressType getProcAddress;
const char* getTag(int dpy, int impl);
public:
~Loader();
void* open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx);
status_t close(void* driver);
private:
Loader();
void *load_driver(const char* kind, const char *tag, egl_connection_t* cnx, uint32_t mask);
static __attribute__((noinline))
void init_api(void* dso,
char const * const * api,
__eglMustCastToProperFunctionPointerType* curr,
getProcAddressType getProcAddress);
};
// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------
#endif /* ANDROID_EGL_LOADER_H */

1865
base/opengl/libs/EGL/egl.cpp Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
EGL_ENTRY(EGLDisplay, eglGetDisplay, NativeDisplayType)
EGL_ENTRY(EGLBoolean, eglInitialize, EGLDisplay, EGLint*, EGLint*)
EGL_ENTRY(EGLBoolean, eglTerminate, EGLDisplay)
EGL_ENTRY(EGLBoolean, eglGetConfigs, EGLDisplay, EGLConfig*, EGLint, EGLint*)
EGL_ENTRY(EGLBoolean, eglChooseConfig, EGLDisplay, const EGLint *, EGLConfig *, EGLint, EGLint *)
EGL_ENTRY(EGLBoolean, eglGetConfigAttrib, EGLDisplay, EGLConfig, EGLint, EGLint *)
EGL_ENTRY(EGLSurface, eglCreateWindowSurface, EGLDisplay, EGLConfig, NativeWindowType, const EGLint *)
EGL_ENTRY(EGLSurface, eglCreatePixmapSurface, EGLDisplay, EGLConfig, NativePixmapType, const EGLint *)
EGL_ENTRY(EGLSurface, eglCreatePbufferSurface, EGLDisplay, EGLConfig, const EGLint *)
EGL_ENTRY(EGLBoolean, eglDestroySurface, EGLDisplay, EGLSurface)
EGL_ENTRY(EGLBoolean, eglQuerySurface, EGLDisplay, EGLSurface, EGLint, EGLint *)
EGL_ENTRY(EGLContext, eglCreateContext, EGLDisplay, EGLConfig, EGLContext, const EGLint *)
EGL_ENTRY(EGLBoolean, eglDestroyContext, EGLDisplay, EGLContext)
EGL_ENTRY(EGLBoolean, eglMakeCurrent, EGLDisplay, EGLSurface, EGLSurface, EGLContext)
EGL_ENTRY(EGLContext, eglGetCurrentContext, void)
EGL_ENTRY(EGLSurface, eglGetCurrentSurface, EGLint)
EGL_ENTRY(EGLDisplay, eglGetCurrentDisplay, void)
EGL_ENTRY(EGLBoolean, eglQueryContext, EGLDisplay, EGLContext, EGLint, EGLint *)
EGL_ENTRY(EGLBoolean, eglWaitGL, void)
EGL_ENTRY(EGLBoolean, eglWaitNative, EGLint)
EGL_ENTRY(EGLBoolean, eglSwapBuffers, EGLDisplay, EGLSurface)
EGL_ENTRY(EGLBoolean, eglCopyBuffers, EGLDisplay, EGLSurface, NativePixmapType)
EGL_ENTRY(EGLint, eglGetError, void)
EGL_ENTRY(const char*, eglQueryString, EGLDisplay, EGLint)
EGL_ENTRY(__eglMustCastToProperFunctionPointerType, eglGetProcAddress, const char *)
/* EGL 1.1 */
EGL_ENTRY(EGLBoolean, eglSurfaceAttrib, EGLDisplay, EGLSurface, EGLint, EGLint)
EGL_ENTRY(EGLBoolean, eglBindTexImage, EGLDisplay, EGLSurface, EGLint)
EGL_ENTRY(EGLBoolean, eglReleaseTexImage, EGLDisplay, EGLSurface, EGLint)
EGL_ENTRY(EGLBoolean, eglSwapInterval, EGLDisplay, EGLint)
/* EGL 1.2 */
EGL_ENTRY(EGLBoolean, eglBindAPI, EGLenum)
EGL_ENTRY(EGLenum, eglQueryAPI, void)
EGL_ENTRY(EGLBoolean, eglWaitClient, void)
EGL_ENTRY(EGLBoolean, eglReleaseThread, void)
EGL_ENTRY(EGLSurface, eglCreatePbufferFromClientBuffer, EGLDisplay, EGLenum, EGLClientBuffer, EGLConfig, const EGLint *)
/* EGL 1.3 */
/* EGL 1.4 */
/* EGL_EGLEXT_VERSION 3 */
EGL_ENTRY(EGLBoolean, eglLockSurfaceKHR, EGLDisplay, EGLSurface, const EGLint *)
EGL_ENTRY(EGLBoolean, eglUnlockSurfaceKHR, EGLDisplay, EGLSurface)
EGL_ENTRY(EGLImageKHR, eglCreateImageKHR, EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint *)
EGL_ENTRY(EGLBoolean, eglDestroyImageKHR, EGLDisplay, EGLImageKHR)
/* ANDROID extensions */
EGL_ENTRY(EGLBoolean, eglSetSwapRectangleANDROID, EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint)
EGL_ENTRY(EGLClientBuffer, eglGetRenderBufferANDROID, EGLDisplay, EGLSurface)

View File

@ -0,0 +1,122 @@
/*
** Copyright 2009, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <cutils/log.h>
#include "hooks.h"
// ----------------------------------------------------------------------------
namespace android {
// ----------------------------------------------------------------------------
#undef API_ENTRY
#undef CALL_GL_EXTENSION_API
#undef GL_EXTENSION
#undef GL_EXTENSION_NAME
#undef GL_EXTENSION_ARRAY
#undef GL_EXTENSION_LIST
#undef GET_TLS
#if defined(__arm__)
#ifdef HAVE_ARM_TLS_REGISTER
#define GET_TLS(reg) \
"mrc p15, 0, " #reg ", c13, c0, 3 \n"
#else
#define GET_TLS(reg) \
"mov " #reg ", #0xFFFF0FFF \n" \
"ldr " #reg ", [" #reg ", #-15] \n"
#endif
#define API_ENTRY(_api) __attribute__((naked)) _api
#define CALL_GL_EXTENSION_API(_api) \
asm volatile( \
GET_TLS(r12) \
"ldr r12, [r12, %[tls]] \n" \
"cmp r12, #0 \n" \
"ldrne r12, [r12, %[api]] \n" \
"cmpne r12, #0 \n" \
"bxne r12 \n" \
"bx lr \n" \
: \
: [tls] "J"(TLS_SLOT_OPENGL_API*4), \
[api] "J"(__builtin_offsetof(gl_hooks_t, \
ext.extensions[_api])) \
: \
);
#define GL_EXTENSION_NAME(_n) __glExtFwd##_n
#define GL_EXTENSION(_n) \
void API_ENTRY(GL_EXTENSION_NAME(_n))() { \
CALL_GL_EXTENSION_API(_n); \
}
#else
#define GL_EXTENSION_NAME(_n) NULL
#define GL_EXTENSION(_n)
#warning "eglGetProcAddress() partially supported on this architecture"
#endif
#define GL_EXTENSION_LIST(name) \
name(0) name(1) name(2) name(3) \
name(4) name(5) name(6) name(7) \
name(8) name(9) name(10) name(11) \
name(12) name(13) name(14) name(15) \
name(16) name(17) name(18) name(19) \
name(20) name(21) name(22) name(23) \
name(24) name(25) name(26) name(27) \
name(28) name(29) name(30) name(31) \
name(32) name(33) name(34) name(35) \
name(36) name(37) name(38) name(39) \
name(40) name(41) name(42) name(43) \
name(44) name(45) name(46) name(47) \
name(48) name(49) name(50) name(51) \
name(52) name(53) name(54) name(55) \
name(56) name(57) name(58) name(59) \
name(60) name(61) name(62) name(63)
GL_EXTENSION_LIST( GL_EXTENSION )
#define GL_EXTENSION_ARRAY(_n) GL_EXTENSION_NAME(_n),
extern const __eglMustCastToProperFunctionPointerType gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS] = {
GL_EXTENSION_LIST( GL_EXTENSION_ARRAY )
};
#undef GET_TLS
#undef GL_EXTENSION_LIST
#undef GL_EXTENSION_ARRAY
#undef GL_EXTENSION_NAME
#undef GL_EXTENSION
#undef API_ENTRY
#undef CALL_GL_EXTENSION_API
// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------

View File

@ -0,0 +1,60 @@
/*
** Copyright 2009, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <cutils/log.h>
#include "hooks.h"
// ----------------------------------------------------------------------------
namespace android {
// ----------------------------------------------------------------------------
void gl_unimplemented() {
LOGE("called unimplemented OpenGL ES API");
}
// ----------------------------------------------------------------------------
// GL / EGL hooks
// ----------------------------------------------------------------------------
#undef GL_ENTRY
#undef EGL_ENTRY
#define GL_ENTRY(_r, _api, ...) #_api,
#define EGL_ENTRY(_r, _api, ...) #_api,
char const * const gl_names[] = {
#include "entries.in"
NULL
};
char const * const egl_names[] = {
#include "egl_entries.in"
NULL
};
#undef GL_ENTRY
#undef EGL_ENTRY
// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------