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

Side by Side Diff: gpu/demos/framework/main_pepper.cc

Issue 6646025: Deleted WebPluginDelegatePepper. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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
« no previous file with comments | « gpu/demos/demos.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 #include "gpu/demos/framework/plugin.h"
6 #include "gpu/pgl/pgl.h"
7 #include "third_party/npapi/bindings/nphostapi.h"
8
9 #if __GNUC__ >= 4
10 #define EXPORT __attribute__ ((visibility("default")))
11 #else
12 // We use .def file to export symbols on OS_WIN. We could potentially use
13 // __declspec(dllexport) but API_CALL always adds something to the function
14 // signature even inside extern "C" {}
15 #define EXPORT
16 #endif // GNUC
17
18 namespace gpu {
19 namespace demos {
20 // NPP entry points.
21 NPError NPP_New(NPMIMEType pluginType,
22 NPP instance,
23 uint16 mode,
24 int16 argc, char* argn[], char* argv[],
25 NPSavedData* saved) {
26 if (g_browser->version < NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL) {
27 return NPERR_INCOMPATIBLE_VERSION_ERROR;
28 }
29
30 Plugin* plugin = static_cast<Plugin*>(
31 g_browser->createobject(instance, Plugin::GetPluginClass()));
32 instance->pdata = plugin;
33 plugin->New(pluginType, argc, argn, argv);
34
35 return NPERR_NO_ERROR;
36 }
37
38 NPError NPP_Destroy(NPP instance, NPSavedData** save) {
39 Plugin* plugin = static_cast<Plugin*>(instance->pdata);
40 if (plugin) g_browser->releaseobject(plugin);
41
42 return NPERR_NO_ERROR;
43 }
44
45 NPError NPP_SetWindow(NPP instance, NPWindow* window) {
46 Plugin* plugin = static_cast<Plugin*>(instance->pdata);
47 if (plugin) plugin->SetWindow(*window);
48
49 return NPERR_NO_ERROR;
50 }
51
52 NPError NPP_NewStream(NPP instance,
53 NPMIMEType type,
54 NPStream* stream,
55 NPBool seekable,
56 uint16* stype) {
57 *stype = NP_ASFILEONLY;
58 return NPERR_NO_ERROR;
59 }
60
61 NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason) {
62 return NPERR_NO_ERROR;
63 }
64
65 void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname) {
66 }
67
68 int32 NPP_Write(NPP instance,
69 NPStream* stream,
70 int32 offset,
71 int32 len,
72 void* buffer) {
73 return 0;
74 }
75
76 int32 NPP_WriteReady(NPP instance, NPStream* stream) {
77 return 0;
78 }
79
80 void NPP_Print(NPP instance, NPPrint* platformPrint) {
81 }
82
83 int16 NPP_HandleEvent(NPP instance, void* event) {
84 Plugin* plugin = static_cast<Plugin*>(instance->pdata);
85
86 if (plugin)
87 return plugin->HandleEvent(*static_cast<NPPepperEvent*>(event));
88
89 return 0;
90 }
91
92 void NPP_URLNotify(NPP instance, const char* url, NPReason reason,
93 void* notify_data) {
94 }
95
96 NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) {
97 NPError err = NPERR_NO_ERROR;
98
99 switch (variable) {
100 #if defined(OS_LINUX)
101 case NPPVpluginNameString:
102 *(static_cast<const char**>(value)) = "Pepper GPU Demo";
103 break;
104 case NPPVpluginDescriptionString:
105 *(static_cast<const char**>(value)) = "Pepper plug-in for GPU demo.";
106 break;
107 case NPPVpluginNeedsXEmbed:
108 *(static_cast<NPBool*>(value)) = true;
109 break;
110 #endif
111 case NPPVpluginScriptableNPObject: {
112 void** v = static_cast<void**>(value);
113 Plugin* plugin = static_cast<Plugin*>(instance->pdata);
114 // Return value is expected to be retained
115 g_browser->retainobject(plugin);
116 *v = plugin;
117 break;
118 }
119 default:
120 err = NPERR_GENERIC_ERROR;
121 break;
122 }
123
124 return err;
125 }
126
127 NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) {
128 return NPERR_GENERIC_ERROR;
129 }
130 } // namespace demos
131 } // namespace gpu
132
133 // NP entry points
134 extern "C" {
135 EXPORT NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
136 plugin_funcs->version = NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL;
137 plugin_funcs->size = sizeof(plugin_funcs);
138 plugin_funcs->newp = gpu::demos::NPP_New;
139 plugin_funcs->destroy = gpu::demos::NPP_Destroy;
140 plugin_funcs->setwindow = gpu::demos::NPP_SetWindow;
141 plugin_funcs->newstream = gpu::demos::NPP_NewStream;
142 plugin_funcs->destroystream = gpu::demos::NPP_DestroyStream;
143 plugin_funcs->asfile = gpu::demos::NPP_StreamAsFile;
144 plugin_funcs->writeready = gpu::demos::NPP_WriteReady;
145 plugin_funcs->write = gpu::demos::NPP_Write;
146 plugin_funcs->print = gpu::demos::NPP_Print;
147 plugin_funcs->event = gpu::demos::NPP_HandleEvent;
148 plugin_funcs->urlnotify = gpu::demos::NPP_URLNotify;
149 plugin_funcs->getvalue = gpu::demos::NPP_GetValue;
150 plugin_funcs->setvalue = gpu::demos::NPP_SetValue;
151
152 return NPERR_NO_ERROR;
153 }
154
155 EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs
156 #if defined(OS_LINUX)
157 , NPPluginFuncs* plugin_funcs
158 #endif // OS_LINUX
159 ) {
160 gpu::demos::g_browser = browser_funcs;
161 pglInitialize();
162
163 #if defined(OS_LINUX)
164 NP_GetEntryPoints(plugin_funcs);
165 #endif // OS_LINUX
166 return NPERR_NO_ERROR;
167 }
168
169 EXPORT void API_CALL NP_Shutdown() {
170 pglTerminate();
171 }
172
173 #if defined(OS_LINUX)
174 EXPORT NPError API_CALL NP_GetValue(NPP instance, NPPVariable variable,
175 void* value) {
176 return gpu::demos::NPP_GetValue(instance, variable, value);
177 }
178
179 EXPORT const char* API_CALL NP_GetMIMEDescription() {
180 return "pepper-application/x-gpu-demo::Pepper GPU Demo";
181 }
182 #endif // OS_LINUX
183 } // extern "C"
OLDNEW
« no previous file with comments | « gpu/demos/demos.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698