| 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 25 matching lines...) Expand all Loading... |
| 36 /* NOTE on PP_Instance: In general Pepper is designed such that a | 36 /* NOTE on PP_Instance: In general Pepper is designed such that a |
| 37 * single plugin process can implement multiple plugin instances. | 37 * single plugin process can implement multiple plugin instances. |
| 38 * This might occur, for example, if a plugin were instantiated by | 38 * This might occur, for example, if a plugin were instantiated by |
| 39 * multiple <embed ...> tags in a single page. | 39 * multiple <embed ...> tags in a single page. |
| 40 * | 40 * |
| 41 * This implementation assumes at most one instance per plugin, | 41 * This implementation assumes at most one instance per plugin, |
| 42 * consistent with limitations of the current implementation of | 42 * consistent with limitations of the current implementation of |
| 43 * Native Client. | 43 * Native Client. |
| 44 */ | 44 */ |
| 45 struct PepperState { | 45 struct PepperState { |
| 46 const struct PPB_Core* core_interface; | 46 const PPB_Core* core_interface; |
| 47 const struct PPB_Graphics2D* graphics_2d_interface; | 47 const PPB_Graphics2D* graphics_2d_interface; |
| 48 const struct PPB_ImageData* image_data_interface; | 48 const PPB_ImageData* image_data_interface; |
| 49 const struct PPB_Instance* instance_interface; | 49 const PPB_Instance* instance_interface; |
| 50 const struct PPB_View* view_interface; | 50 const PPB_View* view_interface; |
| 51 PP_Resource device_context; | 51 PP_Resource device_context; |
| 52 int32_t which_image; | 52 int32_t which_image; |
| 53 PP_Resource image[NUMBER_OF_IMAGES]; | 53 PP_Resource image[NUMBER_OF_IMAGES]; |
| 54 uint32_t* image_data[NUMBER_OF_IMAGES]; | 54 uint32_t* image_data[NUMBER_OF_IMAGES]; |
| 55 PP_Instance instance; | 55 PP_Instance instance; |
| 56 struct PP_Rect position; | 56 struct PP_Rect position; |
| 57 bool ready; | 57 bool ready; |
| 58 }; | 58 }; |
| 59 struct PepperState g_MyState; | 59 struct PepperState g_MyState; |
| 60 bool g_MyStateIsValid = false; | 60 bool g_MyStateIsValid = false; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 static void Instance_DidChangeFocus(PP_Instance pp_instance, | 178 static void Instance_DidChangeFocus(PP_Instance pp_instance, |
| 179 PP_Bool has_focus) { | 179 PP_Bool has_focus) { |
| 180 } | 180 } |
| 181 | 181 |
| 182 static PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, | 182 static PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, |
| 183 PP_Resource pp_url_loader) { | 183 PP_Resource pp_url_loader) { |
| 184 return PP_FALSE; | 184 return PP_FALSE; |
| 185 } | 185 } |
| 186 | 186 |
| 187 static struct PPP_Instance instance_interface = { | 187 static PPP_Instance instance_interface = { |
| 188 &Instance_DidCreate, | 188 &Instance_DidCreate, |
| 189 &Instance_DidDestroy, | 189 &Instance_DidDestroy, |
| 190 &Instance_DidChangeView, | 190 &Instance_DidChangeView, |
| 191 &Instance_DidChangeFocus, | 191 &Instance_DidChangeFocus, |
| 192 &Instance_HandleDocumentLoad | 192 &Instance_HandleDocumentLoad |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 | 195 |
| 196 /* Global entrypoints --------------------------------------------------------*/ | 196 /* Global entrypoints --------------------------------------------------------*/ |
| 197 | 197 |
| 198 PP_EXPORT int32_t PPP_InitializeModule(PP_Module module, | 198 PP_EXPORT int32_t PPP_InitializeModule(PP_Module module, |
| 199 PPB_GetInterface get_browser_interface) { | 199 PPB_GetInterface get_browser_interface) { |
| 200 g_get_browser_interface = get_browser_interface; | 200 g_get_browser_interface = get_browser_interface; |
| 201 | 201 |
| 202 g_MyState.core_interface = (const struct PPB_Core*) | 202 g_MyState.core_interface = (const PPB_Core*) |
| 203 get_browser_interface(PPB_CORE_INTERFACE); | 203 get_browser_interface(PPB_CORE_INTERFACE); |
| 204 g_MyState.instance_interface = (const struct PPB_Instance*) | 204 g_MyState.instance_interface = (const PPB_Instance*) |
| 205 get_browser_interface(PPB_INSTANCE_INTERFACE); | 205 get_browser_interface(PPB_INSTANCE_INTERFACE); |
| 206 g_MyState.image_data_interface = (const struct PPB_ImageData*) | 206 g_MyState.image_data_interface = (const PPB_ImageData*) |
| 207 get_browser_interface(PPB_IMAGEDATA_INTERFACE); | 207 get_browser_interface(PPB_IMAGEDATA_INTERFACE); |
| 208 g_MyState.graphics_2d_interface = (const struct PPB_Graphics2D*) | 208 g_MyState.graphics_2d_interface = (const PPB_Graphics2D*) |
| 209 get_browser_interface(PPB_GRAPHICS_2D_INTERFACE); | 209 get_browser_interface(PPB_GRAPHICS_2D_INTERFACE); |
| 210 g_MyState.view_interface = (const struct PPB_View*) | 210 g_MyState.view_interface = (const PPB_View*) |
| 211 get_browser_interface(PPB_VIEW_INTERFACE); | 211 get_browser_interface(PPB_VIEW_INTERFACE); |
| 212 if (!g_MyState.core_interface || | 212 if (!g_MyState.core_interface || |
| 213 !g_MyState.instance_interface || | 213 !g_MyState.instance_interface || |
| 214 !g_MyState.image_data_interface || | 214 !g_MyState.image_data_interface || |
| 215 !g_MyState.graphics_2d_interface || | 215 !g_MyState.graphics_2d_interface || |
| 216 !g_MyState.view_interface) | 216 !g_MyState.view_interface) |
| 217 return -1; | 217 return -1; |
| 218 | 218 |
| 219 return PP_OK; | 219 return PP_OK; |
| 220 } | 220 } |
| 221 | 221 |
| 222 PP_EXPORT void PPP_ShutdownModule() { | 222 PP_EXPORT void PPP_ShutdownModule() { |
| 223 } | 223 } |
| 224 | 224 |
| 225 PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { | 225 PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { |
| 226 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) | 226 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) |
| 227 return &instance_interface; | 227 return &instance_interface; |
| 228 return NULL; | 228 return NULL; |
| 229 } | 229 } |
| OLD | NEW |