Split GL binding init into core and extension part

This change splits the GL binding initialization into to phases: core
functions and extension functions. This is motivated by two
peculiarities of the EGL window binding layer:

  1. Pointers to core GL entry points may not be queried through
     eglGetProcAddress().

  2. The return value of eglGetProcAddress() is not specified to be NULL
     for unsupported functions.

In light of these limitations, the current strategy of blindly querying
all GL entry points from eglGetProcAddress() and falling back to dlsym()
results in bogus function pointers on some EGL implementations.

This patch fixes the problem as follows:

  1. Add GetGLCoreProcAddress() that only queries dlsym() and use it to
     initialize pointers to all entry points. On EGL based platforms
     pointers to extension functions will most likely be NULL at this
     point.

  2. When a context is first made current, look up the set of supported
     extensions and use GetGLProcAddress() to populate the remaining
     extension function pointers.

The reworked GL bindings generator uses the standard Khronos headers to
recognize the extension functions and produce appropriate initialization
code.

Note that the patch also updates gl2ext.h to match the upstream Khronos
version and corrects some minor errors in the downstream changes.

BUG=5427391
TEST=

Review URL: http://codereview.chromium.org/8381001
Patch from Sami Kyostila <[email protected]>.

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107602 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ui/gfx/gl/gl_implementation_linux.cc b/ui/gfx/gl/gl_implementation_linux.cc
index 568edeb..952e62e5 100644
--- a/ui/gfx/gl/gl_implementation_linux.cc
+++ b/ui/gfx/gl/gl_implementation_linux.cc
@@ -179,6 +179,31 @@
   return true;
 }
 
+bool InitializeGLExtensionBindings(GLImplementation implementation,
+    GLContext* context) {
+  switch (implementation) {
+    case kGLImplementationOSMesaGL:
+      InitializeGLExtensionBindingsGL(context);
+      InitializeGLExtensionBindingsOSMESA(context);
+      break;
+    case kGLImplementationDesktopGL:
+      InitializeGLExtensionBindingsGL(context);
+      InitializeGLExtensionBindingsGLX(context);
+      break;
+    case kGLImplementationEGLGLES2:
+      InitializeGLExtensionBindingsGL(context);
+      InitializeGLExtensionBindingsEGL(context);
+      break;
+    case kGLImplementationMockGL:
+      InitializeGLExtensionBindingsGL(context);
+      break;
+    default:
+      return false;
+  }
+
+  return true;
+}
+
 void InitializeDebugGLBindings() {
   InitializeDebugGLBindingsEGL();
   InitializeDebugGLBindingsGL();