skia/ext: Early out from analysis when we have more than 1 draw op.
[chromium-blink-merge.git] / ppapi / native_client / src / untrusted / pnacl_irt_shim / irt_shim_ppapi.c
blobb52b8e9b3981cb8a79b6c6786d5d5c767b007964
1 /*
2 * Copyright 2014 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
7 #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/irt_shim_ppapi.h"
9 #include "native_client/src/untrusted/irt/irt.h"
10 #include "ppapi/nacl_irt/public/irt_ppapi.h"
11 #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.h"
12 #include "ppapi/nacl_irt/plugin_main.h"
15 * Defines a version of the version irt_ppapi_start and of the irt_ppapihook
16 * that returns a shimmed GetInterface for PNaCl.
18 * The hook will be linked into the IRT but it is considered unstable.
19 * Stable nexes should not use that IRT hook (and a filter prevents
20 * it from being used). Instead PNaCl nexes should embed the
21 * irt_shim_ppapi_start and the shim functions directly into the nexe
22 * for ABI stability.
25 static struct PP_StartFunctions g_user_start_functions;
27 static int32_t shim_PPPInitializeModule(PP_Module module_id,
28 PPB_GetInterface get_browser_intf) {
29 /* Record the original PPB_GetInterface and provide a shimmed one. */
30 __set_real_Pnacl_PPBGetInterface(get_browser_intf);
31 return (*g_user_start_functions.PPP_InitializeModule)(
32 module_id,
33 &__Pnacl_PPBGetInterface);
36 static void shim_PPPShutdownModule(void) {
37 (*g_user_start_functions.PPP_ShutdownModule)();
40 #ifdef PNACL_SHIM_AOT
42 * This will be discovered and set by the shim, since we cannot link
43 * against the IRT directly in the AOT library.
45 int (*real_irt_ppapi_start)(const struct PP_StartFunctions *) = NULL;
46 #else
48 * Otherwise, when linking directly into the IRT, we can refer to the
49 * real irt_ppapi_start from irt_ppapi.
51 extern int irt_ppapi_start(const struct PP_StartFunctions *);
52 static int (* const real_irt_ppapi_start)(const struct PP_StartFunctions *) =
53 &irt_ppapi_start;
54 #endif
56 int irt_shim_ppapi_start(const struct PP_StartFunctions *funcs) {
57 g_user_start_functions = *funcs;
59 * Record the original PPP_GetInterface and provide a shimmed one
60 * via wrapped_ppapi_methods.
62 const struct PP_StartFunctions wrapped_ppapi_methods = {
63 shim_PPPInitializeModule,
64 shim_PPPShutdownModule,
65 __Pnacl_PPPGetInterface
67 __set_real_Pnacl_PPPGetInterface(g_user_start_functions.PPP_GetInterface);
69 * Invoke the IRT's ppapi_start interface with the wrapped interface.
71 return (*real_irt_ppapi_start)(&wrapped_ppapi_methods);
74 #ifndef PNACL_SHIM_AOT
75 const struct nacl_irt_ppapihook nacl_irt_ppapihook_pnacl_private = {
76 irt_shim_ppapi_start,
77 PpapiPluginRegisterThreadCreator,
79 #endif