@@ -118,21 +118,16 @@ status_t Loader::driver_t::set(void* hnd, int32_t api)
118118
119119// ----------------------------------------------------------------------------
120120
121- Loader::entry_t::entry_t (int dpy, int impl, const char * tag)
122- : dpy(dpy), impl(impl), tag(tag) {
123- }
124-
125- // ----------------------------------------------------------------------------
126-
127121Loader::Loader ()
128122{
129123 char line[256 ];
130124 char tag[256 ];
131125
132126 /* Special case for GLES emulation */
133127 if (checkGlesEmulationStatus () == 0 ) {
134- ALOGD (" Emulator without GPU support detected. Fallback to software renderer." );
135- gConfig .add ( entry_t (0 , 0 , " android" ) );
128+ ALOGD (" Emulator without GPU support detected. "
129+ " Fallback to software renderer." );
130+ mDriverTag .setTo (" android" );
136131 return ;
137132 }
138133
@@ -141,14 +136,16 @@ Loader::Loader()
141136 if (cfg == NULL ) {
142137 // default config
143138 ALOGD (" egl.cfg not found, using default config" );
144- gConfig . add ( entry_t ( 0 , 0 , " android" ) );
139+ mDriverTag . setTo ( " android" );
145140 } else {
146141 while (fgets (line, 256 , cfg)) {
147- int dpy;
148- int impl;
142+ int dpy, impl;
149143 if (sscanf (line, " %u %u %s" , &dpy, &impl, tag) == 3 ) {
150144 // ALOGD(">>> %u %u %s", dpy, impl, tag);
151- gConfig .add ( entry_t (dpy, impl, tag) );
145+ // We only load the h/w accelerated implementation
146+ if (tag != String8 (" android" )) {
147+ mDriverTag = tag;
148+ }
152149 }
153150 }
154151 fclose (cfg);
@@ -160,30 +157,12 @@ Loader::~Loader()
160157 GLTrace_stop ();
161158}
162159
163- const char * Loader::getTag ( int dpy, int impl )
160+ void * Loader::open ( egl_connection_t * cnx )
164161{
165- const Vector<entry_t >& cfgs (gConfig );
166- const size_t c = cfgs.size ();
167- for (size_t i=0 ; i<c ; i++) {
168- if (dpy == cfgs[i].dpy )
169- if (impl == cfgs[i].impl )
170- return cfgs[i].tag .string ();
171- }
172- return 0 ;
173- }
174-
175- void * Loader::open (EGLNativeDisplayType display, int impl, egl_connection_t * cnx)
176- {
177- /*
178- * TODO: if we don't find display/0, then use 0/0
179- * (0/0 should always work)
180- */
181-
182162 void * dso;
183- int index = int (display);
184163 driver_t * hnd = 0 ;
185164
186- char const * tag = getTag (index, impl );
165+ char const * tag = mDriverTag . string ( );
187166 if (tag) {
188167 dso = load_driver (" GLES" , tag, cnx, EGL | GLESv1_CM | GLESv2);
189168 if (dso) {
@@ -193,16 +172,14 @@ void* Loader::open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx
193172 dso = load_driver (" EGL" , tag, cnx, EGL);
194173 if (dso) {
195174 hnd = new driver_t (dso);
196-
197175 // TODO: make this more automated
198176 hnd->set ( load_driver (" GLESv1_CM" , tag, cnx, GLESv1_CM), GLESv1_CM );
199-
200- hnd->set ( load_driver (" GLESv2" , tag, cnx, GLESv2), GLESv2 );
177+ hnd->set ( load_driver (" GLESv2" , tag, cnx, GLESv2), GLESv2 );
201178 }
202179 }
203180 }
204181
205- LOG_FATAL_IF (!index && !impl && ! hnd,
182+ LOG_FATAL_IF (!index && !hnd,
206183 " couldn't find the default OpenGL ES implementation "
207184 " for default display" );
208185
@@ -221,7 +198,7 @@ void Loader::init_api(void* dso,
221198 __eglMustCastToProperFunctionPointerType* curr,
222199 getProcAddressType getProcAddress)
223200{
224- const size_t SIZE = 256 ;
201+ const ssize_t SIZE = 256 ;
225202 char scrap[SIZE];
226203 while (*api) {
227204 char const * name = *api;
@@ -326,14 +303,14 @@ void *Loader::load_driver(const char* kind, const char *tag,
326303 if (mask & GLESv1_CM) {
327304 init_api (dso, gl_names,
328305 (__eglMustCastToProperFunctionPointerType*)
329- &cnx->hooks [GLESv1_INDEX]->gl ,
306+ &cnx->hooks [egl_connection_t :: GLESv1_INDEX]->gl ,
330307 getProcAddress);
331308 }
332309
333310 if (mask & GLESv2) {
334311 init_api (dso, gl_names,
335312 (__eglMustCastToProperFunctionPointerType*)
336- &cnx->hooks [GLESv2_INDEX]->gl ,
313+ &cnx->hooks [egl_connection_t :: GLESv2_INDEX]->gl ,
337314 getProcAddress);
338315 }
339316
0 commit comments