diff options
Diffstat (limited to 'mojo/public/platform/native')
-rw-r--r-- | mojo/public/platform/native/BUILD.gn | 51 | ||||
-rw-r--r-- | mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.cc | 32 | ||||
-rw-r--r-- | mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h | 44 | ||||
-rw-r--r-- | mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.cc | 33 | ||||
-rw-r--r-- | mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.h | 45 | ||||
-rw-r--r-- | mojo/public/platform/native/gles2_impl_thunks.cc | 29 | ||||
-rw-r--r-- | mojo/public/platform/native/gles2_impl_thunks.h | 49 | ||||
-rw-r--r-- | mojo/public/platform/native/gles2_thunks.cc | 56 | ||||
-rw-r--r-- | mojo/public/platform/native/gles2_thunks.h | 62 | ||||
-rw-r--r-- | mojo/public/platform/native/system_thunks.cc | 168 | ||||
-rw-r--r-- | mojo/public/platform/native/system_thunks.h | 146 | ||||
-rw-r--r-- | mojo/public/platform/native/thunk_export.h | 18 |
12 files changed, 0 insertions, 733 deletions
diff --git a/mojo/public/platform/native/BUILD.gn b/mojo/public/platform/native/BUILD.gn deleted file mode 100644 index a369e17..0000000 --- a/mojo/public/platform/native/BUILD.gn +++ /dev/null @@ -1,51 +0,0 @@ -# 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. - -import("../../mojo_sdk.gni") - -mojo_sdk_source_set("system") { - sources = [ - "system_thunks.h", - "system_thunks.cc", - ] - defines = [ "MOJO_SYSTEM_IMPLEMENTATION" ] - mojo_sdk_deps = [ "mojo/public/c/system" ] - - # The GYP target analogous to this one builds this code into a - # static library. When building for Android, both the GYP and GN - # builds add --exclude-libs=ALL globally, which means that all - # symbols in static libraries are excluded from export. That's a - # problem, as code outside this target needs to be able to call - # MojoSetSystemThunks(). Therefore, the GYP target needs to specifiy - # that all dependent targets remove that link flag. Since GN uses a - # source_set here, this flag change is not needed. -} - -mojo_sdk_source_set("gles2") { - sources = [ - "gles2_thunks.cc", - "gles2_thunks.h", - "gles2_impl_thunks.cc", - "gles2_impl_thunks.h", - "gles2_impl_chromium_texture_mailbox_thunks.cc", - "gles2_impl_chromium_texture_mailbox_thunks.h", - "gles2_impl_chromium_sync_point_thunks.cc", - "gles2_impl_chromium_sync_point_thunks.h", - ] - - defines = [ "MOJO_GLES2_IMPLEMENTATION" ] - - configs = [ "//third_party/khronos:khronos_headers" ] - - mojo_sdk_deps = [ - "mojo/public/c/gles2:headers", - "mojo/public/c/environment", - "mojo/public/c/system", - ] - - if (is_mac) { - # TODO(GYP): Make it a run-path dependent library. - # 'DYLIB_INSTALL_NAME_BASE': '@loader_path', - } -} 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 deleted file mode 100644 index 0a47f33..0000000 --- a/mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.cc +++ /dev/null @@ -1,32 +0,0 @@ -// 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 deleted file mode 100644 index af6817e..0000000 --- a/mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h +++ /dev/null @@ -1,44 +0,0 @@ -// 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 deleted file mode 100644 index db2bc81..0000000 --- a/mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.cc +++ /dev/null @@ -1,33 +0,0 @@ -// 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 deleted file mode 100644 index 839e441..0000000 --- a/mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.h +++ /dev/null @@ -1,45 +0,0 @@ -// 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 deleted file mode 100644 index 66dbc39..0000000 --- a/mojo/public/platform/native/gles2_impl_thunks.cc +++ /dev/null @@ -1,29 +0,0 @@ -// 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 deleted file mode 100644 index 04174fa..0000000 --- a/mojo/public/platform/native/gles2_impl_thunks.h +++ /dev/null @@ -1,49 +0,0 @@ -// 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 deleted file mode 100644 index 365fac9..0000000 --- a/mojo/public/platform/native/gles2_thunks.cc +++ /dev/null @@ -1,56 +0,0 @@ -// 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_thunks.h" - -#include <assert.h> - -#include "mojo/public/platform/native/thunk_export.h" - -extern "C" { - -static MojoGLES2ControlThunks g_control_thunks = {0}; - -MojoGLES2Context MojoGLES2CreateContext(MojoHandle handle, - MojoGLES2ContextLost lost_callback, - void* closure, - const MojoAsyncWaiter* async_waiter) { - assert(g_control_thunks.GLES2CreateContext); - return g_control_thunks.GLES2CreateContext( - handle, lost_callback, closure, async_waiter); -} - -void MojoGLES2DestroyContext(MojoGLES2Context context) { - assert(g_control_thunks.GLES2DestroyContext); - g_control_thunks.GLES2DestroyContext(context); -} - -void MojoGLES2MakeCurrent(MojoGLES2Context context) { - assert(g_control_thunks.GLES2MakeCurrent); - g_control_thunks.GLES2MakeCurrent(context); -} - -void MojoGLES2SwapBuffers() { - assert(g_control_thunks.GLES2SwapBuffers); - g_control_thunks.GLES2SwapBuffers(); -} - -void* MojoGLES2GetGLES2Interface(MojoGLES2Context context) { - assert(g_control_thunks.GLES2GetGLES2Interface); - return g_control_thunks.GLES2GetGLES2Interface(context); -} - -void* MojoGLES2GetContextSupport(MojoGLES2Context context) { - assert(g_control_thunks.GLES2GetContextSupport); - return g_control_thunks.GLES2GetContextSupport(context); -} - -extern "C" THUNK_EXPORT size_t MojoSetGLES2ControlThunks( - const MojoGLES2ControlThunks* gles2_control_thunks) { - if (gles2_control_thunks->size >= sizeof(g_control_thunks)) - g_control_thunks = *gles2_control_thunks; - return sizeof(g_control_thunks); -} - -} // extern "C" diff --git a/mojo/public/platform/native/gles2_thunks.h b/mojo/public/platform/native/gles2_thunks.h deleted file mode 100644 index 4718ab3..0000000 --- a/mojo/public/platform/native/gles2_thunks.h +++ /dev/null @@ -1,62 +0,0 @@ -// 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_THUNKS_H_ -#define MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_THUNKS_H_ - -#include <stddef.h> - -#include "mojo/public/c/gles2/gles2.h" - -// Structure used to bind the interface which manipulates GLES2 surfaces to a -// DSO to theose of the embedder. -// -// This is the ABI between the embedder and the DSO. It can only have new -// functions added to the end. No other changes are supported. -#pragma pack(push, 8) -struct MojoGLES2ControlThunks { - size_t size; // Should be set to sizeof(MojoGLES2ControlThunks). - - MojoGLES2Context (*GLES2CreateContext)(MojoHandle handle, - MojoGLES2ContextLost lost_callback, - void* closure, - const MojoAsyncWaiter* async_waiter); - void (*GLES2DestroyContext)(MojoGLES2Context context); - void (*GLES2MakeCurrent)(MojoGLES2Context context); - void (*GLES2SwapBuffers)(); - - // TODO(piman): We shouldn't have to leak these 2 interfaces, especially in a - // type-unsafe way. - void* (*GLES2GetGLES2Interface)(MojoGLES2Context context); - void* (*GLES2GetContextSupport)(MojoGLES2Context context); -}; -#pragma pack(pop) - -// Intended to be called from the embedder. Returns an object initialized to -// contain pointers to each of the embedder's MojoGLES2ControlThunks functions. -inline MojoGLES2ControlThunks MojoMakeGLES2ControlThunks() { - MojoGLES2ControlThunks gles2_control_thunks = { - sizeof(MojoGLES2ControlThunks), - MojoGLES2CreateContext, - MojoGLES2DestroyContext, - MojoGLES2MakeCurrent, - MojoGLES2SwapBuffers, - MojoGLES2GetGLES2Interface, - MojoGLES2GetContextSupport - }; - - return gles2_control_thunks; -} - -// Use this type for the function found by dynamically discovering it in -// a DSO linked with mojo_system. For example: -// MojoSetGLES2ControlThunksFn mojo_set_gles2_control_thunks_fn = -// reinterpret_cast<MojoSetGLES2ControlThunksFn>( -// app_library.GetFunctionPointer("MojoSetGLES2ControlThunks")); -// The expected size of |gles2_control_thunks| is returned. -// The contents of |gles2_control_thunks| are copied. -typedef size_t (*MojoSetGLES2ControlThunksFn)( - const MojoGLES2ControlThunks* gles2_control_thunks); - -#endif // MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_THUNKS_H_ diff --git a/mojo/public/platform/native/system_thunks.cc b/mojo/public/platform/native/system_thunks.cc deleted file mode 100644 index ed3227f..0000000 --- a/mojo/public/platform/native/system_thunks.cc +++ /dev/null @@ -1,168 +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/platform/native/system_thunks.h" - -#include <assert.h> - -#include "mojo/public/platform/native/thunk_export.h" - -extern "C" { - -static MojoSystemThunks g_thunks = {0}; - -MojoTimeTicks MojoGetTimeTicksNow() { - assert(g_thunks.GetTimeTicksNow); - return g_thunks.GetTimeTicksNow(); -} - -MojoResult MojoClose(MojoHandle handle) { - assert(g_thunks.Close); - return g_thunks.Close(handle); -} - -MojoResult MojoWait(MojoHandle handle, - MojoHandleSignals signals, - MojoDeadline deadline, - struct MojoHandleSignalsState* signals_state) { - assert(g_thunks.Wait); - return g_thunks.Wait(handle, signals, deadline, signals_state); -} - -MojoResult MojoWaitMany(const MojoHandle* handles, - const MojoHandleSignals* signals, - uint32_t num_handles, - MojoDeadline deadline, - uint32_t* result_index, - struct MojoHandleSignalsState* signals_states) { - assert(g_thunks.WaitMany); - return g_thunks.WaitMany(handles, signals, num_handles, deadline, - result_index, signals_states); -} - -MojoResult MojoCreateMessagePipe(const MojoCreateMessagePipeOptions* options, - MojoHandle* message_pipe_handle0, - MojoHandle* message_pipe_handle1) { - assert(g_thunks.CreateMessagePipe); - return g_thunks.CreateMessagePipe(options, message_pipe_handle0, - message_pipe_handle1); -} - -MojoResult MojoWriteMessage(MojoHandle message_pipe_handle, - const void* bytes, - uint32_t num_bytes, - const MojoHandle* handles, - uint32_t num_handles, - MojoWriteMessageFlags flags) { - assert(g_thunks.WriteMessage); - return g_thunks.WriteMessage(message_pipe_handle, bytes, num_bytes, handles, - num_handles, flags); -} - -MojoResult MojoReadMessage(MojoHandle message_pipe_handle, - void* bytes, - uint32_t* num_bytes, - MojoHandle* handles, - uint32_t* num_handles, - MojoReadMessageFlags flags) { - assert(g_thunks.ReadMessage); - return g_thunks.ReadMessage(message_pipe_handle, bytes, num_bytes, handles, - num_handles, flags); -} - -MojoResult MojoCreateDataPipe(const MojoCreateDataPipeOptions* options, - MojoHandle* data_pipe_producer_handle, - MojoHandle* data_pipe_consumer_handle) { - assert(g_thunks.CreateDataPipe); - return g_thunks.CreateDataPipe(options, data_pipe_producer_handle, - data_pipe_consumer_handle); -} - -MojoResult MojoWriteData(MojoHandle data_pipe_producer_handle, - const void* elements, - uint32_t* num_elements, - MojoWriteDataFlags flags) { - assert(g_thunks.WriteData); - return g_thunks.WriteData(data_pipe_producer_handle, elements, num_elements, - flags); -} - -MojoResult MojoBeginWriteData(MojoHandle data_pipe_producer_handle, - void** buffer, - uint32_t* buffer_num_elements, - MojoWriteDataFlags flags) { - assert(g_thunks.BeginWriteData); - return g_thunks.BeginWriteData(data_pipe_producer_handle, buffer, - buffer_num_elements, flags); -} - -MojoResult MojoEndWriteData(MojoHandle data_pipe_producer_handle, - uint32_t num_elements_written) { - assert(g_thunks.EndWriteData); - return g_thunks.EndWriteData(data_pipe_producer_handle, num_elements_written); -} - -MojoResult MojoReadData(MojoHandle data_pipe_consumer_handle, - void* elements, - uint32_t* num_elements, - MojoReadDataFlags flags) { - assert(g_thunks.ReadData); - return g_thunks.ReadData(data_pipe_consumer_handle, elements, num_elements, - flags); -} - -MojoResult MojoBeginReadData(MojoHandle data_pipe_consumer_handle, - const void** buffer, - uint32_t* buffer_num_elements, - MojoReadDataFlags flags) { - assert(g_thunks.BeginReadData); - return g_thunks.BeginReadData(data_pipe_consumer_handle, buffer, - buffer_num_elements, flags); -} - -MojoResult MojoEndReadData(MojoHandle data_pipe_consumer_handle, - uint32_t num_elements_read) { - assert(g_thunks.EndReadData); - return g_thunks.EndReadData(data_pipe_consumer_handle, num_elements_read); -} - -MojoResult MojoCreateSharedBuffer( - const struct MojoCreateSharedBufferOptions* options, - uint64_t num_bytes, - MojoHandle* shared_buffer_handle) { - assert(g_thunks.CreateSharedBuffer); - return g_thunks.CreateSharedBuffer(options, num_bytes, shared_buffer_handle); -} - -MojoResult MojoDuplicateBufferHandle( - MojoHandle buffer_handle, - const struct MojoDuplicateBufferHandleOptions* options, - MojoHandle* new_buffer_handle) { - assert(g_thunks.DuplicateBufferHandle); - return g_thunks.DuplicateBufferHandle(buffer_handle, options, - new_buffer_handle); -} - -MojoResult MojoMapBuffer(MojoHandle buffer_handle, - uint64_t offset, - uint64_t num_bytes, - void** buffer, - MojoMapBufferFlags flags) { - assert(g_thunks.MapBuffer); - return g_thunks.MapBuffer(buffer_handle, offset, num_bytes, buffer, flags); -} - -MojoResult MojoUnmapBuffer(void* buffer) { - assert(g_thunks.UnmapBuffer); - return g_thunks.UnmapBuffer(buffer); -} - -extern "C" THUNK_EXPORT size_t MojoSetSystemThunks( - const MojoSystemThunks* system_thunks) { - if (system_thunks->size >= sizeof(g_thunks)) - g_thunks = *system_thunks; - return sizeof(g_thunks); -} - -} // extern "C" diff --git a/mojo/public/platform/native/system_thunks.h b/mojo/public/platform/native/system_thunks.h deleted file mode 100644 index bb6ca96..0000000 --- a/mojo/public/platform/native/system_thunks.h +++ /dev/null @@ -1,146 +0,0 @@ -// 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. - -// Note: This header should be compilable as C. - -#ifndef MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_ -#define MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_ - -#include <stddef.h> - -#include "mojo/public/c/system/core.h" - -// The embedder needs to bind the basic Mojo Core functions of a DSO to those of -// the embedder when loading a DSO that is dependent on mojo_system. -// The typical usage would look like: -// base::ScopedNativeLibrary app_library( -// base::LoadNativeLibrary(app_path_, &error)); -// typedef MojoResult (*MojoSetSystemThunksFn)(MojoSystemThunks*); -// MojoSetSystemThunksFn mojo_set_system_thunks_fn = -// reinterpret_cast<MojoSetSystemThunksFn>(app_library.GetFunctionPointer( -// "MojoSetSystemThunks")); -// MojoSystemThunks system_thunks = MojoMakeSystemThunks(); -// size_t expected_size = mojo_set_system_thunks_fn(&system_thunks); -// if (expected_size > sizeof(MojoSystemThunks)) { -// LOG(ERROR) -// << "Invalid DSO. Expected MojoSystemThunks size: " -// << expected_size; -// break; -// } - -// Structure used to bind the basic Mojo Core functions of a DSO to those of -// the embedder. -// This is the ABI between the embedder and the DSO. It can only have new -// functions added to the end. No other changes are supported. -#pragma pack(push, 8) -struct MojoSystemThunks { - size_t size; // Should be set to sizeof(MojoSystemThunks). - MojoTimeTicks (*GetTimeTicksNow)(); - MojoResult (*Close)(MojoHandle handle); - MojoResult (*Wait)(MojoHandle handle, - MojoHandleSignals signals, - MojoDeadline deadline, - struct MojoHandleSignalsState* signals_state); - MojoResult (*WaitMany)(const MojoHandle* handles, - const MojoHandleSignals* signals, - uint32_t num_handles, - MojoDeadline deadline, - uint32_t* result_index, - struct MojoHandleSignalsState* signals_states); - MojoResult (*CreateMessagePipe)( - const struct MojoCreateMessagePipeOptions* options, - MojoHandle* message_pipe_handle0, - MojoHandle* message_pipe_handle1); - MojoResult (*WriteMessage)(MojoHandle message_pipe_handle, - const void* bytes, - uint32_t num_bytes, - const MojoHandle* handles, - uint32_t num_handles, - MojoWriteMessageFlags flags); - MojoResult (*ReadMessage)(MojoHandle message_pipe_handle, - void* bytes, - uint32_t* num_bytes, - MojoHandle* handles, - uint32_t* num_handles, - MojoReadMessageFlags flags); - MojoResult (*CreateDataPipe)(const struct MojoCreateDataPipeOptions* options, - MojoHandle* data_pipe_producer_handle, - MojoHandle* data_pipe_consumer_handle); - MojoResult (*WriteData)(MojoHandle data_pipe_producer_handle, - const void* elements, - uint32_t* num_elements, - MojoWriteDataFlags flags); - MojoResult (*BeginWriteData)(MojoHandle data_pipe_producer_handle, - void** buffer, - uint32_t* buffer_num_elements, - MojoWriteDataFlags flags); - MojoResult (*EndWriteData)(MojoHandle data_pipe_producer_handle, - uint32_t num_elements_written); - MojoResult (*ReadData)(MojoHandle data_pipe_consumer_handle, - void* elements, - uint32_t* num_elements, - MojoReadDataFlags flags); - MojoResult (*BeginReadData)(MojoHandle data_pipe_consumer_handle, - const void** buffer, - uint32_t* buffer_num_elements, - MojoReadDataFlags flags); - MojoResult (*EndReadData)(MojoHandle data_pipe_consumer_handle, - uint32_t num_elements_read); - MojoResult (*CreateSharedBuffer)( - const struct MojoCreateSharedBufferOptions* options, - uint64_t num_bytes, - MojoHandle* shared_buffer_handle); - MojoResult (*DuplicateBufferHandle)( - MojoHandle buffer_handle, - const struct MojoDuplicateBufferHandleOptions* options, - MojoHandle* new_buffer_handle); - MojoResult (*MapBuffer)(MojoHandle buffer_handle, - uint64_t offset, - uint64_t num_bytes, - void** buffer, - MojoMapBufferFlags flags); - MojoResult (*UnmapBuffer)(void* buffer); -}; -#pragma pack(pop) - - -#ifdef __cplusplus -// Intended to be called from the embedder. Returns a |MojoCore| initialized -// to contain pointers to each of the embedder's MojoCore functions. -inline MojoSystemThunks MojoMakeSystemThunks() { - MojoSystemThunks system_thunks = {sizeof(MojoSystemThunks), - MojoGetTimeTicksNow, - MojoClose, - MojoWait, - MojoWaitMany, - MojoCreateMessagePipe, - MojoWriteMessage, - MojoReadMessage, - MojoCreateDataPipe, - MojoWriteData, - MojoBeginWriteData, - MojoEndWriteData, - MojoReadData, - MojoBeginReadData, - MojoEndReadData, - MojoCreateSharedBuffer, - MojoDuplicateBufferHandle, - MojoMapBuffer, - MojoUnmapBuffer}; - return system_thunks; -} -#endif - - -// Use this type for the function found by dynamically discovering it in -// a DSO linked with mojo_system. For example: -// MojoSetSystemThunksFn mojo_set_system_thunks_fn = -// reinterpret_cast<MojoSetSystemThunksFn>(app_library.GetFunctionPointer( -// "MojoSetSystemThunks")); -// The expected size of |system_thunks} is returned. -// The contents of |system_thunks| are copied. -typedef size_t (*MojoSetSystemThunksFn)( - const struct MojoSystemThunks* system_thunks); - -#endif // MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_ diff --git a/mojo/public/platform/native/thunk_export.h b/mojo/public/platform/native/thunk_export.h deleted file mode 100644 index d118fc5..0000000 --- a/mojo/public/platform/native/thunk_export.h +++ /dev/null @@ -1,18 +0,0 @@ -// 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_THUNK_EXPORT_H_ -#define MOJO_PUBLIC_PLATFORM_THUNK_EXPORT_H_ - -// Call this function by looking inside the resulting shared object and -// grabbing the symbol manually. -// -// Always export this api. -#if defined(WIN32) -#define THUNK_EXPORT __declspec(dllexport) -#else -#define THUNK_EXPORT __attribute__((visibility("default"))) -#endif - -#endif // MOJO_PUBLIC_PLATFORM_THUNK_EXPORT_H_ |