OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /* NaCl Earth demo */ | 7 /* NaCl Earth demo */ |
8 /* Pepper code in C */ | 8 /* Pepper code in C */ |
9 | 9 |
10 #include "native_client/tests/earth/earth.h" | 10 #include "native_client/tests/earth/earth.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 /* NOTE on PP_Instance: In general Pepper is designed such that a | 35 /* NOTE on PP_Instance: In general Pepper is designed such that a |
36 * single plugin process can implement multiple plugin instances. | 36 * single plugin process can implement multiple plugin instances. |
37 * This might occur, for example, if a plugin were instantiated by | 37 * This might occur, for example, if a plugin were instantiated by |
38 * multiple <embed ...> tags in a single page. | 38 * multiple <embed ...> tags in a single page. |
39 * | 39 * |
40 * This implementation assumes at most one instance per plugin, | 40 * This implementation assumes at most one instance per plugin, |
41 * consistent with limitations of the current implementation of | 41 * consistent with limitations of the current implementation of |
42 * Native Client. | 42 * Native Client. |
43 */ | 43 */ |
44 struct PepperState { | 44 struct PepperState { |
45 const struct PPB_Core* core_interface; | 45 const PPB_Core* core_interface; |
46 const struct PPB_Graphics2D* graphics_2d_interface; | 46 const PPB_Graphics2D* graphics_2d_interface; |
47 const struct PPB_ImageData* image_data_interface; | 47 const PPB_ImageData* image_data_interface; |
48 const struct PPB_Instance* instance_interface; | 48 const PPB_Instance* instance_interface; |
49 PP_Resource device_context; | 49 PP_Resource device_context; |
50 int32_t which_image; | 50 int32_t which_image; |
51 PP_Resource image[NUMBER_OF_IMAGES]; | 51 PP_Resource image[NUMBER_OF_IMAGES]; |
52 uint32_t* image_data[NUMBER_OF_IMAGES]; | 52 uint32_t* image_data[NUMBER_OF_IMAGES]; |
53 PP_Instance instance; | 53 PP_Instance instance; |
54 struct PP_Rect position; | 54 struct PP_Rect position; |
55 bool ready; | 55 bool ready; |
56 }; | 56 }; |
57 struct PepperState g_MyState; | 57 struct PepperState g_MyState; |
58 bool g_MyStateIsValid = false; | 58 bool g_MyStateIsValid = false; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 static void Instance_DidChangeFocus(PP_Instance pp_instance, | 177 static void Instance_DidChangeFocus(PP_Instance pp_instance, |
178 PP_Bool has_focus) { | 178 PP_Bool has_focus) { |
179 } | 179 } |
180 | 180 |
181 static PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, | 181 static PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, |
182 PP_Resource pp_url_loader) { | 182 PP_Resource pp_url_loader) { |
183 return PP_FALSE; | 183 return PP_FALSE; |
184 } | 184 } |
185 | 185 |
186 static struct PPP_Instance instance_interface = { | 186 static PPP_Instance instance_interface = { |
187 &Instance_DidCreate, | 187 &Instance_DidCreate, |
188 &Instance_DidDestroy, | 188 &Instance_DidDestroy, |
189 &Instance_DidChangeView, | 189 &Instance_DidChangeView, |
190 &Instance_DidChangeFocus, | 190 &Instance_DidChangeFocus, |
191 &Instance_HandleDocumentLoad | 191 &Instance_HandleDocumentLoad |
192 }; | 192 }; |
193 | 193 |
194 | 194 |
195 /* Global entrypoints --------------------------------------------------------*/ | 195 /* Global entrypoints --------------------------------------------------------*/ |
196 | 196 |
197 PP_EXPORT int32_t PPP_InitializeModule(PP_Module module, | 197 PP_EXPORT int32_t PPP_InitializeModule(PP_Module module, |
198 PPB_GetInterface get_browser_interface) { | 198 PPB_GetInterface get_browser_interface) { |
199 g_get_browser_interface = get_browser_interface; | 199 g_get_browser_interface = get_browser_interface; |
200 | 200 |
201 g_MyState.core_interface = (const struct PPB_Core*) | 201 g_MyState.core_interface = (const PPB_Core*) |
202 get_browser_interface(PPB_CORE_INTERFACE); | 202 get_browser_interface(PPB_CORE_INTERFACE); |
203 g_MyState.instance_interface = (const struct PPB_Instance*) | 203 g_MyState.instance_interface = (const PPB_Instance*) |
204 get_browser_interface(PPB_INSTANCE_INTERFACE); | 204 get_browser_interface(PPB_INSTANCE_INTERFACE); |
205 g_MyState.image_data_interface = (const struct PPB_ImageData*) | 205 g_MyState.image_data_interface = (const PPB_ImageData*) |
206 get_browser_interface(PPB_IMAGEDATA_INTERFACE); | 206 get_browser_interface(PPB_IMAGEDATA_INTERFACE); |
207 g_MyState.graphics_2d_interface = (const struct PPB_Graphics2D*) | 207 g_MyState.graphics_2d_interface = (const PPB_Graphics2D*) |
208 get_browser_interface(PPB_GRAPHICS_2D_INTERFACE); | 208 get_browser_interface(PPB_GRAPHICS_2D_INTERFACE); |
209 if (!g_MyState.core_interface || | 209 if (!g_MyState.core_interface || |
210 !g_MyState.instance_interface || | 210 !g_MyState.instance_interface || |
211 !g_MyState.image_data_interface || | 211 !g_MyState.image_data_interface || |
212 !g_MyState.graphics_2d_interface) | 212 !g_MyState.graphics_2d_interface) |
213 return -1; | 213 return -1; |
214 | 214 |
215 return PP_OK; | 215 return PP_OK; |
216 } | 216 } |
217 | 217 |
218 PP_EXPORT void PPP_ShutdownModule() { | 218 PP_EXPORT void PPP_ShutdownModule() { |
219 } | 219 } |
220 | 220 |
221 PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { | 221 PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { |
222 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) | 222 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) |
223 return &instance_interface; | 223 return &instance_interface; |
224 return NULL; | 224 return NULL; |
225 } | 225 } |
OLD | NEW |