summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-22 22:19:27 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-22 22:19:27 +0000
commit826360a32bad92c49f16538ef807eb7b576d2349 (patch)
treeba75a748a49f3194b7003e48b45c90e956909318 /mojo
parent92a4b0ae784ee79e08d3a579cc30815533592cb0 (diff)
downloadchromium_src-826360a32bad92c49f16538ef807eb7b576d2349.zip
chromium_src-826360a32bad92c49f16538ef807eb7b576d2349.tar.gz
chromium_src-826360a32bad92c49f16538ef807eb7b576d2349.tar.bz2
Make mojo_gles2 a stub shared library
This follows the mojo_system pattern, separating mojo_gles2 into a client-side shared library which is just a trampoline into a shell-provided mojo_gles2_impl component. This includes core GLES2 functions which are auto-generated, replacing the use of gles2_c_lib. BUG=333157 R=darin@chromium.org, kbr@chromium.org Review URL: https://codereview.chromium.org/140513003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
-rw-r--r--mojo/gles2/gles2.cc35
-rw-r--r--mojo/gles2/gles2_impl_export.h31
-rw-r--r--mojo/gles2/gles2_support_impl.cc73
-rw-r--r--mojo/gles2/gles2_support_impl.h31
-rw-r--r--mojo/mojo.gyp13
-rw-r--r--mojo/mojo_apps.gypi1
-rw-r--r--mojo/mojo_examples.gypi4
-rw-r--r--mojo/mojo_public.gypi28
-rw-r--r--mojo/public/gles2/gles2.h29
-rw-r--r--mojo/public/gles2/gles2_call_visitor_autogen.h389
-rw-r--r--mojo/public/gles2/gles2_export.h26
-rw-r--r--mojo/public/gles2/gles2_interface.h23
-rw-r--r--mojo/public/gles2/gles2_private.cc57
-rw-r--r--mojo/public/gles2/gles2_private.h33
-rw-r--r--mojo/shell/context.cc2
15 files changed, 709 insertions, 66 deletions
diff --git a/mojo/gles2/gles2.cc b/mojo/gles2/gles2.cc
deleted file mode 100644
index c90a331..0000000
--- a/mojo/gles2/gles2.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2013 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 "mojo/public/gles2/gles2.h"
-
-#include "gpu/command_buffer/client/gles2_lib.h"
-
-extern "C" {
-
-void MojoGLES2Initialize() {
- gles2::Initialize();
-}
-
-void MojoGLES2Terminate() {
- gles2::Terminate();
-}
-
-void MojoGLES2MakeCurrent(uint64_t encoded) {
- // Ack, Hans! It's the giant hack.
- // TODO(abarth): Replace this hack with something more disciplined. Most
- // likley, we should receive a MojoHandle that we use to wire up the
- // client side of an out-of-process command buffer. Given that we're
- // still in-process, we just reinterpret_cast the value into a GL interface.
- gpu::gles2::GLES2Interface* gl_interface =
- reinterpret_cast<gpu::gles2::GLES2Interface*>(
- static_cast<uintptr_t>(encoded));
- gles2::SetGLContext(gl_interface);
-}
-
-void MojoGLES2SwapBuffers() {
- gles2::GetGLContext()->SwapBuffers();
-}
-
-} // extern "C"
diff --git a/mojo/gles2/gles2_impl_export.h b/mojo/gles2/gles2_impl_export.h
new file mode 100644
index 0000000..3299ced
--- /dev/null
+++ b/mojo/gles2/gles2_impl_export.h
@@ -0,0 +1,31 @@
+// Copyright 2014 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 MOJO_GLES2_GLES2_IMPL_EXPORT_H_
+#define MOJO_GLES2_GLES2_IMPL_EXPORT_H_
+
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+
+#if defined(MOJO_GLES2_IMPL_IMPLEMENTATION)
+#define MOJO_GLES2_IMPL_EXPORT __declspec(dllexport)
+#else
+#define MOJO_GLES2_IMPL_EXPORT __declspec(dllimport)
+#endif
+
+#else // !defined(WIN32)
+
+#if defined(MOJO_GLES2_IMPL_IMPLEMENTATION)
+#define MOJO_GLES2_IMPL_EXPORT __attribute__((visibility("default")))
+#else
+#define MOJO_GLES2_IMPL_EXPORT
+#endif
+
+#endif // defined(WIN32)
+
+#else // defined(COMPONENT_BUILD)
+#define MOJO_GLES2_IMPL_EXPORT
+#endif
+
+#endif // MOJO_GLES2_GLES2_IMPL_EXPORT_H_
diff --git a/mojo/gles2/gles2_support_impl.cc b/mojo/gles2/gles2_support_impl.cc
new file mode 100644
index 0000000..f8b96f6
--- /dev/null
+++ b/mojo/gles2/gles2_support_impl.cc
@@ -0,0 +1,73 @@
+// Copyright 2014 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 "mojo/gles2/gles2_support_impl.h"
+
+#include "base/lazy_instance.h"
+#include "gpu/command_buffer/client/gles2_interface.h"
+#include "mojo/public/gles2/gles2_interface.h"
+#include "mojo/public/gles2/gles2_private.h"
+
+namespace mojo {
+namespace gles2 {
+
+namespace {
+
+class GLES2ImplForCommandBuffer : public GLES2Interface {
+ public:
+ GLES2ImplForCommandBuffer() : gpu_interface_(NULL) {}
+
+ void set_gpu_interface(gpu::gles2::GLES2Interface* gpu_interface) {
+ gpu_interface_ = gpu_interface;
+ }
+ gpu::gles2::GLES2Interface* gpu_interface() const { return gpu_interface_; }
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ virtual ReturnType Function PARAMETERS OVERRIDE { \
+ return gpu_interface_->Function ARGUMENTS; \
+ }
+#include "mojo/public/gles2/gles2_call_visitor_autogen.h"
+#undef VISIT_GL_CALL
+
+ private:
+ gpu::gles2::GLES2Interface* gpu_interface_;
+ DISALLOW_COPY_AND_ASSIGN(GLES2ImplForCommandBuffer);
+};
+
+base::LazyInstance<GLES2ImplForCommandBuffer> g_gles2_interface =
+ LAZY_INSTANCE_INITIALIZER;
+
+} // anonymous namespace
+
+GLES2SupportImpl::~GLES2SupportImpl() {}
+
+// static
+void GLES2SupportImpl::Init() { GLES2Support::Init(new GLES2SupportImpl()); }
+
+void GLES2SupportImpl::Initialize() {}
+
+void GLES2SupportImpl::Terminate() {}
+
+void GLES2SupportImpl::MakeCurrent(uint64_t encoded) {
+ // Ack, Hans! It's the giant hack.
+ // TODO(abarth): Replace this hack with something more disciplined. Most
+ // likley, we should receive a MojoHandle that we use to wire up the
+ // client side of an out-of-process command buffer. Given that we're
+ // still in-process, we just reinterpret_cast the value into a GL interface.
+ gpu::gles2::GLES2Interface* gl_interface =
+ reinterpret_cast<gpu::gles2::GLES2Interface*>(
+ static_cast<uintptr_t>(encoded));
+ g_gles2_interface.Get().set_gpu_interface(gl_interface);
+}
+
+void GLES2SupportImpl::SwapBuffers() {
+ g_gles2_interface.Get().gpu_interface()->SwapBuffers();
+}
+
+GLES2Interface* GLES2SupportImpl::GetGLES2InterfaceForCurrentContext() {
+ return &g_gles2_interface.Get();
+}
+
+} // namespace gles2
+} // namespace mojo
diff --git a/mojo/gles2/gles2_support_impl.h b/mojo/gles2/gles2_support_impl.h
new file mode 100644
index 0000000..abe6adc
--- /dev/null
+++ b/mojo/gles2/gles2_support_impl.h
@@ -0,0 +1,31 @@
+// Copyright 2014 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 MOJO_GLES2_GLES2_SUPPORT_IMPL_H_
+#define MOJO_GLES2_GLES2_SUPPORT_IMPL_H_
+
+#include "base/compiler_specific.h"
+#include "mojo/gles2/gles2_impl_export.h"
+#include "mojo/public/gles2/gles2_private.h"
+
+namespace mojo {
+namespace gles2 {
+
+class MOJO_GLES2_IMPL_EXPORT GLES2SupportImpl : public GLES2Support {
+ public:
+ virtual ~GLES2SupportImpl();
+
+ static void Init();
+
+ virtual void Initialize() OVERRIDE;
+ virtual void Terminate() OVERRIDE;
+ virtual void MakeCurrent(uint64_t encoded) OVERRIDE;
+ virtual void SwapBuffers() OVERRIDE;
+ virtual GLES2Interface* GetGLES2InterfaceForCurrentContext() OVERRIDE;
+};
+
+} // namespace gles2
+} // namespace mojo
+
+#endif // MOJO_GLES2_GLES2_SUPPORT_IMPL_H_
diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp
index 5a64fd7..df47a2d 100644
--- a/mojo/mojo.gyp
+++ b/mojo/mojo.gyp
@@ -181,16 +181,20 @@
],
},
{
- 'target_name': 'mojo_gles2',
+ 'target_name': 'mojo_gles2_impl',
'type': '<(component)',
'dependencies': [
- '../gpu/gpu.gyp:gles2_c_lib',
+ '../base/base.gyp:base',
+ '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ 'mojo_gles2',
],
'defines': [
- 'MOJO_GLES2_IMPLEMENTATION',
+ 'MOJO_GLES2_IMPL_IMPLEMENTATION',
],
'sources': [
- 'gles2/gles2.cc',
+ 'gles2/gles2_impl_export.h',
+ 'gles2/gles2_support_impl.cc',
+ 'gles2/gles2_support_impl.h',
],
},
{
@@ -314,6 +318,7 @@
'../base/base.gyp:base',
'../net/net.gyp:net',
'../url/url.gyp:url_lib',
+ 'mojo_gles2_impl',
'mojo_shell_bindings',
'mojo_system',
'mojo_system_impl',
diff --git a/mojo/mojo_apps.gypi b/mojo/mojo_apps.gypi
index 17c8b93..dba5544 100644
--- a/mojo/mojo_apps.gypi
+++ b/mojo/mojo_apps.gypi
@@ -5,7 +5,6 @@
'type': 'static_library',
'dependencies': [
'../base/base.gyp:base',
- '../gpu/gpu.gyp:gles2_c_lib',
'../gin/gin.gyp:gin',
'../ui/gl/gl.gyp:gl',
'../v8/tools/gyp/v8.gyp:v8',
diff --git a/mojo/mojo_examples.gypi b/mojo/mojo_examples.gypi
index 4877f6f..e578329 100644
--- a/mojo/mojo_examples.gypi
+++ b/mojo/mojo_examples.gypi
@@ -8,7 +8,7 @@
'target_name': 'mojo_sample_app',
'type': 'shared_library',
'dependencies': [
- '../gpu/gpu.gyp:gles2_c_lib',
+ # TODO(darin): we should not be linking against these libraries!
'../ui/gfx/gfx.gyp:gfx',
'../ui/gfx/gfx.gyp:gfx_geometry',
'../ui/gl/gl.gyp:gl',
@@ -41,7 +41,6 @@
'dependencies': [
'../base/base.gyp:base',
'../cc/cc.gyp:cc',
- '../gpu/gpu.gyp:gles2_c_lib',
'../gpu/gpu.gyp:gles2_implementation',
'../skia/skia.gyp:skia',
'../ui/gfx/gfx.gyp:gfx',
@@ -80,7 +79,6 @@
'dependencies': [
'../base/base.gyp:base',
'../cc/cc.gyp:cc',
- '../gpu/gpu.gyp:gles2_c_lib',
'../gpu/gpu.gyp:gles2_implementation',
'../skia/skia.gyp:skia',
'../ui/aura/aura.gyp:aura',
diff --git a/mojo/mojo_public.gypi b/mojo/mojo_public.gypi
index 3c029c0..b921e18 100644
--- a/mojo/mojo_public.gypi
+++ b/mojo/mojo_public.gypi
@@ -25,6 +25,34 @@
],
},
{
+ 'target_name': 'mojo_gles2',
+ 'type': 'shared_library',
+ 'defines': [
+ 'MOJO_GLES2_IMPLEMENTATION',
+ 'GLES2_USE_MOJO',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'dependencies': [
+ '../third_party/khronos/khronos.gyp:khronos_headers'
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '..',
+ ],
+ 'defines': [
+ 'GLES2_USE_MOJO',
+ ],
+ },
+ 'sources': [
+ 'public/gles2/gles2.h',
+ 'public/gles2/gles2_private.cc',
+ 'public/gles2/gles2_private.h',
+ 'public/gles2/gles2_export.h',
+ ],
+ },
+ {
'target_name': 'mojo_public_test_support',
'type': 'static_library',
'dependencies': [
diff --git a/mojo/public/gles2/gles2.h b/mojo/public/gles2/gles2.h
index fbcb2c7..2a6ee11 100644
--- a/mojo/public/gles2/gles2.h
+++ b/mojo/public/gles2/gles2.h
@@ -8,30 +8,9 @@
// Note: This header should be compilable as C.
#include <stdint.h>
+#include <GLES2/gl2.h>
-#if defined(COMPONENT_BUILD)
-
-#if defined(WIN32)
-
-#if defined(MOJO_GLES2_IMPLEMENTATION)
-#define MOJO_GLES2_EXPORT __declspec(dllexport)
-#else
-#define MOJO_GLES2_EXPORT __declspec(dllimport)
-#endif
-
-#else // !defined(WIN32)
-
-#if defined(MOJO_GLES2_IMPLEMENTATION)
-#define MOJO_GLES2_EXPORT __attribute__((visibility("default")))
-#else
-#define MOJO_GLES2_EXPORT
-#endif
-
-#endif // defined(WIN32)
-
-#else // !defined(COMPONENT_BUILD)
-#define MOJO_GLES2_EXPORT
-#endif
+#include "mojo/public/gles2/gles2_export.h"
#ifdef __cplusplus
extern "C" {
@@ -42,6 +21,10 @@ MOJO_GLES2_EXPORT void MojoGLES2Terminate();
// TODO(abarth): MojoGLES2MakeCurrent should take a MojoHandle.
MOJO_GLES2_EXPORT void MojoGLES2MakeCurrent(uint64_t encoded);
MOJO_GLES2_EXPORT void MojoGLES2SwapBuffers();
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ MOJO_GLES2_EXPORT ReturnType GL_APIENTRY gl##Function PARAMETERS;
+#include "mojo/public/gles2/gles2_call_visitor_autogen.h"
+#undef VISIT_GL_CALL
#ifdef __cplusplus
} // extern "C"
diff --git a/mojo/public/gles2/gles2_call_visitor_autogen.h b/mojo/public/gles2/gles2_call_visitor_autogen.h
new file mode 100644
index 0000000..8886afb
--- /dev/null
+++ b/mojo/public/gles2/gles2_call_visitor_autogen.h
@@ -0,0 +1,389 @@
+// Copyright (c) 2014 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 is auto-generated from
+// gpu/command_buffer/build_gles2_cmd_buffer.py
+// DO NOT EDIT!
+
+VISIT_GL_CALL(ActiveTexture, void, (GLenum texture), (texture))
+VISIT_GL_CALL(
+ AttachShader, void, (GLuint program, GLuint shader), (program, shader))
+VISIT_GL_CALL(
+ BindAttribLocation, void, (
+ GLuint program, GLuint index, const char* name), (
+ program, index, name))
+VISIT_GL_CALL(
+ BindBuffer, void, (GLenum target, GLuint buffer), (target, buffer))
+VISIT_GL_CALL(
+ BindFramebuffer, void, (
+ GLenum target, GLuint framebuffer), (target, framebuffer))
+VISIT_GL_CALL(
+ BindRenderbuffer, void, (
+ GLenum target, GLuint renderbuffer), (target, renderbuffer))
+VISIT_GL_CALL(
+ BindTexture, void, (GLenum target, GLuint texture), (target, texture))
+VISIT_GL_CALL(
+ BlendColor, void, (
+ GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha), (
+ red, green, blue, alpha))
+VISIT_GL_CALL(BlendEquation, void, (GLenum mode), (mode))
+VISIT_GL_CALL(
+ BlendEquationSeparate, void, (
+ GLenum modeRGB, GLenum modeAlpha), (modeRGB, modeAlpha))
+VISIT_GL_CALL(
+ BlendFunc, void, (GLenum sfactor, GLenum dfactor), (sfactor, dfactor))
+VISIT_GL_CALL(
+ BlendFuncSeparate, void, (
+ GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha), (
+ srcRGB, dstRGB, srcAlpha, dstAlpha))
+VISIT_GL_CALL(
+ BufferData, void, (
+ GLenum target, GLsizeiptr size, const void* data, GLenum usage), (
+ target, size, data, usage))
+VISIT_GL_CALL(
+ BufferSubData, void, (
+ GLenum target, GLintptr offset, GLsizeiptr size, const void* data), (
+ target, offset, size, data))
+VISIT_GL_CALL(CheckFramebufferStatus, GLenum, (GLenum target), (target))
+VISIT_GL_CALL(Clear, void, (GLbitfield mask), (mask))
+VISIT_GL_CALL(
+ ClearColor, void, (
+ GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha), (
+ red, green, blue, alpha))
+VISIT_GL_CALL(ClearDepthf, void, (GLclampf depth), (depth))
+VISIT_GL_CALL(ClearStencil, void, (GLint s), (s))
+VISIT_GL_CALL(
+ ColorMask, void, (
+ GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha), (
+ red, green, blue, alpha))
+VISIT_GL_CALL(CompileShader, void, (GLuint shader), (shader))
+VISIT_GL_CALL(
+ CompressedTexImage2D, void, (
+ GLenum target, GLint level, GLenum internalformat, GLsizei width,
+ GLsizei height, GLint border, GLsizei imageSize, const void* data), (
+ target, level, internalformat, width, height, border, imageSize,
+ data))
+VISIT_GL_CALL(
+ CompressedTexSubImage2D, void, (
+ GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
+ GLsizei height, GLenum format, GLsizei imageSize, const void* data), (
+ target, level, xoffset, yoffset, width, height, format, imageSize,
+ data))
+VISIT_GL_CALL(
+ CopyTexImage2D, void, (
+ GLenum target, GLint level, GLenum internalformat, GLint x, GLint y,
+ GLsizei width, GLsizei height, GLint border), (
+ target, level, internalformat, x, y, width, height, border))
+VISIT_GL_CALL(
+ CopyTexSubImage2D, void, (
+ GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x,
+ GLint y, GLsizei width, GLsizei height), (
+ target, level, xoffset, yoffset, x, y, width, height))
+VISIT_GL_CALL(CreateProgram, GLuint, (), ())
+VISIT_GL_CALL(CreateShader, GLuint, (GLenum type), (type))
+VISIT_GL_CALL(CullFace, void, (GLenum mode), (mode))
+VISIT_GL_CALL(
+ DeleteBuffers, void, (GLsizei n, const GLuint* buffers), (n, buffers))
+VISIT_GL_CALL(
+ DeleteFramebuffers, void, (
+ GLsizei n, const GLuint* framebuffers), (n, framebuffers))
+VISIT_GL_CALL(DeleteProgram, void, (GLuint program), (program))
+VISIT_GL_CALL(
+ DeleteRenderbuffers, void, (
+ GLsizei n, const GLuint* renderbuffers), (n, renderbuffers))
+VISIT_GL_CALL(DeleteShader, void, (GLuint shader), (shader))
+VISIT_GL_CALL(
+ DeleteTextures, void, (GLsizei n, const GLuint* textures), (n, textures))
+VISIT_GL_CALL(DepthFunc, void, (GLenum func), (func))
+VISIT_GL_CALL(DepthMask, void, (GLboolean flag), (flag))
+VISIT_GL_CALL(
+ DepthRangef, void, (GLclampf zNear, GLclampf zFar), (zNear, zFar))
+VISIT_GL_CALL(
+ DetachShader, void, (GLuint program, GLuint shader), (program, shader))
+VISIT_GL_CALL(Disable, void, (GLenum cap), (cap))
+VISIT_GL_CALL(DisableVertexAttribArray, void, (GLuint index), (index))
+VISIT_GL_CALL(
+ DrawArrays, void, (
+ GLenum mode, GLint first, GLsizei count), (mode, first, count))
+VISIT_GL_CALL(
+ DrawElements, void, (
+ GLenum mode, GLsizei count, GLenum type, const void* indices), (
+ mode, count, type, indices))
+VISIT_GL_CALL(Enable, void, (GLenum cap), (cap))
+VISIT_GL_CALL(EnableVertexAttribArray, void, (GLuint index), (index))
+VISIT_GL_CALL(Finish, void, (), ())
+VISIT_GL_CALL(Flush, void, (), ())
+VISIT_GL_CALL(
+ FramebufferRenderbuffer, void, (
+ GLenum target, GLenum attachment, GLenum renderbuffertarget,
+ GLuint renderbuffer), (
+ target, attachment, renderbuffertarget, renderbuffer))
+VISIT_GL_CALL(
+ FramebufferTexture2D, void, (
+ GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
+ GLint level), (target, attachment, textarget, texture, level))
+VISIT_GL_CALL(FrontFace, void, (GLenum mode), (mode))
+VISIT_GL_CALL(GenBuffers, void, (GLsizei n, GLuint* buffers), (n, buffers))
+VISIT_GL_CALL(GenerateMipmap, void, (GLenum target), (target))
+VISIT_GL_CALL(
+ GenFramebuffers, void, (
+ GLsizei n, GLuint* framebuffers), (n, framebuffers))
+VISIT_GL_CALL(
+ GenRenderbuffers, void, (
+ GLsizei n, GLuint* renderbuffers), (n, renderbuffers))
+VISIT_GL_CALL(GenTextures, void, (GLsizei n, GLuint* textures), (n, textures))
+VISIT_GL_CALL(
+ GetActiveAttrib, void, (
+ GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
+ GLint* size, GLenum* type, char* name), (
+ program, index, bufsize, length, size, type, name))
+VISIT_GL_CALL(
+ GetActiveUniform, void, (
+ GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
+ GLint* size, GLenum* type, char* name), (
+ program, index, bufsize, length, size, type, name))
+VISIT_GL_CALL(
+ GetAttachedShaders, void, (
+ GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders), (
+ program, maxcount, count, shaders))
+VISIT_GL_CALL(
+ GetAttribLocation, GLint, (
+ GLuint program, const char* name), (program, name))
+VISIT_GL_CALL(
+ GetBooleanv, void, (GLenum pname, GLboolean* params), (pname, params))
+VISIT_GL_CALL(
+ GetBufferParameteriv, void, (
+ GLenum target, GLenum pname, GLint* params), (target, pname, params))
+VISIT_GL_CALL(GetError, GLenum, (), ())
+VISIT_GL_CALL(
+ GetFloatv, void, (GLenum pname, GLfloat* params), (pname, params))
+VISIT_GL_CALL(
+ GetFramebufferAttachmentParameteriv, void, (
+ GLenum target, GLenum attachment, GLenum pname, GLint* params), (
+ target, attachment, pname, params))
+VISIT_GL_CALL(
+ GetIntegerv, void, (GLenum pname, GLint* params), (pname, params))
+VISIT_GL_CALL(
+ GetProgramiv, void, (
+ GLuint program, GLenum pname, GLint* params), (program, pname, params))
+VISIT_GL_CALL(
+ GetProgramInfoLog, void, (
+ GLuint program, GLsizei bufsize, GLsizei* length, char* infolog), (
+ program, bufsize, length, infolog))
+VISIT_GL_CALL(
+ GetRenderbufferParameteriv, void, (
+ GLenum target, GLenum pname, GLint* params), (target, pname, params))
+VISIT_GL_CALL(
+ GetShaderiv, void, (
+ GLuint shader, GLenum pname, GLint* params), (shader, pname, params))
+VISIT_GL_CALL(
+ GetShaderInfoLog, void, (
+ GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog), (
+ shader, bufsize, length, infolog))
+VISIT_GL_CALL(
+ GetShaderPrecisionFormat, void, (
+ GLenum shadertype, GLenum precisiontype, GLint* range,
+ GLint* precision), (shadertype, precisiontype, range, precision))
+VISIT_GL_CALL(
+ GetShaderSource, void, (
+ GLuint shader, GLsizei bufsize, GLsizei* length, char* source), (
+ shader, bufsize, length, source))
+VISIT_GL_CALL(GetString, const GLubyte*, (GLenum name), (name))
+VISIT_GL_CALL(
+ GetTexParameterfv, void, (
+ GLenum target, GLenum pname, GLfloat* params), (target, pname, params))
+VISIT_GL_CALL(
+ GetTexParameteriv, void, (
+ GLenum target, GLenum pname, GLint* params), (target, pname, params))
+VISIT_GL_CALL(
+ GetUniformfv, void, (
+ GLuint program, GLint location, GLfloat* params), (
+ program, location, params))
+VISIT_GL_CALL(
+ GetUniformiv, void, (
+ GLuint program, GLint location, GLint* params), (
+ program, location, params))
+VISIT_GL_CALL(
+ GetUniformLocation, GLint, (
+ GLuint program, const char* name), (program, name))
+VISIT_GL_CALL(
+ GetVertexAttribfv, void, (
+ GLuint index, GLenum pname, GLfloat* params), (index, pname, params))
+VISIT_GL_CALL(
+ GetVertexAttribiv, void, (
+ GLuint index, GLenum pname, GLint* params), (index, pname, params))
+VISIT_GL_CALL(
+ GetVertexAttribPointerv, void, (
+ GLuint index, GLenum pname, void** pointer), (index, pname, pointer))
+VISIT_GL_CALL(Hint, void, (GLenum target, GLenum mode), (target, mode))
+VISIT_GL_CALL(IsBuffer, GLboolean, (GLuint buffer), (buffer))
+VISIT_GL_CALL(IsEnabled, GLboolean, (GLenum cap), (cap))
+VISIT_GL_CALL(IsFramebuffer, GLboolean, (GLuint framebuffer), (framebuffer))
+VISIT_GL_CALL(IsProgram, GLboolean, (GLuint program), (program))
+VISIT_GL_CALL(IsRenderbuffer, GLboolean, (GLuint renderbuffer), (renderbuffer))
+VISIT_GL_CALL(IsShader, GLboolean, (GLuint shader), (shader))
+VISIT_GL_CALL(IsTexture, GLboolean, (GLuint texture), (texture))
+VISIT_GL_CALL(LineWidth, void, (GLfloat width), (width))
+VISIT_GL_CALL(LinkProgram, void, (GLuint program), (program))
+VISIT_GL_CALL(PixelStorei, void, (GLenum pname, GLint param), (pname, param))
+VISIT_GL_CALL(
+ PolygonOffset, void, (GLfloat factor, GLfloat units), (factor, units))
+VISIT_GL_CALL(
+ ReadPixels, void, (
+ GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
+ GLenum type, void* pixels), (
+ x, y, width, height, format, type, pixels))
+VISIT_GL_CALL(ReleaseShaderCompiler, void, (), ())
+VISIT_GL_CALL(
+ RenderbufferStorage, void, (
+ GLenum target, GLenum internalformat, GLsizei width, GLsizei height), (
+ target, internalformat, width, height))
+VISIT_GL_CALL(
+ SampleCoverage, void, (GLclampf value, GLboolean invert), (value, invert))
+VISIT_GL_CALL(
+ Scissor, void, (
+ GLint x, GLint y, GLsizei width, GLsizei height), (
+ x, y, width, height))
+VISIT_GL_CALL(
+ ShaderBinary, void, (
+ GLsizei n, const GLuint* shaders, GLenum binaryformat,
+ const void* binary, GLsizei length), (
+ n, shaders, binaryformat, binary, length))
+VISIT_GL_CALL(
+ ShaderSource, void, (
+ GLuint shader, GLsizei count, const GLchar* const* str,
+ const GLint* length), (shader, count, str, length))
+VISIT_GL_CALL(
+ StencilFunc, void, (
+ GLenum func, GLint ref, GLuint mask), (func, ref, mask))
+VISIT_GL_CALL(
+ StencilFuncSeparate, void, (
+ GLenum face, GLenum func, GLint ref, GLuint mask), (
+ face, func, ref, mask))
+VISIT_GL_CALL(StencilMask, void, (GLuint mask), (mask))
+VISIT_GL_CALL(
+ StencilMaskSeparate, void, (GLenum face, GLuint mask), (face, mask))
+VISIT_GL_CALL(
+ StencilOp, void, (
+ GLenum fail, GLenum zfail, GLenum zpass), (fail, zfail, zpass))
+VISIT_GL_CALL(
+ StencilOpSeparate, void, (
+ GLenum face, GLenum fail, GLenum zfail, GLenum zpass), (
+ face, fail, zfail, zpass))
+VISIT_GL_CALL(
+ TexImage2D, void, (
+ GLenum target, GLint level, GLint internalformat, GLsizei width,
+ GLsizei height, GLint border, GLenum format, GLenum type,
+ const void* pixels), (
+ target, level, internalformat, width, height, border, format, type,
+ pixels))
+VISIT_GL_CALL(
+ TexParameterf, void, (
+ GLenum target, GLenum pname, GLfloat param), (target, pname, param))
+VISIT_GL_CALL(
+ TexParameterfv, void, (
+ GLenum target, GLenum pname, const GLfloat* params), (
+ target, pname, params))
+VISIT_GL_CALL(
+ TexParameteri, void, (
+ GLenum target, GLenum pname, GLint param), (target, pname, param))
+VISIT_GL_CALL(
+ TexParameteriv, void, (
+ GLenum target, GLenum pname, const GLint* params), (
+ target, pname, params))
+VISIT_GL_CALL(
+ TexSubImage2D, void, (
+ GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
+ GLsizei height, GLenum format, GLenum type, const void* pixels), (
+ target, level, xoffset, yoffset, width, height, format, type,
+ pixels))
+VISIT_GL_CALL(Uniform1f, void, (GLint location, GLfloat x), (location, x))
+VISIT_GL_CALL(
+ Uniform1fv, void, (
+ GLint location, GLsizei count, const GLfloat* v), (location, count, v))
+VISIT_GL_CALL(Uniform1i, void, (GLint location, GLint x), (location, x))
+VISIT_GL_CALL(
+ Uniform1iv, void, (
+ GLint location, GLsizei count, const GLint* v), (location, count, v))
+VISIT_GL_CALL(
+ Uniform2f, void, (GLint location, GLfloat x, GLfloat y), (location, x, y))
+VISIT_GL_CALL(
+ Uniform2fv, void, (
+ GLint location, GLsizei count, const GLfloat* v), (location, count, v))
+VISIT_GL_CALL(
+ Uniform2i, void, (GLint location, GLint x, GLint y), (location, x, y))
+VISIT_GL_CALL(
+ Uniform2iv, void, (
+ GLint location, GLsizei count, const GLint* v), (location, count, v))
+VISIT_GL_CALL(
+ Uniform3f, void, (
+ GLint location, GLfloat x, GLfloat y, GLfloat z), (location, x, y, z))
+VISIT_GL_CALL(
+ Uniform3fv, void, (
+ GLint location, GLsizei count, const GLfloat* v), (location, count, v))
+VISIT_GL_CALL(
+ Uniform3i, void, (
+ GLint location, GLint x, GLint y, GLint z), (location, x, y, z))
+VISIT_GL_CALL(
+ Uniform3iv, void, (
+ GLint location, GLsizei count, const GLint* v), (location, count, v))
+VISIT_GL_CALL(
+ Uniform4f, void, (
+ GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w), (
+ location, x, y, z, w))
+VISIT_GL_CALL(
+ Uniform4fv, void, (
+ GLint location, GLsizei count, const GLfloat* v), (location, count, v))
+VISIT_GL_CALL(
+ Uniform4i, void, (
+ GLint location, GLint x, GLint y, GLint z, GLint w), (
+ location, x, y, z, w))
+VISIT_GL_CALL(
+ Uniform4iv, void, (
+ GLint location, GLsizei count, const GLint* v), (location, count, v))
+VISIT_GL_CALL(
+ UniformMatrix2fv, void, (
+ GLint location, GLsizei count, GLboolean transpose,
+ const GLfloat* value), (location, count, transpose, value))
+VISIT_GL_CALL(
+ UniformMatrix3fv, void, (
+ GLint location, GLsizei count, GLboolean transpose,
+ const GLfloat* value), (location, count, transpose, value))
+VISIT_GL_CALL(
+ UniformMatrix4fv, void, (
+ GLint location, GLsizei count, GLboolean transpose,
+ const GLfloat* value), (location, count, transpose, value))
+VISIT_GL_CALL(UseProgram, void, (GLuint program), (program))
+VISIT_GL_CALL(ValidateProgram, void, (GLuint program), (program))
+VISIT_GL_CALL(VertexAttrib1f, void, (GLuint indx, GLfloat x), (indx, x))
+VISIT_GL_CALL(
+ VertexAttrib1fv, void, (
+ GLuint indx, const GLfloat* values), (indx, values))
+VISIT_GL_CALL(
+ VertexAttrib2f, void, (GLuint indx, GLfloat x, GLfloat y), (indx, x, y))
+VISIT_GL_CALL(
+ VertexAttrib2fv, void, (
+ GLuint indx, const GLfloat* values), (indx, values))
+VISIT_GL_CALL(
+ VertexAttrib3f, void, (
+ GLuint indx, GLfloat x, GLfloat y, GLfloat z), (indx, x, y, z))
+VISIT_GL_CALL(
+ VertexAttrib3fv, void, (
+ GLuint indx, const GLfloat* values), (indx, values))
+VISIT_GL_CALL(
+ VertexAttrib4f, void, (
+ GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w), (
+ indx, x, y, z, w))
+VISIT_GL_CALL(
+ VertexAttrib4fv, void, (
+ GLuint indx, const GLfloat* values), (indx, values))
+VISIT_GL_CALL(
+ VertexAttribPointer, void, (
+ GLuint indx, GLint size, GLenum type, GLboolean normalized,
+ GLsizei stride, const void* ptr), (
+ indx, size, type, normalized, stride, ptr))
+VISIT_GL_CALL(
+ Viewport, void, (
+ GLint x, GLint y, GLsizei width, GLsizei height), (
+ x, y, width, height))
diff --git a/mojo/public/gles2/gles2_export.h b/mojo/public/gles2/gles2_export.h
new file mode 100644
index 0000000..0af46ed
--- /dev/null
+++ b/mojo/public/gles2/gles2_export.h
@@ -0,0 +1,26 @@
+// Copyright 2014 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 MOJO_PUBLIC_GLES2_GLES2_EXPORT_H_
+#define MOJO_PUBLIC_GLES2_GLES2_EXPORT_H_
+
+#if defined(WIN32)
+
+#if defined(MOJO_GLES2_IMPLEMENTATION)
+#define MOJO_GLES2_EXPORT __declspec(dllexport)
+#else
+#define MOJO_GLES2_EXPORT __declspec(dllimport)
+#endif
+
+#else // !defined(WIN32)
+
+#if defined(MOJO_GLES2_IMPLEMENTATION)
+#define MOJO_GLES2_EXPORT __attribute__((visibility("default")))
+#else
+#define MOJO_GLES2_EXPORT
+#endif
+
+#endif // defined(WIN32)
+
+#endif // MOJO_PUBLIC_GLES2_GLES2_EXPORT_H_
diff --git a/mojo/public/gles2/gles2_interface.h b/mojo/public/gles2/gles2_interface.h
new file mode 100644
index 0000000..78845ae229
--- /dev/null
+++ b/mojo/public/gles2/gles2_interface.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2014 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 MOJO_PUBLIC_GLES2_GLES2_INTERFACE_H_
+#define MOJO_PUBLIC_GLES2_GLES2_INTERFACE_H_
+
+#include <GLES2/gl2.h>
+
+namespace mojo {
+
+class GLES2Interface {
+ public:
+ virtual ~GLES2Interface() {}
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ virtual ReturnType Function PARAMETERS = 0;
+#include "mojo/public/gles2/gles2_call_visitor_autogen.h"
+#undef VISIT_GL_CALL
+};
+
+} // namespace mojo
+
+#endif // MOJO_PUBLIC_GLES2_GLES2_INTERFACE_H_
diff --git a/mojo/public/gles2/gles2_private.cc b/mojo/public/gles2/gles2_private.cc
new file mode 100644
index 0000000..ca873c8
--- /dev/null
+++ b/mojo/public/gles2/gles2_private.cc
@@ -0,0 +1,57 @@
+// Copyright 2014 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 "mojo/public/gles2/gles2_private.h"
+
+#include <assert.h>
+#include <stddef.h>
+
+#include "mojo/public/gles2/gles2.h"
+#include "mojo/public/gles2/gles2_interface.h"
+
+static mojo::GLES2Support* g_gles2_support = NULL;
+static mojo::GLES2Interface* g_gles2_interface = NULL;
+
+extern "C" {
+
+void MojoGLES2Initialize() {
+ assert(g_gles2_support);
+ return g_gles2_support->Initialize();
+}
+
+void MojoGLES2Terminate() {
+ assert(g_gles2_support);
+ return g_gles2_support->Terminate();
+}
+
+void MojoGLES2MakeCurrent(uint64_t encoded) {
+ assert(g_gles2_support);
+ g_gles2_support->MakeCurrent(encoded);
+ g_gles2_interface = g_gles2_support->GetGLES2InterfaceForCurrentContext();
+}
+
+void MojoGLES2SwapBuffers() {
+ assert(g_gles2_support);
+ return g_gles2_support->SwapBuffers();
+}
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ ReturnType gl##Function PARAMETERS { \
+ return g_gles2_interface->Function ARGUMENTS; \
+ }
+#include "mojo/public/gles2/gles2_call_visitor_autogen.h"
+#undef VISIT_GL_CALL
+
+} // extern "C"
+
+namespace mojo {
+
+GLES2Support::~GLES2Support() {}
+
+void GLES2Support::Init(GLES2Support* gles2_support) {
+ assert(!g_gles2_support);
+ g_gles2_support = gles2_support;
+}
+
+} // namespace mojo
diff --git a/mojo/public/gles2/gles2_private.h b/mojo/public/gles2/gles2_private.h
new file mode 100644
index 0000000..f50f41d
--- /dev/null
+++ b/mojo/public/gles2/gles2_private.h
@@ -0,0 +1,33 @@
+// Copyright 2014 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 MOJO_PUBLIC_GLES2_GLES2_PRIVATE_H_
+#define MOJO_PUBLIC_GLES2_GLES2_PRIVATE_H_
+
+#include <stdint.h>
+
+#include "mojo/public/gles2/gles2_export.h"
+
+namespace mojo {
+class GLES2Interface;
+
+// Implementors of the GLES2 APIs can use this interface to install their
+// implementation into the mojo_gles2 dynamic library. Mojo clients should not
+// call these functions directly.
+class MOJO_GLES2_EXPORT GLES2Support {
+ public:
+ virtual ~GLES2Support();
+
+ static void Init(GLES2Support* gles2_support);
+
+ virtual void Initialize() = 0;
+ virtual void Terminate() = 0;
+ virtual void MakeCurrent(uint64_t encoded) = 0;
+ virtual void SwapBuffers() = 0;
+ virtual GLES2Interface* GetGLES2InterfaceForCurrentContext() = 0;
+};
+
+} // namespace mojo
+
+#endif // MOJO_PUBLIC_GLES2_GLES2_PRIVATE_H_
diff --git a/mojo/shell/context.cc b/mojo/shell/context.cc
index c9b664c..4b044fc 100644
--- a/mojo/shell/context.cc
+++ b/mojo/shell/context.cc
@@ -4,6 +4,7 @@
#include "mojo/shell/context.h"
+#include "mojo/gles2/gles2_support_impl.h"
#include "mojo/shell/dynamic_service_loader.h"
#include "mojo/shell/network_delegate.h"
#include "mojo/system/embedder/embedder.h"
@@ -20,6 +21,7 @@ Context::Context()
scoped_ptr<net::NetworkDelegate>(new NetworkDelegate()),
storage_.profile_path()) {
embedder::Init();
+ gles2::GLES2SupportImpl::Init();
dynamic_service_loader_.reset(new DynamicServiceLoader(this));
service_manager_.set_default_loader(dynamic_service_loader_.get());
}