summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-13 20:37:48 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-13 20:37:48 +0000
commitf61a49a05e4097e2503caae5e28116eb1dd0a42b (patch)
treeefe7153050c4336b54377f7c7b889ef0b6ddf811
parentb7939ab76ec63457d2bb066d4abc6d702f9cb101 (diff)
downloadchromium_src-f61a49a05e4097e2503caae5e28116eb1dd0a42b.zip
chromium_src-f61a49a05e4097e2503caae5e28116eb1dd0a42b.tar.gz
chromium_src-f61a49a05e4097e2503caae5e28116eb1dd0a42b.tar.bz2
Expose CHROMIUM_texture_mailbox/sync_point stubs in mojo public headers
BUG= R=piman@chromium.org Review URL: https://codereview.chromium.org/453163002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289367 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py45
-rw-r--r--mojo/gles2/DEPS1
-rw-r--r--mojo/gles2/gles2_impl.cc3
-rw-r--r--mojo/mojo_apps.gypi4
-rw-r--r--mojo/mojo_base.gyp5
-rw-r--r--mojo/mojo_public.gypi6
-rw-r--r--mojo/public/c/gles2/chromium_sync_point.h30
-rw-r--r--mojo/public/c/gles2/chromium_texture_mailbox.h30
-rw-r--r--mojo/public/c/gles2/gles2_call_visitor_chromium_sync_point_autogen.h12
-rw-r--r--mojo/public/c/gles2/gles2_call_visitor_chromium_texture_mailbox_autogen.h27
-rw-r--r--mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.cc32
-rw-r--r--mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h44
-rw-r--r--mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.cc33
-rw-r--r--mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.h45
-rw-r--r--mojo/public/platform/native/gles2_impl_thunks.cc29
-rw-r--r--mojo/public/platform/native/gles2_impl_thunks.h49
-rw-r--r--mojo/public/platform/native/gles2_thunks.cc16
-rw-r--r--mojo/public/platform/native/gles2_thunks.h40
-rw-r--r--mojo/shell/in_process_dynamic_service_runner.cc86
19 files changed, 426 insertions, 111 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 1216a7f..ca63b94 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -1382,7 +1382,7 @@ _FUNCTION_INFO = {
'count': 64, # GL_MAILBOX_SIZE_CHROMIUM
'unit_test': False,
'client_test': False,
- 'extension': True,
+ 'extension': "CHROMIUM_texture_mailbox",
'chromium': True,
'trace_level': 1,
},
@@ -1393,7 +1393,7 @@ _FUNCTION_INFO = {
'data_transfer_methods': ['immediate'],
'unit_test': False,
'client_test': False,
- 'extension': True,
+ 'extension': "CHROMIUM_texture_mailbox",
'chromium': True,
},
'ClearStencil': {
@@ -1648,7 +1648,7 @@ _FUNCTION_INFO = {
'GenMailboxCHROMIUM': {
'type': 'HandWritten',
'impl_func': False,
- 'extension': True,
+ 'extension': "CHROMIUM_texture_mailbox",
'chromium': True,
},
'GenFramebuffers': {
@@ -1976,7 +1976,7 @@ _FUNCTION_INFO = {
'count': 64, # GL_MAILBOX_SIZE_CHROMIUM
'unit_test': False,
'client_test': False,
- 'extension': True,
+ 'extension': "CHROMIUM_texture_mailbox",
'chromium': True,
'trace_level': 1,
},
@@ -1987,7 +1987,7 @@ _FUNCTION_INFO = {
'count': 64, # GL_MAILBOX_SIZE_CHROMIUM
'unit_test': False,
'client_test': False,
- 'extension': True,
+ 'extension': "CHROMIUM_texture_mailbox",
'chromium': True,
'trace_level': 1,
},
@@ -2559,13 +2559,13 @@ _FUNCTION_INFO = {
'InsertSyncPointCHROMIUM': {
'type': 'HandWritten',
'impl_func': False,
- 'extension': True,
+ 'extension': "CHROMIUM_sync_point",
'chromium': True,
},
'WaitSyncPointCHROMIUM': {
'type': 'Custom',
'impl_func': True,
- 'extension': True,
+ 'extension': "CHROMIUM_sync_point",
'chromium': True,
'trace_level': 1,
},
@@ -8225,6 +8225,22 @@ const size_t GLES2Util::enum_to_string_table_len_ =
file.Close()
+ def WriteMojoGLCallVisitorForExtension(self, filename, extension):
+ """Provides the GL implementation for mojo for a particular extension"""
+ file = CWriter(filename)
+ file.Write(_LICENSE)
+ file.Write(_DO_NOT_EDIT_WARNING)
+
+ for func in self.original_functions:
+ if func.GetInfo("extension") != extension:
+ continue
+ file.Write("VISIT_GL_CALL(%s, %s, (%s), (%s))\n" %
+ (func.name, func.return_type,
+ func.MakeTypedOriginalArgString(""),
+ func.MakeOriginalArgString("")))
+
+ file.Close()
+
def Format(generated_files):
for filename in generated_files:
call(["clang-format", "-i", "-style=chromium", filename])
@@ -8306,8 +8322,14 @@ def main(argv):
gen.WriteCommonUtilsHeader("common/gles2_cmd_utils_autogen.h")
gen.WriteCommonUtilsImpl("common/gles2_cmd_utils_implementation_autogen.h")
gen.WriteGLES2Header("../GLES2/gl2chromium_autogen.h")
- gen.WriteMojoGLCallVisitor(
- "../../mojo/public/c/gles2/gles2_call_visitor_autogen.h")
+ mojo_gles2_prefix = "../../mojo/public/c/gles2/gles2_call_visitor"
+ gen.WriteMojoGLCallVisitor(mojo_gles2_prefix + "_autogen.h")
+ gen.WriteMojoGLCallVisitorForExtension(
+ mojo_gles2_prefix + "_chromium_texture_mailbox_autogen.h",
+ "CHROMIUM_texture_mailbox")
+ gen.WriteMojoGLCallVisitorForExtension(
+ mojo_gles2_prefix + "_chromium_sync_point_autogen.h",
+ "CHROMIUM_sync_point")
Format([
"common/gles2_cmd_format_autogen.h",
@@ -8337,9 +8359,12 @@ def main(argv):
"service/gles2_cmd_validation_autogen.h",
"service/gles2_cmd_validation_implementation_autogen.h"])
os.chdir("../..")
+ mojo_gles2_prefix = "mojo/public/c/gles2/gles2_call_visitor"
Format([
"gpu/GLES2/gl2chromium_autogen.h",
- "mojo/public/c/gles2/gles2_call_visitor_autogen.h",
+ mojo_gles2_prefix + "_autogen.h",
+ mojo_gles2_prefix + "_chromium_texture_mailbox_autogen.h",
+ mojo_gles2_prefix + "_chromium_sync_point_autogen.h",
"ppapi/c/dev/ppb_opengles2ext_dev.h",
"ppapi/c/ppb_opengles2.h",
"ppapi/lib/gl/gles2/gles2.c",
diff --git a/mojo/gles2/DEPS b/mojo/gles2/DEPS
index a0e373e..db90643 100644
--- a/mojo/gles2/DEPS
+++ b/mojo/gles2/DEPS
@@ -1,4 +1,5 @@
include_rules = [
"+gpu/command_buffer/client",
"+gpu/command_buffer/common",
+ "+gpu/GLES2",
]
diff --git a/mojo/gles2/gles2_impl.cc b/mojo/gles2/gles2_impl.cc
index a77405f..3d46ecd 100644
--- a/mojo/gles2/gles2_impl.cc
+++ b/mojo/gles2/gles2_impl.cc
@@ -6,6 +6,7 @@
#include "base/lazy_instance.h"
#include "base/threading/thread_local.h"
+#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "mojo/gles2/gles2_context.h"
@@ -65,6 +66,8 @@ void* MojoGLES2GetContextSupport(MojoGLES2Context context) {
return g_gpu_interface.Get().Get()->Function ARGUMENTS; \
}
#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h"
+#include "mojo/public/c/gles2/gles2_call_visitor_chromium_sync_point_autogen.h"
+#include "mojo/public/c/gles2/gles2_call_visitor_chromium_texture_mailbox_autogen.h"
#undef VISIT_GL_CALL
} // extern "C"
diff --git a/mojo/mojo_apps.gypi b/mojo/mojo_apps.gypi
index 7d96a23..fda9084 100644
--- a/mojo/mojo_apps.gypi
+++ b/mojo/mojo_apps.gypi
@@ -1,3 +1,7 @@
+# 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.
+
{
'targets': [
{
diff --git a/mojo/mojo_base.gyp b/mojo/mojo_base.gyp
index 192c4d7..70b6310 100644
--- a/mojo/mojo_base.gyp
+++ b/mojo/mojo_base.gyp
@@ -379,9 +379,10 @@
'<(mojo_system_for_component)',
],
'defines': [
- 'MOJO_GLES2_IMPL_IMPLEMENTATION',
- 'MOJO_GLES2_IMPLEMENTATION',
'GLES2_USE_MOJO',
+ 'GL_GLEXT_PROTOTYPES',
+ 'MOJO_GLES2_IMPLEMENTATION',
+ 'MOJO_GLES2_IMPL_IMPLEMENTATION',
'MOJO_USE_GLES2_IMPL'
],
'direct_dependent_settings': {
diff --git a/mojo/mojo_public.gypi b/mojo/mojo_public.gypi
index f1c7ede..0c94c6a 100644
--- a/mojo/mojo_public.gypi
+++ b/mojo/mojo_public.gypi
@@ -81,6 +81,12 @@
'public/c/gles2/gles2_export.h',
'public/platform/native/gles2_thunks.cc',
'public/platform/native/gles2_thunks.h',
+ 'public/platform/native/gles2_impl_thunks.cc',
+ 'public/platform/native/gles2_impl_thunks.h',
+ 'public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.cc',
+ 'public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.h',
+ 'public/platform/native/gles2_impl_chromium_sync_point_thunks.cc',
+ 'public/platform/native/gles2_impl_chromium_sync_point_thunks.h',
],
},
{
diff --git a/mojo/public/c/gles2/chromium_sync_point.h b/mojo/public/c/gles2/chromium_sync_point.h
new file mode 100644
index 0000000..6369712
--- /dev/null
+++ b/mojo/public/c/gles2/chromium_sync_point.h
@@ -0,0 +1,30 @@
+// 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_C_GLES2_CHROMIUM_SYNC_POINT_H_
+#define MOJO_PUBLIC_C_GLES2_CHROMIUM_SYNC_POINT_H_
+
+// Note: This header should be compilable as C.
+
+#include <stdint.h>
+#include <GLES2/gl2.h>
+
+#include "mojo/public/c/gles2/gles2_export.h"
+#include "mojo/public/c/gles2/gles2_types.h"
+#include "mojo/public/c/system/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ MOJO_GLES2_EXPORT ReturnType GL_APIENTRY gl##Function PARAMETERS;
+#include "mojo/public/c/gles2/gles2_call_visitor_chromium_sync_point_autogen.h"
+#undef VISIT_GL_CALL
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // MOJO_PUBLIC_C_GLES2_CHROMIUM_SYNC_POINT_H_
diff --git a/mojo/public/c/gles2/chromium_texture_mailbox.h b/mojo/public/c/gles2/chromium_texture_mailbox.h
new file mode 100644
index 0000000..177ebbb
--- /dev/null
+++ b/mojo/public/c/gles2/chromium_texture_mailbox.h
@@ -0,0 +1,30 @@
+// 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_C_GLES2_CHROMIUM_TEXTURE_MAILBOX_H_
+#define MOJO_PUBLIC_C_GLES2_CHROMIUM_TEXTURE_MAILBOX_H_
+
+// Note: This header should be compilable as C.
+
+#include <stdint.h>
+#include <GLES2/gl2.h>
+
+#include "mojo/public/c/gles2/gles2_export.h"
+#include "mojo/public/c/gles2/gles2_types.h"
+#include "mojo/public/c/system/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ MOJO_GLES2_EXPORT ReturnType GL_APIENTRY gl##Function PARAMETERS;
+#include "mojo/public/c/gles2/gles2_call_visitor_chromium_texture_mailbox_autogen.h"
+#undef VISIT_GL_CALL
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // MOJO_PUBLIC_C_GLES2_CHROMIUM_TEXTURE_MAILBOX_H_
diff --git a/mojo/public/c/gles2/gles2_call_visitor_chromium_sync_point_autogen.h b/mojo/public/c/gles2/gles2_call_visitor_chromium_sync_point_autogen.h
new file mode 100644
index 0000000..3c3c4b9
--- /dev/null
+++ b/mojo/public/c/gles2/gles2_call_visitor_chromium_sync_point_autogen.h
@@ -0,0 +1,12 @@
+// 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.
+
+// This file is auto-generated from
+// gpu/command_buffer/build_gles2_cmd_buffer.py
+// It's formatted by clang-format using chromium coding style:
+// clang-format -i -style=chromium filename
+// DO NOT EDIT!
+
+VISIT_GL_CALL(InsertSyncPointCHROMIUM, GLuint, (), ())
+VISIT_GL_CALL(WaitSyncPointCHROMIUM, void, (GLuint sync_point), (sync_point))
diff --git a/mojo/public/c/gles2/gles2_call_visitor_chromium_texture_mailbox_autogen.h b/mojo/public/c/gles2/gles2_call_visitor_chromium_texture_mailbox_autogen.h
new file mode 100644
index 0000000..184c2f2
--- /dev/null
+++ b/mojo/public/c/gles2/gles2_call_visitor_chromium_texture_mailbox_autogen.h
@@ -0,0 +1,27 @@
+// 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.
+
+// This file is auto-generated from
+// gpu/command_buffer/build_gles2_cmd_buffer.py
+// It's formatted by clang-format using chromium coding style:
+// clang-format -i -style=chromium filename
+// DO NOT EDIT!
+
+VISIT_GL_CALL(GenMailboxCHROMIUM, void, (GLbyte * mailbox), (mailbox))
+VISIT_GL_CALL(ProduceTextureCHROMIUM,
+ void,
+ (GLenum target, const GLbyte* mailbox),
+ (target, mailbox))
+VISIT_GL_CALL(ProduceTextureDirectCHROMIUM,
+ void,
+ (GLuint texture, GLenum target, const GLbyte* mailbox),
+ (texture, target, mailbox))
+VISIT_GL_CALL(ConsumeTextureCHROMIUM,
+ void,
+ (GLenum target, const GLbyte* mailbox),
+ (target, mailbox))
+VISIT_GL_CALL(CreateAndConsumeTextureCHROMIUM,
+ GLuint,
+ (GLenum target, const GLbyte* mailbox),
+ (target, mailbox))
diff --git a/mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.cc b/mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.cc
new file mode 100644
index 0000000..0a47f33
--- /dev/null
+++ b/mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.cc
@@ -0,0 +1,32 @@
+// 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/platform/native/gles2_impl_chromium_sync_point_thunks.h"
+
+#include <assert.h>
+
+#include "mojo/public/platform/native/thunk_export.h"
+
+extern "C" {
+static MojoGLES2ImplChromiumSyncPointThunks g_impl_chromium_sync_point_thunks =
+ {0};
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ ReturnType gl##Function PARAMETERS { \
+ assert(g_impl_chromium_sync_point_thunks.Function); \
+ return g_impl_chromium_sync_point_thunks.Function ARGUMENTS; \
+ }
+#include "mojo/public/c/gles2/gles2_call_visitor_chromium_sync_point_autogen.h"
+#undef VISIT_GL_CALL
+
+extern "C" THUNK_EXPORT size_t MojoSetGLES2ImplChromiumSyncPointThunks(
+ const MojoGLES2ImplChromiumSyncPointThunks*
+ gles2_impl_chromium_sync_point_thunks) {
+ if (gles2_impl_chromium_sync_point_thunks->size >=
+ sizeof(g_impl_chromium_sync_point_thunks))
+ g_impl_chromium_sync_point_thunks = *gles2_impl_chromium_sync_point_thunks;
+ return sizeof(g_impl_chromium_sync_point_thunks);
+}
+
+} // extern "C"
diff --git a/mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h b/mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h
new file mode 100644
index 0000000..af6817e
--- /dev/null
+++ b/mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h
@@ -0,0 +1,44 @@
+// 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_PLATFORM_NATIVE_GLES2_IMPL_CHROMIUM_SYNC_POINT_THUNKS_H_
+#define MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_IMPL_CHROMIUM_SYNC_POINT_THUNKS_H_
+
+#include <stddef.h>
+
+#include "mojo/public/c/gles2/chromium_sync_point.h"
+
+// Specifies the frozen API for the GLES2 CHROMIUM_sync_point extension.
+#pragma pack(push, 8)
+struct MojoGLES2ImplChromiumSyncPointThunks {
+ size_t size; // Should be set to sizeof(*this).
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ ReturnType(*Function) PARAMETERS;
+#include "mojo/public/c/gles2/gles2_call_visitor_chromium_sync_point_autogen.h"
+#undef VISIT_GL_CALL
+};
+#pragma pack(pop)
+
+// Intended to be called from the embedder to get the embedder's implementation
+// of GLES2.
+inline MojoGLES2ImplChromiumSyncPointThunks
+MojoMakeGLES2ImplChromiumSyncPointThunks() {
+ MojoGLES2ImplChromiumSyncPointThunks gles2_impl_chromium_sync_point_thunks = {
+ sizeof(MojoGLES2ImplChromiumSyncPointThunks),
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) gl##Function,
+#include "mojo/public/c/gles2/gles2_call_visitor_chromium_sync_point_autogen.h"
+#undef VISIT_GL_CALL
+ };
+
+ return gles2_impl_chromium_sync_point_thunks;
+}
+
+// Use this type for the function found by dynamically discovering it in
+// a DSO linked with mojo_system.
+// The contents of |gles2_impl_chromium_sync_point_thunks| are copied.
+typedef size_t (*MojoSetGLES2ImplChromiumSyncPointThunksFn)(
+ const MojoGLES2ImplChromiumSyncPointThunks* thunks);
+
+#endif // MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_IMPL_CHROMIUM_SYNC_POINT_THUNKS_H_
diff --git a/mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.cc b/mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.cc
new file mode 100644
index 0000000..db2bc81
--- /dev/null
+++ b/mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.cc
@@ -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.
+
+#include "mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.h"
+
+#include <assert.h>
+
+#include "mojo/public/platform/native/thunk_export.h"
+
+extern "C" {
+static MojoGLES2ImplChromiumTextureMailboxThunks
+ g_impl_chromium_texture_mailbox_thunks = {0};
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ ReturnType gl##Function PARAMETERS { \
+ assert(g_impl_chromium_texture_mailbox_thunks.Function); \
+ return g_impl_chromium_texture_mailbox_thunks.Function ARGUMENTS; \
+ }
+#include "mojo/public/c/gles2/gles2_call_visitor_chromium_texture_mailbox_autogen.h"
+#undef VISIT_GL_CALL
+
+extern "C" THUNK_EXPORT size_t MojoSetGLES2ImplChromiumTextureMailboxThunks(
+ const MojoGLES2ImplChromiumTextureMailboxThunks*
+ gles2_impl_chromium_texture_mailbox_thunks) {
+ if (gles2_impl_chromium_texture_mailbox_thunks->size >=
+ sizeof(g_impl_chromium_texture_mailbox_thunks))
+ g_impl_chromium_texture_mailbox_thunks =
+ *gles2_impl_chromium_texture_mailbox_thunks;
+ return sizeof(g_impl_chromium_texture_mailbox_thunks);
+}
+
+} // extern "C"
diff --git a/mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.h b/mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.h
new file mode 100644
index 0000000..839e441
--- /dev/null
+++ b/mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.h
@@ -0,0 +1,45 @@
+// 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_PLATFORM_NATIVE_GLES2_IMPL_CHROMIUM_TEXTURE_MAILBOX_THUNKS_H_
+#define MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_IMPL_CHROMIUM_TEXTURE_MAILBOX_THUNKS_H_
+
+#include <stddef.h>
+
+#include "mojo/public/c/gles2/chromium_texture_mailbox.h"
+
+// Specifies the frozen API for the GLES2 CHROMIUM_texture_mailbox extension.
+#pragma pack(push, 8)
+struct MojoGLES2ImplChromiumTextureMailboxThunks {
+ size_t size; // Should be set to sizeof(*this).
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ ReturnType(*Function) PARAMETERS;
+#include "mojo/public/c/gles2/gles2_call_visitor_chromium_texture_mailbox_autogen.h"
+#undef VISIT_GL_CALL
+};
+#pragma pack(pop)
+
+// Intended to be called from the embedder to get the embedder's implementation
+// of GLES2.
+inline MojoGLES2ImplChromiumTextureMailboxThunks
+MojoMakeGLES2ImplChromiumTextureMailboxThunks() {
+ MojoGLES2ImplChromiumTextureMailboxThunks
+ gles2_impl_chromium_texture_mailbox_thunks = {
+ sizeof(MojoGLES2ImplChromiumTextureMailboxThunks),
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) gl##Function,
+#include "mojo/public/c/gles2/gles2_call_visitor_chromium_texture_mailbox_autogen.h"
+#undef VISIT_GL_CALL
+ };
+
+ return gles2_impl_chromium_texture_mailbox_thunks;
+}
+
+// Use this type for the function found by dynamically discovering it in
+// a DSO linked with mojo_system.
+// The contents of |gles2_impl_chromium_texture_mailbox_thunks| are copied.
+typedef size_t (*MojoSetGLES2ImplChromiumTextureMailboxThunksFn)(
+ const MojoGLES2ImplChromiumTextureMailboxThunks* thunks);
+
+#endif // MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_IMPL_CHROMIUM_TEXTURE_MAILBOX_THUNKS_H_
diff --git a/mojo/public/platform/native/gles2_impl_thunks.cc b/mojo/public/platform/native/gles2_impl_thunks.cc
new file mode 100644
index 0000000..66dbc39
--- /dev/null
+++ b/mojo/public/platform/native/gles2_impl_thunks.cc
@@ -0,0 +1,29 @@
+// 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/platform/native/gles2_impl_thunks.h"
+
+#include <assert.h>
+
+#include "mojo/public/platform/native/thunk_export.h"
+
+extern "C" {
+static MojoGLES2ImplThunks g_impl_thunks = {0};
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ ReturnType gl##Function PARAMETERS { \
+ assert(g_impl_thunks.Function); \
+ return g_impl_thunks.Function ARGUMENTS; \
+ }
+#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h"
+#undef VISIT_GL_CALL
+
+extern "C" THUNK_EXPORT size_t
+MojoSetGLES2ImplThunks(const MojoGLES2ImplThunks* gles2_impl_thunks) {
+ if (gles2_impl_thunks->size >= sizeof(g_impl_thunks))
+ g_impl_thunks = *gles2_impl_thunks;
+ return sizeof(g_impl_thunks);
+}
+
+} // extern "C"
diff --git a/mojo/public/platform/native/gles2_impl_thunks.h b/mojo/public/platform/native/gles2_impl_thunks.h
new file mode 100644
index 0000000..04174fa
--- /dev/null
+++ b/mojo/public/platform/native/gles2_impl_thunks.h
@@ -0,0 +1,49 @@
+// 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_PLATFORM_NATIVE_GLES2_IMPL_THUNKS_H_
+#define MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_IMPL_THUNKS_H_
+
+#include <stddef.h>
+
+#include "mojo/public/c/gles2/gles2.h"
+
+// Like MojoGLES2ControlThunks, but specifies the frozen GLES2 API. Separated
+// out as MojoGLES2ControlThunks may be modified and added to, but this
+// interface is frozen.
+#pragma pack(push, 8)
+struct MojoGLES2ImplThunks {
+ size_t size; // Should be set to sizeof(MojoGLES2ImplThunks).
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ ReturnType(*Function) PARAMETERS;
+#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h"
+#undef VISIT_GL_CALL
+};
+#pragma pack(pop)
+
+// Intended to be called from the embedder to get the embedder's implementation
+// of GLES2.
+inline MojoGLES2ImplThunks MojoMakeGLES2ImplThunks() {
+ MojoGLES2ImplThunks gles2_impl_thunks = {
+ sizeof(MojoGLES2ImplThunks),
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) gl##Function,
+#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h"
+#undef VISIT_GL_CALL
+ };
+
+ return gles2_impl_thunks;
+}
+
+// Use this type for the function found by dynamically discovering it in
+// a DSO linked with mojo_system. For example:
+// MojoSetGLES2ImplThunksFn mojo_set_gles2_impl_thunks_fn =
+// reinterpret_cast<MojoSetGLES2ImplThunksFn>(
+// app_library.GetFunctionPointer("MojoSetGLES2ImplThunks"));
+// The expected size of |gles2_impl_thunks| is returned.
+// The contents of |gles2_impl_thunks| are copied.
+typedef size_t (*MojoSetGLES2ImplThunksFn)(
+ const MojoGLES2ImplThunks* gles2_impl_thunks);
+
+#endif // MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_IMPL_THUNKS_H_
diff --git a/mojo/public/platform/native/gles2_thunks.cc b/mojo/public/platform/native/gles2_thunks.cc
index a8c00a1a..365fac9 100644
--- a/mojo/public/platform/native/gles2_thunks.cc
+++ b/mojo/public/platform/native/gles2_thunks.cc
@@ -11,7 +11,6 @@
extern "C" {
static MojoGLES2ControlThunks g_control_thunks = {0};
-static MojoGLES2ImplThunks g_impl_thunks = {0};
MojoGLES2Context MojoGLES2CreateContext(MojoHandle handle,
MojoGLES2ContextLost lost_callback,
@@ -47,14 +46,6 @@ void* MojoGLES2GetContextSupport(MojoGLES2Context context) {
return g_control_thunks.GLES2GetContextSupport(context);
}
-#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
- ReturnType gl##Function PARAMETERS { \
- assert(g_impl_thunks.Function); \
- return g_impl_thunks.Function ARGUMENTS; \
- }
-#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h"
-#undef VISIT_GL_CALL
-
extern "C" THUNK_EXPORT size_t MojoSetGLES2ControlThunks(
const MojoGLES2ControlThunks* gles2_control_thunks) {
if (gles2_control_thunks->size >= sizeof(g_control_thunks))
@@ -62,11 +53,4 @@ extern "C" THUNK_EXPORT size_t MojoSetGLES2ControlThunks(
return sizeof(g_control_thunks);
}
-extern "C" THUNK_EXPORT size_t MojoSetGLES2ImplThunks(
- const MojoGLES2ImplThunks* gles2_impl_thunks) {
- if (gles2_impl_thunks->size >= sizeof(g_impl_thunks))
- g_impl_thunks = *gles2_impl_thunks;
- return sizeof(g_impl_thunks);
-}
-
} // extern "C"
diff --git a/mojo/public/platform/native/gles2_thunks.h b/mojo/public/platform/native/gles2_thunks.h
index 53375e2..4718ab3 100644
--- a/mojo/public/platform/native/gles2_thunks.h
+++ b/mojo/public/platform/native/gles2_thunks.h
@@ -59,44 +59,4 @@ inline MojoGLES2ControlThunks MojoMakeGLES2ControlThunks() {
typedef size_t (*MojoSetGLES2ControlThunksFn)(
const MojoGLES2ControlThunks* gles2_control_thunks);
-// -----------------------------------------------------------------------------
-
-// Like MojoGLES2ControlThunks, but specifies the frozen GLES2 API. Separated
-// out as MojoGLES2ControlThunks may be modified and added to, but this
-// interface is frozen.
-#pragma pack(push, 8)
-struct MojoGLES2ImplThunks {
- size_t size; // Should be set to sizeof(MojoGLES2ImplThunks).
-
-#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
- ReturnType (*Function) PARAMETERS;
-#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h"
-#undef VISIT_GL_CALL
-};
-#pragma pack(pop)
-
-// Intended to be called from the embedder to get the embedder's implementation
-// of GLES2.
-inline MojoGLES2ImplThunks MojoMakeGLES2ImplThunks() {
- MojoGLES2ImplThunks gles2_impl_thunks = {
- sizeof(MojoGLES2ImplThunks),
-#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
- gl##Function,
-#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h"
-#undef VISIT_GL_CALL
- };
-
- return gles2_impl_thunks;
-}
-
-// Use this type for the function found by dynamically discovering it in
-// a DSO linked with mojo_system. For example:
-// MojoSetGLES2ImplThunksFn mojo_set_gles2_impl_thunks_fn =
-// reinterpret_cast<MojoSetGLES2ImplThunksFn>(
-// app_library.GetFunctionPointer("MojoSetGLES2ImplThunks"));
-// The expected size of |gles2_impl_thunks| is returned.
-// The contents of |gles2_impl_thunks| are copied.
-typedef size_t (*MojoSetGLES2ImplThunksFn)(
- const MojoGLES2ImplThunks* gles2_impl_thunks);
-
#endif // MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_THUNKS_H_
diff --git a/mojo/shell/in_process_dynamic_service_runner.cc b/mojo/shell/in_process_dynamic_service_runner.cc
index c243870..8b38239 100644
--- a/mojo/shell/in_process_dynamic_service_runner.cc
+++ b/mojo/shell/in_process_dynamic_service_runner.cc
@@ -9,12 +9,37 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h"
+#include "mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.h"
+#include "mojo/public/platform/native/gles2_impl_thunks.h"
#include "mojo/public/platform/native/gles2_thunks.h"
#include "mojo/public/platform/native/system_thunks.h"
namespace mojo {
namespace shell {
+namespace {
+
+template <typename Thunks>
+bool SetThunks(Thunks (*make_thunks)(),
+ const char* function_name,
+ base::ScopedNativeLibrary* library) {
+ typedef size_t (*SetThunksFn)(const Thunks* thunks);
+ SetThunksFn set_thunks =
+ reinterpret_cast<SetThunksFn>(library->GetFunctionPointer(function_name));
+ if (!set_thunks)
+ return false;
+ Thunks thunks = make_thunks();
+ size_t expected_size = set_thunks(&thunks);
+ if (expected_size > sizeof(Thunks)) {
+ LOG(ERROR) << "Invalid app library: expected " << function_name
+ << " to return thunks of size: " << expected_size;
+ return false;
+ }
+ return true;
+}
+}
+
InProcessDynamicServiceRunner::InProcessDynamicServiceRunner(
Context* context)
: keep_alive_(context) {
@@ -66,19 +91,8 @@ void InProcessDynamicServiceRunner::Run() {
break;
}
- MojoSetSystemThunksFn mojo_set_system_thunks_fn =
- reinterpret_cast<MojoSetSystemThunksFn>(app_library_.GetFunctionPointer(
- "MojoSetSystemThunks"));
- if (mojo_set_system_thunks_fn) {
- MojoSystemThunks system_thunks = MojoMakeSystemThunks();
- size_t expected_size = mojo_set_system_thunks_fn(&system_thunks);
- if (expected_size > sizeof(MojoSystemThunks)) {
- LOG(ERROR)
- << "Invalid app library: expected MojoSystemThunks size: "
- << expected_size;
- break;
- }
- } else {
+ if (!SetThunks(
+ &MojoMakeSystemThunks, "MojoSetSystemThunks", &app_library_)) {
// In the component build, Mojo Apps link against mojo_system_impl.
#if !defined(COMPONENT_BUILD)
// Strictly speaking this is not required, but it's very unusual to have
@@ -87,38 +101,14 @@ void InProcessDynamicServiceRunner::Run() {
#endif
}
- MojoSetGLES2ControlThunksFn mojo_set_gles2_control_thunks_fn =
- reinterpret_cast<MojoSetGLES2ControlThunksFn>(
- app_library_.GetFunctionPointer("MojoSetGLES2ControlThunks"));
- if (mojo_set_gles2_control_thunks_fn) {
- MojoGLES2ControlThunks gles2_control_thunks =
- MojoMakeGLES2ControlThunks();
- size_t expected_size = mojo_set_gles2_control_thunks_fn(
- &gles2_control_thunks);
- if (expected_size > sizeof(MojoGLES2ControlThunks)) {
- LOG(ERROR)
- << "Invalid app library: expected MojoGLES2ControlThunks size: "
- << expected_size;
- break;
- }
-
+ if (SetThunks(&MojoMakeGLES2ControlThunks,
+ "MojoSetGLES2ControlThunks",
+ &app_library_)) {
// If we have the control thunks, we probably also have the
// GLES2 implementation thunks.
- MojoSetGLES2ImplThunksFn mojo_set_gles2_impl_thunks_fn =
- reinterpret_cast<MojoSetGLES2ImplThunksFn>(
- app_library_.GetFunctionPointer("MojoSetGLES2ImplThunks"));
- if (mojo_set_gles2_impl_thunks_fn) {
- MojoGLES2ImplThunks gles2_impl_thunks =
- MojoMakeGLES2ImplThunks();
- size_t expected_size = mojo_set_gles2_impl_thunks_fn(
- &gles2_impl_thunks);
- if (expected_size > sizeof(MojoGLES2ImplThunks)) {
- LOG(ERROR)
- << "Invalid app library: expected MojoGLES2ImplThunks size: "
- << expected_size;
- break;
- }
- } else {
+ if (!SetThunks(&MojoMakeGLES2ImplThunks,
+ "MojoSetGLES2ImplThunks",
+ &app_library_)) {
// In the component build, Mojo Apps link against mojo_gles2_impl.
#if !defined(COMPONENT_BUILD)
// Warn on this really weird case: The library requires the GLES2
@@ -127,6 +117,16 @@ void InProcessDynamicServiceRunner::Run() {
"doesn't have MojoSetGLES2ImplThunks.";
#endif
}
+
+ // If the application is using GLES2 extension points, register those
+ // thunks. Applications may use or not use any of these, so don't warn if
+ // they are missing.
+ SetThunks(MojoMakeGLES2ImplChromiumTextureMailboxThunks,
+ "MojoSetGLES2ImplChromiumTextureMailboxThunks",
+ &app_library_);
+ SetThunks(MojoMakeGLES2ImplChromiumSyncPointThunks,
+ "MojoSetGLES2ImplChromiumSyncPointThunks",
+ &app_library_);
}
// Unlike system thunks, we don't warn on a lack of GLES2 thunks because
// not everything is a visual app.