Make most of VirtualGL auto-generated

I'm not sure if this is the best way

GLApi is a pure virtual interface

GLApiBase is a class that calls driver->fnGLfunction
so it can be shared with RealGLApi and VirtualGLApi

RealGLApi is basically has nothing currenlty. It's just
GLApiBase but I guess the point is you can override something
if you need to

VirtualGLApi can now override just what it needs to so adding
new functions to generate_bindings.py no longer needs manual
editing

BUG=none
[email protected]


Review URL: https://chromiumcodereview.appspot.com/11565005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173364 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ui/gl/generate_bindings.py b/ui/gl/generate_bindings.py
index 3671fed..7f11d58 100755
--- a/ui/gl/generate_bindings.py
+++ b/ui/gl/generate_bindings.py
@@ -1484,7 +1484,7 @@
     return_type = func['return_type']
     arguments = func['arguments']
     file.write('\n')
-    file.write('%s Real%sApi::%sFn(%s) {\n' %
+    file.write('%s %sApiBase::%sFn(%s) {\n' %
         (return_type, set_name.upper(), names[0], arguments))
     argument_names = re.sub(
         r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments)
diff --git a/ui/gl/gl_egl_api_implementation.cc b/ui/gl/gl_egl_api_implementation.cc
index 26fe6b6..35994d6 100644
--- a/ui/gl/gl_egl_api_implementation.cc
+++ b/ui/gl/gl_egl_api_implementation.cc
@@ -40,6 +40,17 @@
 EGLApi::~EGLApi() {
 }
 
+EGLApiBase::EGLApiBase()
+    : driver_(NULL) {
+}
+
+EGLApiBase::~EGLApiBase() {
+}
+
+void EGLApiBase::InitializeBase(DriverEGL* driver) {
+  driver_ = driver;
+}
+
 RealEGLApi::RealEGLApi() {
 }
 
@@ -47,7 +58,7 @@
 }
 
 void RealEGLApi::Initialize(DriverEGL* driver) {
-  driver_ = driver;
+  InitializeBase(driver);
 }
 
 }  // namespace gfx
diff --git a/ui/gl/gl_egl_api_implementation.h b/ui/gl/gl_egl_api_implementation.h
index f0a75f4..457f60e 100644
--- a/ui/gl/gl_egl_api_implementation.h
+++ b/ui/gl/gl_egl_api_implementation.h
@@ -18,21 +18,28 @@
 void InitializeDebugGLBindingsEGL();
 void ClearGLBindingsEGL();
 
-class GL_EXPORT RealEGLApi : public EGLApi {
+class GL_EXPORT EGLApiBase : public EGLApi {
  public:
-  RealEGLApi();
-  virtual ~RealEGLApi();
-  void Initialize(DriverEGL* driver);
-
   // Include the auto-generated part of this class. We split this because
   // it means we can easily edit the non-auto generated parts right here in
   // this file instead of having to edit some template or the code generator.
   #include "gl_bindings_api_autogen_egl.h"
 
- private:
+ protected:
+  EGLApiBase();
+  virtual ~EGLApiBase();
+  void InitializeBase(DriverEGL* driver);
+
   DriverEGL* driver_;
 };
 
+class GL_EXPORT RealEGLApi : public EGLApiBase {
+ public:
+  RealEGLApi();
+  virtual ~RealEGLApi();
+  void Initialize(DriverEGL* driver);
+};
+
 }  // namespace gfx
 
 #endif  // UI_GL_EGL_API_IMPLEMENTATION_H_
diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc
index dc35232..672f1ea 100644
--- a/ui/gl/gl_gl_api_implementation.cc
+++ b/ui/gl/gl_gl_api_implementation.cc
@@ -60,6 +60,17 @@
 GLApi::~GLApi() {
 }
 
+GLApiBase::GLApiBase()
+    : driver_(NULL) {
+}
+
+GLApiBase::~GLApiBase() {
+}
+
+void GLApiBase::InitializeBase(DriverGL* driver) {
+  driver_ = driver;
+}
+
 RealGLApi::RealGLApi() {
 }
 
@@ -67,12 +78,11 @@
 }
 
 void RealGLApi::Initialize(DriverGL* driver) {
-  driver_ = driver;
+  InitializeBase(driver);
 }
 
 VirtualGLApi::VirtualGLApi()
-    : driver_(NULL),
-      real_context_(NULL),
+    : real_context_(NULL),
       current_context_(NULL) {
 }
 
@@ -80,7 +90,7 @@
 }
 
 void VirtualGLApi::Initialize(DriverGL* driver, GLContext* real_context) {
-  driver_ = driver;
+  InitializeBase(driver);
   real_context_ = real_context;
 
   DCHECK(real_context->IsCurrent(NULL));
@@ -147,473 +157,6 @@
     current_context_ = NULL;
 }
 
-void VirtualGLApi::glActiveTextureFn(GLenum texture) {
-  driver_->fn.glActiveTextureFn(texture);
-}
-
-void VirtualGLApi::glAttachShaderFn(GLuint program, GLuint shader) {
-  driver_->fn.glAttachShaderFn(program, shader);
-}
-
-void VirtualGLApi::glBeginQueryFn(GLenum target, GLuint id) {
-  driver_->fn.glBeginQueryFn(target, id);
-}
-
-void VirtualGLApi::glBeginQueryARBFn(GLenum target, GLuint id) {
-  driver_->fn.glBeginQueryARBFn(target, id);
-}
-
-void VirtualGLApi::glBindAttribLocationFn(
-    GLuint program, GLuint index, const char* name) {
-  driver_->fn.glBindAttribLocationFn(program, index, name);
-}
-
-void VirtualGLApi::glBindBufferFn(GLenum target, GLuint buffer) {
-  driver_->fn.glBindBufferFn(target, buffer);
-}
-
-void VirtualGLApi::glBindFragDataLocationFn(
-    GLuint program, GLuint colorNumber, const char* name) {
-  driver_->fn.glBindFragDataLocationFn(program, colorNumber, name);
-}
-
-void VirtualGLApi::glBindFragDataLocationIndexedFn(
-    GLuint program, GLuint colorNumber, GLuint index, const char* name) {
-  driver_->fn.glBindFragDataLocationIndexedFn(
-      program, colorNumber, index, name);
-}
-
-void VirtualGLApi::glBindFramebufferEXTFn(GLenum target, GLuint framebuffer) {
-  driver_->fn.glBindFramebufferEXTFn(target, framebuffer);
-}
-
-void VirtualGLApi::glBindRenderbufferEXTFn(GLenum target, GLuint renderbuffer) {
-  driver_->fn.glBindRenderbufferEXTFn(target, renderbuffer);
-}
-
-void VirtualGLApi::glBindTextureFn(GLenum target, GLuint texture) {
-  driver_->fn.glBindTextureFn(target, texture);
-}
-
-void VirtualGLApi::glBlendColorFn(
-    GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
-  driver_->fn.glBlendColorFn(red, green, blue, alpha);
-}
-
-void VirtualGLApi::glBlendEquationFn( GLenum mode ) {
-  driver_->fn.glBlendEquationFn( mode );
-}
-
-void VirtualGLApi::glBlendEquationSeparateFn(GLenum modeRGB, GLenum modeAlpha) {
-  driver_->fn.glBlendEquationSeparateFn(modeRGB, modeAlpha);
-}
-
-void VirtualGLApi::glBlendFuncFn(GLenum sfactor, GLenum dfactor) {
-  driver_->fn.glBlendFuncFn(sfactor, dfactor);
-}
-
-void VirtualGLApi::glBlendFuncSeparateFn(
-    GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) {
-  driver_->fn.glBlendFuncSeparateFn(srcRGB, dstRGB, srcAlpha, dstAlpha);
-}
-
-void VirtualGLApi::glBlitFramebufferEXTFn(
-    GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
-    GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
-    GLbitfield mask, GLenum filter) {
-  driver_->fn.glBlitFramebufferEXTFn(
-      srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-}
-
-void VirtualGLApi::glBlitFramebufferANGLEFn(
-    GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
-    GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
-    GLbitfield mask, GLenum filter) {
-  driver_->fn.glBlitFramebufferANGLEFn(
-      srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-}
-
-void VirtualGLApi::glBufferDataFn(
-    GLenum target, GLsizei size, const void* data, GLenum usage) {
-  driver_->fn.glBufferDataFn(target, size, data, usage);
-}
-
-void VirtualGLApi::glBufferSubDataFn(
-    GLenum target, GLint offset, GLsizei size, const void* data) {
-  driver_->fn.glBufferSubDataFn(target, offset, size, data);
-}
-
-GLenum VirtualGLApi::glCheckFramebufferStatusEXTFn(GLenum target) {
-  return driver_->fn.glCheckFramebufferStatusEXTFn(target);
-}
-
-void VirtualGLApi::glClearFn(GLbitfield mask) {
-  driver_->fn.glClearFn(mask);
-}
-
-void VirtualGLApi::glClearColorFn(
-    GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
-  driver_->fn.glClearColorFn(red, green, blue, alpha);
-}
-
-void VirtualGLApi::glClearDepthFn(GLclampd depth) {
-  driver_->fn.glClearDepthFn(depth);
-}
-
-void VirtualGLApi::glClearDepthfFn(GLclampf depth) {
-  driver_->fn.glClearDepthfFn(depth);
-}
-
-void VirtualGLApi::glClearStencilFn(GLint s) {
-  driver_->fn.glClearStencilFn(s);
-}
-
-void VirtualGLApi::glColorMaskFn(
-    GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
-  driver_->fn.glColorMaskFn(red, green, blue, alpha);
-}
-
-void VirtualGLApi::glCompileShaderFn(GLuint shader) {
-  driver_->fn.glCompileShaderFn(shader);
-}
-
-void VirtualGLApi::glCompressedTexImage2DFn(
-    GLenum target, GLint level, GLenum internalformat,
-    GLsizei width, GLsizei height, GLint border,
-    GLsizei imageSize, const void* data) {
-  driver_->fn.glCompressedTexImage2DFn(
-      target, level, internalformat, width, height, border, imageSize, data);
-}
-
-void VirtualGLApi::glCompressedTexSubImage2DFn(
-    GLenum target, GLint level, GLint xoffset, GLint yoffset,
-    GLsizei width, GLsizei height, GLenum format,
-    GLsizei imageSize, const void* data) {
-  driver_->fn.glCompressedTexSubImage2DFn(
-      target, level, xoffset, yoffset, width, height, format, imageSize, data);
-}
-
-void VirtualGLApi::glCopyTexImage2DFn(
-    GLenum target, GLint level, GLenum internalformat,
-    GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
-  driver_->fn.glCopyTexImage2DFn(
-      target, level, internalformat, x, y, width, height, border);
-}
-
-void VirtualGLApi::glCopyTexSubImage2DFn(
-    GLenum target, GLint level, GLint xoffset, GLint yoffset,
-    GLint x, GLint y, GLsizei width, GLsizei height) {
-  driver_->fn.glCopyTexSubImage2DFn(
-      target, level, xoffset, yoffset, x, y, width, height);
-}
-
-GLuint VirtualGLApi::glCreateProgramFn(void) {
-  return driver_->fn.glCreateProgramFn();
-}
-
-GLuint VirtualGLApi::glCreateShaderFn(GLenum type) {
-  return driver_->fn.glCreateShaderFn(type);
-}
-
-void VirtualGLApi::glCullFaceFn(GLenum mode) {
-  driver_->fn.glCullFaceFn(mode);
-}
-
-void VirtualGLApi::glDeleteBuffersARBFn(GLsizei n, const GLuint* buffers) {
-  driver_->fn.glDeleteBuffersARBFn(n, buffers);
-}
-
-void VirtualGLApi::glDeleteFramebuffersEXTFn(
-    GLsizei n, const GLuint* framebuffers) {
-  driver_->fn.glDeleteFramebuffersEXTFn(n, framebuffers);
-}
-
-void VirtualGLApi::glDeleteProgramFn(GLuint program) {
-  driver_->fn.glDeleteProgramFn(program);
-}
-
-void VirtualGLApi::glDeleteQueriesFn(GLsizei n, const GLuint* ids) {
-  driver_->fn.glDeleteQueriesFn(n, ids);
-}
-
-void VirtualGLApi::glDeleteQueriesARBFn(GLsizei n, const GLuint* ids) {
-  driver_->fn.glDeleteQueriesARBFn(n, ids);
-}
-
-void VirtualGLApi::glDeleteRenderbuffersEXTFn(
-    GLsizei n, const GLuint* renderbuffers) {
-  driver_->fn.glDeleteRenderbuffersEXTFn(n, renderbuffers);
-}
-
-void VirtualGLApi::glDeleteShaderFn(GLuint shader) {
-  driver_->fn.glDeleteShaderFn(shader);
-}
-
-void VirtualGLApi::glDeleteTexturesFn(GLsizei n, const GLuint* textures) {
-  driver_->fn.glDeleteTexturesFn(n, textures);
-}
-
-void VirtualGLApi::glDepthFuncFn(GLenum func) {
-  driver_->fn.glDepthFuncFn(func);
-}
-
-void VirtualGLApi::glDepthMaskFn(GLboolean flag) {
-  driver_->fn.glDepthMaskFn(flag);
-}
-
-void VirtualGLApi::glDepthRangeFn(GLclampd zNear, GLclampd zFar) {
-  driver_->fn.glDepthRangeFn(zNear, zFar);
-}
-
-void VirtualGLApi::glDepthRangefFn(GLclampf zNear, GLclampf zFar) {
-  driver_->fn.glDepthRangefFn(zNear, zFar);
-}
-
-void VirtualGLApi::glDetachShaderFn(GLuint program, GLuint shader) {
-  driver_->fn.glDetachShaderFn(program, shader);
-}
-
-void VirtualGLApi::glDisableFn(GLenum cap) {
-  driver_->fn.glDisableFn(cap);
-}
-
-void VirtualGLApi::glDisableVertexAttribArrayFn(GLuint index) {
-  driver_->fn.glDisableVertexAttribArrayFn(index);
-}
-
-void VirtualGLApi::glDiscardFramebufferEXTFn(GLenum target,
-                                           GLsizei numAttachments,
-                                           const GLenum* attachments) {
-  driver_->fn.glDiscardFramebufferEXTFn(target, numAttachments, attachments);
-}
-
-void VirtualGLApi::glDrawArraysFn(GLenum mode, GLint first, GLsizei count) {
-  driver_->fn.glDrawArraysFn(mode, first, count);
-}
-
-void VirtualGLApi::glDrawBufferFn(GLenum mode) {
-  driver_->fn.glDrawBufferFn(mode);
-}
-
-void VirtualGLApi::glDrawBuffersARBFn(GLsizei n, const GLenum* bufs) {
-  driver_->fn.glDrawBuffersARBFn(n, bufs);
-}
-
-void VirtualGLApi::glDrawElementsFn(
-    GLenum mode, GLsizei count, GLenum type, const void* indices) {
-  driver_->fn.glDrawElementsFn(mode, count, type, indices);
-}
-
-void VirtualGLApi::glEGLImageTargetTexture2DOESFn(
-    GLenum target, GLeglImageOES image) {
-  driver_->fn.glEGLImageTargetTexture2DOESFn(target, image);
-}
-
-void VirtualGLApi::glEGLImageTargetRenderbufferStorageOESFn(
-    GLenum target, GLeglImageOES image) {
-  driver_->fn.glEGLImageTargetRenderbufferStorageOESFn(target, image);
-}
-
-void VirtualGLApi::glEnableFn(GLenum cap) {
-  driver_->fn.glEnableFn(cap);
-}
-
-void VirtualGLApi::glEnableVertexAttribArrayFn(GLuint index) {
-  driver_->fn.glEnableVertexAttribArrayFn(index);
-}
-
-void VirtualGLApi::glEndQueryFn(GLenum target) {
-  driver_->fn.glEndQueryFn(target);
-}
-
-void VirtualGLApi::glEndQueryARBFn(GLenum target) {
-  driver_->fn.glEndQueryARBFn(target);
-}
-
-void VirtualGLApi::glFinishFn(void) {
-  driver_->fn.glFinishFn();
-}
-
-void VirtualGLApi::glFlushFn(void) {
-  driver_->fn.glFlushFn();
-}
-
-void VirtualGLApi::glFramebufferRenderbufferEXTFn(
-    GLenum target, GLenum attachment,
-    GLenum renderbuffertarget, GLuint renderbuffer) {
-  driver_->fn.glFramebufferRenderbufferEXTFn(
-      target, attachment, renderbuffertarget, renderbuffer);
-}
-
-void VirtualGLApi::glFramebufferTexture2DEXTFn(
-    GLenum target, GLenum attachment,
-    GLenum textarget, GLuint texture, GLint level) {
-  driver_->fn.glFramebufferTexture2DEXTFn(
-      target, attachment, textarget, texture, level);
-}
-
-void VirtualGLApi::glFrontFaceFn(GLenum mode) {
-  driver_->fn.glFrontFaceFn(mode);
-}
-
-void VirtualGLApi::glGenBuffersARBFn(GLsizei n, GLuint* buffers) {
-  driver_->fn.glGenBuffersARBFn(n, buffers);
-}
-
-void VirtualGLApi::glGenQueriesFn(GLsizei n, GLuint* ids) {
-  driver_->fn.glGenQueriesFn(n, ids);
-}
-
-void VirtualGLApi::glGenQueriesARBFn(GLsizei n, GLuint* ids) {
-  driver_->fn.glGenQueriesARBFn(n, ids);
-}
-
-void VirtualGLApi::glGenerateMipmapEXTFn(GLenum target) {
-  driver_->fn.glGenerateMipmapEXTFn(target);
-}
-
-void VirtualGLApi::glGenFramebuffersEXTFn(GLsizei n, GLuint* framebuffers) {
-  driver_->fn.glGenFramebuffersEXTFn(n, framebuffers);
-}
-
-void VirtualGLApi::glGenRenderbuffersEXTFn(GLsizei n, GLuint* renderbuffers) {
-  driver_->fn.glGenRenderbuffersEXTFn(n, renderbuffers);
-}
-
-void VirtualGLApi::glGenTexturesFn(GLsizei n, GLuint* textures) {
-  driver_->fn.glGenTexturesFn(n, textures);
-}
-
-void VirtualGLApi::glGetActiveAttribFn(
-    GLuint program, GLuint index, GLsizei bufsize,
-    GLsizei* length, GLint* size, GLenum* type, char* name) {
-  driver_->fn.glGetActiveAttribFn(
-      program, index, bufsize, length, size, type, name);
-}
-
-void VirtualGLApi::glGetActiveUniformFn(
-    GLuint program, GLuint index, GLsizei bufsize,
-    GLsizei* length, GLint* size, GLenum* type, char* name) {
-  driver_->fn.glGetActiveUniformFn(
-      program, index, bufsize, length, size, type, name);
-}
-
-void VirtualGLApi::glGetAttachedShadersFn(
-    GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
-  driver_->fn.glGetAttachedShadersFn(program, maxcount, count, shaders);
-}
-
-GLint VirtualGLApi::glGetAttribLocationFn(GLuint program, const char* name) {
-  return driver_->fn.glGetAttribLocationFn(program, name);
-}
-
-void VirtualGLApi::glGetBooleanvFn(GLenum pname, GLboolean* params) {
-  driver_->fn.glGetBooleanvFn(pname, params);
-}
-
-void VirtualGLApi::glGetBufferParameterivFn(
-    GLenum target, GLenum pname, GLint* params) {
-  driver_->fn.glGetBufferParameterivFn(target, pname, params);
-}
-
-GLenum VirtualGLApi::glGetErrorFn(void) {
-  return driver_->fn.glGetErrorFn();
-}
-
-void VirtualGLApi::glGetFloatvFn(GLenum pname, GLfloat* params) {
-  driver_->fn.glGetFloatvFn(pname, params);
-}
-
-void VirtualGLApi::glGetFramebufferAttachmentParameterivEXTFn(
-    GLenum target, GLenum attachment, GLenum pname, GLint* params) {
-  driver_->fn.glGetFramebufferAttachmentParameterivEXTFn(
-      target, attachment, pname, params);
-}
-
-GLenum VirtualGLApi::glGetGraphicsResetStatusARBFn(void) {
-  return driver_->fn.glGetGraphicsResetStatusARBFn();
-}
-
-void VirtualGLApi::glGetIntegervFn(GLenum pname, GLint* params) {
-  driver_->fn.glGetIntegervFn(pname, params);
-}
-
-void VirtualGLApi::glGetProgramBinaryFn(
-    GLuint program, GLsizei bufSize,
-    GLsizei* length, GLenum* binaryFormat, GLvoid* binary) {
-  driver_->fn.glGetProgramBinaryFn(
-      program, bufSize, length, binaryFormat, binary);
-}
-
-void VirtualGLApi::glGetProgramivFn(
-    GLuint program, GLenum pname, GLint* params) {
-  driver_->fn.glGetProgramivFn(program, pname, params);
-}
-
-void VirtualGLApi::glGetProgramInfoLogFn(
-    GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) {
-  driver_->fn.glGetProgramInfoLogFn(program, bufsize, length, infolog);
-}
-
-void VirtualGLApi::glGetQueryivFn(GLenum target, GLenum pname, GLint* params) {
-  driver_->fn.glGetQueryivFn(target, pname, params);
-}
-
-void VirtualGLApi::glGetQueryivARBFn(
-    GLenum target, GLenum pname, GLint* params) {
-  driver_->fn.glGetQueryivARBFn(target, pname, params);
-}
-
-void VirtualGLApi::glGetQueryObjecti64vFn(
-    GLuint id, GLenum pname, GLint64* params) {
-  driver_->fn.glGetQueryObjecti64vFn(id, pname, params);
-}
-
-void VirtualGLApi::glGetQueryObjectivFn(
-    GLuint id, GLenum pname, GLint* params) {
-  driver_->fn.glGetQueryObjectivFn(id, pname, params);
-}
-
-void VirtualGLApi::glGetQueryObjectui64vFn(
-    GLuint id, GLenum pname, GLuint64* params) {
-  driver_->fn.glGetQueryObjectui64vFn(id, pname, params);
-}
-
-void VirtualGLApi::glGetQueryObjectuivFn(
-    GLuint id, GLenum pname, GLuint* params) {
-  driver_->fn.glGetQueryObjectuivFn(id, pname, params);
-}
-
-void VirtualGLApi::glGetQueryObjectuivARBFn(
-    GLuint id, GLenum pname, GLuint* params) {
-  driver_->fn.glGetQueryObjectuivARBFn(id, pname, params);
-}
-
-void VirtualGLApi::glGetRenderbufferParameterivEXTFn(
-    GLenum target, GLenum pname, GLint* params) {
-  driver_->fn.glGetRenderbufferParameterivEXTFn(target, pname, params);
-}
-
-void VirtualGLApi::glGetShaderivFn(GLuint shader, GLenum pname, GLint* params) {
-  driver_->fn.glGetShaderivFn(shader, pname, params);
-}
-
-void VirtualGLApi::glGetShaderInfoLogFn(
-    GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) {
-  driver_->fn.glGetShaderInfoLogFn(shader, bufsize, length, infolog);
-}
-
-void VirtualGLApi::glGetShaderPrecisionFormatFn(
-    GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
-  driver_->fn.glGetShaderPrecisionFormatFn(
-      shadertype, precisiontype, range, precision);
-}
-
-void VirtualGLApi::glGetShaderSourceFn(
-    GLuint shader, GLsizei bufsize, GLsizei* length, char* source) {
-  driver_->fn.glGetShaderSourceFn(shader, bufsize, length, source);
-}
-
 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
   switch (name) {
     case GL_EXTENSIONS:
@@ -623,476 +166,4 @@
   }
 }
 
-void VirtualGLApi::glGetTexLevelParameterfvFn(
-    GLenum target, GLint level, GLenum pname, GLfloat* params) {
-  driver_->fn.glGetTexLevelParameterfvFn(target, level, pname, params);
-}
-
-void VirtualGLApi::glGetTexLevelParameterivFn(
-    GLenum target, GLint level, GLenum pname, GLint* params) {
-  driver_->fn.glGetTexLevelParameterivFn(target, level, pname, params);
-}
-
-void VirtualGLApi::glGetTexParameterfvFn(
-    GLenum target, GLenum pname, GLfloat* params) {
-  driver_->fn.glGetTexParameterfvFn(target, pname, params);
-}
-
-void VirtualGLApi::glGetTexParameterivFn(
-    GLenum target, GLenum pname, GLint* params) {
-  driver_->fn.glGetTexParameterivFn(target, pname, params);
-}
-
-void VirtualGLApi::glGetTranslatedShaderSourceANGLEFn(
-    GLuint shader, GLsizei bufsize, GLsizei* length, char* source) {
-  driver_->fn.glGetTranslatedShaderSourceANGLEFn(
-      shader, bufsize, length, source);
-}
-
-void VirtualGLApi::glGetUniformfvFn(
-    GLuint program, GLint location, GLfloat* params) {
-  driver_->fn.glGetUniformfvFn(program, location, params);
-}
-
-void VirtualGLApi::glGetUniformivFn(
-    GLuint program, GLint location, GLint* params) {
-  driver_->fn.glGetUniformivFn(program, location, params);
-}
-
-GLint VirtualGLApi::glGetUniformLocationFn(GLuint program, const char* name) {
-  return driver_->fn.glGetUniformLocationFn(program, name);
-}
-
-void VirtualGLApi::glGetVertexAttribfvFn(
-    GLuint index, GLenum pname, GLfloat* params) {
-  driver_->fn.glGetVertexAttribfvFn(index, pname, params);
-}
-
-void VirtualGLApi::glGetVertexAttribivFn(
-    GLuint index, GLenum pname, GLint* params) {
-  driver_->fn.glGetVertexAttribivFn(index, pname, params);
-}
-
-void VirtualGLApi::glGetVertexAttribPointervFn(
-    GLuint index, GLenum pname, void** pointer) {
-  driver_->fn.glGetVertexAttribPointervFn(index, pname, pointer);
-}
-
-void VirtualGLApi::glHintFn(GLenum target, GLenum mode) {
-  driver_->fn.glHintFn(target, mode);
-}
-
-GLboolean VirtualGLApi::glIsBufferFn(GLuint buffer) {
-  return driver_->fn.glIsBufferFn(buffer);
-}
-
-GLboolean VirtualGLApi::glIsEnabledFn(GLenum cap) {
-  return driver_->fn.glIsEnabledFn(cap);
-}
-
-GLboolean VirtualGLApi::glIsFramebufferEXTFn(GLuint framebuffer) {
-  return driver_->fn.glIsFramebufferEXTFn(framebuffer);
-}
-
-GLboolean VirtualGLApi::glIsProgramFn(GLuint program) {
-  return driver_->fn.glIsProgramFn(program);
-}
-
-GLboolean VirtualGLApi::glIsQueryARBFn(GLuint query) {
-  return driver_->fn.glIsQueryARBFn(query);
-}
-
-GLboolean VirtualGLApi::glIsRenderbufferEXTFn(GLuint renderbuffer) {
-  return driver_->fn.glIsRenderbufferEXTFn(renderbuffer);
-}
-
-GLboolean VirtualGLApi::glIsShaderFn(GLuint shader) {
-  return driver_->fn.glIsShaderFn(shader);
-}
-
-GLboolean VirtualGLApi::glIsTextureFn(GLuint texture) {
-  return driver_->fn.glIsTextureFn(texture);
-}
-
-void VirtualGLApi::glLineWidthFn(GLfloat width) {
-  driver_->fn.glLineWidthFn(width);
-}
-
-void VirtualGLApi::glLinkProgramFn(GLuint program) {
-  driver_->fn.glLinkProgramFn(program);
-}
-
-void* VirtualGLApi::glMapBufferFn(GLenum target, GLenum access) {
-  return driver_->fn.glMapBufferFn(target, access);
-}
-
-void VirtualGLApi::glPixelStoreiFn(GLenum pname, GLint param) {
-  driver_->fn.glPixelStoreiFn(pname, param);
-}
-
-void VirtualGLApi::glPointParameteriFn(GLenum pname, GLint param) {
-  driver_->fn.glPointParameteriFn(pname, param);
-}
-
-void VirtualGLApi::glPolygonOffsetFn(GLfloat factor, GLfloat units) {
-  driver_->fn.glPolygonOffsetFn(factor, units);
-}
-
-void VirtualGLApi::glProgramBinaryFn(
-    GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) {
-  driver_->fn.glProgramBinaryFn(program, binaryFormat, binary, length);
-}
-
-void VirtualGLApi::glProgramParameteriFn(
-    GLuint program, GLenum pname, GLint value) {
-  driver_->fn.glProgramParameteriFn(program, pname, value);
-}
-
-void VirtualGLApi::glQueryCounterFn(GLuint id, GLenum target) {
-  driver_->fn.glQueryCounterFn(id, target);
-}
-
-void VirtualGLApi::glReadBufferFn(GLenum src) {
-  driver_->fn.glReadBufferFn(src);
-}
-
-void VirtualGLApi::glReadPixelsFn(
-    GLint x, GLint y, GLsizei width, GLsizei height,
-    GLenum format, GLenum type, void* pixels) {
-  driver_->fn.glReadPixelsFn(x, y, width, height, format, type, pixels);
-}
-
-void VirtualGLApi::glReleaseShaderCompilerFn(void) {
-  driver_->fn.glReleaseShaderCompilerFn();
-}
-
-void VirtualGLApi::glRenderbufferStorageMultisampleEXTFn(
-    GLenum target, GLsizei samples, GLenum internalformat,
-    GLsizei width, GLsizei height) {
-  driver_->fn.glRenderbufferStorageMultisampleEXTFn(
-      target, samples, internalformat, width, height);
-}
-
-void VirtualGLApi::glRenderbufferStorageMultisampleANGLEFn(
-    GLenum target, GLsizei samples, GLenum internalformat,
-    GLsizei width, GLsizei height) {
-  driver_->fn.glRenderbufferStorageMultisampleANGLEFn(
-      target, samples, internalformat, width, height);
-}
-
-void VirtualGLApi::glRenderbufferStorageEXTFn(
-    GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
-  driver_->fn.glRenderbufferStorageEXTFn(target, internalformat, width, height);
-}
-
-void VirtualGLApi::glSampleCoverageFn(GLclampf value, GLboolean invert) {
-  driver_->fn.glSampleCoverageFn(value, invert);
-}
-
-void VirtualGLApi::glScissorFn(
-    GLint x, GLint y, GLsizei width, GLsizei height) {
-  driver_->fn.glScissorFn(x, y, width, height);
-}
-
-void VirtualGLApi::glShaderBinaryFn(
-    GLsizei n, const GLuint* shaders, GLenum binaryformat,
-    const void* binary, GLsizei length) {
-  driver_->fn.glShaderBinaryFn(n, shaders, binaryformat, binary, length);
-}
-
-void VirtualGLApi::glShaderSourceFn(
-    GLuint shader, GLsizei count, const char** str, const GLint* length) {
-  driver_->fn.glShaderSourceFn(shader, count, str, length);
-}
-
-void VirtualGLApi::glStencilFuncFn(GLenum func, GLint ref, GLuint mask) {
-  driver_->fn.glStencilFuncFn(func, ref, mask);
-}
-
-void VirtualGLApi::glStencilFuncSeparateFn(
-    GLenum face, GLenum func, GLint ref, GLuint mask) {
-  driver_->fn.glStencilFuncSeparateFn(face, func, ref, mask);
-}
-
-void VirtualGLApi::glStencilMaskFn(GLuint mask) {
-  driver_->fn.glStencilMaskFn(mask);
-}
-
-void VirtualGLApi::glStencilMaskSeparateFn(GLenum face, GLuint mask) {
-  driver_->fn.glStencilMaskSeparateFn(face, mask);
-}
-
-void VirtualGLApi::glStencilOpFn(GLenum fail, GLenum zfail, GLenum zpass) {
-  driver_->fn.glStencilOpFn(fail, zfail, zpass);
-}
-
-void VirtualGLApi::glStencilOpSeparateFn(
-    GLenum face, GLenum fail, GLenum zfail, GLenum zpass) {
-  driver_->fn.glStencilOpSeparateFn(face, fail, zfail, zpass);
-}
-
-void VirtualGLApi::glTexImage2DFn(
-    GLenum target, GLint level, GLint internalformat,
-    GLsizei width, GLsizei height,
-    GLint border, GLenum format, GLenum type, const void* pixels) {
-  driver_->fn.glTexImage2DFn(
-      target, level, internalformat, width, height,
-      border, format, type, pixels);
-}
-
-void VirtualGLApi::glTexParameterfFn(
-    GLenum target, GLenum pname, GLfloat param) {
-  driver_->fn.glTexParameterfFn(target, pname, param);
-}
-
-void VirtualGLApi::glTexParameterfvFn(
-    GLenum target, GLenum pname, const GLfloat* params) {
-  driver_->fn.glTexParameterfvFn(target, pname, params);
-}
-
-void VirtualGLApi::glTexParameteriFn(GLenum target, GLenum pname, GLint param) {
-  driver_->fn.glTexParameteriFn(target, pname, param);
-}
-
-void VirtualGLApi::glTexParameterivFn(
-    GLenum target, GLenum pname, const GLint* params) {
-  driver_->fn.glTexParameterivFn(target, pname, params);
-}
-
-void VirtualGLApi::glTexStorage2DEXTFn(
-    GLenum target, GLsizei levels, GLenum internalformat,
-    GLsizei width, GLsizei height) {
-  driver_->fn.glTexStorage2DEXTFn(
-      target, levels, internalformat, width, height);
-}
-
-void VirtualGLApi::glTexSubImage2DFn(
-    GLenum target, GLint level, GLint xoffset, GLint yoffset,
-    GLsizei width, GLsizei height, GLenum format, GLenum type,
-    const void* pixels) {
-  driver_->fn.glTexSubImage2DFn(
-      target, level, xoffset, yoffset, width, height, format, type, pixels);
-}
-
-void VirtualGLApi::glUniform1fFn(GLint location, GLfloat x) {
-  driver_->fn.glUniform1fFn(location, x);
-}
-
-void VirtualGLApi::glUniform1fvFn(
-    GLint location, GLsizei count, const GLfloat* v) {
-  driver_->fn.glUniform1fvFn(location, count, v);
-}
-
-void VirtualGLApi::glUniform1iFn(GLint location, GLint x) {
-  driver_->fn.glUniform1iFn(location, x);
-}
-
-void VirtualGLApi::glUniform1ivFn(
-    GLint location, GLsizei count, const GLint* v) {
-  driver_->fn.glUniform1ivFn(location, count, v);
-}
-
-void VirtualGLApi::glUniform2fFn(GLint location, GLfloat x, GLfloat y) {
-  driver_->fn.glUniform2fFn(location, x, y);
-}
-
-void VirtualGLApi::glUniform2fvFn(
-    GLint location, GLsizei count, const GLfloat* v) {
-  driver_->fn.glUniform2fvFn(location, count, v);
-}
-
-void VirtualGLApi::glUniform2iFn(GLint location, GLint x, GLint y) {
-  driver_->fn.glUniform2iFn(location, x, y);
-}
-
-void VirtualGLApi::glUniform2ivFn(
-    GLint location, GLsizei count, const GLint* v) {
-  driver_->fn.glUniform2ivFn(location, count, v);
-}
-
-void VirtualGLApi::glUniform3fFn(
-    GLint location, GLfloat x, GLfloat y, GLfloat z) {
-  driver_->fn.glUniform3fFn(location, x, y, z);
-}
-
-void VirtualGLApi::glUniform3fvFn(
-    GLint location, GLsizei count, const GLfloat* v) {
-  driver_->fn.glUniform3fvFn(location, count, v);
-}
-
-void VirtualGLApi::glUniform3iFn(GLint location, GLint x, GLint y, GLint z) {
-  driver_->fn.glUniform3iFn(location, x, y, z);
-}
-
-void VirtualGLApi::glUniform3ivFn(
-    GLint location, GLsizei count, const GLint* v) {
-  driver_->fn.glUniform3ivFn(location, count, v);
-}
-
-void VirtualGLApi::glUniform4fFn(
-    GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
-  driver_->fn.glUniform4fFn(location, x, y, z, w);
-}
-
-void VirtualGLApi::glUniform4fvFn(
-    GLint location, GLsizei count, const GLfloat* v) {
-  driver_->fn.glUniform4fvFn(location, count, v);
-}
-
-void VirtualGLApi::glUniform4iFn(
-    GLint location, GLint x, GLint y, GLint z, GLint w) {
-  driver_->fn.glUniform4iFn(location, x, y, z, w);
-}
-
-void VirtualGLApi::glUniform4ivFn(
-    GLint location, GLsizei count, const GLint* v) {
-  driver_->fn.glUniform4ivFn(location, count, v);
-}
-
-void VirtualGLApi::glUniformMatrix2fvFn(
-    GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-  driver_->fn.glUniformMatrix2fvFn(location, count, transpose, value);
-}
-
-void VirtualGLApi::glUniformMatrix3fvFn(
-    GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-  driver_->fn.glUniformMatrix3fvFn(location, count, transpose, value);
-}
-
-void VirtualGLApi::glUniformMatrix4fvFn(
-    GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-  driver_->fn.glUniformMatrix4fvFn(location, count, transpose, value);
-}
-
-GLboolean VirtualGLApi::glUnmapBufferFn(GLenum target) {
-  return driver_->fn.glUnmapBufferFn(target);
-}
-
-void VirtualGLApi::glUseProgramFn(GLuint program) {
-  driver_->fn.glUseProgramFn(program);
-}
-
-void VirtualGLApi::glValidateProgramFn(GLuint program) {
-  driver_->fn.glValidateProgramFn(program);
-}
-
-void VirtualGLApi::glVertexAttrib1fFn(GLuint indx, GLfloat x) {
-  driver_->fn.glVertexAttrib1fFn(indx, x);
-}
-
-void VirtualGLApi::glVertexAttrib1fvFn(GLuint indx, const GLfloat* values) {
-  driver_->fn.glVertexAttrib1fvFn(indx, values);
-}
-
-void VirtualGLApi::glVertexAttrib2fFn(GLuint indx, GLfloat x, GLfloat y) {
-  driver_->fn.glVertexAttrib2fFn(indx, x, y);
-}
-
-void VirtualGLApi::glVertexAttrib2fvFn(GLuint indx, const GLfloat* values) {
-  driver_->fn.glVertexAttrib2fvFn(indx, values);
-}
-
-void VirtualGLApi::glVertexAttrib3fFn(
-    GLuint indx, GLfloat x, GLfloat y, GLfloat z) {
-  driver_->fn.glVertexAttrib3fFn(indx, x, y, z);
-}
-
-void VirtualGLApi::glVertexAttrib3fvFn(GLuint indx, const GLfloat* values) {
-  driver_->fn.glVertexAttrib3fvFn(indx, values);
-}
-
-void VirtualGLApi::glVertexAttrib4fFn(
-    GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
-  driver_->fn.glVertexAttrib4fFn(indx, x, y, z, w);
-}
-
-void VirtualGLApi::glVertexAttrib4fvFn(GLuint indx, const GLfloat* values) {
-  driver_->fn.glVertexAttrib4fvFn(indx, values);
-}
-
-void VirtualGLApi::glVertexAttribPointerFn(
-    GLuint indx, GLint size, GLenum type, GLboolean normalized,
-    GLsizei stride, const void* ptr) {
-  driver_->fn.glVertexAttribPointerFn(
-      indx, size, type, normalized, stride, ptr);
-}
-
-void VirtualGLApi::glViewportFn(
-    GLint x, GLint y, GLsizei width, GLsizei height) {
-  driver_->fn.glViewportFn(x, y, width, height);
-}
-
-void VirtualGLApi::glGenFencesNVFn(GLsizei n, GLuint* fences) {
-  driver_->fn.glGenFencesNVFn(n, fences);
-}
-
-void VirtualGLApi::glDeleteFencesNVFn(GLsizei n, const GLuint* fences) {
-  driver_->fn.glDeleteFencesNVFn(n, fences);
-}
-
-void VirtualGLApi::glSetFenceNVFn(GLuint fence, GLenum condition) {
-  driver_->fn.glSetFenceNVFn(fence, condition);
-}
-
-GLboolean VirtualGLApi::glTestFenceNVFn(GLuint fence) {
-  return driver_->fn.glTestFenceNVFn(fence);
-}
-
-void VirtualGLApi::glFinishFenceNVFn(GLuint fence) {
-  driver_->fn.glFinishFenceNVFn(fence);
-}
-
-GLboolean VirtualGLApi::glIsFenceNVFn(GLuint fence) {
-  return driver_->fn.glIsFenceNVFn(fence);
-}
-
-void VirtualGLApi::glGetFenceivNVFn(GLuint fence, GLenum pname, GLint* params) {
-  driver_->fn.glGetFenceivNVFn(fence, pname, params);
-}
-
-GLsync VirtualGLApi::glFenceSyncFn(GLenum condition, GLbitfield flags) {
-  return driver_->fn.glFenceSyncFn(condition, flags);
-}
-
-void VirtualGLApi::glDeleteSyncFn(GLsync sync) {
-  driver_->fn.glDeleteSyncFn(sync);
-}
-
-void VirtualGLApi::glGetSyncivFn(
-    GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length,GLint* values) {
-  driver_->fn.glGetSyncivFn(sync, pname, bufSize, length,values);
-}
-
-void VirtualGLApi::glDrawArraysInstancedANGLEFn(
-    GLenum mode, GLint first, GLsizei count, GLsizei primcount) {
-  driver_->fn.glDrawArraysInstancedANGLEFn(mode, first, count, primcount);
-}
-
-void VirtualGLApi::glDrawElementsInstancedANGLEFn(
-    GLenum mode, GLsizei count, GLenum type, const void* indices,
-    GLsizei primcount) {
-  driver_->fn.glDrawElementsInstancedANGLEFn(
-      mode, count, type, indices, primcount);
-}
-
-void VirtualGLApi::glVertexAttribDivisorANGLEFn(GLuint index, GLuint divisor) {
-  driver_->fn.glVertexAttribDivisorANGLEFn(index, divisor);
-}
-
-void VirtualGLApi::glGenVertexArraysOESFn(GLsizei n, GLuint* arrays) {
-  driver_->fn.glGenVertexArraysOESFn(n, arrays);
-}
-
-void VirtualGLApi::glDeleteVertexArraysOESFn(GLsizei n, const GLuint* arrays) {
-  driver_->fn.glDeleteVertexArraysOESFn(n, arrays);
-}
-
-void VirtualGLApi::glBindVertexArrayOESFn(GLuint array) {
-  driver_->fn.glBindVertexArrayOESFn(array);
-}
-
-GLboolean VirtualGLApi::glIsVertexArrayOESFn(GLuint array) {
-  return driver_->fn.glIsVertexArrayOESFn(array);
-}
-
 }  // namespace gfx
diff --git a/ui/gl/gl_gl_api_implementation.h b/ui/gl/gl_gl_api_implementation.h
index 4842194..8226f89 100644
--- a/ui/gl/gl_gl_api_implementation.h
+++ b/ui/gl/gl_gl_api_implementation.h
@@ -26,44 +26,47 @@
 void SetGLToRealGLApi();
 void SetGLApi(GLApi* api);
 
-// Implemenents the GL API by calling directly into the driver.
-class GL_EXPORT RealGLApi : public GLApi {
+class GL_EXPORT GLApiBase : public GLApi {
  public:
-  RealGLApi();
-  virtual ~RealGLApi();
-  void Initialize(DriverGL* driver);
-
   // Include the auto-generated part of this class. We split this because
   // it means we can easily edit the non-auto generated parts right here in
   // this file instead of having to edit some template or the code generator.
   #include "gl_bindings_api_autogen_gl.h"
 
- private:
+ protected:
+  GLApiBase();
+  virtual ~GLApiBase();
+  void InitializeBase(DriverGL* driver);
+
   DriverGL* driver_;
 };
 
+// Implemenents the GL API by calling directly into the driver.
+class GL_EXPORT RealGLApi : public GLApiBase {
+ public:
+  RealGLApi();
+  virtual ~RealGLApi();
+  void Initialize(DriverGL* driver);
+};
+
 // Implementents the GL API using co-operative state restoring.
 // Assumes there is only one real GL context and that multiple virtual contexts
 // are implemented above it. Restores the needed state from the current context.
-class GL_EXPORT VirtualGLApi : public GLApi {
+class GL_EXPORT VirtualGLApi : public GLApiBase {
  public:
   VirtualGLApi();
   virtual ~VirtualGLApi();
   void Initialize(DriverGL* driver, GLContext* real_context);
 
-  // Include the auto-generated part of this class. We split this because
-  // it means we can easily edit the non-auto generated parts right here in
-  // this file instead of having to edit some template or the code generator.
-  #include "gl_bindings_api_autogen_gl.h"
-
   // Sets the current virutal context.
   bool MakeCurrent(GLContext* virtual_context, GLSurface* surface);
 
   void OnDestroyVirtualContext(GLContext* virtual_context);
 
- private:
-  DriverGL* driver_;
+  // Overridden functions from GLApiBase
+  virtual const GLubyte* glGetStringFn(GLenum name) OVERRIDE;
 
+ private:
   // The real context we're running on.
   GLContext* real_context_;
 
diff --git a/ui/gl/gl_glx_api_implementation.cc b/ui/gl/gl_glx_api_implementation.cc
index 8989756..dc145ad9b 100644
--- a/ui/gl/gl_glx_api_implementation.cc
+++ b/ui/gl/gl_glx_api_implementation.cc
@@ -40,6 +40,17 @@
 GLXApi::~GLXApi() {
 }
 
+GLXApiBase::GLXApiBase()
+    : driver_(NULL) {
+}
+
+GLXApiBase::~GLXApiBase() {
+}
+
+void GLXApiBase::InitializeBase(DriverGLX* driver) {
+  driver_ = driver;
+}
+
 RealGLXApi::RealGLXApi() {
 }
 
@@ -47,7 +58,7 @@
 }
 
 void RealGLXApi::Initialize(DriverGLX* driver) {
-  driver_ = driver;
+  InitializeBase(driver);
 }
 
 }  // namespace gfx
diff --git a/ui/gl/gl_glx_api_implementation.h b/ui/gl/gl_glx_api_implementation.h
index 396deeb1..4ce4fdc8 100644
--- a/ui/gl/gl_glx_api_implementation.h
+++ b/ui/gl/gl_glx_api_implementation.h
@@ -18,21 +18,28 @@
 void InitializeDebugGLBindingsGLX();
 void ClearGLBindingsGLX();
 
-class GL_EXPORT RealGLXApi : public GLXApi {
+class GL_EXPORT GLXApiBase : public GLXApi {
  public:
-  RealGLXApi();
-  virtual ~RealGLXApi();
-  void Initialize(DriverGLX* driver);
-
   // Include the auto-generated part of this class. We split this because
   // it means we can easily edit the non-auto generated parts right here in
   // this file instead of having to edit some template or the code generator.
   #include "gl_bindings_api_autogen_glx.h"
 
- private:
+ protected:
+  GLXApiBase();
+  virtual ~GLXApiBase();
+  void InitializeBase(DriverGLX* driver);
+
   DriverGLX* driver_;
 };
 
+class GL_EXPORT RealGLXApi : public GLXApiBase {
+ public:
+  RealGLXApi();
+  virtual ~RealGLXApi();
+  void Initialize(DriverGLX* driver);
+};
+
 }  // namespace gfx
 
 #endif  // UI_GL_GLX_API_IMPLEMENTATION_H_
diff --git a/ui/gl/gl_osmesa_api_implementation.cc b/ui/gl/gl_osmesa_api_implementation.cc
index 37cc57e..4d8fc2a6 100644
--- a/ui/gl/gl_osmesa_api_implementation.cc
+++ b/ui/gl/gl_osmesa_api_implementation.cc
@@ -40,6 +40,17 @@
 OSMESAApi::~OSMESAApi() {
 }
 
+OSMESAApiBase::OSMESAApiBase()
+    : driver_(NULL) {
+}
+
+OSMESAApiBase::~OSMESAApiBase() {
+}
+
+void OSMESAApiBase::InitializeBase(DriverOSMESA* driver) {
+  driver_ = driver;
+}
+
 RealOSMESAApi::RealOSMESAApi() {
 }
 
@@ -47,7 +58,7 @@
 }
 
 void RealOSMESAApi::Initialize(DriverOSMESA* driver) {
-  driver_ = driver;
+  InitializeBase(driver);
 }
 
 }  // namespace gfx
diff --git a/ui/gl/gl_osmesa_api_implementation.h b/ui/gl/gl_osmesa_api_implementation.h
index 4101c74a..6d7681c 100644
--- a/ui/gl/gl_osmesa_api_implementation.h
+++ b/ui/gl/gl_osmesa_api_implementation.h
@@ -18,21 +18,28 @@
 void InitializeDebugGLBindingsOSMESA();
 void ClearGLBindingsOSMESA();
 
-class GL_EXPORT RealOSMESAApi : public OSMESAApi {
+class GL_EXPORT OSMESAApiBase : public OSMESAApi {
  public:
-  RealOSMESAApi();
-  virtual ~RealOSMESAApi();
-  void Initialize(DriverOSMESA* driver);
-
   // Include the auto-generated part of this class. We split this because
   // it means we can easily edit the non-auto generated parts right here in
   // this file instead of having to edit some template or the code generator.
   #include "gl_bindings_api_autogen_osmesa.h"
 
- private:
+ protected:
+  OSMESAApiBase();
+  virtual ~OSMESAApiBase();
+  void InitializeBase(DriverOSMESA* driver);
+
   DriverOSMESA* driver_;
 };
 
+class GL_EXPORT RealOSMESAApi : public OSMESAApiBase {
+ public:
+  RealOSMESAApi();
+  virtual ~RealOSMESAApi();
+  void Initialize(DriverOSMESA* driver);
+};
+
 }  // namespace gfx
 
 #endif  // UI_GL_OSMESA_API_IMPLEMENTATION_H_
diff --git a/ui/gl/gl_wgl_api_implementation.cc b/ui/gl/gl_wgl_api_implementation.cc
index bbe1ecb..2fba6d2 100644
--- a/ui/gl/gl_wgl_api_implementation.cc
+++ b/ui/gl/gl_wgl_api_implementation.cc
@@ -40,6 +40,17 @@
 WGLApi::~WGLApi() {
 }
 
+WGLApiBase::WGLApiBase()
+    : driver_(NULL) {
+}
+
+WGLApiBase::~WGLApiBase() {
+}
+
+void WGLApiBase::InitializeBase(DriverWGL* driver) {
+  driver_ = driver;
+}
+
 RealWGLApi::RealWGLApi() {
 }
 
@@ -47,7 +58,7 @@
 }
 
 void RealWGLApi::Initialize(DriverWGL* driver) {
-  driver_ = driver;
+  InitializeBase(driver);
 }
 
 }  // namespace gfx
diff --git a/ui/gl/gl_wgl_api_implementation.h b/ui/gl/gl_wgl_api_implementation.h
index 2b7a09a..8af846c 100644
--- a/ui/gl/gl_wgl_api_implementation.h
+++ b/ui/gl/gl_wgl_api_implementation.h
@@ -18,21 +18,28 @@
 void InitializeDebugGLBindingsWGL();
 void ClearGLBindingsWGL();
 
-class GL_EXPORT RealWGLApi : public WGLApi {
+class GL_EXPORT WGLApiBase : public WGLApi {
  public:
-  RealWGLApi();
-  virtual ~RealWGLApi();
-  void Initialize(DriverWGL* driver);
-
   // Include the auto-generated part of this class. We split this because
   // it means we can easily edit the non-auto generated parts right here in
   // this file instead of having to edit some template or the code generator.
   #include "gl_bindings_api_autogen_wgl.h"
 
- private:
+ protected:
+  WGLApiBase();
+  virtual ~WGLApiBase();
+  void InitializeBase(DriverWGL* driver);
+
   DriverWGL* driver_;
 };
 
+class GL_EXPORT RealWGLApi : public WGLApiBase {
+ public:
+  RealWGLApi();
+  virtual ~RealWGLApi();
+  void Initialize(DriverWGL* driver);
+};
+
 }  // namespace gfx
 
 #endif  // UI_GL_WGL_API_IMPLEMENTATION_H_