Commit 7e2975ae authored by jamesr@chromium.org's avatar jamesr@chromium.org

Expose CHROMIUM_texture_mailbox/sync_point stubs in mojo public headers

BUG=
R=piman@chromium.org

Review URL: https://codereview.chromium.org/453163002

Cr-Commit-Position: refs/heads/master@{#289367}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289367 0039d316-1c4b-4281-b951-d872f2087c98
parent 2e0f267a
......@@ -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",
......
include_rules = [
"+gpu/command_buffer/client",
"+gpu/command_buffer/common",
"+gpu/GLES2",
]
......@@ -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"
# 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': [
{
......
......@@ -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': {
......
......@@ -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',
],
},
{
......
// 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_
// 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_
// 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))
// 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))
// 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"
// 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_
// 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"
// 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_
// 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"
// 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_
......@@ -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"
......@@ -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_
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment