Fix null functions in gles2_decoder_context_t

This patch is related to parts of the crash reports about
gles2_decoder_context_t. More details can be find here:

https://code.google.com/p/android/issues/detail?id=199346

The crash happens because of the following. The crashing function is
glBindVertexArrayOES. This function is defined in gl2ext and not
necessarily supported by all desktop GL driver. The crash can be
reproduced in the following usage case. A user is writing an APP,
he gets the function poiter by calling:

    glBindVertexArrayOES = eglGetProcAddress ( "glBindVertexArrayOES" );

Then he executes it:

    glBindVertexArrayOES(0);

What happens is that eglGetProcAddress in the native code returns the
function address in the GL encoder (!). Neither the native code or the
encoder knows if the decoder has glBindVertexArrayOES==NULL. Thus the
encoder sends the command to the decoder, the decoder tries to execute
it, reaches a NULL function pointer and crashes.

The ideal behavior should be as followed. When the decoder holds a NULL
pointer to glBindVertexArrayOES, the native code should get a NULL
pointer when loading the symbol "glBindVertexArrayOES". But this cannot
be implemented easily without making big changes to the native code
because the native code is actually loading it in the encoder library,
and "glBindVertexArrayOES" is always in the encoder library.

Notice that if the native code receive a NULL pointer when loading
symbols, it will redirect the function to a "gl_unimplemented" function
which prints error messages in logcat.

This patch gives another solution on the host by trying to give
similar behavior as the native code handles the null function
pointer. When the host fails to load a function, it redirects the
pointer in its function table to the "gl_unimplemented" function on the
host side. When the user calls unimplemented function, he will see
an error message in the console. Notice that from the user's point of
view, this is slightly different from the ideal behavior where the
error message should show up in logcat.

Change-Id: Ib0947d4229c7a63f95c20e929bcab84542d911ad
2 files changed
tree: 23bd51c74fb648beb30741af6d551ccb8108efa0
  1. android/
  2. distrib/
  3. .gitignore