Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef PPAPI_SIMPLE_PS_H_ | |
| 6 #define PPAPI_SIMPLE_PS_H_ | |
| 7 | |
| 8 #include "ppapi/c/pp_instance.h" | |
| 9 #include "utils/macros.h" | |
| 10 | |
| 11 EXTERN_C_BEGIN | |
| 12 | |
| 13 /** | |
| 14 * The ppapi_simple library simplifies the use of the Pepper interfaces by | |
| 15 * providing a more traditional 'C' or 'C++' style framework. The library | |
| 16 * creates an PSInstance derived object based on the ppapi_cpp library and | |
| 17 * initializes the nacl_io library to provide a POSIX friendly I/O environment. | |
| 18 * | |
| 19 * In order to provide a standard blocking environment, the library will hide | |
|
binji
2013/05/30 05:07:50
nit: indent 1 space
noelallen1
2013/05/30 18:07:19
Done.
| |
| 20 * the actual "Pepper Thread" which is the thread that standartd events | |
|
binji
2013/05/30 05:07:50
sp: standard
noelallen1
2013/05/30 18:07:19
Done.
| |
| 21 * such as window resize, mouse keyboard, or other inputs arrive. To prevent | |
| 22 * blocking, instead we enqueue these events onto a thread safe linked list | |
| 23 * and expect them to be processed on a new thread. In addition, the library | |
| 24 * will automatically start a new thread on which can be used effectively | |
| 25 * as a "main" entry point. | |
| 26 * | |
| 27 * For C style development, the PPAPI_SIMPLE_REGISTER_MAIN(XX) macros provide a | |
| 28 * mechanism to register the entry an point for "main". All events are pushed | |
| 29 * onto an event queue which can then be pulled from this new thread. | |
| 30 * NOTE: The link will still need libstdc++ and libppapi_cpp since the library | |
| 31 * is still creating a C++ object which does the initialization work and | |
| 32 * forwards the events. | |
| 33 * | |
| 34 * For C++ style development, use the ppapi_simple_instance.h, | |
| 35 * ppapi_simple_instance_2d.h, and ppapi_simple_instance_3d.h headers as | |
| 36 * a base class, and overload the appropriate virtual functions such as | |
| 37 * Main, ChangeContext, or Render. | |
| 38 */ | |
| 39 | |
| 40 /** | |
| 41 * PSGetInstanceId | |
| 42 * | |
| 43 * Return the PP_Instance id of this instance of the module. This is required | |
| 44 * by most of the Pepper resource creation routines. | |
| 45 */ | |
| 46 PP_Instance PSGetInstanceId(); | |
| 47 | |
| 48 | |
| 49 /** | |
| 50 * PSGetInterface | |
| 51 * | |
| 52 * Return the Pepper instance refered to by 'name'. Will return a pointer | |
|
binji
2013/05/30 05:07:50
sp: referred
noelallen1
2013/05/30 18:07:19
Done.
| |
| 53 * to the interface, or NULL if not found or not available. | |
| 54 */ | |
| 55 const void* PSGetInterface(const char *name); | |
| 56 | |
| 57 | |
| 58 /** | |
| 59 * PSUserCreateInstance | |
| 60 * | |
| 61 * Prototype for the user provided function which creates and configures | |
| 62 * the instance object. This function is defined by one of the macros below, | |
| 63 * or by the equivilent macro in one of the other headers. For 'C' | |
|
binji
2013/05/30 05:07:50
sp: equivalent
noelallen1
2013/05/30 18:07:19
Done.
| |
| 64 * development, one of the basic instances which support C callback are used. | |
| 65 * For C++, this function should instantiate the user defined instance. See | |
| 66 * the two macros bellow. | |
|
binji
2013/05/30 05:07:50
sp: below
noelallen1
2013/05/30 18:07:19
Done.
| |
| 67 */ | |
| 68 extern void* PSUserCreateInstance(PP_Instance inst); | |
| 69 | |
| 70 | |
| 71 /** | |
| 72 * PPAPI_SIMPLE_DECLARE_PARAMS | |
| 73 * | |
| 74 * Macro for creating the param string array. Used by the Factory macros | |
| 75 * to enable wrapping of the param array with terminating NULL, NULL. | |
| 76 */ | |
| 77 #define PPAPI_SIMPLE_DECLARE_PARAMS(params, ...) \ | |
| 78 static const char* params[] = { __VA_ARGS__ }; | |
| 79 | |
| 80 | |
| 81 /** | |
| 82 * PPAPI_SIMPLE_USE_MAIN | |
| 83 * | |
| 84 * For use with C projects, this macro calls the provided factory with | |
| 85 * configuration information and optional extra arguments which are passed to | |
| 86 * the 'main' function. See the appropriate ppapi_simple_main(XX).h header. | |
| 87 */ | |
| 88 #define PPAPI_SIMPLE_USE_MAIN(factory, func, ...) \ | |
| 89 void* PSUserCreateInstance(PP_Instance inst) { \ | |
| 90 PPAPI_SIMPLE_DECLARE_PARAMS(params, ##__VA_ARGS__, NULL, NULL) \ | |
| 91 return factory(inst, func, params); \ | |
| 92 } | |
| 93 | |
| 94 | |
| 95 /** | |
| 96 * PPAPI_SIMPLE_USE_CLASS | |
| 97 * | |
| 98 * For use with C++ projects, this macro instantiates the provided class | |
| 99 * passing it back to the generic module initialization code. Simply derive | |
| 100 * a class from the appropriate ppapi_simple_instance(XX).h and pass the | |
| 101 * class name here. | |
| 102 */ | |
| 103 #define PPAPI_SIMPLE_USE_CLASS(class, ...) \ | |
|
binji
2013/05/30 05:07:50
might not want to use a keyword as macro param
noelallen1
2013/05/30 18:07:19
Done.
| |
| 104 void* PSUserCreateInstance(PP_Instance inst) { \ | |
| 105 PPAPI_SIMPLE_DECLARE_PARAMS(params, ##__VA_ARGS__, NULL, NULL) \ | |
| 106 return (void *) new class(inst, params); \ | |
| 107 } | |
| 108 | |
| 109 EXTERN_C_END | |
| 110 | |
| 111 | |
| 112 #endif // PPAPI_SIMPLE_PPAPI_SIMPLE_H | |
| 113 | |
| OLD | NEW |