summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DEPS2
-rw-r--r--app/app_base.gypi103
-rw-r--r--app/gfx/gl/generate_bindings.py548
-rw-r--r--app/gfx/gl/gl_bindings.h77
-rw-r--r--app/gfx/gl/gl_context.cc68
-rw-r--r--app/gfx/gl/gl_context.h4
-rw-r--r--app/gfx/gl/gl_context_egl.cc241
-rw-r--r--app/gfx/gl/gl_context_egl.h93
-rw-r--r--app/gfx/gl/gl_context_linux.cc159
-rw-r--r--app/gfx/gl/gl_context_mac.cc54
-rw-r--r--app/gfx/gl/gl_context_osmesa.cc18
-rw-r--r--app/gfx/gl/gl_context_osmesa.h4
-rw-r--r--app/gfx/gl/gl_context_stub.h (renamed from gpu/command_buffer/service/gl_context_stub.cc)34
-rw-r--r--app/gfx/gl/gl_context_win.cc329
-rw-r--r--app/gfx/gl/gl_implementation.h30
-rw-r--r--app/gfx/gl/gl_implementation_linux.cc80
-rw-r--r--app/gfx/gl/gl_implementation_mac.cc76
-rw-r--r--app/gfx/gl/gl_implementation_win.cc140
-rw-r--r--app/gfx/gl/gl_interface.cc (renamed from gpu/command_buffer/service/gl_interface.cc)6
-rw-r--r--app/gfx/gl/gl_interface.h (renamed from gpu/command_buffer/service/gl_interface.h)199
-rw-r--r--app/gfx/gl/gl_mock.h (renamed from gpu/command_buffer/service/gl_mock.h)22
-rw-r--r--app/surface/accelerated_surface_mac.cc1
-rw-r--r--app/surface/accelerated_surface_mac.h8
-rw-r--r--build/common.gypi8
-rw-r--r--chrome/chrome.gyp4
-rw-r--r--chrome/gpu/gpu_backing_store_glx.cc62
-rw-r--r--chrome/gpu/gpu_backing_store_glx_context.cc31
-rw-r--r--chrome/gpu/gpu_main.cc7
-rw-r--r--chrome/gpu/gpu_video_layer_glx.cc6
-rw-r--r--chrome/gpu/gpu_view_x.cc28
-rw-r--r--gpu/command_buffer/client/gles2_implementation.h3
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format.h43
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils.cc2
-rw-r--r--gpu/command_buffer/common/unittest_main.cc13
-rw-r--r--gpu/command_buffer/service/gl_mock.cc11
-rw-r--r--gpu/command_buffer/service/gl_utils.h95
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc164
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc6
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc4
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc4
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc10
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h8
-rw-r--r--gpu/command_buffer/service/gpu_processor.h4
-rw-r--r--gpu/command_buffer/service/gpu_processor_linux.cc5
-rw-r--r--gpu/command_buffer/service/gpu_processor_mac.cc22
-rw-r--r--gpu/command_buffer/service/gpu_processor_win.cc8
-rw-r--r--gpu/command_buffer/service/program_manager_unittest.cc11
-rw-r--r--gpu/gpu.gyp169
-rw-r--r--media/media.gyp2
-rw-r--r--third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.c2
50 files changed, 2011 insertions, 1017 deletions
diff --git a/DEPS b/DEPS
index 72011b0..cfb330d 100644
--- a/DEPS
+++ b/DEPS
@@ -28,7 +28,7 @@ deps = {
"http://googletest.googlecode.com/svn/trunk@408",
"src/third_party/angle":
- "http://angleproject.googlecode.com/svn/trunk@317",
+ "http://angleproject.googlecode.com/svn/trunk@321",
"src/third_party/WebKit":
"/trunk/deps/third_party/WebKit@33467",
diff --git a/app/app_base.gypi b/app/app_base.gypi
index 4f391c5..247118a 100644
--- a/app/app_base.gypi
+++ b/app/app_base.gypi
@@ -67,6 +67,7 @@
'msvs_guid': '4631946D-7D5F-44BD-A5A8-504C0A7033BE',
'variables': {
'app_base_target': 1,
+ 'gl_binding_output_dir': '<(SHARED_INTERMEDIATE_DIR)/app',
},
'dependencies': [
# app resources and app_strings should be shared with the 64-bit
@@ -85,17 +86,17 @@
'../third_party/sqlite/sqlite.gyp:sqlite',
'../third_party/zlib/zlib.gyp:zlib',
],
- 'defines': [
- 'GLEW_STATIC',
- ],
'include_dirs': [
- '../third_party/glew/include',
+ '../third_party/mesa/MesaLib/include',
+ '<(gl_binding_output_dir)',
],
# TODO(gregoryd): The direct_dependent_settings should be shared with
# the 64-bit target, but it doesn't work due to a bug in gyp
'direct_dependent_settings': {
'include_dirs': [
'..',
+ '../third_party/mesa/MesaLib/include',
+ '<(gl_binding_output_dir)',
],
},
'sources': [
@@ -123,16 +124,23 @@
'file_download_interface.h',
'gfx/font_util.h',
'gfx/font_util.cc',
+ 'gfx/gl/gl_bindings.h',
'gfx/gl/gl_context.cc',
'gfx/gl/gl_context.h',
- 'gfx/gl/gl_context_osmesa.cc',
- 'gfx/gl/gl_context_osmesa.h',
'gfx/gl/gl_context_linux.cc',
- 'gfx/gl/gl_context_linux.h',
'gfx/gl/gl_context_mac.cc',
- 'gfx/gl/gl_context_mac.h',
+ 'gfx/gl/gl_context_osmesa.cc',
+ 'gfx/gl/gl_context_osmesa.h',
+ 'gfx/gl/gl_context_stub.h',
'gfx/gl/gl_context_win.cc',
- 'gfx/gl/gl_context_win.h',
+ 'gfx/gl/gl_headers.h',
+ 'gfx/gl/gl_implementation.h',
+ 'gfx/gl/gl_implementation_linux.cc',
+ 'gfx/gl/gl_implementation_mac.cc',
+ 'gfx/gl/gl_implementation_win.cc',
+ 'gfx/gl/gl_interface.h',
+ 'gfx/gl/gl_interface.cc',
+ 'gfx/gl/gl_mock.h',
'gtk_dnd_util.cc',
'gtk_dnd_util.h',
'gtk_signal.cc',
@@ -203,7 +211,42 @@
'x11_util.cc',
'x11_util.h',
'x11_util_internal.h',
- '../third_party/glew/src/glew.c',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_gl.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_gl.h',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_mock.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.h',
+ ],
+ # hard_dependency is necessary for this target because it has actions
+ # that generate header files included by dependent targtets. The header
+ # files must be generated before the dependents are compiled. The usual
+ # semantics are to allow the two targets to build concurrently.
+ 'hard_dependency': 1,
+ 'actions': [
+ {
+ 'action_name': 'generate_gl_bindings',
+ 'inputs': [
+ 'gfx/gl/generate_bindings.py',
+ ],
+ 'outputs': [
+ '<(gl_binding_output_dir)/gl_bindings_autogen_egl.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_egl.h',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_gl.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_gl.h',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_glx.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_glx.h',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_mock.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.h',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_wgl.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_wgl.h',
+ ],
+ 'action': [
+ 'python',
+ 'gfx/gl/generate_bindings.py',
+ '<(gl_binding_output_dir)',
+ ],
+ },
],
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
@@ -255,6 +298,46 @@
'win/window_impl.h',
],
}],
+ ['OS=="linux"', {
+ 'sources': [
+ '<(gl_binding_output_dir)/gl_bindings_autogen_glx.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_glx.h',
+ ],
+ 'all_dependent_settings': {
+ 'defines': [
+ 'GL_GLEXT_PROTOTYPES',
+ ],
+ 'ldflags': [
+ '-L<(PRODUCT_DIR)',
+ ],
+ 'link_settings': {
+ 'libraries': [
+ '-lX11',
+ '-ldl',
+ ],
+ },
+ },
+ }],
+ ['OS=="mac"', {
+ 'link_settings': {
+ 'libraries': [
+ '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
+ ],
+ },
+ }],
+ ['OS=="win"', {
+ 'include_dirs': [
+ '../third_party/angle/include',
+ ],
+ 'sources': [
+ 'gfx/gl/gl_context_egl.cc',
+ 'gfx/gl/gl_context_egl.h',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_egl.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_egl.h',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_wgl.cc',
+ '<(gl_binding_output_dir)/gl_bindings_autogen_wgl.h',
+ ],
+ }],
],
},
],
diff --git a/app/gfx/gl/generate_bindings.py b/app/gfx/gl/generate_bindings.py
new file mode 100644
index 0000000..7aaf6d4
--- /dev/null
+++ b/app/gfx/gl/generate_bindings.py
@@ -0,0 +1,548 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""code generator for GL/GLES extension wrangler."""
+
+import os
+import re
+import sys
+
+GL_FUNCTIONS = [
+['void', ['glActiveTexture'], 'GLenum texture'],
+['void', ['glAttachShader'], 'GLuint program, GLuint shader'],
+['void', ['glBindAttribLocation'],
+ 'GLuint program, GLuint index, const char* name'],
+['void', ['glBindBuffer'], 'GLenum target, GLuint buffer'],
+['void', ['glBindFramebufferEXT', 'glBindFramebuffer'],
+ 'GLenum target, GLuint framebuffer'],
+['void', ['glBindRenderbufferEXT', 'glBindRenderbuffer'],
+ 'GLenum target, GLuint renderbuffer'],
+['void', ['glBindTexture'], 'GLenum target, GLuint texture'],
+['void', ['glBlendColor'],
+ 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha'],
+['void', ['glBlendEquation'], ' GLenum mode '],
+['void', ['glBlendEquationSeparate'], 'GLenum modeRGB, GLenum modeAlpha'],
+['void', ['glBlendFunc'], 'GLenum sfactor, GLenum dfactor'],
+['void', ['glBlendFuncSeparate'],
+ 'GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha'],
+['void', ['glBufferData'],
+ 'GLenum target, GLsizei size, const void* data, GLenum usage'],
+['void', ['glBufferSubData'],
+ 'GLenum target, GLint offset, GLsizei size, const void* data'],
+['GLenum', ['glCheckFramebufferStatusEXT',
+ 'glCheckFramebufferStatus'], 'GLenum target'],
+['void', ['glClear'], 'GLbitfield mask'],
+['void', ['glClearColor'],
+ 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha'],
+['void', ['glClearDepth'], 'GLclampd depth'],
+['void', ['glClearDepthf'], 'GLclampf depth'],
+['void', ['glClearStencil'], 'GLint s'],
+['void', ['glColorMask'],
+ 'GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha'],
+['void', ['glCompileShader'], 'GLuint shader'],
+['void', ['glCompressedTexImage2D'],
+ 'GLenum target, GLint level, GLenum internalformat, GLsizei width, '
+ 'GLsizei height, GLint border, GLsizei imageSize, const void* data'],
+['void', ['glCompressedTexSubImage2D'],
+ 'GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, '
+ 'GLsizei height, GLenum format, GLsizei imageSize, const void* data'],
+['void', ['glCopyTexImage2D'],
+ 'GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, '
+ 'GLsizei width, GLsizei height, GLint border'],
+['void', ['glCopyTexSubImage2D'], 'GLenum target, GLint level, GLint xoffset, '
+ 'GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height'],
+['GLuint', ['glCreateProgram'], 'void'],
+['GLuint', ['glCreateShader'], 'GLenum type'],
+['void', ['glCullFace'], 'GLenum mode'],
+['void', ['glDeleteBuffersARB', 'glDeleteBuffers'],
+ 'GLsizei n, const GLuint* buffers'],
+['void', ['glDeleteFramebuffersEXT', 'glDeleteFramebuffers'],
+ 'GLsizei n, const GLuint* framebuffers'],
+['void', ['glDeleteProgram'], 'GLuint program'],
+['void', ['glDeleteRenderbuffersEXT', 'glDeleteRenderbuffers'],
+ 'GLsizei n, const GLuint* renderbuffers'],
+['void', ['glDeleteShader'], 'GLuint shader'],
+['void', ['glDeleteTextures'], 'GLsizei n, const GLuint* textures'],
+['void', ['glDepthFunc'], 'GLenum func'],
+['void', ['glDepthMask'], 'GLboolean flag'],
+['void', ['glDepthRange'], 'GLclampd zNear, GLclampd zFar'],
+['void', ['glDepthRangef'], 'GLclampf zNear, GLclampf zFar'],
+['void', ['glDetachShader'], 'GLuint program, GLuint shader'],
+['void', ['glDisable'], 'GLenum cap'],
+['void', ['glDisableVertexAttribArray'], 'GLuint index'],
+['void', ['glDrawArrays'], 'GLenum mode, GLint first, GLsizei count'],
+['void', ['glDrawElements'],
+ 'GLenum mode, GLsizei count, GLenum type, const void* indices'],
+['void', ['glEnable'], 'GLenum cap'],
+['void', ['glEnableVertexAttribArray'], 'GLuint index'],
+['void', ['glFinish'], 'void'],
+['void', ['glFlush'], 'void'],
+['void', ['glFramebufferRenderbufferEXT', 'glFramebufferRenderbuffer'],
+ 'GLenum target, GLenum attachment, GLenum renderbuffertarget, '
+ 'GLuint renderbuffer'],
+['void', ['glFramebufferTexture2DEXT', 'glFramebufferTexture2D'],
+ 'GLenum target, GLenum attachment, GLenum textarget, GLuint texture, '
+ 'GLint level'],
+['void', ['glFrontFace'], 'GLenum mode'],
+['void', ['glGenBuffersARB', 'glGenBuffers'], 'GLsizei n, GLuint* buffers'],
+['void', ['glGenerateMipmapEXT', 'glGenerateMipmap'], 'GLenum target'],
+['void', ['glGenFramebuffersEXT', 'glGenFramebuffers'],
+ 'GLsizei n, GLuint* framebuffers'],
+['void', ['glGenRenderbuffersEXT', 'glGenRenderbuffers'],
+ 'GLsizei n, GLuint* renderbuffers'],
+['void', ['glGenTextures'], 'GLsizei n, GLuint* textures'],
+['void', ['glGetActiveAttrib'],
+ 'GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, '
+ 'GLint* size, GLenum* type, char* name'],
+['void', ['glGetActiveUniform'],
+ 'GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, '
+ 'GLint* size, GLenum* type, char* name'],
+['void', ['glGetAttachedShaders'],
+ 'GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders'],
+['GLint', ['glGetAttribLocation'], 'GLuint program, const char* name'],
+['void', ['glGetBooleanv'], 'GLenum pname, GLboolean* params'],
+['void', ['glGetBufferParameteriv'], 'GLenum target, GLenum pname, GLint* params'],
+['GLenum', ['glGetError'], 'void'],
+['void', ['glGetFloatv'], 'GLenum pname, GLfloat* params'],
+['void', ['glGetFramebufferAttachmentParameterivEXT',
+ 'glGetFramebufferAttachmentParameteriv'], 'GLenum target, '
+ 'GLenum attachment, GLenum pname, GLint* params'],
+['void', ['glGetIntegerv'], 'GLenum pname, GLint* params'],
+['void', ['glGetProgramiv'], 'GLuint program, GLenum pname, GLint* params'],
+['void', ['glGetProgramInfoLog'],
+ 'GLuint program, GLsizei bufsize, GLsizei* length, char* infolog'],
+['void', ['glGetRenderbufferParameterivEXT', 'glGetRenderbufferParameteriv'],
+ 'GLenum target, GLenum pname, GLint* params'],
+['void', ['glGetShaderiv'], 'GLuint shader, GLenum pname, GLint* params'],
+['void', ['glGetShaderInfoLog'],
+ 'GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog'],
+['void', ['glGetShaderPrecisionFormat'],
+ 'GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision'],
+['void', ['glGetShaderSource'],
+ 'GLuint shader, GLsizei bufsize, GLsizei* length, char* source'],
+['const GLubyte*', ['glGetString'], 'GLenum name'],
+['void', ['glGetTexParameterfv'],
+ 'GLenum target, GLenum pname, GLfloat* params'],
+['void', ['glGetTexParameteriv'], 'GLenum target, GLenum pname, GLint* params'],
+['void', ['glGetUniformfv'], 'GLuint program, GLint location, GLfloat* params'],
+['void', ['glGetUniformiv'], 'GLuint program, GLint location, GLint* params'],
+['GLint', ['glGetUniformLocation'], 'GLuint program, const char* name'],
+['void', ['glGetVertexAttribfv'],
+ 'GLuint index, GLenum pname, GLfloat* params'],
+['void', ['glGetVertexAttribiv'], 'GLuint index, GLenum pname, GLint* params'],
+['void', ['glGetVertexAttribPointerv'],
+ 'GLuint index, GLenum pname, void** pointer'],
+['void', ['glHint'], 'GLenum target, GLenum mode'],
+['GLboolean', ['glIsBuffer'], 'GLuint buffer'],
+['GLboolean', ['glIsEnabled'], 'GLenum cap'],
+['GLboolean', ['glIsFramebuffer'], 'GLuint framebuffer'],
+['GLboolean', ['glIsProgram'], 'GLuint program'],
+['GLboolean', ['glIsRenderbuffer'], 'GLuint renderbuffer'],
+['GLboolean', ['glIsShader'], 'GLuint shader'],
+['GLboolean', ['glIsTexture'], 'GLuint texture'],
+['void', ['glLineWidth'], 'GLfloat width'],
+['void', ['glLinkProgram'], 'GLuint program'],
+['void', ['glPixelStorei'], 'GLenum pname, GLint param'],
+['void', ['glPolygonOffset'], 'GLfloat factor, GLfloat units'],
+['void', ['glReadPixels'],
+ 'GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, '
+ 'GLenum type, void* pixels'],
+['void', ['glReleaseShaderCompiler'], 'void'],
+['void', ['glRenderbufferStorageEXT', 'glRenderbufferStorage'],
+ 'GLenum target, GLenum internalformat, GLsizei width, GLsizei height'],
+['void', ['glSampleCoverage'], 'GLclampf value, GLboolean invert'],
+['void', ['glScissor'], 'GLint x, GLint y, GLsizei width, GLsizei height'],
+['void', ['glShaderBinary'],
+ 'GLsizei n, const GLuint* shaders, GLenum binaryformat, '
+ 'const void* binary, GLsizei length'],
+['void', ['glShaderSource'],
+ 'GLuint shader, GLsizei count, const char** str, const GLint* length'],
+['void', ['glStencilFunc'], 'GLenum func, GLint ref, GLuint mask'],
+['void', ['glStencilFuncSeparate'],
+ 'GLenum face, GLenum func, GLint ref, GLuint mask'],
+['void', ['glStencilMask'], 'GLuint mask'],
+['void', ['glStencilMaskSeparate'], 'GLenum face, GLuint mask'],
+['void', ['glStencilOp'], 'GLenum fail, GLenum zfail, GLenum zpass'],
+['void', ['glStencilOpSeparate'],
+ 'GLenum face, GLenum fail, GLenum zfail, GLenum zpass'],
+['void', ['glTexImage2D'],
+ 'GLenum target, GLint level, GLint internalformat, GLsizei width, '
+ 'GLsizei height, GLint border, GLenum format, GLenum type, '
+ 'const void* pixels'],
+['void', ['glTexParameterf'], 'GLenum target, GLenum pname, GLfloat param'],
+['void', ['glTexParameterfv'],
+ 'GLenum target, GLenum pname, const GLfloat* params'],
+['void', ['glTexParameteri'], 'GLenum target, GLenum pname, GLint param'],
+['void', ['glTexParameteriv'],
+ 'GLenum target, GLenum pname, const GLint* params'],
+['void', ['glTexSubImage2D'],
+ 'GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, '
+ 'GLsizei height, GLenum format, GLenum type, const void* pixels'],
+['void', ['glUniform1f'], 'GLint location, GLfloat x'],
+['void', ['glUniform1fv'], 'GLint location, GLsizei count, const GLfloat* v'],
+['void', ['glUniform1i'], 'GLint location, GLint x'],
+['void', ['glUniform1iv'], 'GLint location, GLsizei count, const GLint* v'],
+['void', ['glUniform2f'], 'GLint location, GLfloat x, GLfloat y'],
+['void', ['glUniform2fv'], 'GLint location, GLsizei count, const GLfloat* v'],
+['void', ['glUniform2i'], 'GLint location, GLint x, GLint y'],
+['void', ['glUniform2iv'], 'GLint location, GLsizei count, const GLint* v'],
+['void', ['glUniform3f'], 'GLint location, GLfloat x, GLfloat y, GLfloat z'],
+['void', ['glUniform3fv'], 'GLint location, GLsizei count, const GLfloat* v'],
+['void', ['glUniform3i'], 'GLint location, GLint x, GLint y, GLint z'],
+['void', ['glUniform3iv'], 'GLint location, GLsizei count, const GLint* v'],
+['void', ['glUniform4f'],
+ 'GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w'],
+['void', ['glUniform4fv'], 'GLint location, GLsizei count, const GLfloat* v'],
+['void', ['glUniform4i'], 'GLint location, GLint x, GLint y, GLint z, GLint w'],
+['void', ['glUniform4iv'], 'GLint location, GLsizei count, const GLint* v'],
+['void', ['glUniformMatrix2fv'],
+ 'GLint location, GLsizei count, GLboolean transpose, const GLfloat* value'],
+['void', ['glUniformMatrix3fv'],
+ 'GLint location, GLsizei count, GLboolean transpose, const GLfloat* value'],
+['void', ['glUniformMatrix4fv'],
+ 'GLint location, GLsizei count, GLboolean transpose, const GLfloat* value'],
+['void', ['glUseProgram'], 'GLuint program'],
+['void', ['glValidateProgram'], 'GLuint program'],
+['void', ['glVertexAttrib1f'], 'GLuint indx, GLfloat x'],
+['void', ['glVertexAttrib1fv'], 'GLuint indx, const GLfloat* values'],
+['void', ['glVertexAttrib2f'], 'GLuint indx, GLfloat x, GLfloat y'],
+['void', ['glVertexAttrib2fv'], 'GLuint indx, const GLfloat* values'],
+['void', ['glVertexAttrib3f'], 'GLuint indx, GLfloat x, GLfloat y, GLfloat z'],
+['void', ['glVertexAttrib3fv'], 'GLuint indx, const GLfloat* values'],
+['void', ['glVertexAttrib4f'],
+ 'GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w'],
+['void', ['glVertexAttrib4fv'], 'GLuint indx, const GLfloat* values'],
+['void', ['glVertexAttribPointer'],
+ 'GLuint indx, GLint size, GLenum type, GLboolean normalized, '
+ 'GLsizei stride, const void* ptr'],
+['void', ['glViewport'], 'GLint x, GLint y, GLsizei width, GLsizei height'],
+]
+
+OSMESA_FUNCTIONS = [
+['OSMesaContext', ['OSMesaCreateContext'],
+ 'GLenum format, OSMesaContext sharelist'],
+['OSMesaContext', ['OSMesaCreateContextExt'],
+ 'GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, '
+ 'OSMesaContext sharelist'],
+['void', ['OSMesaDestroyContext'], 'OSMesaContext ctx'],
+['GLboolean', ['OSMesaMakeCurrent'],
+ 'OSMesaContext ctx, void* buffer, GLenum type, GLsizei width, '
+ 'GLsizei height'],
+['OSMesaContext', ['OSMesaGetCurrentContext'], 'void'],
+['void', ['OSMesaPixelStore'], 'GLint pname, GLint value'],
+['void', ['OSMesaGetIntegerv'], 'GLint pname, GLint* value'],
+['GLboolean', ['OSMesaGetDepthBuffer'],
+ 'OSMesaContext c, GLint* width, GLint* height, GLint* bytesPerValue, '
+ 'void** buffer'],
+['GLboolean', ['OSMesaGetColorBuffer'],
+ 'OSMesaContext c, GLint* width, GLint* height, GLint* format, '
+ 'void** buffer'],
+['OSMESAproc', ['OSMesaGetProcAddress'], 'const char* funcName'],
+['void', ['OSMesaColorClamp'], 'GLboolean enable'],
+]
+
+EGL_FUNCTIONS = [
+['EGLint', ['eglGetError'], 'void'],
+['EGLDisplay', ['eglGetDisplay'], 'void* display_id'],
+['EGLBoolean', ['eglInitialize'],
+ 'EGLDisplay dpy, EGLint* major, EGLint* minor'],
+['EGLBoolean', ['eglTerminate'], 'EGLDisplay dpy'],
+['const char*', ['eglQueryString'], 'EGLDisplay dpy, EGLint name'],
+['EGLBoolean', ['eglGetConfigs'],
+ 'EGLDisplay dpy, EGLConfig* configs, EGLint config_size, '
+ 'EGLint* num_config'],
+['EGLBoolean', ['eglChooseConfig'],
+ 'EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, '
+ 'EGLint config_size, EGLint* num_config'],
+['EGLBoolean', ['eglGetConfigAttrib'],
+ 'EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value'],
+['EGLSurface', ['eglCreateWindowSurface'],
+ 'EGLDisplay dpy, EGLConfig config, void* win, const EGLint* attrib_list'],
+['EGLSurface', ['eglCreatePbufferSurface'],
+ 'EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list'],
+['EGLSurface', ['eglCreatePixmapSurface'],
+ 'EGLDisplay dpy, EGLConfig config, void* pixmap, '
+ 'const EGLint* attrib_list'],
+['EGLBoolean', ['eglDestroySurface'], 'EGLDisplay dpy, EGLSurface surface'],
+['EGLBoolean', ['eglQuerySurface'],
+ 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value'],
+['EGLBoolean', ['eglBindAPI'], 'EGLenum api'],
+['EGLenum', ['eglQueryAPI'], 'void'],
+['EGLBoolean', ['eglWaitClient'], 'void'],
+['EGLBoolean', ['eglReleaseThread'], 'void'],
+['EGLSurface', ['eglCreatePbufferFromClientBuffer'],
+ 'EGLDisplay dpy, EGLenum buftype, void* buffer, EGLConfig config, '
+ 'const EGLint* attrib_list'],
+['EGLBoolean', ['eglSurfaceAttrib'],
+ 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value'],
+['EGLBoolean', ['eglBindTexImage'],
+ 'EGLDisplay dpy, EGLSurface surface, EGLint buffer'],
+['EGLBoolean', ['eglReleaseTexImage'],
+ 'EGLDisplay dpy, EGLSurface surface, EGLint buffer'],
+['EGLBoolean', ['eglSwapInterval'], 'EGLDisplay dpy, EGLint interval'],
+['EGLContext', ['eglCreateContext'],
+ 'EGLDisplay dpy, EGLConfig config, EGLContext share_context, '
+ 'const EGLint* attrib_list'],
+['EGLBoolean', ['eglDestroyContext'], 'EGLDisplay dpy, EGLContext ctx'],
+['EGLBoolean', ['eglMakeCurrent'],
+ 'EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx'],
+['EGLContext', ['eglGetCurrentContext'], 'void'],
+['EGLSurface', ['eglGetCurrentSurface'], 'EGLint readdraw'],
+['EGLDisplay', ['eglGetCurrentDisplay'], 'void'],
+['EGLBoolean', ['eglQueryContext'],
+ 'EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value'],
+['EGLBoolean', ['eglWaitGL'], 'void'],
+['EGLBoolean', ['eglWaitNative'], 'EGLint engine'],
+['EGLBoolean', ['eglSwapBuffers'], 'EGLDisplay dpy, EGLSurface surface'],
+['EGLBoolean', ['eglCopyBuffers'],
+ 'EGLDisplay dpy, EGLSurface surface, void* target'],
+['__eglMustCastToProperFunctionPointerType', ['eglGetProcAddress'],
+ 'const char* procname'],
+]
+
+WGL_FUNCTIONS = [
+['HGLRC', ['wglCreateContext'], 'HDC hdc'],
+['HGLRC', ['wglCreateLayerContext'], 'HDC hdc, int iLayerPlane'],
+['BOOL', ['wglCopyContext'], 'HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask'],
+['BOOL', ['wglDeleteContext'], 'HGLRC hglrc'],
+['HGLRC', ['wglGetCurrentContext'], ''],
+['HDC', ['wglGetCurrentDC'], ''],
+['BOOL', ['wglMakeCurrent'], 'HDC hdc, HGLRC hglrc'],
+['BOOL', ['wglShareLists'], 'HGLRC hglrc1, HGLRC hglrc2'],
+['BOOL', ['wglSwapLayerBuffers'], 'HDC hdc, UINT fuPlanes'],
+['const char*', ['wglGetExtensionsStringARB', 'wglGetExtensionsStringEXT'],
+ 'HDC hDC'],
+['BOOL', ['wglChoosePixelFormatARB'],
+ 'HDC dc, const int* int_attrib_list, const float* float_attrib_list, '
+ 'UINT max_formats, int* formats, UINT* num_formats'],
+['HPBUFFERARB', ['wglCreatePbufferARB'],
+ 'HDC hDC, int iPixelFormat, int iWidth, int iHeight, '
+ 'const int* piAttribList'],
+['HDC', ['wglGetPbufferDCARB'], 'HPBUFFERARB hPbuffer'],
+['int', ['wglReleasePbufferDCARB'], 'HPBUFFERARB hPbuffer, HDC hDC'],
+['BOOL', ['wglDestroyPbufferARB'], 'HPBUFFERARB hPbuffer'],
+['BOOL', ['wglQueryPbufferARB'],
+ 'HPBUFFERARB hPbuffer, int iAttribute, int* piValue'],
+]
+
+GLX_FUNCTIONS = [
+['XVisualInfo*', ['glXChooseVisual'],
+ 'Display* dpy, int screen, int* attribList'],
+['GLXContext', ['glXCreateContext'],
+ 'Display* dpy, XVisualInfo* vis, GLXContext shareList, int direct'],
+['void', ['glXDestroyContext'], 'Display* dpy, GLXContext ctx'],
+['int', ['glXMakeCurrent'],
+ 'Display* dpy, GLXDrawable drawable, GLXContext ctx'],
+['void', ['glXCopyContext'],
+ 'Display* dpy, GLXContext src, GLXContext dst, unsigned long mask'],
+['void', ['glXSwapBuffers'], 'Display* dpy, GLXDrawable drawable'],
+['GLXPixmap', ['glXCreateGLXPixmap'],
+ 'Display* dpy, XVisualInfo* visual, Pixmap pixmap'],
+['void', ['glXDestroyGLXPixmap'], 'Display* dpy, GLXPixmap pixmap'],
+['int', ['glXQueryExtension'], 'Display* dpy, int* errorb, int* event'],
+['int', ['glXQueryVersion'], 'Display* dpy, int* maj, int* min'],
+['int', ['glXIsDirect'], 'Display* dpy, GLXContext ctx'],
+['int', ['glXGetConfig'],
+ 'Display* dpy, XVisualInfo* visual, int attrib, int* value'],
+['GLXContext', ['glXGetCurrentContext'], 'void'],
+['GLXDrawable', ['glXGetCurrentDrawable'], 'void'],
+['void', ['glXWaitGL'], 'void'],
+['void', ['glXWaitX'], 'void'],
+['void', ['glXUseXFont'], 'Font font, int first, int count, int list'],
+['const char*', ['glXQueryExtensionsString'], 'Display* dpy, int screen'],
+['const char*', ['glXQueryServerString'], 'Display* dpy, int screen, int name'],
+['const char*', ['glXGetClientString'], 'Display* dpy, int name'],
+['Display*', ['glXGetCurrentDisplay'], 'void'],
+['GLXFBConfig*', ['glXChooseFBConfig'],
+ 'Display* dpy, int screen, const int* attribList, int* nitems'],
+['int', ['glXGetFBConfigAttrib'],
+ 'Display* dpy, GLXFBConfig config, int attribute, int* value'],
+['GLXFBConfig*', ['glXGetFBConfigs'],
+ 'Display* dpy, int screen, int* nelements'],
+['XVisualInfo*', ['glXGetVisualFromFBConfig'],
+ 'Display* dpy, GLXFBConfig config'],
+['GLXWindow', ['glXCreateWindow'],
+ 'Display* dpy, GLXFBConfig config, Window win, const int* attribList'],
+['void', ['glXDestroyWindow'], 'Display* dpy, GLXWindow window'],
+['GLXPixmap', ['glXCreatePixmap'],
+ 'Display* dpy, GLXFBConfig config, Pixmap pixmap, const int* attribList'],
+['void', ['glXDestroyPixmap'], 'Display* dpy, GLXPixmap pixmap'],
+['GLXPbuffer', ['glXCreatePbuffer'],
+ 'Display* dpy, GLXFBConfig config, const int* attribList'],
+['void', ['glXDestroyPbuffer'], 'Display* dpy, GLXPbuffer pbuf'],
+['void', ['glXQueryDrawable'],
+ 'Display* dpy, GLXDrawable draw, int attribute, unsigned int* value'],
+['GLXContext', ['glXCreateNewContext'],
+ 'Display* dpy, GLXFBConfig config, int renderType, '
+ 'GLXContext shareList, int direct'],
+['int', ['glXMakeContextCurrent'],
+ 'Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx'],
+['GLXDrawable', ['glXGetCurrentReadDrawable'], 'void'],
+['int', ['glXQueryContext'],
+ 'Display* dpy, GLXContext ctx, int attribute, int* value'],
+['void', ['glXSelectEvent'],
+ 'Display* dpy, GLXDrawable drawable, unsigned long mask'],
+['void', ['glXGetSelectedEvent'],
+ 'Display* dpy, GLXDrawable drawable, unsigned long* mask'],
+]
+
+FUNCTION_SETS = [
+ [GL_FUNCTIONS, 'gl'],
+ [OSMESA_FUNCTIONS, 'osmesa'],
+ [EGL_FUNCTIONS, 'egl'],
+ [WGL_FUNCTIONS, 'wgl'],
+ [GLX_FUNCTIONS, 'glx'],
+]
+
+def GenerateHeader(file, functions, setName):
+ """Generates gl_binding_autogen_x.h"""
+
+ # Write file header.
+ file.write('// Copyright (c) 2010 The Chromium Authors. All rights reserved.\n')
+ file.write('// Use of this source code is governed by a BSD-style license that can be\n')
+ file.write('// found in the LICENSE file.\n')
+ file.write('\n')
+ file.write('// This file is automatically generated.\n')
+ file.write('\n')
+ file.write('#ifndef APP_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' % setName.upper())
+ file.write('#define APP_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' % setName.upper())
+
+ # Write prototype for initialization function.
+ file.write('\n')
+ file.write('namespace gfx {\n')
+ file.write('\n')
+ file.write('void InitializeGLBindings%s();\n' % setName.upper())
+
+ # Write typedefs for function pointer types. Always use the GL name for the
+ # typedef.
+ file.write('\n')
+ for [returnType, names, arguments] in functions:
+ file.write('typedef %s (GL_BINDING_CALL *%sProc)(%s);\n' %
+ (returnType, names[0], arguments))
+
+ # Write declarations for function pointers. Always use the GL name for the
+ # declaration.
+ file.write('\n')
+ for [returnType, names, arguments] in functions:
+ file.write('extern %sProc g_%s;\n' % (names[0], names[0]))
+ file.write('\n')
+ file.write( '} // namespace gfx\n')
+
+ # Write macros to invoke function pointers. Always use the GL name for the
+ # macro.
+ file.write('\n')
+ for [returnType, names, arguments] in functions:
+ file.write('#define %s ::gfx::g_%s\n' %
+ (names[0], names[0]))
+
+ file.write('\n')
+ file.write('#endif // APP_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' %
+ setName.upper())
+
+def GenerateSource(file, functions, setName):
+ """Generates gl_binding_autogen_x.cc"""
+
+ # Write file header.
+ file.write('// Copyright (c) 2010 The Chromium Authors. All rights reserved.\n')
+ file.write('// Use of this source code is governed by a BSD-style license that can be\n')
+ file.write('// found in the LICENSE file.\n')
+ file.write('\n')
+ file.write('// This file is automatically generated.\n')
+ file.write('\n')
+ file.write('#include "app/gfx/gl/gl_bindings.h"\n')
+ file.write('#include "app/gfx/gl/gl_implementation.h"\n')
+
+ # Write definitions of function pointers.
+ file.write('\n')
+ file.write('namespace gfx {\n')
+ file.write('\n')
+ for [returnType, names, arguments] in functions:
+ file.write('%sProc g_%s;\n' % (names[0], names[0]))
+
+ # Write function to initialize the function pointers.
+ file.write('\n')
+ file.write('void InitializeGLBindings%s() {\n' % setName.upper())
+ for [returnType, names, arguments] in functions:
+ for name in names:
+ file.write(' if (!g_%s)\n' % names[0])
+ file.write(
+ ' g_%s = reinterpret_cast<%sProc>(GetGLProcAddress("%s"));\n' %
+ (names[0], names[0], name))
+ file.write('}\n')
+ file.write('\n')
+ file.write( '} // namespace gfx\n')
+
+def GenerateMockSource(file, functions):
+ """Generates functions that invoke a mock GLInterface"""
+
+ file.write('// Copyright (c) 2010 The Chromium Authors. All rights reserved.\n')
+ file.write('// Use of this source code is governed by a BSD-style license that can be\n')
+ file.write('// found in the LICENSE file.\n')
+ file.write('\n')
+ file.write('// This file is automatically generated.\n')
+ file.write('\n')
+ file.write('#include <string.h>\n')
+ file.write('\n')
+ file.write('#include "app/gfx/gl/gl_interface.h"\n')
+
+ file.write('\n')
+ file.write('namespace gfx {\n')
+
+ # Write function that trampoline into the GLInterface.
+ for [returnType, names, arguments] in functions:
+ file.write('\n')
+ file.write('%s GL_BINDING_CALL Mock_%s(%s) {\n' %
+ (returnType, names[0], arguments))
+ argumentNames = re.sub(r'(const )?[a-zA-Z0-9]+\** ([a-zA-Z0-9]+)', r'\2',
+ arguments)
+ if argumentNames == 'void':
+ argumentNames = ''
+ functionName = names[0][2:]
+ if returnType == 'void':
+ file.write(' GLInterface::GetGLInterface()->%s(%s);\n' %
+ (functionName, argumentNames))
+ else:
+ file.write(' return GLInterface::GetGLInterface()->%s(%s);\n' %
+ (functionName, argumentNames))
+ file.write('}\n')
+
+ # Write a function to lookup a mock GL function based on its name.
+ file.write('\n')
+ file.write('void* GL_BINDING_CALL GetMockGLProcAddress(const char* name) {\n')
+ for [returnType, names, arguments] in functions:
+ file.write(' if (strcmp(name, "%s") == 0)\n' % names[0])
+ file.write(' return reinterpret_cast<void*>(Mock_%s);\n' % names[0])
+ file.write(' return NULL;\n')
+ file.write('}\n');
+
+ file.write('\n')
+ file.write('} // namespace gfx\n')
+
+def main(argv):
+ """This is the main function."""
+
+ if len(argv) >= 1:
+ dir = argv[0]
+ else:
+ dir = '.'
+
+ for [functions, setName] in FUNCTION_SETS:
+ headerFile = open(
+ os.path.join(dir, 'gl_bindings_autogen_%s.h' % setName), 'wb')
+ GenerateHeader(headerFile, functions, setName)
+ headerFile.close()
+
+ sourceFile = open(
+ os.path.join(dir, 'gl_bindings_autogen_%s.cc' % setName), 'wb')
+ GenerateSource(sourceFile, functions, setName)
+ sourceFile.close()
+
+ sourceFile = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb')
+ GenerateMockSource(sourceFile, GL_FUNCTIONS)
+ sourceFile.close()
+
+if __name__ == '__main__':
+ main(sys.argv[1:])
diff --git a/app/gfx/gl/gl_bindings.h b/app/gfx/gl/gl_bindings.h
new file mode 100644
index 0000000..c9dbbee
--- /dev/null
+++ b/app/gfx/gl/gl_bindings.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Includes the platform independent and platform dependent GL headers.
+// Only include this in cc files. It pulls in system headers, including
+// the X11 headers on linux, which define all kinds of macros that are
+// liable to cause conflicts.
+
+#ifndef APP_GFX_GL_GL_BINDINGS_H_
+#define APP_GFX_GL_GL_BINDINGS_H_
+
+#include <GL/gl.h>
+#include <GL/glext.h>
+
+#include "build/build_config.h"
+
+// The standard OpenGL native extension headers are also included.
+#if defined(OS_WIN)
+#include <GL/wglext.h>
+#elif defined(OS_LINUX)
+#include <GL/glx.h>
+#include <GL/glxext.h>
+
+// Undefine some macros defined by X headers. This is why this file should only
+// be included in .cc files.
+#undef Bool
+#undef None
+#undef Status
+
+#elif defined(OS_MACOSX)
+#include <OpenGL/OpenGL.h>
+#endif
+
+#if defined(OS_WIN)
+#define GL_BINDING_CALL WINAPI
+#else
+#define GL_BINDING_CALL
+#endif
+
+// Forward declare OSMesa types.
+typedef struct osmesa_context *OSMesaContext;
+typedef void (*OSMESAproc)();
+
+#if defined(OS_WIN)
+
+// Forward declare EGL types.
+typedef unsigned int EGLBoolean;
+typedef unsigned int EGLenum;
+typedef int EGLint;
+typedef void *EGLConfig;
+typedef void *EGLContext;
+typedef void *EGLDisplay;
+typedef void *EGLSurface;
+typedef void *EGLClientBuffer;
+typedef void (*__eglMustCastToProperFunctionPointerType)(void);
+
+#endif // OS_WIN
+
+#include "gl_bindings_autogen_gl.h"
+#include "gl_bindings_autogen_osmesa.h"
+
+#if defined(OS_WIN)
+#include "gl_bindings_autogen_egl.h"
+#include "gl_bindings_autogen_wgl.h"
+#elif defined(OS_LINUX)
+#include "gl_bindings_autogen_glx.h"
+#endif
+
+namespace gfx {
+
+// Find an entry point to the mock GL implementation.
+void* GL_BINDING_CALL GetMockGLProcAddress(const char* name);
+
+} // namespace gfx
+
+#endif // APP_GFX_GL_GL_BINDINGS_H_
diff --git a/app/gfx/gl/gl_context.cc b/app/gfx/gl/gl_context.cc
index f4e7073..d9b81f3 100644
--- a/app/gfx/gl/gl_context.cc
+++ b/app/gfx/gl/gl_context.cc
@@ -2,77 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <GL/glew.h>
-
#include "app/gfx/gl/gl_context.h"
+#include "app/gfx/gl/gl_bindings.h"
+#include "app/gfx/gl/gl_implementation.h"
#include "base/logging.h"
namespace gfx {
-// GLEW initialization is extremely expensive because it looks up
-// hundreds of function pointers. Realistically we are not going to
-// switch between GL implementations on the fly, so for the time being
-// we only do the context-dependent GLEW initialization once.
-bool InitializeGLEW() {
-#if defined(UNIT_TEST)
- return true;
-#else
- static bool initialized = false;
- if (initialized)
- return true;
-
- // Initializes context-dependent parts of GLEW.
- if (glewInit() != GLEW_OK) {
- LOG(ERROR) << "GLEW failed initialization";
- return false;
- }
-
- // Check to see that we can use the OpenGL vertex attribute APIs
- // TODO(petersont): Return false if this check fails, but because some
- // Intel hardware does not support OpenGL 2.0, yet does support all of the
- // extensions we require, we only log an error. A future CL should change
- // this check to ensure that all of the extension strings we require are
- // present.
- if (!GLEW_VERSION_2_0) {
- DLOG(ERROR) << "GL drivers do not have OpenGL 2.0 functionality.";
- }
-
- // Check for necessary extensions.
- bool extensions_found = true;
- if (!GLEW_ARB_vertex_buffer_object) {
- // NOTE: Linux NVidia drivers claim to support OpenGL 2.0 when using
- // indirect rendering (e.g. remote X), but it is actually lying. The
- // ARB_vertex_buffer_object functions silently no-op (!) when using
- // indirect rendering, leading to crashes. Fortunately, in that case, the
- // driver claims to not support ARB_vertex_buffer_object, so fail in that
- // case.
- DLOG(ERROR) << "GL drivers do not support vertex buffer objects.";
- extensions_found = false;
- }
- if (!GLEW_EXT_framebuffer_object) {
- DLOG(ERROR) << "GL drivers do not support framebuffer objects.";
- extensions_found = false;
- }
- if (!GLEW_VERSION_2_0 && !GLEW_EXT_stencil_two_side) {
- DLOG(ERROR) << "Two sided stencil extension missing.";
- extensions_found = false;
- }
- if (!GLEW_VERSION_1_4 && !GLEW_EXT_blend_func_separate) {
- DLOG(ERROR) <<"Separate blend func extension missing.";
- extensions_found = false;
- }
- if (!GLEW_VERSION_2_0 && !GLEW_EXT_blend_equation_separate) {
- DLOG(ERROR) << "Separate blend function extension missing.";
- extensions_found = false;
- }
- if (!extensions_found)
- return false;
-
- initialized = true;
- return true;
-#endif
-}
-
bool GLContext::InitializeCommon() {
if (!MakeCurrent())
return false;
diff --git a/app/gfx/gl/gl_context.h b/app/gfx/gl/gl_context.h
index 2a9b3df..1b04985 100644
--- a/app/gfx/gl/gl_context.h
+++ b/app/gfx/gl/gl_context.h
@@ -12,8 +12,6 @@
namespace gfx {
-bool InitializeGLEW();
-
// Encapsulates an OpenGL context, hiding platform specific management.
class GLContext {
public:
@@ -50,7 +48,7 @@ class GLContext {
// Create a GL context used for offscreen rendering. It is initially backed by
// a 1x1 pbuffer. Use it to create an FBO to do useful rendering.
- static GLContext* CreateOffscreenGLContext(void* shared_handle);
+ static GLContext* CreateOffscreenGLContext(GLContext* shared_context);
protected:
bool InitializeCommon();
diff --git a/app/gfx/gl/gl_context_egl.cc b/app/gfx/gl/gl_context_egl.cc
new file mode 100644
index 0000000..ec64ae91
--- /dev/null
+++ b/app/gfx/gl/gl_context_egl.cc
@@ -0,0 +1,241 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <EGL/egl.h>
+
+#include "base/scoped_ptr.h"
+#include "app/gfx/gl/gl_bindings.h"
+#include "app/gfx/gl/gl_context_egl.h"
+
+namespace gfx {
+
+namespace {
+
+// The EGL configuration to use.
+EGLDisplay g_display;
+EGLConfig g_config;
+
+bool InitializeOneOff() {
+ static bool initialized = false;
+ if (initialized)
+ return true;
+
+ g_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ if (!g_display)
+ return false;
+
+ if (!eglInitialize(g_display, NULL, NULL) == EGL_TRUE)
+ return false;
+
+ // Choose an EGL configuration.
+ static const EGLint kConfigAttribs[] = {
+ EGL_BUFFER_SIZE, 32,
+ EGL_ALPHA_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_RED_SIZE, 8,
+ EGL_DEPTH_SIZE, 24,
+ EGL_STENCIL_SIZE, 8,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_NONE
+ };
+
+ EGLint num_configs;
+ if (!eglChooseConfig(g_display,
+ kConfigAttribs,
+ NULL,
+ 0,
+ &num_configs)) {
+ return false;
+ }
+
+ if (num_configs == 0)
+ return false;
+
+ scoped_array<EGLConfig> configs(new EGLConfig[num_configs]);
+ if (!eglChooseConfig(g_display,
+ kConfigAttribs,
+ configs.get(),
+ num_configs,
+ &num_configs)) {
+ return false;
+ }
+
+ g_config = configs[0];
+
+ initialized = true;
+ return true;
+}
+} // namespace anonymous
+
+NativeViewEGLContext::NativeViewEGLContext(void* window)
+ : window_(window),
+ surface_(NULL),
+ context_(NULL)
+{
+}
+
+NativeViewEGLContext::~NativeViewEGLContext() {
+}
+
+bool NativeViewEGLContext::Initialize() {
+ DCHECK(!context_);
+
+ if (!InitializeOneOff())
+ return NULL;
+
+ // Create a surface for the native window.
+ surface_ = eglCreateWindowSurface(g_display,
+ g_config,
+ static_cast<EGLNativeWindowType>(window_),
+ NULL);
+ if (!surface_) {
+ Destroy();
+ return false;
+ }
+
+ // Create a context.
+ context_ = eglCreateContext(g_display, g_config, NULL, NULL);
+ if (!context_) {
+ Destroy();
+ return false;
+ }
+
+ if (!MakeCurrent()) {
+ Destroy();
+ return false;
+ }
+
+ if (!InitializeCommon()) {
+ Destroy();
+ return false;
+ }
+
+ return true;
+}
+
+void NativeViewEGLContext::Destroy() {
+ if (context_) {
+ eglDestroyContext(g_display, context_);
+ context_ = NULL;
+ }
+
+ if (surface_) {
+ eglDestroySurface(g_display, surface_);
+ surface_ = NULL;
+ }
+}
+
+bool NativeViewEGLContext::MakeCurrent() {
+ DCHECK(context_);
+ return eglMakeCurrent(g_display,
+ surface_, surface_,
+ context_) == GL_TRUE;
+}
+
+bool NativeViewEGLContext::IsCurrent() {
+ DCHECK(context_);
+ return context_ == eglGetCurrentContext();
+}
+
+bool NativeViewEGLContext::IsOffscreen() {
+ return false;
+}
+
+void NativeViewEGLContext::SwapBuffers() {
+ eglSwapBuffers(g_display, surface_);
+}
+
+gfx::Size NativeViewEGLContext::GetSize() {
+#if defined(OS_WIN)
+ RECT rect;
+ CHECK(GetClientRect(static_cast<HWND>(window_), &rect));
+ return gfx::Size(rect.right - rect.left, rect.bottom - rect.top);
+#else
+ NOTREACHED()
+ << "NativeViewEGLContext::GetSize not implemented on this platform.";
+#endif
+}
+
+void* NativeViewEGLContext::GetHandle() {
+ return context_;
+}
+
+EGLSurface NativeViewEGLContext::GetSurface() {
+ return surface_;
+}
+
+SecondaryEGLContext::SecondaryEGLContext()
+ : surface_(NULL),
+ context_(NULL)
+{
+}
+
+SecondaryEGLContext::~SecondaryEGLContext() {
+}
+
+bool SecondaryEGLContext::Initialize(GLContext* shared_context) {
+ DCHECK(shared_context);
+ DCHECK(!context_);
+
+ if (!InitializeOneOff())
+ return NULL;
+
+ surface_ = static_cast<BaseEGLContext*>(shared_context)->GetSurface();
+
+ // Create a context.
+ context_ = eglCreateContext(g_display,
+ g_config,
+ shared_context->GetHandle(),
+ NULL);
+ if (!context_) {
+ Destroy();
+ return false;
+ }
+
+ return true;
+}
+
+void SecondaryEGLContext::Destroy() {
+ surface_ = NULL;
+
+ if (context_) {
+ eglDestroyContext(g_display, context_);
+ context_ = NULL;
+ }
+}
+
+bool SecondaryEGLContext::MakeCurrent() {
+ DCHECK(context_);
+ return eglMakeCurrent(g_display,
+ surface_, surface_,
+ context_) == GL_TRUE;
+}
+
+bool SecondaryEGLContext::IsCurrent() {
+ DCHECK(context_);
+ return context_ == eglGetCurrentContext();
+}
+
+bool SecondaryEGLContext::IsOffscreen() {
+ return true;
+}
+
+void SecondaryEGLContext::SwapBuffers() {
+ NOTREACHED() << "Attempted to call SwapBuffers on a SecondaryEGLContext.";
+}
+
+gfx::Size SecondaryEGLContext::GetSize() {
+ NOTREACHED() << "Should not be requesting size of this SecondaryEGLContext.";
+ return gfx::Size(1, 1);
+}
+
+void* SecondaryEGLContext::GetHandle() {
+ return context_;
+}
+
+EGLSurface SecondaryEGLContext::GetSurface() {
+ return surface_;
+}
+
+} // namespace gfx
diff --git a/app/gfx/gl/gl_context_egl.h b/app/gfx/gl/gl_context_egl.h
new file mode 100644
index 0000000..4bfff9b
--- /dev/null
+++ b/app/gfx/gl/gl_context_egl.h
@@ -0,0 +1,93 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef APP_GFX_GL_GL_CONTEXT_EGL_H_
+#define APP_GFX_GL_GL_CONTEXT_EGL_H_
+
+#include "gfx/size.h"
+#include "app/gfx/gl/gl_context.h"
+
+typedef void *EGLContext;
+typedef void* EGLSurface;
+
+namespace gfx {
+
+// Interface for EGL contexts. Adds an EGL specific accessor for retreiving
+// the surface.
+class BaseEGLContext : public GLContext {
+ public:
+ BaseEGLContext() {}
+ virtual ~BaseEGLContext() {}
+
+ // Implement GLContext.
+ virtual EGLSurface GetSurface() = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BaseEGLContext);
+};
+
+// Encapsulates an EGL OpenGL ES context that renders to a view.
+class NativeViewEGLContext : public BaseEGLContext {
+ public:
+ explicit NativeViewEGLContext(void* window);
+ virtual ~NativeViewEGLContext();
+
+ // Initialize an EGL context.
+ bool Initialize();
+
+ // Implement GLContext.
+ virtual void Destroy();
+ virtual bool MakeCurrent();
+ virtual bool IsCurrent();
+ virtual bool IsOffscreen();
+ virtual void SwapBuffers();
+ virtual gfx::Size GetSize();
+ virtual void* GetHandle();
+
+ // Implement BaseEGLContext.
+ virtual EGLSurface GetSurface();
+
+ private:
+ void* window_;
+ EGLSurface surface_;
+ EGLContext context_;
+
+ DISALLOW_COPY_AND_ASSIGN(NativeViewEGLContext);
+};
+
+// Encapsulates an EGL OpenGL ES context intended for offscreen use. It is
+// actually associated with a native window and will render to it. The caller
+// must bind an FBO to prevent this. Not using pbuffers because ANGLE does not
+// support them.
+class SecondaryEGLContext : public BaseEGLContext {
+ public:
+ SecondaryEGLContext();
+ virtual ~SecondaryEGLContext();
+
+ // Initialize an EGL context that shares a namespace with another.
+ bool Initialize(GLContext* shared_context);
+
+ // Implement GLContext.
+ virtual void Destroy();
+ virtual bool MakeCurrent();
+ virtual bool IsCurrent();
+ virtual bool IsOffscreen();
+ virtual void SwapBuffers();
+ virtual gfx::Size GetSize();
+ virtual void* GetHandle();
+
+ // Implement BaseEGLContext.
+ virtual EGLSurface GetSurface();
+
+ private:
+ // All offscreen
+ EGLSurface surface_;
+ EGLContext context_;
+
+ DISALLOW_COPY_AND_ASSIGN(SecondaryEGLContext);
+};
+
+} // namespace gfx
+
+#endif // APP_GFX_GL_GL_CONTEXT_EGL_H_
diff --git a/app/gfx/gl/gl_context_linux.cc b/app/gfx/gl/gl_context_linux.cc
index 77d6573..d2c5a4f 100644
--- a/app/gfx/gl/gl_context_linux.cc
+++ b/app/gfx/gl/gl_context_linux.cc
@@ -4,19 +4,14 @@
// This file implements the ViewGLContext and PbufferGLContext classes.
-#include <dlfcn.h>
-#include <GL/glew.h>
-#include <GL/glxew.h>
-#include <GL/glx.h>
-#include <GL/osmew.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
#include "app/x11_util.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
+#include "app/gfx/gl/gl_bindings.h"
#include "app/gfx/gl/gl_context.h"
#include "app/gfx/gl/gl_context_osmesa.h"
+#include "app/gfx/gl/gl_context_stub.h"
+#include "app/gfx/gl/gl_implementation.h"
namespace gfx {
@@ -62,7 +57,7 @@ class PbufferGLContext : public GLContext {
}
// Initializes the GL context.
- bool Initialize(void* shared_handle);
+ bool Initialize(GLContext* shared_context);
virtual void Destroy();
virtual bool MakeCurrent();
@@ -89,7 +84,7 @@ class PixmapGLContext : public GLContext {
}
// Initializes the GL context.
- bool Initialize(void* shared_handle);
+ bool Initialize(GLContext* shared_context);
virtual void Destroy();
virtual bool MakeCurrent();
@@ -117,39 +112,23 @@ class ScopedPtrXFree {
}
};
-// Some versions of NVIDIA's GL libGL.so include a broken version of
-// dlopen/dlsym, and so linking it into chrome breaks it. So we dynamically
-// load it, and use glew to dynamically resolve symbols.
-// See http://code.google.com/p/chromium/issues/detail?id=16800
-
static bool InitializeOneOff() {
static bool initialized = false;
if (initialized)
return true;
- osmewInit();
- if (!OSMesaCreateContext) {
- void* handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
- if (!handle) {
- LOG(ERROR) << "Could not find libGL.so.1";
- return false;
- }
+ // Initialize the GL bindings if they haven't already been initialized. If
+ // the GPU unit tests are running, the mock GL implementation will already
+ // have been initialized.
+ if (!InitializeGLBindings(kGLImplementationDesktopGL)) {
+ LOG(ERROR) << "Could not initialize GL.";
+ return false;
+ }
- // Initializes context-independent parts of GLEW
- if (glxewInit() != GLEW_OK) {
- LOG(ERROR) << "glxewInit failed";
- return false;
- }
- // glxewContextInit really only needs a display connection to
- // complete, and we don't want to have to create an OpenGL context
- // just to get access to GLX 1.3 entry points to create pbuffers.
- // We therefore added a glxewContextInitWithDisplay entry point.
+ // Only check the GLX version if we are in fact using GLX. We might actually
+ // be using the mock GL implementation.
+ if (GetGLImplementation() == kGLImplementationDesktopGL) {
Display* display = x11_util::GetXDisplay();
- if (glxewContextInitWithDisplay(display) != GLEW_OK) {
- LOG(ERROR) << "glxewContextInit failed";
- return false;
- }
-
int major, minor;
if (!glXQueryVersion(display, &major, &minor)) {
LOG(ERROR) << "glxQueryVersion failed";
@@ -199,11 +178,6 @@ bool ViewGLContext::Initialize(bool multisampled) {
return false;
}
- if (!InitializeGLEW()) {
- Destroy();
- return false;
- }
-
if (!InitializeCommon()) {
Destroy();
return false;
@@ -214,7 +188,7 @@ bool ViewGLContext::Initialize(bool multisampled) {
void ViewGLContext::Destroy() {
Display* display = x11_util::GetXDisplay();
- Bool result = glXMakeCurrent(display, 0, 0);
+ bool result = glXMakeCurrent(display, 0, 0);
// glXMakeCurrent isn't supposed to fail when unsetting the context, unless
// we have pending draws on an invalid window - which shouldn't be the case
@@ -272,29 +246,24 @@ GLContext* GLContext::CreateViewGLContext(gfx::PluginWindowHandle window,
if (!InitializeOneOff())
return NULL;
- if (OSMesaCreateContext) {
- // TODO(apatrick): Support OSMesa rendering to a window on Linux.
- NOTREACHED() << "OSMesa rendering to a window is not yet implemented.";
- return NULL;
- } else {
- scoped_ptr<ViewGLContext> context(new ViewGLContext(window));
+ switch (GetGLImplementation()) {
+ case kGLImplementationDesktopGL: {
+ scoped_ptr<ViewGLContext> context(new ViewGLContext(window));
- if (!context->Initialize(multisampled))
- return NULL;
+ if (!context->Initialize(multisampled))
+ return NULL;
- return context.release();
+ return context.release();
+ }
+ case kGLImplementationMockGL:
+ return new StubGLContext;
+ default:
+ NOTREACHED();
+ return NULL;
}
}
-bool PbufferGLContext::Initialize(void* shared_handle) {
- if (!glXChooseFBConfig ||
- !glXCreateNewContext ||
- !glXCreatePbuffer ||
- !glXDestroyPbuffer) {
- LOG(ERROR) << "Pbuffer support not available.";
- return false;
- }
-
+bool PbufferGLContext::Initialize(GLContext* shared_context) {
static const int config_attributes[] = {
GLX_DRAWABLE_TYPE,
GLX_PBUFFER_BIT,
@@ -319,10 +288,15 @@ bool PbufferGLContext::Initialize(void* shared_handle) {
LOG(ERROR) << "glXChooseFBConfig returned 0 elements.";
return false;
}
+
+ GLContextHandle shared_handle = NULL;
+ if (shared_context)
+ shared_handle = static_cast<GLContextHandle>(shared_context->GetHandle());
+
context_ = glXCreateNewContext(display,
config.get()[0],
GLX_RGBA_TYPE,
- static_cast<GLContextHandle>(shared_handle),
+ shared_handle,
True);
if (!context_) {
LOG(ERROR) << "glXCreateNewContext failed.";
@@ -349,11 +323,6 @@ bool PbufferGLContext::Initialize(void* shared_handle) {
return false;
}
- if (!InitializeGLEW()) {
- Destroy();
- return false;
- }
-
if (!InitializeCommon()) {
Destroy();
return false;
@@ -364,7 +333,7 @@ bool PbufferGLContext::Initialize(void* shared_handle) {
void PbufferGLContext::Destroy() {
Display* display = x11_util::GetXDisplay();
- Bool result = glXMakeCurrent(display, 0, 0);
+ bool result = glXMakeCurrent(display, 0, 0);
// glXMakeCurrent isn't supposed to fail when unsetting the context, unless
// we have pending draws on an invalid window - which shouldn't be the case
// here.
@@ -417,14 +386,8 @@ void* PbufferGLContext::GetHandle() {
return context_;
}
-bool PixmapGLContext::Initialize(void* shared_handle) {
+bool PixmapGLContext::Initialize(GLContext* shared_context) {
LOG(INFO) << "GL context: using pixmaps.";
- if (!glXChooseVisual ||
- !glXCreateGLXPixmap ||
- !glXDestroyGLXPixmap) {
- LOG(ERROR) << "Pixmap support not available.";
- return false;
- }
static int attributes[] = {
GLX_RGBA,
@@ -441,9 +404,12 @@ bool PixmapGLContext::Initialize(void* shared_handle) {
LOG(ERROR) << "glXChooseVisual failed.";
return false;
}
- context_ = glXCreateContext(display, visual_info.get(),
- static_cast<GLContextHandle>(shared_handle),
- True);
+
+ GLContextHandle shared_handle = NULL;
+ if (shared_context)
+ shared_handle = static_cast<GLContextHandle>(shared_context->GetHandle());
+
+ context_ = glXCreateContext(display, visual_info.get(), shared_handle, True);
if (!context_) {
LOG(ERROR) << "glXCreateContext failed.";
return false;
@@ -468,11 +434,6 @@ bool PixmapGLContext::Initialize(void* shared_handle) {
return false;
}
- if (!InitializeGLEW()) {
- Destroy();
- return false;
- }
-
if (!InitializeCommon()) {
Destroy();
return false;
@@ -483,7 +444,7 @@ bool PixmapGLContext::Initialize(void* shared_handle) {
void PixmapGLContext::Destroy() {
Display* display = x11_util::GetXDisplay();
- Bool result = glXMakeCurrent(display, 0, 0);
+ bool result = glXMakeCurrent(display, 0, 0);
// glXMakeCurrent isn't supposed to fail when unsetting the context, unless
// we have pending draws on an invalid window - which shouldn't be the case
// here.
@@ -541,27 +502,27 @@ void* PixmapGLContext::GetHandle() {
return context_;
}
-GLContext* GLContext::CreateOffscreenGLContext(void* shared_handle) {
+GLContext* GLContext::CreateOffscreenGLContext(GLContext* shared_context) {
if (!InitializeOneOff())
return NULL;
- if (OSMesaCreateContext) {
- scoped_ptr<OSMesaGLContext> context(new OSMesaGLContext);
+ switch (GetGLImplementation()) {
+ case kGLImplementationDesktopGL: {
+ scoped_ptr<PbufferGLContext> context(new PbufferGLContext);
+ if (context->Initialize(shared_context))
+ return context.release();
- if (!context->Initialize(shared_handle))
- return NULL;
-
- return context.release();
- } else {
- scoped_ptr<PbufferGLContext> context(new PbufferGLContext);
- if (context->Initialize(shared_handle))
- return context.release();
+ scoped_ptr<PixmapGLContext> context_pixmap(new PixmapGLContext);
+ if (context_pixmap->Initialize(shared_context))
+ return context_pixmap.release();
- scoped_ptr<PixmapGLContext> context_pixmap(new PixmapGLContext);
- if (context_pixmap->Initialize(shared_handle))
- return context_pixmap.release();
-
- return NULL;
+ return NULL;
+ }
+ case kGLImplementationMockGL:
+ return new StubGLContext;
+ default:
+ NOTREACHED();
+ return NULL;
}
}
diff --git a/app/gfx/gl/gl_context_mac.cc b/app/gfx/gl/gl_context_mac.cc
index ab08c60..e69f644 100644
--- a/app/gfx/gl/gl_context_mac.cc
+++ b/app/gfx/gl/gl_context_mac.cc
@@ -4,15 +4,15 @@
// This file implements the ViewGLContext and PbufferGLContext classes.
-#include <GL/glew.h>
-#include <GL/osmew.h>
#include <OpenGL/OpenGL.h>
#include "app/surface/accelerated_surface_mac.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
+#include "app/gfx/gl/gl_bindings.h"
#include "app/gfx/gl/gl_context.h"
-#include "app/gfx/gl/gl_context_osmesa.h"
+#include "app/gfx/gl/gl_context_stub.h"
+#include "app/gfx/gl/gl_implementation.h"
namespace gfx {
@@ -30,7 +30,7 @@ class PbufferGLContext : public GLContext {
}
// Initializes the GL context.
- bool Initialize(void* shared_handle);
+ bool Initialize(GLContext* shared_context);
virtual void Destroy();
virtual bool MakeCurrent();
@@ -52,12 +52,16 @@ static bool InitializeOneOff() {
if (initialized)
return true;
- osmewInit();
+ if (!InitializeGLBindings(kGLImplementationDesktopGL)) {
+ LOG(ERROR) << "Could not initialize GL.";
+ return false;
+ }
+
initialized = true;
return true;
}
-bool PbufferGLContext::Initialize(void* shared_handle) {
+bool PbufferGLContext::Initialize(GLContext* shared_context) {
// Create a 1x1 pbuffer and associated context to bootstrap things.
static const CGLPixelFormatAttribute attribs[] = {
(CGLPixelFormatAttribute) kCGLPFAPBuffer,
@@ -75,9 +79,12 @@ bool PbufferGLContext::Initialize(void* shared_handle) {
if (!pixel_format) {
return false;
}
- CGLError res = CGLCreateContext(pixel_format,
- static_cast<GLContextHandle>(shared_handle),
- &context_);
+
+ GLContextHandle shared_handle = NULL;
+ if (shared_context)
+ shared_handle = static_cast<GLContextHandle>(shared_context->GetHandle());
+
+ CGLError res = CGLCreateContext(pixel_format, shared_handle, &context_);
CGLDestroyPixelFormat(pixel_format);
if (res != kCGLNoError) {
DLOG(ERROR) << "Error creating context.";
@@ -103,11 +110,6 @@ bool PbufferGLContext::Initialize(void* shared_handle) {
return false;
}
- if (!InitializeGLEW()) {
- Destroy();
- return false;
- }
-
if (!InitializeCommon()) {
Destroy();
return false;
@@ -160,23 +162,23 @@ void* PbufferGLContext::GetHandle() {
return context_;
}
-GLContext* GLContext::CreateOffscreenGLContext(void* shared_handle) {
+GLContext* GLContext::CreateOffscreenGLContext(GLContext* shared_context) {
if (!InitializeOneOff())
return NULL;
- if (OSMesaCreateContext) {
- scoped_ptr<OSMesaGLContext> context(new OSMesaGLContext);
-
- if (!context->Initialize(shared_handle))
- return NULL;
+ switch (GetGLImplementation()) {
+ case kGLImplementationDesktopGL: {
+ scoped_ptr<PbufferGLContext> context(new PbufferGLContext);
+ if (!context->Initialize(shared_context))
+ return NULL;
- return context.release();
- } else {
- scoped_ptr<PbufferGLContext> context(new PbufferGLContext);
- if (!context->Initialize(shared_handle))
+ return context.release();
+ }
+ case kGLImplementationMockGL:
+ return new StubGLContext;
+ default:
+ NOTREACHED();
return NULL;
-
- return context.release();
}
}
diff --git a/app/gfx/gl/gl_context_osmesa.cc b/app/gfx/gl/gl_context_osmesa.cc
index 49057d2..6d144cb 100644
--- a/app/gfx/gl/gl_context_osmesa.cc
+++ b/app/gfx/gl/gl_context_osmesa.cc
@@ -2,11 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <GL/glew.h>
-#include <GL/osmew.h>
-
#include <algorithm>
+#include "app/gfx/gl/gl_bindings.h"
#include "app/gfx/gl/gl_context_osmesa.h"
namespace gfx {
@@ -18,14 +16,17 @@ OSMesaGLContext::OSMesaGLContext() : context_(NULL)
OSMesaGLContext::~OSMesaGLContext() {
}
-bool OSMesaGLContext::Initialize(void* shared_handle) {
+bool OSMesaGLContext::Initialize(GLContext* shared_context) {
DCHECK(!context_);
size_ = gfx::Size(1, 1);
buffer_.reset(new int32[1]);
- context_ = OSMesaCreateContext(GL_RGBA,
- static_cast<OSMesaContext>(shared_handle));
+ OSMesaContext shared_handle = NULL;
+ if (shared_context)
+ shared_handle = static_cast<OSMesaContext>(shared_context->GetHandle());
+
+ context_ = OSMesaCreateContext(GL_RGBA, shared_handle);
if (!context_)
return false;
@@ -34,11 +35,6 @@ bool OSMesaGLContext::Initialize(void* shared_handle) {
return false;
}
- if (!InitializeGLEW()) {
- Destroy();
- return false;
- }
-
if (!InitializeCommon()) {
Destroy();
return false;
diff --git a/app/gfx/gl/gl_context_osmesa.h b/app/gfx/gl/gl_context_osmesa.h
index 4959c846..62acc5b 100644
--- a/app/gfx/gl/gl_context_osmesa.h
+++ b/app/gfx/gl/gl_context_osmesa.h
@@ -20,7 +20,7 @@ class OSMesaGLContext : public GLContext {
virtual ~OSMesaGLContext();
// Initialize an OSMesa GL context with the default 1 x 1 initial size.
- bool Initialize(void* shared_handle);
+ bool Initialize(GLContext* shared_context);
// Implement GLContext.
virtual void Destroy();
@@ -40,11 +40,9 @@ class OSMesaGLContext : public GLContext {
}
private:
-#if !defined(UNIT_TEST)
gfx::Size size_;
scoped_array<int32> buffer_;
OSMesaContext context_;
-#endif
DISALLOW_COPY_AND_ASSIGN(OSMesaGLContext);
};
diff --git a/gpu/command_buffer/service/gl_context_stub.cc b/app/gfx/gl/gl_context_stub.h
index d6df0b7..f7b6044 100644
--- a/gpu/command_buffer/service/gl_context_stub.cc
+++ b/app/gfx/gl/gl_context_stub.h
@@ -4,41 +4,31 @@
// This file implements the StubGLContext.
-#include "build/build_config.h"
+#ifndef APP_GFX_GL_GL_CONTEXT_STUB_H_
+#define APP_GFX_GL_GL_CONTEXT_STUB_H_
+
#include "app/gfx/gl/gl_context.h"
-namespace gpu {
+namespace gfx {
// A GLContext that does nothing for unit tests.
class StubGLContext : public gfx::GLContext {
public:
-
// Implement GLContext.
virtual void Destroy() {}
virtual bool MakeCurrent() { return true; }
virtual bool IsCurrent() { return true; }
- virtual bool IsOffscreen() { return true; }
+ virtual bool IsOffscreen() { return false; }
virtual void SwapBuffers() {}
- virtual gfx::Size GetSize() { return gfx::Size(); }
+ virtual gfx::Size GetSize() { return size_; }
virtual void* GetHandle() { return NULL; }
-};
-
-} // namespace gpu
-namespace gfx {
+ void SetSize(const gfx::Size& size) { size_ = size; }
-#if !defined(OS_MACOSX)
-
-GLContext* GLContext::CreateViewGLContext(PluginWindowHandle /* window */,
- bool /* multisampled */) {
- return new gpu::StubGLContext;
-}
-
-#endif // OS_MACOSX
-
-GLContext* GLContext::CreateOffscreenGLContext(
- void* /* shared_handle */) {
- return new gpu::StubGLContext;
-}
+ private:
+ gfx::Size size_;
+};
} // namespace gfx
+
+#endif // APP_GFX_GL_GL_CONTEXT_STUB_H_
diff --git a/app/gfx/gl/gl_context_win.cc b/app/gfx/gl/gl_context_win.cc
index 8bbb6268..b6bac4d 100644
--- a/app/gfx/gl/gl_context_win.cc
+++ b/app/gfx/gl/gl_context_win.cc
@@ -4,17 +4,16 @@
// This file implements the NativeViewGLContext and PbufferGLContext classes.
-#include <GL/glew.h>
-#include <GL/osmew.h>
-#include <GL/wglew.h>
-#include <windows.h>
-
#include <algorithm>
#include "base/logging.h"
#include "base/scoped_ptr.h"
+#include "app/gfx/gl/gl_bindings.h"
#include "app/gfx/gl/gl_context.h"
+#include "app/gfx/gl/gl_context_egl.h"
#include "app/gfx/gl/gl_context_osmesa.h"
+#include "app/gfx/gl/gl_context_stub.h"
+#include "app/gfx/gl/gl_implementation.h"
namespace gfx {
@@ -100,7 +99,7 @@ class PbufferGLContext : public GLContext {
}
// Initializes the GL context.
- bool Initialize(void* shared_handle);
+ bool Initialize(GLContext* shared_context);
virtual void Destroy();
virtual bool MakeCurrent();
@@ -118,9 +117,14 @@ class PbufferGLContext : public GLContext {
DISALLOW_COPY_AND_ASSIGN(PbufferGLContext);
};
+static HWND g_window;
static int g_regular_pixel_format = 0;
static int g_multisampled_pixel_format = 0;
+// When using ANGLE we still need a window for D3D. This context creates the
+// D3D device.
+static BaseEGLContext* g_default_context;
+
const PIXELFORMATDESCRIPTOR kPixelFormatDescriptor = {
sizeof(kPixelFormatDescriptor), // Size of structure.
1, // Default version.
@@ -155,94 +159,103 @@ static bool InitializeOneOff() {
if (initialized)
return true;
- osmewInit();
- if (!OSMesaCreateContext) {
- // We must initialize a GL context before we can determine the multi-
- // sampling supported on the current hardware, so we create an intermediate
- // window and context here.
- HINSTANCE module_handle;
- if (!::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT |
- GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
- reinterpret_cast<wchar_t*>(IntermediateWindowProc),
- &module_handle)) {
- return false;
+ if (!InitializeGLBindings(kGLImplementationOSMesaGL)) {
+ if (!InitializeGLBindings(kGLImplementationEGLGLES2)) {
+ if (!InitializeGLBindings(kGLImplementationDesktopGL)) {
+ LOG(ERROR) << "Could not initialize GL.";
+ return false;
+ }
}
+ }
- WNDCLASS intermediate_class;
- intermediate_class.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
- intermediate_class.lpfnWndProc = IntermediateWindowProc;
- intermediate_class.cbClsExtra = 0;
- intermediate_class.cbWndExtra = 0;
- intermediate_class.hInstance = module_handle;
- intermediate_class.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- intermediate_class.hCursor = LoadCursor(NULL, IDC_ARROW);
- intermediate_class.hbrBackground = NULL;
- intermediate_class.lpszMenuName = NULL;
- intermediate_class.lpszClassName = L"Intermediate GL Window";
-
- ATOM class_registration = ::RegisterClass(&intermediate_class);
- if (!class_registration) {
- return false;
- }
- HWND intermediate_window = ::CreateWindow(
- reinterpret_cast<wchar_t*>(class_registration),
- L"",
- WS_OVERLAPPEDWINDOW,
- 0, 0,
- CW_USEDEFAULT, CW_USEDEFAULT,
- NULL,
- NULL,
- NULL,
- NULL);
-
- if (!intermediate_window) {
- ::UnregisterClass(reinterpret_cast<wchar_t*>(class_registration),
- module_handle);
- return false;
- }
+ // We must initialize a GL context before we can determine the multi-
+ // sampling supported on the current hardware, so we create an intermediate
+ // window and context here.
+ HINSTANCE module_handle;
+ if (!::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT |
+ GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+ reinterpret_cast<wchar_t*>(IntermediateWindowProc),
+ &module_handle)) {
+ return false;
+ }
- HDC intermediate_dc = ::GetDC(intermediate_window);
- g_regular_pixel_format = ::ChoosePixelFormat(intermediate_dc,
- &kPixelFormatDescriptor);
- if (g_regular_pixel_format == 0) {
- DLOG(ERROR) << "Unable to get the pixel format for GL context.";
- ::ReleaseDC(intermediate_window, intermediate_dc);
- ::DestroyWindow(intermediate_window);
- ::UnregisterClass(reinterpret_cast<wchar_t*>(class_registration),
- module_handle);
- return false;
- }
- if (!::SetPixelFormat(intermediate_dc, g_regular_pixel_format,
- &kPixelFormatDescriptor)) {
- DLOG(ERROR) << "Unable to set the pixel format for GL context.";
- ::ReleaseDC(intermediate_window, intermediate_dc);
- ::DestroyWindow(intermediate_window);
- ::UnregisterClass(reinterpret_cast<wchar_t*>(class_registration),
- module_handle);
- return false;
- }
+ WNDCLASS intermediate_class;
+ intermediate_class.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
+ intermediate_class.lpfnWndProc = IntermediateWindowProc;
+ intermediate_class.cbClsExtra = 0;
+ intermediate_class.cbWndExtra = 0;
+ intermediate_class.hInstance = module_handle;
+ intermediate_class.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+ intermediate_class.hCursor = LoadCursor(NULL, IDC_ARROW);
+ intermediate_class.hbrBackground = NULL;
+ intermediate_class.lpszMenuName = NULL;
+ intermediate_class.lpszClassName = L"Intermediate GL Window";
+
+ ATOM class_registration = ::RegisterClass(&intermediate_class);
+ if (!class_registration) {
+ return false;
+ }
- // Create a temporary GL context to query for multisampled pixel formats.
- HGLRC gl_context = ::wglCreateContext(intermediate_dc);
- if (::wglMakeCurrent(intermediate_dc, gl_context)) {
- // GL context was successfully created and applied to the window's DC.
- // Startup GLEW, the GL extensions wrangler.
- if (InitializeGLEW()) {
- DLOG(INFO) << "Initialized GLEW " << glewGetString(GLEW_VERSION);
- } else {
- ::wglMakeCurrent(intermediate_dc, NULL);
- ::wglDeleteContext(gl_context);
- ::ReleaseDC(intermediate_window, intermediate_dc);
- ::DestroyWindow(intermediate_window);
- ::UnregisterClass(reinterpret_cast<wchar_t*>(class_registration),
- module_handle);
- return false;
- }
+ g_window = ::CreateWindow(
+ reinterpret_cast<wchar_t*>(class_registration),
+ L"",
+ WS_OVERLAPPEDWINDOW,
+ 0, 0,
+ 100, 100,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+
+ if (!g_window) {
+ ::UnregisterClass(reinterpret_cast<wchar_t*>(class_registration),
+ module_handle);
+ return false;
+ }
+
+ // Early out if OSMesa offscreen renderer or EGL is present.
+ if (GetGLImplementation() != kGLImplementationDesktopGL) {
+ initialized = true;
+ return true;
+ }
+
+ HDC intermediate_dc = ::GetDC(g_window);
+ g_regular_pixel_format = ::ChoosePixelFormat(intermediate_dc,
+ &kPixelFormatDescriptor);
+ if (g_regular_pixel_format == 0) {
+ DLOG(ERROR) << "Unable to get the pixel format for GL context.";
+ ::ReleaseDC(g_window, intermediate_dc);
+ ::DestroyWindow(g_window);
+ ::UnregisterClass(reinterpret_cast<wchar_t*>(class_registration),
+ module_handle);
+ return false;
+ }
+ if (!::SetPixelFormat(intermediate_dc, g_regular_pixel_format,
+ &kPixelFormatDescriptor)) {
+ DLOG(ERROR) << "Unable to set the pixel format for GL context.";
+ ::ReleaseDC(g_window, intermediate_dc);
+ ::DestroyWindow(g_window);
+ ::UnregisterClass(reinterpret_cast<wchar_t*>(class_registration),
+ module_handle);
+ return false;
+ }
- // If the multi-sample extensions are present, query the api to determine
- // the pixel format.
- if (WGLEW_ARB_pixel_format && WGLEW_ARB_multisample) {
+ // Create a temporary GL context to query for multisampled pixel formats.
+ HGLRC gl_context = wglCreateContext(intermediate_dc);
+ if (wglMakeCurrent(intermediate_dc, gl_context)) {
+ // Get bindings to extension functions that cannot be acquired without a
+ // current context.
+ InitializeGLBindingsGL();
+ InitializeGLBindingsWGL();
+
+ // If the multi-sample extensions are present, query the api to determine
+ // the pixel format.
+ if (wglGetExtensionsStringARB) {
+ std::string extensions =
+ std::string(wglGetExtensionsStringARB(intermediate_dc));
+ extensions += std::string(" ");
+ if (extensions.find("WGL_ARB_pixel_format ")) {
int pixel_attributes[] = {
WGL_SAMPLES_ARB, 4,
WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
@@ -264,28 +277,26 @@ static bool InitializeOneOff() {
static const int kNumSamples = 2;
for (int sample = 0; sample < kNumSamples; ++sample) {
pixel_attributes[1] = kSampleCount[sample];
- if (GL_TRUE == ::wglChoosePixelFormatARB(intermediate_dc,
- pixel_attributes,
- pixel_attributes_f,
- 1,
- &g_multisampled_pixel_format,
- &num_formats)) {
+ if (GL_TRUE == wglChoosePixelFormatARB(intermediate_dc,
+ pixel_attributes,
+ pixel_attributes_f,
+ 1,
+ &g_multisampled_pixel_format,
+ &num_formats)) {
break;
}
}
}
}
-
- ::wglMakeCurrent(intermediate_dc, NULL);
- ::wglDeleteContext(gl_context);
- ::ReleaseDC(intermediate_window, intermediate_dc);
- ::DestroyWindow(intermediate_window);
- ::UnregisterClass(reinterpret_cast<wchar_t*>(class_registration),
- module_handle);
}
- initialized = true;
+ wglMakeCurrent(intermediate_dc, NULL);
+ wglDeleteContext(gl_context);
+ ReleaseDC(g_window, intermediate_dc);
+ UnregisterClass(reinterpret_cast<wchar_t*>(class_registration),
+ module_handle);
+ initialized = true;
return true;
}
@@ -352,11 +363,6 @@ bool NativeViewGLContext::Initialize(bool multisampled) {
return false;
}
- if (!InitializeGLEW()) {
- Destroy();
- return false;
- }
-
if (!InitializeCommon()) {
Destroy();
return false;
@@ -510,7 +516,7 @@ void* OSMesaViewGLContext::GetHandle() {
void OSMesaViewGLContext::UpdateSize() {
// Change back buffer size to that of window.
RECT rect;
- GetWindowRect(window_, &rect);
+ GetClientRect(window_, &rect);
gfx::Size window_size = gfx::Size(
std::max(1, static_cast<int>(rect.right - rect.left)),
std::max(1, static_cast<int>(rect.bottom - rect.top)));
@@ -522,24 +528,38 @@ GLContext* GLContext::CreateViewGLContext(gfx::PluginWindowHandle window,
if (!InitializeOneOff())
return NULL;
- if (OSMesaCreateContext) {
- scoped_ptr<OSMesaViewGLContext> context(new OSMesaViewGLContext(window));
+ switch (GetGLImplementation()) {
+ case kGLImplementationOSMesaGL: {
+ scoped_ptr<OSMesaViewGLContext> context(new OSMesaViewGLContext(window));
+ if (!context->Initialize())
+ return NULL;
- if (!context->Initialize())
- return NULL;
+ return context.release();
+ }
+ case kGLImplementationEGLGLES2: {
+ scoped_ptr<NativeViewEGLContext> context(
+ new NativeViewEGLContext(window));
+ if (!context->Initialize())
+ return NULL;
- return context.release();
- } else {
- scoped_ptr<NativeViewGLContext> context(new NativeViewGLContext(window));
+ return context.release();
+ }
+ case kGLImplementationDesktopGL: {
+ scoped_ptr<NativeViewGLContext> context(new NativeViewGLContext(window));
+ if (!context->Initialize(multisampled))
+ return NULL;
- if (!context->Initialize(multisampled))
+ return context.release();
+ }
+ case kGLImplementationMockGL:
+ return new StubGLContext;
+ default:
+ NOTREACHED();
return NULL;
-
- return context.release();
}
}
-bool PbufferGLContext::Initialize(void* shared_handle) {
+bool PbufferGLContext::Initialize(GLContext* shared_context) {
// Create a device context compatible with the primary display.
HDC display_device_context = ::CreateDC(L"DISPLAY", NULL, NULL, NULL);
@@ -547,10 +567,10 @@ bool PbufferGLContext::Initialize(void* shared_handle) {
// a stepping stone towards creating a frame buffer object. It doesn't
// matter what size it is.
const int kNoAttributes[] = { 0 };
- pbuffer_ = ::wglCreatePbufferARB(display_device_context,
- g_regular_pixel_format,
- 1, 1,
- kNoAttributes);
+ pbuffer_ = wglCreatePbufferARB(display_device_context,
+ g_regular_pixel_format,
+ 1, 1,
+ kNoAttributes);
::DeleteDC(display_device_context);
if (!pbuffer_) {
DLOG(ERROR) << "Unable to create pbuffer.";
@@ -558,22 +578,23 @@ bool PbufferGLContext::Initialize(void* shared_handle) {
return false;
}
- device_context_ = ::wglGetPbufferDCARB(pbuffer_);
+ device_context_ = wglGetPbufferDCARB(pbuffer_);
if (!device_context_) {
DLOG(ERROR) << "Unable to get pbuffer device context.";
Destroy();
return false;
}
- context_ = ::wglCreateContext(device_context_);
+ context_ = wglCreateContext(device_context_);
if (!context_) {
DLOG(ERROR) << "Failed to create GL context.";
Destroy();
return false;
}
- if (shared_handle) {
- if (!wglShareLists(static_cast<GLContextHandle>(shared_handle), context_)) {
+ if (shared_context) {
+ if (!wglShareLists(
+ static_cast<GLContextHandle>(shared_context->GetHandle()), context_)) {
DLOG(ERROR) << "Could not share GL contexts.";
Destroy();
return false;
@@ -585,11 +606,6 @@ bool PbufferGLContext::Initialize(void* shared_handle) {
return false;
}
- if (!InitializeGLEW()) {
- Destroy();
- return false;
- }
-
if (!InitializeCommon()) {
Destroy();
return false;
@@ -649,23 +665,50 @@ void* PbufferGLContext::GetHandle() {
return context_;
}
-GLContext* GLContext::CreateOffscreenGLContext(void* shared_handle) {
+GLContext* GLContext::CreateOffscreenGLContext(GLContext* shared_context) {
if (!InitializeOneOff())
return NULL;
- if (OSMesaCreateContext) {
- scoped_ptr<OSMesaGLContext> context(new OSMesaGLContext);
+ switch (GetGLImplementation()) {
+ case kGLImplementationOSMesaGL: {
+ scoped_ptr<OSMesaGLContext> context(new OSMesaGLContext);
+ if (!context->Initialize(shared_context))
+ return NULL;
- if (!context->Initialize(shared_handle))
- return NULL;
+ return context.release();
+ }
+ case kGLImplementationEGLGLES2: {
+ if (!shared_context) {
+ if (!g_default_context) {
+ scoped_ptr<NativeViewEGLContext> default_context(
+ new NativeViewEGLContext(g_window));
+ if (!default_context->Initialize())
+ return NULL;
+
+ g_default_context = default_context.release();
+ }
+ shared_context = g_default_context;
+ }
- return context.release();
- } else {
- scoped_ptr<PbufferGLContext> context(new PbufferGLContext);
- if (!context->Initialize(shared_handle))
- return NULL;
+ scoped_ptr<SecondaryEGLContext> context(
+ new SecondaryEGLContext());
+ if (!context->Initialize(shared_context))
+ return NULL;
- return context.release();
+ return context.release();
+ }
+ case kGLImplementationDesktopGL: {
+ scoped_ptr<PbufferGLContext> context(new PbufferGLContext);
+ if (!context->Initialize(shared_context))
+ return NULL;
+
+ return context.release();
+ }
+ case kGLImplementationMockGL:
+ return new StubGLContext;
+ default:
+ NOTREACHED();
+ return NULL;
}
}
diff --git a/app/gfx/gl/gl_implementation.h b/app/gfx/gl/gl_implementation.h
new file mode 100644
index 0000000..0f1df36
--- /dev/null
+++ b/app/gfx/gl/gl_implementation.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef APP_GFX_GL_GL_IMPLEMENTATION_H_
+#define APP_GFX_GL_GL_IMPLEMENTATION_H_
+
+namespace gfx {
+
+// The GL implementation currently in use.
+enum GLImplementation {
+ kGLImplementationNone,
+ kGLImplementationDesktopGL,
+ kGLImplementationOSMesaGL,
+ kGLImplementationEGLGLES2,
+ kGLImplementationMockGL
+};
+
+// Initialize a particular GL implementation.
+bool InitializeGLBindings(GLImplementation implementation);
+
+// Get the current GL implementation.
+GLImplementation GetGLImplementation();
+
+// Find an entry point in the current GL implementation.
+void* GetGLProcAddress(const char* name);
+
+} // namespace gfx
+
+#endif // APP_GFX_GL_GL_IMPLEMENTATION_H_
diff --git a/app/gfx/gl/gl_implementation_linux.cc b/app/gfx/gl/gl_implementation_linux.cc
new file mode 100644
index 0000000..e27cdae
--- /dev/null
+++ b/app/gfx/gl/gl_implementation_linux.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <dlfcn.h>
+
+#include "base/logging.h"
+#include "app/gfx/gl/gl_bindings.h"
+#include "app/gfx/gl/gl_context_stub.h"
+#include "app/gfx/gl/gl_implementation.h"
+
+namespace gfx {
+namespace {
+typedef void* (*GetProcAddressProc)(const char* name);
+
+GLImplementation g_gl_implementation = kGLImplementationNone;
+void* g_shared_library;
+GetProcAddressProc g_get_proc_address;
+} // namespace anonymous
+
+bool InitializeGLBindings(GLImplementation implementation) {
+ // Prevent reinitialization with a different implementation. Once the gpu
+ // unit tests have initialized with kGLImplementationMock, we don't want to
+ // later switch to another GL implementation.
+ if (g_gl_implementation != kGLImplementationNone)
+ return true;
+
+ switch (implementation) {
+ case kGLImplementationDesktopGL:
+ g_shared_library = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
+ if (!g_shared_library)
+ return false;
+
+ g_gl_implementation = kGLImplementationDesktopGL;
+
+ g_get_proc_address = reinterpret_cast<GetProcAddressProc>(
+ dlsym(g_shared_library, "glXGetProcAddress"));
+ CHECK(g_get_proc_address);
+
+ InitializeGLBindingsGL();
+ InitializeGLBindingsGLX();
+ break;
+
+ case kGLImplementationMockGL:
+ g_get_proc_address = GetMockGLProcAddress;
+ g_gl_implementation = kGLImplementationMockGL;
+ InitializeGLBindingsGL();
+ break;
+
+ default:
+ return false;
+ }
+
+
+ return true;
+}
+
+GLImplementation GetGLImplementation() {
+ return g_gl_implementation;
+}
+
+void* GetGLProcAddress(const char* name) {
+ DCHECK(g_gl_implementation != kGLImplementationNone);
+
+ if (g_get_proc_address) {
+ void* proc = g_get_proc_address(name);
+ if (proc)
+ return proc;
+ }
+
+ if (g_shared_library) {
+ void* proc = dlsym(g_shared_library, name);
+ if (proc)
+ return proc;
+ }
+
+ return NULL;
+}
+
+} // namespace gfx
diff --git a/app/gfx/gl/gl_implementation_mac.cc b/app/gfx/gl/gl_implementation_mac.cc
new file mode 100644
index 0000000..7975726
--- /dev/null
+++ b/app/gfx/gl/gl_implementation_mac.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <dlfcn.h>
+
+#include "base/logging.h"
+#include "app/gfx/gl/gl_bindings.h"
+#include "app/gfx/gl/gl_implementation.h"
+
+namespace gfx {
+namespace {
+typedef void* (*GetProcAddressProc)(const char* name);
+
+GLImplementation g_gl_implementation = kGLImplementationNone;
+void* g_shared_library;
+GetProcAddressProc g_get_proc_address;
+} // namespace anonymous
+
+bool InitializeGLBindings(GLImplementation implementation) {
+ // Prevent reinitialization with a different implementation. Once the gpu
+ // unit tests have initialized with kGLImplementationMock, we don't want to
+ // later switch to another GL implementation.
+ if (g_gl_implementation != kGLImplementationNone)
+ return true;
+
+ switch (implementation) {
+ case kGLImplementationDesktopGL:
+ g_shared_library = dlopen(
+ "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL",
+ RTLD_LAZY | RTLD_LOCAL);
+ if (!g_shared_library)
+ return false;
+
+ g_gl_implementation = kGLImplementationDesktopGL;
+ g_get_proc_address = NULL;
+
+ InitializeGLBindingsGL();
+ break;
+
+ case kGLImplementationMockGL:
+ g_get_proc_address = GetMockGLProcAddress;
+ g_gl_implementation = kGLImplementationMockGL;
+ InitializeGLBindingsGL();
+ break;
+
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+GLImplementation GetGLImplementation() {
+ return g_gl_implementation;
+}
+
+void* GetGLProcAddress(const char* name) {
+ DCHECK(g_gl_implementation != kGLImplementationNone);
+
+ if (g_get_proc_address) {
+ void* proc = g_get_proc_address(name);
+ if (proc)
+ return proc;
+ }
+
+ if (g_shared_library) {
+ void* proc = dlsym(g_shared_library, name);
+ if (proc)
+ return proc;
+ }
+
+ return NULL;
+}
+
+} // namespace gfx
diff --git a/app/gfx/gl/gl_implementation_win.cc b/app/gfx/gl/gl_implementation_win.cc
new file mode 100644
index 0000000..cb25f07
--- /dev/null
+++ b/app/gfx/gl/gl_implementation_win.cc
@@ -0,0 +1,140 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <vector>
+
+#include "base/logging.h"
+#include "app/gfx/gl/gl_bindings.h"
+#include "app/gfx/gl/gl_implementation.h"
+
+namespace gfx {
+
+namespace {
+
+typedef void* (GL_BINDING_CALL *GetProcAddressProc)(const char* name);
+
+GLImplementation g_gl_implementation = kGLImplementationNone;
+std::vector<HMODULE> g_modules;
+static GetProcAddressProc g_get_proc_address;
+
+void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) {
+ glClearDepthf(static_cast<GLclampf>(depth));
+}
+
+void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
+ GLclampd z_far) {
+ glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
+}
+
+} // namespace anonymous
+
+bool InitializeGLBindings(GLImplementation implementation) {
+ // Prevent reinitialization with a different implementation. Once the gpu
+ // unit tests have initialized with kGLImplementationMock, we don't want to
+ // later switch to another GL implementation.
+ if (g_gl_implementation != kGLImplementationNone)
+ return true;
+
+ HMODULE module;
+ switch (implementation) {
+ case kGLImplementationOSMesaGL:
+ // When using OSMesa, just use OSMesaGetProcAddress to find entry points.
+ module = LoadLibraryA("osmesa.dll");
+ if (!module)
+ return false;
+
+ g_gl_implementation = kGLImplementationOSMesaGL;
+
+ g_get_proc_address = reinterpret_cast<GetProcAddressProc>(
+ GetProcAddress(module, "OSMesaGetProcAddress"));
+ DCHECK(g_get_proc_address);
+
+ InitializeGLBindingsGL();
+ InitializeGLBindingsOSMESA();
+ break;
+
+ case kGLImplementationEGLGLES2:
+ // When using EGL, first try eglGetProcAddress and then Windows
+ // GetProcAddress on both the EGL and GLES2 DLLs.
+ module = LoadLibraryA("libegl.dll");
+ if (!module)
+ return false;
+
+ g_gl_implementation = kGLImplementationEGLGLES2;
+
+ g_get_proc_address = reinterpret_cast<GetProcAddressProc>(
+ GetProcAddress(module, "eglGetProcAddress"));
+ DCHECK(g_get_proc_address);
+
+ g_modules.push_back(module);
+
+ module = LoadLibraryA("libglesv2.dll");
+ DCHECK(module);
+
+ g_modules.push_back(module);
+
+ InitializeGLBindingsGL();
+ InitializeGLBindingsEGL();
+
+ // These two functions take single precision float ranther than double
+ // precision float parameters in GLES.
+ ::gfx::g_glClearDepth = MarshalClearDepthToClearDepthf;
+ ::gfx::g_glDepthRange = MarshalDepthRangeToDepthRangef;
+ break;
+
+ case kGLImplementationDesktopGL:
+ // When using Windows OpenGL, first try wglGetProcAddress and then
+ // Windows GetProcAddress.
+ module = LoadLibraryA("opengl32.dll");
+ if (!module)
+ return false;
+
+ g_gl_implementation = kGLImplementationDesktopGL;
+
+ g_get_proc_address = reinterpret_cast<GetProcAddressProc>(
+ GetProcAddress(module, "wglGetProcAddress"));
+ DCHECK(g_get_proc_address);
+
+ g_modules.push_back(module);
+
+ InitializeGLBindingsGL();
+ InitializeGLBindingsWGL();
+ break;
+
+ case kGLImplementationMockGL:
+ g_get_proc_address = GetMockGLProcAddress;
+ g_gl_implementation = kGLImplementationMockGL;
+ InitializeGLBindingsGL();
+ break;
+
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+GLImplementation GetGLImplementation() {
+ return g_gl_implementation;
+}
+
+void* GetGLProcAddress(const char* name) {
+ DCHECK(g_gl_implementation != kGLImplementationNone);
+
+ if (g_get_proc_address) {
+ void* proc = g_get_proc_address(name);
+ if (proc)
+ return proc;
+ }
+
+ for (size_t i = 0; i < g_modules.size(); ++i) {
+ void* proc = GetProcAddress(g_modules[i], name);
+ if (proc)
+ return proc;
+ }
+
+ return NULL;
+}
+
+} // namespace gfx
diff --git a/gpu/command_buffer/service/gl_interface.cc b/app/gfx/gl/gl_interface.cc
index b077a84..22edd3d 100644
--- a/gpu/command_buffer/service/gl_interface.cc
+++ b/app/gfx/gl/gl_interface.cc
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "gpu/command_buffer/service/gl_interface.h"
+#include "app/gfx/gl/gl_interface.h"
-namespace gles2 {
+namespace gfx {
GLInterface* GLInterface::interface_;
@@ -16,5 +16,5 @@ GLInterface* GLInterface::GetGLInterface() {
return interface_;
}
-} // namespace gles2
+} // namespace gfx
diff --git a/gpu/command_buffer/service/gl_interface.h b/app/gfx/gl/gl_interface.h
index 29ce544..2c9a6fb 100644
--- a/gpu/command_buffer/service/gl_interface.h
+++ b/app/gfx/gl/gl_interface.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,35 +6,12 @@
// testing. It has to be Desktop GL, not GLES2 as it is used to test the service
// side code.
-#ifndef GPU_COMMAND_BUFFER_SERVICE_GL_INTERFACE_H_
-#define GPU_COMMAND_BUFFER_SERVICE_GL_INTERFACE_H_
-
-#include <GLES2/gl2types.h>
-
-// These are Desktop GL constants that we want to test that our GLES2
-// implemenation does not let through.
-#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
-#define GL_BGR 0x80E0
-#define GL_BGRA 0x80E1
-#define GL_UNPACK_SWAP_BYTES 0x0CF0
-#define GL_PACK_SWAP_BYTES 0x0D00
-#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
-#define GL_QUADS 0x0007
-#define GL_POLYGON 0x0009
-#define GL_FOG 0x0B60
-#define GL_CLIP_PLANE0 0x3000
-#define GL_GENERATE_MIPMAP 0x8191
-#define GL_PIXEL_PACK_BUFFER 0x88EB
-#define GL_POINT_SPRITE 0x8861
-#define GL_MIN 0x8007
-#define GL_MAX 0x8008
-#define GL_TEXTURE_1D 0x0DE0
-#define GL_TEXTURE_3D 0x806F
-#define GL_DOUBLE 0x140A
-#define GL_GEOMETRY_SHADER 0x8DD9
-#define GL_FOG_HINT 0x0C54
-
-namespace gles2 {
+#ifndef APP_GFX_GL_GL_INTERFACE_H_
+#define APP_GFX_GL_GL_INTERFACE_H_
+
+#include "app/gfx/gl/gl_bindings.h"
+
+namespace gfx {
class GLInterface {
public:
@@ -85,7 +62,9 @@ class GLInterface {
virtual void ClearColor(
GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = 0;
- virtual void ClearDepth(GLclampf depth) = 0;
+ virtual void ClearDepth(GLclampd depth) = 0;
+
+ virtual void ClearDepthf(GLclampf depth) = 0;
virtual void ClearStencil(GLint s) = 0;
@@ -133,7 +112,9 @@ class GLInterface {
virtual void DepthMask(GLboolean flag) = 0;
- virtual void DepthRange(GLclampf zNear, GLclampf zFar) = 0;
+ virtual void DepthRange(GLclampd zNear, GLclampd zFar) = 0;
+
+ virtual void DepthRangef(GLclampf zNear, GLclampf zFar) = 0;
virtual void DetachShader(GLuint program, GLuint shader) = 0;
@@ -407,157 +388,9 @@ class GLInterface {
static GLInterface* interface_;
};
-} // namespace gles2
-
-#define GL_IFACE_GET_FUN(name) ::gles2::GLInterface::GetGLInterface()->name
-
-#define glActiveTexture GL_IFACE_GET_FUN(ActiveTexture)
-#define glAttachShader GL_IFACE_GET_FUN(AttachShader)
-#define glBindAttribLocation GL_IFACE_GET_FUN(BindAttribLocation)
-#define glBindBuffer GL_IFACE_GET_FUN(BindBuffer)
-#define glBindFramebufferEXT GL_IFACE_GET_FUN(BindFramebufferEXT)
-#define glBindRenderbufferEXT GL_IFACE_GET_FUN(BindRenderbufferEXT)
-#define glBindTexture GL_IFACE_GET_FUN(BindTexture)
-#define glBlendColor GL_IFACE_GET_FUN(BlendColor)
-#define glBlendEquation GL_IFACE_GET_FUN(BlendEquation)
-#define glBlendEquationSeparate GL_IFACE_GET_FUN(BlendEquationSeparate)
-#define glBlendFunc GL_IFACE_GET_FUN(BlendFunc)
-#define glBlendFuncSeparate GL_IFACE_GET_FUN(BlendFuncSeparate)
-#define glBufferData GL_IFACE_GET_FUN(BufferData)
-#define glBufferSubData GL_IFACE_GET_FUN(BufferSubData)
-#define glCheckFramebufferStatusEXT GL_IFACE_GET_FUN(CheckFramebufferStatusEXT)
-#define glClear GL_IFACE_GET_FUN(Clear)
-#define glClearColor GL_IFACE_GET_FUN(ClearColor)
-#define glClearDepth GL_IFACE_GET_FUN(ClearDepth)
-#define glClearStencil GL_IFACE_GET_FUN(ClearStencil)
-#define glColorMask GL_IFACE_GET_FUN(ColorMask)
-#define glCompileShader GL_IFACE_GET_FUN(CompileShader)
-#define glCompressedTexImage2D GL_IFACE_GET_FUN(CompressedTexImage2D)
-#define glCompressedTexSubImage2D GL_IFACE_GET_FUN(CompressedTexSubImage2D)
-#define glCopyTexImage2D GL_IFACE_GET_FUN(CopyTexImage2D)
-#define glCopyTexSubImage2D GL_IFACE_GET_FUN(CopyTexSubImage2D)
-#define glCreateProgram GL_IFACE_GET_FUN(CreateProgram)
-#define glCreateShader GL_IFACE_GET_FUN(CreateShader)
-#define glCullFace GL_IFACE_GET_FUN(CullFace)
-#define glDeleteBuffersARB GL_IFACE_GET_FUN(DeleteBuffersARB)
-#define glDeleteFramebuffersEXT GL_IFACE_GET_FUN(DeleteFramebuffersEXT)
-#define glDeleteProgram GL_IFACE_GET_FUN(DeleteProgram)
-#define glDeleteRenderbuffersEXT GL_IFACE_GET_FUN(DeleteRenderbuffersEXT)
-#define glDeleteShader GL_IFACE_GET_FUN(DeleteShader)
-#define glDeleteTextures GL_IFACE_GET_FUN(DeleteTextures)
-#define glDepthFunc GL_IFACE_GET_FUN(DepthFunc)
-#define glDepthMask GL_IFACE_GET_FUN(DepthMask)
-#define glDepthRange GL_IFACE_GET_FUN(DepthRange)
-#define glDetachShader GL_IFACE_GET_FUN(DetachShader)
-#define glDisable GL_IFACE_GET_FUN(Disable)
-#define glDisableVertexAttribArray GL_IFACE_GET_FUN(DisableVertexAttribArray)
-#define glDrawArrays GL_IFACE_GET_FUN(DrawArrays)
-#define glDrawElements GL_IFACE_GET_FUN(DrawElements)
-#define glEnable GL_IFACE_GET_FUN(Enable)
-#define glEnableVertexAttribArray GL_IFACE_GET_FUN(EnableVertexAttribArray)
-#define glFinish GL_IFACE_GET_FUN(Finish)
-#define glFlush GL_IFACE_GET_FUN(Flush)
-#define glFramebufferRenderbufferEXT \
- GL_IFACE_GET_FUN(FramebufferRenderbufferEXT)
-#define glFramebufferTexture2DEXT GL_IFACE_GET_FUN(FramebufferTexture2DEXT)
-#define glFrontFace GL_IFACE_GET_FUN(FrontFace)
-#define glGenBuffersARB GL_IFACE_GET_FUN(GenBuffersARB)
-#define glGenerateMipmapEXT GL_IFACE_GET_FUN(GenerateMipmapEXT)
-#define glGenFramebuffersEXT GL_IFACE_GET_FUN(GenFramebuffersEXT)
-#define glGenRenderbuffersEXT GL_IFACE_GET_FUN(GenRenderbuffersEXT)
-#define glGenTextures GL_IFACE_GET_FUN(GenTextures)
-#define glGetActiveAttrib GL_IFACE_GET_FUN(GetActiveAttrib)
-#define glGetActiveUniform GL_IFACE_GET_FUN(GetActiveUniform)
-#define glGetAttachedShaders GL_IFACE_GET_FUN(GetAttachedShaders)
-#define glGetAttribLocation GL_IFACE_GET_FUN(GetAttribLocation)
-#define glGetBooleanv GL_IFACE_GET_FUN(GetBooleanv)
-#define glGetBufferParameteriv GL_IFACE_GET_FUN(GetBufferParameteriv)
-#define glGetError GL_IFACE_GET_FUN(GetError)
-#define glGetFloatv GL_IFACE_GET_FUN(GetFloatv)
-#define glGetFramebufferAttachmentParameterivEXT \
- GL_IFACE_GET_FUN(GetFramebufferAttachmentParameterivEXT)
-#define glGetIntegerv GL_IFACE_GET_FUN(GetIntegerv)
-#define glGetProgramiv GL_IFACE_GET_FUN(GetProgramiv)
-#define glGetProgramInfoLog GL_IFACE_GET_FUN(GetProgramInfoLog)
-#define glGetRenderbufferParameterivEXT \
- GL_IFACE_GET_FUN(GetRenderbufferParameterivEXT)
-#define glGetShaderiv GL_IFACE_GET_FUN(GetShaderiv)
-#define glGetShaderInfoLog GL_IFACE_GET_FUN(GetShaderInfoLog)
-#define glGetShaderPrecisionFormat GL_IFACE_GET_FUN(GetShaderPrecisionFormat)
-#define glGetShaderSource GL_IFACE_GET_FUN(GetShaderSource)
-#define glGetString GL_IFACE_GET_FUN(GetString)
-#define glGetTexParameterfv GL_IFACE_GET_FUN(GetTexParameterfv)
-#define glGetTexParameteriv GL_IFACE_GET_FUN(GetTexParameteriv)
-#define glGetUniformfv GL_IFACE_GET_FUN(GetUniformfv)
-#define glGetUniformiv GL_IFACE_GET_FUN(GetUniformiv)
-#define glGetUniformLocation GL_IFACE_GET_FUN(GetUniformLocation)
-#define glGetVertexAttribfv GL_IFACE_GET_FUN(GetVertexAttribfv)
-#define glGetVertexAttribiv GL_IFACE_GET_FUN(GetVertexAttribiv)
-#define glGetVertexAttribPointerv GL_IFACE_GET_FUN(GetVertexAttribPointerv)
-#define glHint GL_IFACE_GET_FUN(Hint)
-#define glIsBuffer GL_IFACE_GET_FUN(IsBuffer)
-#define glIsEnabled GL_IFACE_GET_FUN(IsEnabled)
-#define glIsFramebufferEXT GL_IFACE_GET_FUN(IsFramebufferEXT)
-#define glIsProgram GL_IFACE_GET_FUN(IsProgram)
-#define glIsRenderbufferEXT GL_IFACE_GET_FUN(IsRenderbufferEXT)
-#define glIsShader GL_IFACE_GET_FUN(IsShader)
-#define glIsTexture GL_IFACE_GET_FUN(IsTexture)
-#define glLineWidth GL_IFACE_GET_FUN(LineWidth)
-#define glLinkProgram GL_IFACE_GET_FUN(LinkProgram)
-#define glPixelStorei GL_IFACE_GET_FUN(PixelStorei)
-#define glPolygonOffset GL_IFACE_GET_FUN(PolygonOffset)
-#define glReadPixels GL_IFACE_GET_FUN(ReadPixels)
-#define glReleaseShaderCompiler GL_IFACE_GET_FUN(ReleaseShaderCompiler)
-#define glRenderbufferStorageEXT GL_IFACE_GET_FUN(RenderbufferStorageEXT)
-#define glSampleCoverage GL_IFACE_GET_FUN(SampleCoverage)
-#define glScissor GL_IFACE_GET_FUN(Scissor)
-#define glShaderBinary GL_IFACE_GET_FUN(ShaderBinary)
-#define glShaderSource GL_IFACE_GET_FUN(ShaderSource)
-#define glStencilFunc GL_IFACE_GET_FUN(StencilFunc)
-#define glStencilFuncSeparate GL_IFACE_GET_FUN(StencilFuncSeparate)
-#define glStencilMask GL_IFACE_GET_FUN(StencilMask)
-#define glStencilMaskSeparate GL_IFACE_GET_FUN(StencilMaskSeparate)
-#define glStencilOp GL_IFACE_GET_FUN(StencilOp)
-#define glStencilOpSeparate GL_IFACE_GET_FUN(StencilOpSeparate)
-#define glTexImage2D GL_IFACE_GET_FUN(TexImage2D)
-#define glTexParameterf GL_IFACE_GET_FUN(TexParameterf)
-#define glTexParameterfv GL_IFACE_GET_FUN(TexParameterfv)
-#define glTexParameteri GL_IFACE_GET_FUN(TexParameteri)
-#define glTexParameteriv GL_IFACE_GET_FUN(TexParameteriv)
-#define glTexSubImage2D GL_IFACE_GET_FUN(TexSubImage2D)
-#define glUniform1f GL_IFACE_GET_FUN(Uniform1f)
-#define glUniform1fv GL_IFACE_GET_FUN(Uniform1fv)
-#define glUniform1i GL_IFACE_GET_FUN(Uniform1i)
-#define glUniform1iv GL_IFACE_GET_FUN(Uniform1iv)
-#define glUniform2f GL_IFACE_GET_FUN(Uniform2f)
-#define glUniform2fv GL_IFACE_GET_FUN(Uniform2fv)
-#define glUniform2i GL_IFACE_GET_FUN(Uniform2i)
-#define glUniform2iv GL_IFACE_GET_FUN(Uniform2iv)
-#define glUniform3f GL_IFACE_GET_FUN(Uniform3f)
-#define glUniform3fv GL_IFACE_GET_FUN(Uniform3fv)
-#define glUniform3i GL_IFACE_GET_FUN(Uniform3i)
-#define glUniform3iv GL_IFACE_GET_FUN(Uniform3iv)
-#define glUniform4f GL_IFACE_GET_FUN(Uniform4f)
-#define glUniform4fv GL_IFACE_GET_FUN(Uniform4fv)
-#define glUniform4i GL_IFACE_GET_FUN(Uniform4i)
-#define glUniform4iv GL_IFACE_GET_FUN(Uniform4iv)
-#define glUniformMatrix2fv GL_IFACE_GET_FUN(UniformMatrix2fv)
-#define glUniformMatrix3fv GL_IFACE_GET_FUN(UniformMatrix3fv)
-#define glUniformMatrix4fv GL_IFACE_GET_FUN(UniformMatrix4fv)
-#define glUseProgram GL_IFACE_GET_FUN(UseProgram)
-#define glValidateProgram GL_IFACE_GET_FUN(ValidateProgram)
-#define glVertexAttrib1f GL_IFACE_GET_FUN(VertexAttrib1f)
-#define glVertexAttrib1fv GL_IFACE_GET_FUN(VertexAttrib1fv)
-#define glVertexAttrib2f GL_IFACE_GET_FUN(VertexAttrib2f)
-#define glVertexAttrib2fv GL_IFACE_GET_FUN(VertexAttrib2fv)
-#define glVertexAttrib3f GL_IFACE_GET_FUN(VertexAttrib3f)
-#define glVertexAttrib3fv GL_IFACE_GET_FUN(VertexAttrib3fv)
-#define glVertexAttrib4f GL_IFACE_GET_FUN(VertexAttrib4f)
-#define glVertexAttrib4fv GL_IFACE_GET_FUN(VertexAttrib4fv)
-#define glVertexAttribPointer GL_IFACE_GET_FUN(VertexAttribPointer)
-#define glViewport GL_IFACE_GET_FUN(Viewport)
-
-#endif // GPU_COMMAND_BUFFER_SERVICE_GL_INTERFACE_H_
+} // namespace gfx
+
+#endif // APP_GFX_GL_GL_INTERFACE_H_
diff --git a/gpu/command_buffer/service/gl_mock.h b/app/gfx/gl/gl_mock.h
index 3378112..47e048d 100644
--- a/gpu/command_buffer/service/gl_mock.h
+++ b/app/gfx/gl/gl_mock.h
@@ -1,17 +1,17 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file implements mock GL Interface for unit testing. It has to mock
// Desktop GL, not GLES2 as it is used to test the service side code.
-#ifndef GPU_COMMAND_BUFFER_SERVICE_GL_MOCK_H_
-#define GPU_COMMAND_BUFFER_SERVICE_GL_MOCK_H_
+#ifndef APP_GFX_GL_GL_MOCK_H_
+#define APP_GFX_GL_GL_MOCK_H_
-#include "gpu/command_buffer/service/gl_interface.h"
+#include "app/gfx/gl/gl_interface.h"
#include "testing/gmock/include/gmock/gmock.h"
-namespace gles2 {
+namespace gfx {
class MockGLInterface : public GLInterface {
public:
@@ -58,7 +58,9 @@ class MockGLInterface : public GLInterface {
MOCK_METHOD4(ClearColor, void(
GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha));
- MOCK_METHOD1(ClearDepth, void(GLclampf depth));
+ MOCK_METHOD1(ClearDepth, void(GLclampd depth));
+
+ MOCK_METHOD1(ClearDepthf, void(GLclampf depth));
MOCK_METHOD1(ClearStencil, void(GLint s));
@@ -107,7 +109,9 @@ class MockGLInterface : public GLInterface {
MOCK_METHOD1(DepthMask, void(GLboolean flag));
- MOCK_METHOD2(DepthRange, void(GLclampf zNear, GLclampf zFar));
+ MOCK_METHOD2(DepthRange, void(GLclampd zNear, GLclampd zFar));
+
+ MOCK_METHOD2(DepthRangef, void(GLclampf zNear, GLclampf zFar));
MOCK_METHOD2(DetachShader, void(GLuint program, GLuint shader));
@@ -381,9 +385,9 @@ class MockGLInterface : public GLInterface {
GLuint buffer_id, GLsizei count, GLenum type, GLuint offset));
};
-} // namespace gles2
+} // namespace gfx
-#endif // GPU_COMMAND_BUFFER_SERVICE_GL_MOCK_H_
+#endif // APP_GFX_GL_GL_MOCK_H_
diff --git a/app/surface/accelerated_surface_mac.cc b/app/surface/accelerated_surface_mac.cc
index 2d6ac7a..06e48ddb 100644
--- a/app/surface/accelerated_surface_mac.cc
+++ b/app/surface/accelerated_surface_mac.cc
@@ -4,6 +4,7 @@
#include "app/surface/accelerated_surface_mac.h"
+#include "app/gfx/gl/gl_bindings.h"
#include "app/surface/io_surface_support_mac.h"
#include "base/logging.h"
#include "gfx/rect.h"
diff --git a/app/surface/accelerated_surface_mac.h b/app/surface/accelerated_surface_mac.h
index f01bbc7..d1fe311 100644
--- a/app/surface/accelerated_surface_mac.h
+++ b/app/surface/accelerated_surface_mac.h
@@ -6,7 +6,6 @@
#define APP_SURFACE_ACCELERATED_SURFACE_MAC_H_
#include <CoreFoundation/CoreFoundation.h>
-#include <OpenGL/OpenGL.h>
#include "app/surface/transport_dib.h"
#include "base/callback.h"
@@ -15,6 +14,13 @@
#include "gfx/rect.h"
#include "gfx/size.h"
+// Should not include GL headers in a header file. Forward declare these types
+// instead.
+typedef struct _CGLContextObject* CGLContextObj;
+typedef struct _CGLPBufferObject* CGLPBufferObj;
+typedef unsigned int GLenum;
+typedef unsigned int GLuint;
+
namespace gfx {
class Rect;
}
diff --git a/build/common.gypi b/build/common.gypi
index 496db7e..70f42dd 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -255,9 +255,6 @@
# Enable new NPDevice API.
'enable_new_npdevice_api%': 0,
-
- # Enable OpenGL ES.
- 'enable_gles%': 0,
# Enable EGLImage support in OpenMAX
'enable_eglimage%': 0,
@@ -443,11 +440,6 @@
'ENABLE_GPU=1',
],
}],
- ['enable_gles==1', {
- 'defines': [
- 'ENABLE_GLES=1',
- ],
- }],
['enable_eglimage==1', {
'defines': [
'ENABLE_EGLIMAGE=1',
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 4c8d24e..013e8ea 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -593,6 +593,7 @@
'type': '<(library)',
'msvs_guid': 'F10F1ECD-D84D-4C33-8468-9DDFE19F4D8A',
'dependencies': [
+ '../app/app.gyp:app_base',
'../base/base.gyp:base',
'common',
'../skia/skia.gyp:skia',
@@ -635,9 +636,6 @@
'gpu/gpu_video_layer_glx.cc',
'gpu/gpu_video_layer_glx.h',
],
- 'dependencies': [
- '../gpu/gpu.gyp:gl_libs',
- ],
}],
['enable_gpu==1', {
'dependencies': [
diff --git a/chrome/gpu/gpu_backing_store_glx.cc b/chrome/gpu/gpu_backing_store_glx.cc
index 5f022cc..1c91a641 100644
--- a/chrome/gpu/gpu_backing_store_glx.cc
+++ b/chrome/gpu/gpu_backing_store_glx.cc
@@ -4,8 +4,7 @@
#include "chrome/gpu/gpu_backing_store_glx.h"
-#include <GL/glew.h>
-
+#include "app/gfx/gl/gl_bindings.h"
#include "app/surface/transport_dib.h"
#include "base/scoped_ptr.h"
#include "chrome/common/gpu_messages.h"
@@ -31,7 +30,8 @@ GpuBackingStoreGLX::GpuBackingStoreGLX(GpuViewX* view,
glGenTextures(1, &texture_id_);
glBindTexture(GL_TEXTURE_2D, texture_id_);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ // TODO(apatrick): This function are not available in GLES2.
+ // glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
@@ -92,28 +92,33 @@ void GpuBackingStoreGLX::OnScrollBackingStore(int dx, int dy,
// Set up the the tranform so we can paint exact pixels to the screen, with
// (0, 0) at the bottom left.
- float w = static_cast<float>(size_.width());
- float h = static_cast<float>(size_.height());
+ // TODO(apatrick): Commenting out because these variables were only used by
+ // code that is now commented out.
+ // float w = static_cast<float>(size_.width());
+ // float h = static_cast<float>(size_.height());
glViewport(0, 0, size_.width(), size_.height());
- glLoadIdentity();
- glOrtho(0.0, w, 0.0, h, -1.0, 1.0);
+
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glLoadIdentity();
+ // glOrtho(0.0, w, 0.0, h, -1.0, 1.0);
// Paint the non-scrolled background of the page. Note that we try to avoid
// this if the entire thing is scrolling, which is a common case.
if (view_size != clip_rect.size()) {
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f);
- glVertex2f(0.0, 0.0);
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glBegin(GL_QUADS);
+ // glTexCoord2f(0.0f, 0.0f);
+ // glVertex2f(0.0, 0.0);
- glTexCoord2f(0.0f, 1.0f);
- glVertex2f(0.0, h);
+ // glTexCoord2f(0.0f, 1.0f);
+ // glVertex2f(0.0, h);
- glTexCoord2f(1.0f, 1.0f);
- glVertex2f(w, h);
+ // glTexCoord2f(1.0f, 1.0f);
+ // glVertex2f(w, h);
- glTexCoord2f(1.0f, 0.0f);
- glVertex2f(w, 0.0);
- glEnd();
+ // glTexCoord2f(1.0f, 0.0f);
+ // glVertex2f(w, 0.0);
+ // glEnd();
}
// Constrain the painting to only the area we're scrolling. Compute the clip
@@ -126,20 +131,21 @@ void GpuBackingStoreGLX::OnScrollBackingStore(int dx, int dy,
gl_clip_rect.width(), gl_clip_rect.height());
// Paint the offset texture.
- glTranslatef(static_cast<float>(dx), static_cast<float>(dy), 0.0f);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f);
- glVertex2f(0.0, 0.0);
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glTranslatef(static_cast<float>(dx), static_cast<float>(dy), 0.0f);
+ // glBegin(GL_QUADS);
+ // glTexCoord2f(0.0f, 0.0f);
+ // glVertex2f(0.0, 0.0);
- glTexCoord2f(0.0f, 1.0f);
- glVertex2f(0.0, h);
+ // glTexCoord2f(0.0f, 1.0f);
+ // glVertex2f(0.0, h);
- glTexCoord2f(1.0f, 1.0f);
- glVertex2f(w, h);
+ // glTexCoord2f(1.0f, 1.0f);
+ // glVertex2f(w, h);
- glTexCoord2f(1.0f, 0.0f);
- glVertex2f(w, 0.0);
- glEnd();
+ // glTexCoord2f(1.0f, 0.0f);
+ // glVertex2f(w, 0.0);
+ // glEnd();
glDisable(GL_SCISSOR_TEST);
glBindTexture(GL_TEXTURE_2D, 0);
diff --git a/chrome/gpu/gpu_backing_store_glx_context.cc b/chrome/gpu/gpu_backing_store_glx_context.cc
index 96c6917..ea70651 100644
--- a/chrome/gpu/gpu_backing_store_glx_context.cc
+++ b/chrome/gpu/gpu_backing_store_glx_context.cc
@@ -4,13 +4,12 @@
#include "chrome/gpu/gpu_backing_store_glx_context.h"
+#include "app/gfx/gl/gl_bindings.h"
#include "app/x11_util.h"
#include "base/scoped_ptr.h"
#include "chrome/gpu/gpu_thread.h"
// Must be last.
-#include <GL/glew.h>
-#include <GL/glxew.h>
#include <X11/Xutil.h>
GpuBackingStoreGLXContext::GpuBackingStoreGLXContext(GpuThread* gpu_thread)
@@ -30,7 +29,7 @@ GpuBackingStoreGLXContext::~GpuBackingStoreGLXContext() {
}
if (frame_buffer_for_scrolling_)
- glDeleteFramebuffers(1, &frame_buffer_for_scrolling_);
+ glDeleteFramebuffersEXT(1, &frame_buffer_for_scrolling_);
if (context_)
glXDestroyContext(gpu_thread_->display(), context_);
@@ -43,8 +42,8 @@ GLXContext GpuBackingStoreGLXContext::BindContext(XID window_id) {
if (!context_)
return NULL;
if (!previous_window_id_ || previous_window_id_ != window_id) {
- bool success = ::glXMakeCurrent(gpu_thread_->display(), window_id,
- context_);
+ bool success = glXMakeCurrent(gpu_thread_->display(), window_id,
+ context_);
DCHECK(success);
}
previous_window_id_ = window_id;
@@ -52,18 +51,16 @@ GLXContext GpuBackingStoreGLXContext::BindContext(XID window_id) {
}
tried_to_init_ = true;
- int attrib_list[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None };
+ int attrib_list[] = { GLX_RGBA, GLX_DOUBLEBUFFER, 0 };
scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> visual_info(
- ::glXChooseVisual(gpu_thread_->display(), 0, attrib_list));
+ glXChooseVisual(gpu_thread_->display(), 0, attrib_list));
if (!visual_info.get())
return NULL;
- context_ = ::glXCreateContext(gpu_thread_->display(), visual_info.get(),
- NULL, True);
- bool success = ::glXMakeCurrent(gpu_thread_->display(), window_id, context_);
+ context_ = glXCreateContext(gpu_thread_->display(), visual_info.get(),
+ NULL, True);
+ bool success = glXMakeCurrent(gpu_thread_->display(), window_id, context_);
DCHECK(success);
- glewInit();
- glewInitGL2Hack(); // Work around for I915. See gpu_video_layer_glx.cc.
return context_;
}
@@ -95,13 +92,13 @@ bool GpuBackingStoreGLXContext::BindTextureForScrolling(
}
if (!frame_buffer_for_scrolling_)
- glGenFramebuffers(1, &frame_buffer_for_scrolling_);
- glBindFramebuffer(GL_FRAMEBUFFER, frame_buffer_for_scrolling_);
+ glGenFramebuffersEXT(1, &frame_buffer_for_scrolling_);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, frame_buffer_for_scrolling_);
is_frame_buffer_bound_ = true;
// Release our color attachment.
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
- temp_scroll_texture_id_, 0);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+ temp_scroll_texture_id_, 0);
DCHECK(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) ==
GL_FRAMEBUFFER_COMPLETE_EXT);
@@ -113,7 +110,7 @@ unsigned int GpuBackingStoreGLXContext::SwapTextureForScrolling(
const gfx::Size& old_size) {
// Unbind the framebuffer, which we expect to be bound.
DCHECK(is_frame_buffer_bound_);
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
is_frame_buffer_bound_ = false;
DCHECK(temp_scroll_texture_id_);
diff --git a/chrome/gpu/gpu_main.cc b/chrome/gpu/gpu_main.cc
index c6c4aee..2e248ab 100644
--- a/chrome/gpu/gpu_main.cc
+++ b/chrome/gpu/gpu_main.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "app/gfx/gl/gl_implementation.h"
#include "base/message_loop.h"
#include "build/build_config.h"
#include "chrome/common/chrome_constants.h"
@@ -17,9 +18,6 @@
#if defined(OS_WIN)
#include "app/win_util.h"
-#elif defined(GPU_USE_GLX)
-#include <dlfcn.h>
-#include <GL/glxew.h>
#endif
// Main function for starting the Gpu process.
@@ -40,8 +38,7 @@ int GpuMain(const MainFunctionParams& parameters) {
#if defined(OS_WIN)
win_util::ScopedCOMInitializer com_initializer;
#elif defined(GPU_USE_GLX)
- dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
- glxewInit();
+ gfx::InitializeGLBindings(gfx::kGLImplementationDesktopGL);
#endif
GpuProcess gpu_process;
diff --git a/chrome/gpu/gpu_video_layer_glx.cc b/chrome/gpu/gpu_video_layer_glx.cc
index 21e1bc1..d0578ad 100644
--- a/chrome/gpu/gpu_video_layer_glx.cc
+++ b/chrome/gpu/gpu_video_layer_glx.cc
@@ -4,8 +4,7 @@
#include "chrome/gpu/gpu_video_layer_glx.h"
-#include <GL/glew.h>
-
+#include "app/gfx/gl/gl_bindings.h"
#include "chrome/common/gpu_messages.h"
#include "chrome/gpu/gpu_thread.h"
#include "chrome/gpu/gpu_view_x.h"
@@ -107,7 +106,8 @@ GpuVideoLayerGLX::GpuVideoLayerGLX(GpuViewX* view,
view_->BindContext(); // Must do this before issuing OpenGl.
- glMatrixMode(GL_MODELVIEW);
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glMatrixMode(GL_MODELVIEW);
// Create 3 textures, one for each plane, and bind them to different
// texture units.
diff --git a/chrome/gpu/gpu_view_x.cc b/chrome/gpu/gpu_view_x.cc
index b4c0f10..d9fd9d7 100644
--- a/chrome/gpu/gpu_view_x.cc
+++ b/chrome/gpu/gpu_view_x.cc
@@ -4,6 +4,7 @@
#include "chrome/gpu/gpu_view_x.h"
+#include "app/gfx/gl/gl_bindings.h"
#include "base/scoped_ptr.h"
#include "chrome/common/gpu_messages.h"
#include "chrome/gpu/gpu_backing_store_glx.h"
@@ -13,7 +14,6 @@
// X stuff must be last since it does "#define Status int" which messes up some
// of the header files we indirectly pull in.
-#include <GL/glxew.h>
#include <X11/Xutil.h>
GpuViewX::GpuViewX(GpuThread* gpu_thread,
@@ -63,8 +63,9 @@ void GpuViewX::Repaint() {
glViewport(0, 0, size.width(), size.height());
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glMatrixMode(GL_MODELVIEW);
+ // glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, backing_store_->texture_id());
@@ -72,19 +73,20 @@ void GpuViewX::Repaint() {
// TODO(brettw) use vertex buffers.
// TODO(brettw) make this so we use the texture size rather than the whole
// area size so we don't stretch bitmaps.
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f);
- glVertex2f(-1.0, 1.0);
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glBegin(GL_QUADS);
+ // glTexCoord2f(0.0f, 0.0f);
+ // glVertex2f(-1.0, 1.0);
- glTexCoord2f(0.0f, 1.0f);
- glVertex2f(-1.0, -1.0);
+ // glTexCoord2f(0.0f, 1.0f);
+ // glVertex2f(-1.0, -1.0);
- glTexCoord2f(1.0f, 1.0f);
- glVertex2f(1.0, -1.0);
+ // glTexCoord2f(1.0f, 1.0f);
+ // glVertex2f(1.0, -1.0);
- glTexCoord2f(1.0f, 0.0f);
- glVertex2f(1.0, 1.0);
- glEnd();
+ // glTexCoord2f(1.0f, 0.0f);
+ // glVertex2f(1.0, 1.0);
+ // glEnd();
DCHECK(glGetError() == GL_NO_ERROR);
if (video_layer_.get()) {
diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h
index 5ff41a2..5875040 100644
--- a/gpu/command_buffer/client/gles2_implementation.h
+++ b/gpu/command_buffer/client/gles2_implementation.h
@@ -5,9 +5,12 @@
#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
#define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
+#include <GLES2/gl2.h>
+
#include <map>
#include <string>
#include <vector>
+
#include "../common/gles2_cmd_utils.h"
#include "../common/scoped_ptr.h"
#include "../client/gles2_cmd_helper.h"
diff --git a/gpu/command_buffer/common/gles2_cmd_format.h b/gpu/command_buffer/common/gles2_cmd_format.h
index 2be1e36..d32a83f 100644
--- a/gpu/command_buffer/common/gles2_cmd_format.h
+++ b/gpu/command_buffer/common/gles2_cmd_format.h
@@ -7,25 +7,8 @@
#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_
#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_
-// This is here because service side code must include the system's version of
-// the GL headers where as client side code includes the Chrome version. Also
-// the unit test code must include a mock GL header.
-#if defined(UNIT_TEST)
- #include "../service/gl_mock.h"
-#elif defined(GLES2_GPU_SERVICE)
- // TODO(gman): Set this from gyp
- // #define GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 1
- #if defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
- #include <GLES2/gl2.h> // NOLINT
- #else // !GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
- #include <GL/glew.h> // NOLINT
- #if defined(OS_WIN)
- #include <GL/wglew.h> // NOLINT
- #endif
- #endif // !GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
-#else // !GLES2_CPU_SERVICE
- #include <GLES2/gl2types.h> // NOLINT
-#endif // UNIT_TEST
+
+#include <KHR/khrplatform.h>
#include <string.h>
@@ -34,6 +17,28 @@
#include "../common/cmd_buffer_common.h"
#include "../common/gles2_cmd_ids.h"
+// GL types are forward declared to avoid including the GL headers. The problem
+// is determining which GL headers to include from code that is common to the
+// client and service sides (GLES2 or one of several GL implementations).
+typedef unsigned int GLenum;
+typedef unsigned int GLbitfield;
+typedef unsigned int GLuint;
+typedef int GLint;
+typedef int GLsizei;
+typedef unsigned char GLboolean;
+typedef signed char GLbyte;
+typedef short GLshort;
+typedef unsigned char GLubyte;
+typedef unsigned short GLushort;
+typedef unsigned long GLulong;
+typedef float GLfloat;
+typedef float GLclampf;
+typedef double GLdouble;
+typedef double GLclampd;
+typedef void GLvoid;
+typedef khronos_intptr_t GLintptr;
+typedef khronos_ssize_t GLsizeiptr;
+
namespace gpu {
namespace gles2 {
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc
index bde062d..0f281ec 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -5,6 +5,8 @@
// This file is here so other GLES2 related files can have a common set of
// includes where appropriate.
+#include <GLES2/gl2.h>
+
#include "../common/gles2_cmd_utils.h"
#include "../common/gles2_cmd_format.h"
diff --git a/gpu/command_buffer/common/unittest_main.cc b/gpu/command_buffer/common/unittest_main.cc
new file mode 100644
index 0000000..f0df23f
--- /dev/null
+++ b/gpu/command_buffer/common/unittest_main.cc
@@ -0,0 +1,13 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "app/gfx/gl/gl_implementation.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+int main(int argc, char** argv) {
+ gfx::InitializeGLBindings(gfx::kGLImplementationMockGL);
+ testing::InitGoogleMock(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/gpu/command_buffer/service/gl_mock.cc b/gpu/command_buffer/service/gl_mock.cc
deleted file mode 100644
index 12b5b34..0000000
--- a/gpu/command_buffer/service/gl_mock.cc
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "gpu/command_buffer/service/gl_mock.h"
-
-namespace gles2 {
-
-
-} // namespace gles2
-
diff --git a/gpu/command_buffer/service/gl_utils.h b/gpu/command_buffer/service/gl_utils.h
index c7cf11b..2e59179 100644
--- a/gpu/command_buffer/service/gl_utils.h
+++ b/gpu/command_buffer/service/gl_utils.h
@@ -8,82 +8,25 @@
#ifndef GPU_COMMAND_BUFFER_SERVICE_GL_UTILS_H_
#define GPU_COMMAND_BUFFER_SERVICE_GL_UTILS_H_
-#include <build/build_config.h>
-
-#if defined(UNIT_TEST)
- #include "gpu/command_buffer/service/gl_mock.h"
- // OpenGL constants not defined in OpenGL ES 2.0 needed when compiling
- // unit tests. For native OpenGL ES 2.0 backend these are not used. For OpenGL
- // backend these must be defined by the local system.
- #if !defined(GL_VERTEX_PROGRAM_POINT_SIZE)
- #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
- #endif
- #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
- #define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
- #define GL_MAX_VARYING_FLOATS 0x8B4B
-#else
- #if defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
- #include <GLES2/gl2.h> // NOLINT
-
- #define glClearDepth glClearDepthf
- #define glDepthRange glDepthRangef
-
- // Buffer Objects
- #define glBindBufferARB glBindBuffer
- #define glBufferDataARB glBufferData
- #define glBufferSubDataARB glBufferSubData
- #define glDeleteBuffersARB glDeleteBuffers
- #define glGenBuffersARB glGenBuffers
-
- // Framebuffer Objects
- #define glBindFramebufferEXT glBindFramebuffer
- #define glBindRenderbufferEXT glBindRenderbuffer
- #define glCheckFramebufferStatusEXT glCheckFramebufferStatus
- #define glDeleteFramebuffersEXT glDeleteFramebuffers
- #define glDeleteRenderbuffersEXT glDeleteRenderbuffers
- #define glFramebufferRenderbufferEXT glFramebufferRenderbuffer
- #define glFramebufferTexture2DEXT glFramebufferTexture2D
- #define glGenFramebuffersEXT glGenFramebuffers
- #define glGenRenderbuffersEXT glGenRenderbuffers
- #define glGetFramebufferAttachmentParameterivEXT \
- glGetFramebufferAttachmentParameteriv
- #define glGetRenderbufferParameterivEXT glGetRenderbufferParameteriv
- #define glIsFramebufferEXT glIsFramebuffer
- #define glIsRenderbufferEXT glIsFramebuffer
- #define glRenderbufferStorageEXT glRenderbufferStorage
-
- // Texture Objects
- #define glGenerateMipmapEXT glGenerateMipmap
-
- #else // !GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
- #include <GL/glew.h> // NOLINT
- #include <GL/osmew.h>
- #if defined(OS_WIN)
- #include <GL/wglew.h> // NOLINT
- #elif defined(OS_LINUX)
- #include <GL/glxew.h> // NOLINT
- #endif // OS_WIN
-
- // GLES2 defines not part of Desktop GL
- // Shader Precision-Specified Types
- #define GL_LOW_FLOAT 0x8DF0
- #define GL_MEDIUM_FLOAT 0x8DF1
- #define GL_HIGH_FLOAT 0x8DF2
- #define GL_LOW_INT 0x8DF3
- #define GL_MEDIUM_INT 0x8DF4
- #define GL_HIGH_INT 0x8DF5
- #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
- #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
- #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
- #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
- #define GL_MAX_VARYING_VECTORS 0x8DFC
- #define GL_SHADER_BINARY_FORMATS 0x8DF8
- #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
- #define GL_SHADER_COMPILER 0x8DFA
-
- #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
-
-#endif // UNIT_TEST
+#include "build/build_config.h"
+#include "app/gfx/gl/gl_bindings.h"
+
+// GLES2 defines not part of Desktop GL
+// Shader Precision-Specified Types
+#define GL_LOW_FLOAT 0x8DF0
+#define GL_MEDIUM_FLOAT 0x8DF1
+#define GL_HIGH_FLOAT 0x8DF2
+#define GL_LOW_INT 0x8DF3
+#define GL_MEDIUM_INT 0x8DF4
+#define GL_HIGH_INT 0x8DF5
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
+#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
+#define GL_MAX_VARYING_VECTORS 0x8DFC
+#define GL_SHADER_BINARY_FORMATS 0x8DF8
+#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
+#define GL_SHADER_COMPILER 0x8DFA
#define GL_GLEXT_PROTOTYPES 1
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 22f226e..9122b81 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -13,6 +13,7 @@
#include <vector>
#include "app/gfx/gl/gl_context.h"
+#include "app/gfx/gl/gl_implementation.h"
#include "base/callback.h"
#include "base/scoped_ptr.h"
#include "base/weak_ptr.h"
@@ -246,9 +247,9 @@ class FrameBuffer {
// Attach a color render buffer to a frame buffer.
void AttachRenderTexture(Texture* texture);
- // Attach a depth stencil render buffer to a frame buffer. Note that
- // this unbinds any currently bound frame buffer.
- void AttachDepthStencilRenderBuffer(RenderBuffer* render_buffer);
+ // Attach a render buffer to a frame buffer. Note that this unbinds any
+ // currently bound frame buffer.
+ void AttachRenderBuffer(GLenum target, RenderBuffer* render_buffer);
// Clear the given attached buffers.
void Clear(GLbitfield buffers);
@@ -1126,10 +1127,14 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
bool anti_aliased_;
- // The offscreen frame buffer that the client renders to.
+ // The offscreen frame buffer that the client renders to. With EGL, the
+ // depth and stencil buffers are separate. With regular GL there is a single
+ // packed depth stencil buffer in offscreen_target_depth_render_buffer_.
+ // offscreen_target_stencil_render_buffer_ is unused.
scoped_ptr<FrameBuffer> offscreen_target_frame_buffer_;
scoped_ptr<Texture> offscreen_target_color_texture_;
- scoped_ptr<RenderBuffer> offscreen_target_depth_stencil_render_buffer_;
+ scoped_ptr<RenderBuffer> offscreen_target_depth_render_buffer_;
+ scoped_ptr<RenderBuffer> offscreen_target_stencil_render_buffer_;
// The copy that is saved when SwapBuffers is called.
scoped_ptr<Texture> offscreen_saved_color_texture_;
@@ -1249,7 +1254,6 @@ bool Texture::AllocateStorage(const gfx::Size& size) {
GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D,
0, // mip level
@@ -1353,17 +1357,14 @@ void FrameBuffer::AttachRenderTexture(Texture* texture) {
0);
}
-void FrameBuffer::AttachDepthStencilRenderBuffer(RenderBuffer* render_buffer) {
+void FrameBuffer::AttachRenderBuffer(GLenum target,
+ RenderBuffer* render_buffer) {
DCHECK_NE(id_, 0u);
ScopedGLErrorSuppressor suppressor(decoder_);
ScopedFrameBufferBinder binder(decoder_, id_);
GLuint attach_id = render_buffer ? render_buffer->id() : 0;
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER,
- GL_DEPTH_ATTACHMENT,
- GL_RENDERBUFFER,
- attach_id);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER,
- GL_STENCIL_ATTACHMENT,
+ target,
GL_RENDERBUFFER,
attach_id);
}
@@ -1411,6 +1412,16 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
attrib_0_value_.v[1] = 0.0f;
attrib_0_value_.v[2] = 0.0f;
attrib_0_value_.v[3] = 1.0f;
+
+ // The shader translator is not needed for EGL because it already uses the
+ // GLSL ES syntax. It is translated for the unit tests because
+ // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the empty
+ // string to CompileShader and this is not a valid shader. TODO(apatrick):
+ // fix this test.
+ if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ||
+ gfx::GetGLImplementation() == gfx::kGLImplementationMockGL) {
+ use_shader_translator_ = false;
+ }
}
bool GLES2DecoderImpl::Initialize(gfx::GLContext* context,
@@ -1423,8 +1434,7 @@ bool GLES2DecoderImpl::Initialize(gfx::GLContext* context,
// Create a GL context that is kept in a default state and shares a namespace
// with the main GL context.
- default_context_.reset(gfx::GLContext::CreateOffscreenGLContext(
- context_->GetHandle()));
+ default_context_.reset(gfx::GLContext::CreateOffscreenGLContext(context_));
if (!default_context_.get()) {
Destroy();
return false;
@@ -1483,7 +1493,6 @@ bool GLES2DecoderImpl::Initialize(gfx::GLContext* context,
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
CHECK_GL_ERROR();
-#if !defined(UNIT_TEST)
if (context_->IsOffscreen()) {
// Create the target frame buffer. This is the one that the client renders
// directly to.
@@ -1491,9 +1500,12 @@ bool GLES2DecoderImpl::Initialize(gfx::GLContext* context,
offscreen_target_frame_buffer_->Create();
offscreen_target_color_texture_.reset(new Texture(this));
offscreen_target_color_texture_->Create();
- offscreen_target_depth_stencil_render_buffer_.reset(
+ offscreen_target_depth_render_buffer_.reset(
+ new RenderBuffer(this));
+ offscreen_target_depth_render_buffer_->Create();
+ offscreen_target_stencil_render_buffer_.reset(
new RenderBuffer(this));
- offscreen_target_depth_stencil_render_buffer_->Create();
+ offscreen_target_stencil_render_buffer_->Create();
// Create the saved offscreen texture. The target frame buffer is copied
// here when SwapBuffers is called.
@@ -1522,24 +1534,27 @@ bool GLES2DecoderImpl::Initialize(gfx::GLContext* context,
// This should now be associated with ID zero.
DoBindFramebuffer(GL_FRAMEBUFFER, 0);
}
-#endif // UNIT_TEST
-#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
// OpenGL ES 2.0 implicitly enables the desktop GL capability
// VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact
// isn't well documented; it was discovered in the Khronos OpenGL ES
// mailing list archives.
- glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
+ if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
+ glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
+ }
-#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER) && !defined(UNIT_TEST)
+#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
// Initialize GLSL ES to GLSL translator.
- if (!ShInitialize()) {
- DLOG(ERROR) << "Could not initialize GLSL translator.";
- Destroy();
- return false;
+ static bool glsl_translator_initialized = false;
+ if (!glsl_translator_initialized) {
+ if (!ShInitialize()) {
+ DLOG(ERROR) << "Could not initialize GLSL translator.";
+ Destroy();
+ return false;
+ }
+ glsl_translator_initialized = true;
}
#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
-#endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
return true;
}
@@ -1655,11 +1670,7 @@ void GLES2DecoderImpl::DeleteTexturesHelper(
// } // anonymous namespace
bool GLES2DecoderImpl::MakeCurrent() {
-#if defined(UNIT_TEST)
- return true;
-#else
return context_->MakeCurrent();
-#endif
}
gfx::Size GLES2DecoderImpl::GetBoundFrameBufferSize() {
@@ -1738,11 +1749,7 @@ gfx::Size GLES2DecoderImpl::GetBoundFrameBufferSize() {
} else if (offscreen_target_color_texture_.get()) {
return offscreen_target_color_texture_->size();
} else {
-#if defined(UNIT_TEST)
- return gfx::Size(INT_MAX, INT_MAX);
-#else
return context_->GetSize();
-#endif
}
}
@@ -1763,20 +1770,19 @@ bool GLES2DecoderImpl::UpdateOffscreenFrameBufferSize() {
return false;
}
-#if !defined(UNIT_TEST)
+ // TODO(apatrick): Fix this once ANGLE supports shared contexts.
// Clear the saved offscreen color texture. Use default GL context
// to ensure clear is not affected by client set state.
- { // NOLINT
+ if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
ScopedDefaultGLContext scoped_context(this);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,
+ glBindFramebufferEXT(GL_FRAMEBUFFER,
offscreen_target_frame_buffer_->id());
glClear(GL_COLOR_BUFFER_BIT);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
if (glGetError() != GL_NO_ERROR)
return false;
}
-#endif
}
// Reallocate the offscreen target buffers.
@@ -1785,35 +1791,60 @@ bool GLES2DecoderImpl::UpdateOffscreenFrameBufferSize() {
return false;
}
- if (!offscreen_target_depth_stencil_render_buffer_->AllocateStorage(
- pending_offscreen_size_, GL_DEPTH24_STENCIL8)) {
- return false;
+ if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) {
+ // ANGLE only allows 16-bit depth buffers to be requested. As it happens,
+ // it creates a 24-bit depth buffer behind the scenes.
+ // TODO(apatrick): Attempt to use a packed 24/8 depth stencil buffer here if
+ // the extension is available.
+ if (!offscreen_target_depth_render_buffer_->AllocateStorage(
+ pending_offscreen_size_, GL_DEPTH_COMPONENT16)) {
+ return false;
+ }
+
+ if (!offscreen_target_stencil_render_buffer_->AllocateStorage(
+ pending_offscreen_size_, GL_STENCIL_INDEX8)) {
+ return false;
+ }
+ } else {
+ if (!offscreen_target_depth_render_buffer_->AllocateStorage(
+ pending_offscreen_size_, GL_DEPTH24_STENCIL8)) {
+ return false;
+ }
}
// Attach the offscreen target buffers to the target frame buffer.
offscreen_target_frame_buffer_->AttachRenderTexture(
offscreen_target_color_texture_.get());
- offscreen_target_frame_buffer_->AttachDepthStencilRenderBuffer(
- offscreen_target_depth_stencil_render_buffer_.get());
+ offscreen_target_frame_buffer_->AttachRenderBuffer(
+ GL_DEPTH_ATTACHMENT,
+ offscreen_target_depth_render_buffer_.get());
+ if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) {
+ offscreen_target_frame_buffer_->AttachRenderBuffer(
+ GL_STENCIL_ATTACHMENT,
+ offscreen_target_stencil_render_buffer_.get());
+ } else {
+ offscreen_target_frame_buffer_->AttachRenderBuffer(
+ GL_STENCIL_ATTACHMENT,
+ offscreen_target_depth_render_buffer_.get());
+ }
if (offscreen_target_frame_buffer_->CheckStatus() !=
GL_FRAMEBUFFER_COMPLETE) {
return false;
}
-#if !defined(UNIT_TEST)
+ // TODO(apatrick): Fix this once ANGLE supports shared contexts.
// Clear offscreen frame buffer to its initial state. Use default GL context
// to ensure clear is not affected by client set state.
- { // NOLINT
+ if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
ScopedDefaultGLContext scoped_context(this);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,
+ glBindFramebufferEXT(GL_FRAMEBUFFER,
offscreen_target_frame_buffer_->id());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
if (glGetError() != GL_NO_ERROR)
return false;
}
-#endif
if (parent_) {
// Create the saved offscreen color texture (only accessible to parent).
@@ -1885,9 +1916,14 @@ void GLES2DecoderImpl::Destroy() {
offscreen_target_color_texture_.reset();
}
- if (offscreen_target_depth_stencil_render_buffer_.get()) {
- offscreen_target_depth_stencil_render_buffer_->Destroy();
- offscreen_target_depth_stencil_render_buffer_.reset();
+ if (offscreen_target_depth_render_buffer_.get()) {
+ offscreen_target_depth_render_buffer_->Destroy();
+ offscreen_target_depth_render_buffer_.reset();
+ }
+
+ if (offscreen_target_stencil_render_buffer_.get()) {
+ offscreen_target_stencil_render_buffer_->Destroy();
+ offscreen_target_stencil_render_buffer_.reset();
}
if (offscreen_saved_color_texture_.get()) {
@@ -1900,13 +1936,6 @@ void GLES2DecoderImpl::Destroy() {
default_context_->Destroy();
default_context_.reset();
}
-
-#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) && !defined(UNIT_TEST)
-#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
- // Terminate GLSL translator.
- ShFinalize();
-#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
-#endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
}
void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) {
@@ -2176,8 +2205,8 @@ void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) {
bool GLES2DecoderImpl::GetHelper(
GLenum pname, GLint* params, GLsizei* num_written) {
DCHECK(num_written);
- switch (pname) {
-#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+ if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
+ switch (pname) {
case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
*num_written = 1;
if (params) {
@@ -2208,7 +2237,9 @@ bool GLES2DecoderImpl::GetHelper(
*params = group_->max_vertex_uniform_vectors();
}
return true;
-#endif
+ }
+ }
+ switch (pname) {
case GL_COMPRESSED_TEXTURE_FORMATS:
*num_written = 0;
// We don't support compressed textures.
@@ -3235,7 +3266,6 @@ void GLES2DecoderImpl::DoCompileShader(GLuint client_id) {
// Translate GL ES 2.0 shader to Desktop GL shader and pass that to
// glShaderSource and then glCompileShader.
const char* shader_src = info->source().c_str();
-#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) && !defined(UNIT_TEST)
#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
ShHandle compiler = 0;
if (use_shader_translator_) {
@@ -3261,21 +3291,19 @@ void GLES2DecoderImpl::DoCompileShader(GLuint client_id) {
ShDestruct(compiler);
return;
}
+
info->SetTranslationStatus(true, "");
shader_src = ShGetObjectCode(compiler);
}
#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
-#endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
glShaderSource(info->service_id(), 1, &shader_src, NULL);
glCompileShader(info->service_id());
-#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) && !defined(UNIT_TEST)
#ifdef GLES2_GPU_SERVICE_TRANSLATE_SHADER
if (use_shader_translator_) {
ShDestruct(compiler);
}
#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
-#endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
};
void GLES2DecoderImpl::DoGetShaderiv(
@@ -4012,7 +4040,7 @@ error::Error GLES2DecoderImpl::HandleGetString(
}
void GLES2DecoderImpl::DoBufferData(
- GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) {
+ GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) {
if (!ValidateGLenumBufferTarget(target)) {
SetGLError(GL_INVALID_ENUM, "glBufferData: target GL_INVALID_ENUM");
return;
@@ -4677,9 +4705,7 @@ error::Error GLES2DecoderImpl::HandleSwapBuffers(
offscreen_saved_color_texture_->Copy(
offscreen_saved_color_texture_->size());
} else {
-#if !defined(UNIT_TEST)
context_->SwapBuffers();
-#endif
}
// TODO(kbr): when the back buffer is multisampled, then at least on Mac
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index a45c982..989af20 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "app/gfx/gl/gl_mock.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/common/id_allocator.h"
-#include "gpu/command_buffer/service/gl_mock.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/program_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
-using ::gles2::MockGLInterface;
+using ::gfx::MockGLInterface;
using ::testing::_;
using ::testing::DoAll;
using ::testing::InSequence;
@@ -1466,6 +1466,8 @@ TEST_F(GLES2DecoderTest, ReadPixels) {
31, 34, 39, 37, 32, 37, 32, 31, 34, 39, 37, 32, 37, 32, 34,
};
+ context_->SetSize(gfx::Size(INT_MAX, INT_MAX));
+
ReadPixelsEmulator emu(
kWidth, kHeight, kBytesPerPixel, kSrcPixels, kPackAlignment);
typedef ReadPixels::Result Result;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc
index 7be16d6..c233d96 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc
@@ -4,16 +4,16 @@
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
+#include "app/gfx/gl/gl_mock.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
-#include "gpu/command_buffer/service/gl_mock.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/program_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
-using ::gles2::MockGLInterface;
+using ::gfx::MockGLInterface;
using ::testing::_;
using ::testing::DoAll;
using ::testing::InSequence;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc
index 54964d8..0d29046 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc
@@ -4,16 +4,16 @@
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
+#include "app/gfx/gl/gl_mock.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
-#include "gpu/command_buffer/service/gl_mock.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/program_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
-using ::gles2::MockGLInterface;
+using ::gfx::MockGLInterface;
using ::testing::_;
using ::testing::DoAll;
using ::testing::InSequence;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
index bda68e8..7d61fe6 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -3,16 +3,16 @@
// found in the LICENSE file.
#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
+#include "app/gfx/gl/gl_mock.h"
#include "base/string_util.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
-#include "gpu/command_buffer/service/gl_mock.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/program_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
-using ::gles2::MockGLInterface;
+using ::gfx::MockGLInterface;
using ::testing::_;
using ::testing::DoAll;
using ::testing::InSequence;
@@ -29,7 +29,7 @@ namespace gles2 {
void GLES2DecoderTestBase::SetUp() {
gl_.reset(new StrictMock<MockGLInterface>());
- ::gles2::GLInterface::SetGLInterface(gl_.get());
+ ::gfx::GLInterface::SetGLInterface(gl_.get());
InSequence sequence;
@@ -148,7 +148,7 @@ void GLES2DecoderTestBase::SetUp() {
shared_memory_offset_;
shared_memory_id_ = kSharedMemoryId;
- context_.reset(gfx::GLContext::CreateOffscreenGLContext(NULL));
+ context_.reset(new gfx::StubGLContext);
decoder_.reset(GLES2Decoder::Create(&group_));
decoder_->Initialize(context_.get(), gfx::Size(), NULL, 0);
@@ -202,7 +202,7 @@ void GLES2DecoderTestBase::TearDown() {
decoder_->Destroy();
decoder_.reset();
engine_.reset();
- ::gles2::GLInterface::SetGLInterface(NULL);
+ ::gfx::GLInterface::SetGLInterface(NULL);
gl_.reset();
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
index d96ef99..c90a464 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
@@ -5,14 +5,14 @@
#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_
#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_
-#include "app/gfx/gl/gl_context.h"
+#include "app/gfx/gl/gl_context_stub.h"
+#include "app/gfx/gl/gl_mock.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/buffer_manager.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/framebuffer_manager.h"
-#include "gpu/command_buffer/service/gl_mock.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/program_manager.h"
#include "gpu/command_buffer/service/renderbuffer_manager.h"
@@ -215,8 +215,8 @@ class GLES2DecoderTestBase : public testing::Test {
}
// Use StrictMock to make 100% sure we know how GL will be called.
- scoped_ptr< ::testing::StrictMock< ::gles2::MockGLInterface> > gl_;
- scoped_ptr<gfx::GLContext> context_;
+ scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
+ scoped_ptr<gfx::StubGLContext> context_;
scoped_ptr<GLES2Decoder> decoder_;
GLuint client_buffer_id_;
diff --git a/gpu/command_buffer/service/gpu_processor.h b/gpu/command_buffer/service/gpu_processor.h
index 47164cd..7d5a110 100644
--- a/gpu/command_buffer/service/gpu_processor.h
+++ b/gpu/command_buffer/service/gpu_processor.h
@@ -19,7 +19,7 @@
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
-#if defined(OS_MACOSX) && !defined(UNIT_TEST)
+#if defined(OS_MACOSX)
#include "app/surface/accelerated_surface_mac.h"
#endif
@@ -103,7 +103,7 @@ class GPUProcessor : public CommandBufferEngine {
scoped_ptr<CommandParser> parser_;
scoped_ptr<gfx::GLContext> context_;
-#if defined(OS_MACOSX) && !defined(UNIT_TEST)
+#if defined(OS_MACOSX)
scoped_ptr<AcceleratedSurface> surface_;
#endif
diff --git a/gpu/command_buffer/service/gpu_processor_linux.cc b/gpu/command_buffer/service/gpu_processor_linux.cc
index 614704c..dd1fe6a 100644
--- a/gpu/command_buffer/service/gpu_processor_linux.cc
+++ b/gpu/command_buffer/service/gpu_processor_linux.cc
@@ -27,9 +27,6 @@ bool GPUProcessor::Initialize(gfx::PluginWindowHandle window,
parent_context = parent_decoder->GetGLContext();
DCHECK(parent_context);
-
- parent_handle = parent_context->GetHandle();
- DCHECK(parent_handle);
}
// Create either a view or pbuffer based GLContext.
@@ -39,7 +36,7 @@ bool GPUProcessor::Initialize(gfx::PluginWindowHandle window,
// TODO(apatrick): support multisampling.
context_.reset(gfx::GLContext::CreateViewGLContext(window, false));
} else {
- context_.reset(gfx::GLContext::CreateOffscreenGLContext(parent_handle));
+ context_.reset(gfx::GLContext::CreateOffscreenGLContext(parent_context));
}
if (!context_.get())
diff --git a/gpu/command_buffer/service/gpu_processor_mac.cc b/gpu/command_buffer/service/gpu_processor_mac.cc
index d47681f..8191cef 100644
--- a/gpu/command_buffer/service/gpu_processor_mac.cc
+++ b/gpu/command_buffer/service/gpu_processor_mac.cc
@@ -20,19 +20,15 @@ bool GPUProcessor::Initialize(gfx::PluginWindowHandle window,
// Get the parent decoder and the GLContext to share IDs with, if any.
gles2::GLES2Decoder* parent_decoder = NULL;
gfx::GLContext* parent_context = NULL;
- void* parent_handle = NULL;
if (parent) {
parent_decoder = parent->decoder_.get();
DCHECK(parent_decoder);
parent_context = parent_decoder->GetGLContext();
DCHECK(parent_context);
-
- parent_handle = parent_context->GetHandle();
- DCHECK(parent_handle);
}
- context_.reset(gfx::GLContext::CreateOffscreenGLContext(parent_handle));
+ context_.reset(gfx::GLContext::CreateOffscreenGLContext(parent_context));
if (!context_.get())
return false;
@@ -42,7 +38,6 @@ bool GPUProcessor::Initialize(gfx::PluginWindowHandle window,
// is whether we allocate an AcceleratedSurface, which transmits the
// rendering results back to the browser.
if (window) {
-#if !defined(UNIT_TEST)
surface_.reset(new AcceleratedSurface());
// TODO(apatrick): AcceleratedSurface will not work with an OSMesa context.
if (!surface_->Initialize(
@@ -50,7 +45,6 @@ bool GPUProcessor::Initialize(gfx::PluginWindowHandle window,
Destroy();
return false;
}
-#endif
}
return InitializeCommon(size, parent_decoder, parent_texture_id);
@@ -59,51 +53,37 @@ bool GPUProcessor::Initialize(gfx::PluginWindowHandle window,
}
void GPUProcessor::Destroy() {
-#if !defined(UNIT_TEST)
if (surface_.get()) {
surface_->Destroy();
}
surface_.reset();
-#endif
DestroyCommon();
}
uint64 GPUProcessor::SetWindowSizeForIOSurface(const gfx::Size& size) {
-#if !defined(UNIT_TEST)
ResizeOffscreenFrameBuffer(size);
decoder_->UpdateOffscreenFrameBufferSize();
return surface_->SetSurfaceSize(size);
-#else
- return 0;
-#endif
}
TransportDIB::Handle GPUProcessor::SetWindowSizeForTransportDIB(
const gfx::Size& size) {
-#if !defined(UNIT_TEST)
ResizeOffscreenFrameBuffer(size);
decoder_->UpdateOffscreenFrameBufferSize();
return surface_->SetTransportDIBSize(size);
-#else
- return TransportDIB::DefaultHandleValue();
-#endif
}
void GPUProcessor::SetTransportDIBAllocAndFree(
Callback2<size_t, TransportDIB::Handle*>::Type* allocator,
Callback1<TransportDIB::Id>::Type* deallocator) {
-#if !defined(UNIT_TEST)
surface_->SetTransportDIBAllocAndFree(allocator, deallocator);
-#endif
}
void GPUProcessor::WillSwapBuffers() {
DCHECK(context_->IsCurrent());
-#if !defined(UNIT_TEST)
if (surface_.get()) {
surface_->SwapBuffers();
}
-#endif
if (wrapped_swap_buffers_callback_.get()) {
wrapped_swap_buffers_callback_->Run();
diff --git a/gpu/command_buffer/service/gpu_processor_win.cc b/gpu/command_buffer/service/gpu_processor_win.cc
index e37c636..85962b9 100644
--- a/gpu/command_buffer/service/gpu_processor_win.cc
+++ b/gpu/command_buffer/service/gpu_processor_win.cc
@@ -22,26 +22,22 @@ bool GPUProcessor::Initialize(gfx::PluginWindowHandle window,
// Get the parent decoder and the GLContext to share IDs with, if any.
gles2::GLES2Decoder* parent_decoder = NULL;
gfx::GLContext* parent_context = NULL;
- void* parent_handle = NULL;
if (parent) {
parent_decoder = parent->decoder_.get();
DCHECK(parent_decoder);
parent_context = parent_decoder->GetGLContext();
DCHECK(parent_context);
-
- parent_handle = parent_context->GetHandle();
- DCHECK(parent_handle);
}
// Create either a view or pbuffer based GLContext.
if (window) {
- DCHECK(!parent_handle);
+ DCHECK(!parent_context);
// TODO(apatrick): support multisampling.
context_.reset(gfx::GLContext::CreateViewGLContext(window, false));
} else {
- context_.reset(gfx::GLContext::CreateOffscreenGLContext(parent_handle));
+ context_.reset(gfx::GLContext::CreateOffscreenGLContext(parent_context));
}
if (!context_.get())
diff --git a/gpu/command_buffer/service/program_manager_unittest.cc b/gpu/command_buffer/service/program_manager_unittest.cc
index b683927..2d8f22a 100644
--- a/gpu/command_buffer/service/program_manager_unittest.cc
+++ b/gpu/command_buffer/service/program_manager_unittest.cc
@@ -3,12 +3,12 @@
// found in the LICENSE file.
#include "gpu/command_buffer/service/program_manager.h"
+#include "app/gfx/gl/gl_mock.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "gpu/command_buffer/service/gl_mock.h"
-using ::gles2::MockGLInterface;
+using ::gfx::MockGLInterface;
using ::testing::_;
using ::testing::DoAll;
using ::testing::InSequence;
@@ -120,8 +120,8 @@ class ProgramManagerWithShaderTest : public testing::Test {
};
virtual void SetUp() {
- gl_.reset(new StrictMock<MockGLInterface>());
- ::gles2::GLInterface::SetGLInterface(gl_.get());
+ gl_.reset(new StrictMock<gfx::MockGLInterface>());
+ ::gfx::GLInterface::SetGLInterface(gl_.get());
SetupDefaultShaderExpectations();
@@ -217,12 +217,13 @@ class ProgramManagerWithShaderTest : public testing::Test {
}
virtual void TearDown() {
+ ::gfx::GLInterface::SetGLInterface(NULL);
}
static AttribInfo kAttribs[];
static UniformInfo kUniforms[];
- scoped_ptr<StrictMock<MockGLInterface> > gl_;
+ scoped_ptr<StrictMock<gfx::MockGLInterface> > gl_;
ProgramManager manager_;
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index ef39e53..0d10e60 100644
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -5,106 +5,9 @@
{
'variables': {
'chromium_code': 1,
- # This is defined here because we need to compile this set of files
- # twice with different defines. Once so it calls real GL, again so it
- # calls mock GL for the unit tests.
- 'gpu_service_source_files': [
- 'command_buffer/service/buffer_manager.h',
- 'command_buffer/service/buffer_manager.cc',
- 'command_buffer/service/framebuffer_manager.h',
- 'command_buffer/service/framebuffer_manager.cc',
- 'command_buffer/service/context_group.h',
- 'command_buffer/service/context_group.cc',
- 'command_buffer/service/gles2_cmd_decoder.h',
- 'command_buffer/service/gles2_cmd_decoder_autogen.h',
- 'command_buffer/service/gles2_cmd_decoder.cc',
- 'command_buffer/service/gles2_cmd_validation.h',
- 'command_buffer/service/gles2_cmd_validation.cc',
- 'command_buffer/service/gles2_cmd_validation_autogen.h',
- 'command_buffer/service/gles2_cmd_validation_implementation_autogen.h',
- 'command_buffer/service/gl_utils.h',
- 'command_buffer/service/gpu_processor.h',
- 'command_buffer/service/gpu_processor.cc',
- 'command_buffer/service/gpu_processor_linux.cc',
- 'command_buffer/service/gpu_processor_mac.cc',
- 'command_buffer/service/gpu_processor_win.cc',
- 'command_buffer/service/gpu_processor_mock.h',
- 'command_buffer/service/id_manager.h',
- 'command_buffer/service/id_manager.cc',
- 'command_buffer/service/program_manager.h',
- 'command_buffer/service/program_manager.cc',
- 'command_buffer/service/renderbuffer_manager.h',
- 'command_buffer/service/renderbuffer_manager.cc',
- 'command_buffer/service/shader_manager.h',
- 'command_buffer/service/shader_manager.cc',
- 'command_buffer/service/texture_manager.h',
- 'command_buffer/service/texture_manager.cc',
- ],
},
'targets': [
{
- 'target_name': 'gl_libs',
- 'type': 'static_library',
- 'include_dirs': [
- '../third_party/glew/include',
- ],
- 'defines': [
- 'GLEW_STATIC',
- ],
- 'all_dependent_settings': {
- 'include_dirs': [
- '../third_party/glew/include',
- ],
- 'defines': [
- 'GLEW_STATIC',
- ],
- },
- 'sources': [
- '../third_party/glew/src/glew.c',
- ],
- 'conditions': [
- [ 'OS=="linux"',
- {
- 'all_dependent_settings': {
- 'defines': [
- 'GL_GLEXT_PROTOTYPES',
- ],
- 'ldflags': [
- '-L<(PRODUCT_DIR)',
- ],
- 'link_settings': {
- 'libraries': [
- '-lX11',
- # For dlsym() in '../third_party/glew/src/glew.c'
- '-ldl',
- ],
- },
- },
- },
- ],
- [ 'OS=="mac"',
- {
- 'link_settings': {
- 'libraries': [
- '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
- ],
- },
- },
- ],
- [ 'OS=="win"',
- {
- 'all_dependent_settings': {
- 'link_settings': {
- 'libraries': [
- '-lOpenGL32.lib',
- ],
- },
- },
- },
- ],
- ],
- },
- {
'target_name': 'command_buffer_common',
'type': 'static_library',
'include_dirs': [
@@ -218,7 +121,7 @@
],
},
{
- 'target_name': 'command_buffer_service_impl',
+ 'target_name': 'command_buffer_service',
'type': 'static_library',
'include_dirs': [
'..',
@@ -230,38 +133,48 @@
},
'dependencies': [
'command_buffer_common',
- 'gl_libs',
+ '../app/app.gyp:app_base',
'../gfx/gfx.gyp:gfx',
],
'sources': [
- 'command_buffer/service/common_decoder.cc',
- 'command_buffer/service/common_decoder.h',
+ 'command_buffer/service/buffer_manager.h',
+ 'command_buffer/service/buffer_manager.cc',
+ 'command_buffer/service/framebuffer_manager.h',
+ 'command_buffer/service/framebuffer_manager.cc',
'command_buffer/service/cmd_buffer_engine.h',
- 'command_buffer/service/command_buffer_service.cc',
- 'command_buffer/service/command_buffer_service.h',
'command_buffer/service/cmd_parser.cc',
'command_buffer/service/cmd_parser.h',
+ 'command_buffer/service/command_buffer_service.cc',
+ 'command_buffer/service/command_buffer_service.h',
+ 'command_buffer/service/common_decoder.cc',
+ 'command_buffer/service/common_decoder.h',
+ 'command_buffer/service/context_group.h',
+ 'command_buffer/service/context_group.cc',
+ 'command_buffer/service/gles2_cmd_decoder.h',
+ 'command_buffer/service/gles2_cmd_decoder_autogen.h',
+ 'command_buffer/service/gles2_cmd_decoder.cc',
+ 'command_buffer/service/gles2_cmd_validation.h',
+ 'command_buffer/service/gles2_cmd_validation.cc',
+ 'command_buffer/service/gles2_cmd_validation_autogen.h',
+ 'command_buffer/service/gles2_cmd_validation_implementation_autogen.h',
+ 'command_buffer/service/gl_utils.h',
+ 'command_buffer/service/gpu_processor.h',
+ 'command_buffer/service/gpu_processor.cc',
+ 'command_buffer/service/gpu_processor_linux.cc',
+ 'command_buffer/service/gpu_processor_mac.cc',
+ 'command_buffer/service/gpu_processor_mock.h',
+ 'command_buffer/service/gpu_processor_win.cc',
+ 'command_buffer/service/id_manager.h',
+ 'command_buffer/service/id_manager.cc',
'command_buffer/service/mocks.h',
- ],
- },
- {
- 'target_name': 'command_buffer_service',
- 'type': 'static_library',
- 'include_dirs': [
- '..',
- ],
- 'all_dependent_settings': {
- 'include_dirs': [
- '..',
- ],
- },
- 'dependencies': [
- 'command_buffer_service_impl',
- 'gl_libs',
- '../app/app.gyp:app_base',
- ],
- 'sources': [
- '<@(gpu_service_source_files)',
+ 'command_buffer/service/program_manager.h',
+ 'command_buffer/service/program_manager.cc',
+ 'command_buffer/service/renderbuffer_manager.h',
+ 'command_buffer/service/renderbuffer_manager.cc',
+ 'command_buffer/service/shader_manager.h',
+ 'command_buffer/service/shader_manager.cc',
+ 'command_buffer/service/texture_manager.h',
+ 'command_buffer/service/texture_manager.cc',
],
'conditions': [
['OS == "linux"', {
@@ -305,18 +218,18 @@
'target_name': 'gpu_unittests',
'type': 'executable',
'dependencies': [
+ '../app/app.gyp:app_base',
'../testing/gmock.gyp:gmock',
'../testing/gmock.gyp:gmockmain',
'../testing/gtest.gyp:gtest',
'command_buffer_client',
'command_buffer_common',
- 'command_buffer_service_impl',
+ 'command_buffer_service',
'gles2_lib',
'gles2_implementation',
'gles2_cmd_helper',
],
'sources': [
- '<@(gpu_service_source_files)',
'command_buffer/client/cmd_buffer_helper_test.cc',
'command_buffer/client/fenced_allocator_test.cc',
'command_buffer/client/gles2_implementation_unittest.cc',
@@ -335,6 +248,7 @@
'command_buffer/common/gles2_cmd_id_test.cc',
'command_buffer/common/gles2_cmd_id_test_autogen.h',
'command_buffer/common/id_allocator_test.cc',
+ 'command_buffer/common/unittest_main.cc',
'command_buffer/service/buffer_manager_unittest.cc',
'command_buffer/service/context_group_unittest.cc',
'command_buffer/service/cmd_parser_test.cc',
@@ -342,11 +256,6 @@
'command_buffer/service/common_decoder_unittest.cc',
'command_buffer/service/framebuffer_manager_unittest.cc',
'command_buffer/service/gpu_processor_unittest.cc',
- 'command_buffer/service/gl_context_stub.cc',
- 'command_buffer/service/gl_interface.h',
- 'command_buffer/service/gl_interface.cc',
- 'command_buffer/service/gl_mock.h',
- 'command_buffer/service/gl_mock.cc',
'command_buffer/service/gles2_cmd_decoder_unittest_base.h',
'command_buffer/service/gles2_cmd_decoder_unittest_base.cc',
'command_buffer/service/gles2_cmd_decoder_unittest.cc',
diff --git a/media/media.gyp b/media/media.gyp
index abd32d9..39aadd3 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -435,7 +435,7 @@
}],
['player_x11_renderer == "gl"', {
'dependencies': [
- '../gpu/gpu.gyp:gl_libs',
+ '../app/app.gyp:app_base',
],
'sources': [
'tools/player_x11/gl_video_renderer.cc',
diff --git a/third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.c b/third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.c
index 108aade..7a6b577 100644
--- a/third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.c
+++ b/third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.c
@@ -59,7 +59,7 @@ int svsInit ( ESContext *esContext )
glBufferData ( GL_ARRAY_BUFFER, 3 * numVertices * sizeof(GLfloat),
vertices, GL_STATIC_DRAW );
glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER, userData->vboIds[1] );
- glBufferData ( GL_ELEMENT_ARRAY_BUFFER, userData->numIndices * sizeof(GL_UNSIGNED_SHORT),
+ glBufferData ( GL_ELEMENT_ARRAY_BUFFER, userData->numIndices * sizeof(GLushort),
indices, GL_STATIC_DRAW );
if ( vertices != NULL ) free ( vertices );
if ( indices != NULL ) free ( indices );