Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: native_client_sdk/src/libraries/ppapi_simple/ppapi_simple.h

Issue 15011003: ppapi_simple (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore images Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
binji 2013/05/23 18:06:49 2013
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_PPAPI_SIMPLE_H_
6 #define PPAPI_SIMPLE_PPAPI_SIMPLE_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 * automatically creates an instance based on the ppapi_cpp library and
17 * initializes the nacl_io library to provide a POSIX friendly I/O environment.
18 *
19 * For C style development, the PPAPI_SIMPLE_MAIN(XX) macros provide a
nfullagar1 2013/05/23 21:58:36 maybe PPAPI_SIMPLE_REGISTER_MAIN(XX) is a bit more
20 * mechanism to register entry points for "main", and changes in the view
21 * context, or even callbacks to render a frame. Use the appropriate
22 * ppapi_simple_main.h, ppapi_simple_main_2d.h, and ppapi_simple_main_3d.h
binji 2013/05/23 18:06:49 3d files aren't in this CL. not uploaded?
noelallen1 2013/05/23 22:01:24 Adding 2D/3D will be a separate CL that will also
23 * header file to simplify pure compute, 2D, or 3D development for 'C'.
24 *
25 * For C++ style development, use the ppapi_simple_instance.h,
26 * ppapi_simple_instance_2d.h, and ppapi_simple_instance_3d.h headers as
27 * a base class, and overload the appropriate virtual functions such as
28 * Main, ChangeContext, or Render.
29 *
30 */
31
32 /**
33 * PSGetInstanceId
34 *
35 * Return the PP_Instance id of this instance of the module. This is required
36 * by most of the Pepper resouce creation routines.
binji 2013/05/23 18:06:49 sp: resource
noelallen1 2013/05/23 22:01:24 Done.
37 */
38 PP_Instance PSGetInstanceId();
39
40
41 /**
42 * PSGetInterface
43 *
44 * Return the Pepper instance refered to by 'name'. Will return a pointer
45 * to the interface, or NULL if not found or not available.
46 */
47 const void* PSGetInterface(const char *name);
48
49
50 /**
51 * PSUserCreateInstance
52 *
53 * Prototype for the user provided function which creates and configures
54 * the instance object. This function is defined by one of the macros bellow,
binji 2013/05/23 18:06:49 sp: below
noelallen1 2013/05/23 22:01:24 Done.
55 * or by the equivilent macro in one of the other headers. For 'C'
56 * development, one of the basic instances which support C callback are used.
57 * For C++, this function should instantiate the user defined instance. See
58 * the two macros bellow.
59 */
60 extern void* PSUserCreateInstance(PP_Instance inst);
61
62
63 /**
64 * PPAPI_DECLARE_PARAMS
nfullagar1 2013/05/23 21:58:36 These macros PPAPI_DECLARE_PARAMS, PPAPI_USE_MAIN,
65 *
66 * Macro for creating the param string array. Used by the Factory macros
67 * to enable wrapping of the param array with terminating NULL, NULL.
68 */
69 #define PPAPI_DECLARE_PARAMS(params, ...) \
70 static const char* params[] = { __VA_ARGS__ };
71
72
73 /**
74 * PPAPI_USE_MAIN
75 *
76 * For use with C projects, this macro calls the provided factory with
77 * configuration information and optional extra arguments which are passed to
78 * the 'main' function. See the appropriate ppapi_simple_main(XX).h header.
79 */
80 #define PPAPI_USE_MAIN(factory, func, ...) \
81 void* PSUserCreateInstance(PP_Instance inst) { \
82 PPAPI_DECLARE_PARAMS(params, ##__VA_ARGS__, NULL, NULL) \
83 return factory(inst, func, params); \
84 }
85
86
87 /**
88 * PPAPI_USE_CLASS
89 *
90 * For use with C++ projects, this macro instantiates the provided class
91 * passing it back to the generic module initialization code. Simply derive
92 * a class from the appropriate ppapi_simple_instance(XX).h and pass the
93 * class name here.
94 */
95 #define PPAPI_USE_CLASS(class, ...) \
96 void* PSUserCreateInstance(PP_Instance inst) { \
97 PPAPI_DECLARE_PARAMS(params, ##__VA_ARGS__, NULL, NULL) \
98 return (void *) new class(inst, params); \
99 }
100
101 EXTERN_C_END
102
103
104 #endif // PPAPI_SIMPLE_PPAPI_SIMPLE_H
105
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698