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

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

Issue 599020: Implemented linux-specific NPAPI interface for pepper demos. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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 | « no previous file | 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "gpu/demos/framework/plugin.h" 7 #include "gpu/demos/framework/plugin.h"
8 #include "gpu/pgl/pgl.h" 8 #include "gpu/pgl/pgl.h"
9 #include "webkit/glue/plugins/nphostapi.h" 9 #include "webkit/glue/plugins/nphostapi.h"
10 10
11 #if __GNUC__ >= 4
12 #define EXPORT __attribute__ ((visibility("default")))
13 #else
14 // We use .def file to export symbols on OS_WIN. We could potentially use
15 // __declspec(dllexport) but API_CALL always adds something to the function
16 // signature even inside extern "C" {}
17 #define EXPORT
18 #endif // GNUC
19
11 namespace { 20 namespace {
12 // AtExitManager is used by singleton classes to delete themselves when 21 // AtExitManager is used by singleton classes to delete themselves when
13 // the program terminates. There should be only one instance of this class 22 // the program terminates. There should be only one instance of this class
14 // per thread; 23 // per thread;
15 base::AtExitManager* g_at_exit_manager_; 24 base::AtExitManager* g_at_exit_manager;
16 } // namespace 25 } // namespace
17 26
18 namespace gpu { 27 namespace gpu {
19 namespace demos { 28 namespace demos {
20 // NPP entry points. 29 // NPP entry points.
21 NPError NPP_New(NPMIMEType pluginType, 30 NPError NPP_New(NPMIMEType pluginType,
22 NPP instance, 31 NPP instance,
23 uint16 mode, 32 uint16 mode,
24 int16 argc, char* argn[], char* argv[], 33 int16 argc, char* argn[], char* argv[],
25 NPSavedData* saved) { 34 NPSavedData* saved) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 94 }
86 95
87 void NPP_URLNotify(NPP instance, const char* url, NPReason reason, 96 void NPP_URLNotify(NPP instance, const char* url, NPReason reason,
88 void* notify_data) { 97 void* notify_data) {
89 } 98 }
90 99
91 NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) { 100 NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) {
92 NPError err = NPERR_NO_ERROR; 101 NPError err = NPERR_NO_ERROR;
93 102
94 switch (variable) { 103 switch (variable) {
104 #if defined(OS_LINUX)
105 case NPPVpluginNameString:
106 *(static_cast<const char**>(value)) = "Pepper GPU Demo";
107 break;
108 case NPPVpluginDescriptionString:
109 *(static_cast<const char**>(value)) = "Pepper plug-in for GPU demo.";
110 break;
111 case NPPVpluginNeedsXEmbed:
112 *(static_cast<NPBool*>(value)) = TRUE;
113 break;
114 #endif
95 case NPPVpluginScriptableNPObject: { 115 case NPPVpluginScriptableNPObject: {
96 void** v = reinterpret_cast<void**>(value); 116 void** v = static_cast<void**>(value);
97 Plugin* plugin = static_cast<Plugin*>(instance->pdata); 117 Plugin* plugin = static_cast<Plugin*>(instance->pdata);
98 // Return value is expected to be retained 118 // Return value is expected to be retained
99 g_browser->retainobject(plugin); 119 g_browser->retainobject(plugin);
100 *v = plugin; 120 *v = plugin;
101 break; 121 break;
102 } 122 }
103 default: 123 default:
104 LOG(INFO) << "Unhandled variable to NPP_GetValue\n"; 124 LOG(INFO) << "Unhandled variable to NPP_GetValue\n";
105 err = NPERR_GENERIC_ERROR; 125 err = NPERR_GENERIC_ERROR;
106 break; 126 break;
107 } 127 }
108 128
109 return err; 129 return err;
110 } 130 }
111 131
112 NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) { 132 NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) {
113 return NPERR_GENERIC_ERROR; 133 return NPERR_GENERIC_ERROR;
114 } 134 }
115 } // namespace demos 135 } // namespace demos
116 } // namespace gpu 136 } // namespace gpu
117 137
118 // NP entry points 138 // NP entry points
119 extern "C" { 139 extern "C" {
120 NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) { 140 EXPORT NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
121 plugin_funcs->version = NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL; 141 plugin_funcs->version = NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL;
122 plugin_funcs->size = sizeof(plugin_funcs); 142 plugin_funcs->size = sizeof(plugin_funcs);
123 plugin_funcs->newp = gpu::demos::NPP_New; 143 plugin_funcs->newp = gpu::demos::NPP_New;
124 plugin_funcs->destroy = gpu::demos::NPP_Destroy; 144 plugin_funcs->destroy = gpu::demos::NPP_Destroy;
125 plugin_funcs->setwindow = gpu::demos::NPP_SetWindow; 145 plugin_funcs->setwindow = gpu::demos::NPP_SetWindow;
126 plugin_funcs->newstream = gpu::demos::NPP_NewStream; 146 plugin_funcs->newstream = gpu::demos::NPP_NewStream;
127 plugin_funcs->destroystream = gpu::demos::NPP_DestroyStream; 147 plugin_funcs->destroystream = gpu::demos::NPP_DestroyStream;
128 plugin_funcs->asfile = gpu::demos::NPP_StreamAsFile; 148 plugin_funcs->asfile = gpu::demos::NPP_StreamAsFile;
129 plugin_funcs->writeready = gpu::demos::NPP_WriteReady; 149 plugin_funcs->writeready = gpu::demos::NPP_WriteReady;
130 plugin_funcs->write = gpu::demos::NPP_Write; 150 plugin_funcs->write = gpu::demos::NPP_Write;
131 plugin_funcs->print = gpu::demos::NPP_Print; 151 plugin_funcs->print = gpu::demos::NPP_Print;
132 plugin_funcs->event = gpu::demos::NPP_HandleEvent; 152 plugin_funcs->event = gpu::demos::NPP_HandleEvent;
133 plugin_funcs->urlnotify = gpu::demos::NPP_URLNotify; 153 plugin_funcs->urlnotify = gpu::demos::NPP_URLNotify;
134 plugin_funcs->getvalue = gpu::demos::NPP_GetValue; 154 plugin_funcs->getvalue = gpu::demos::NPP_GetValue;
135 plugin_funcs->setvalue = gpu::demos::NPP_SetValue; 155 plugin_funcs->setvalue = gpu::demos::NPP_SetValue;
136 156
137 return NPERR_NO_ERROR; 157 return NPERR_NO_ERROR;
138 } 158 }
139 159
140 NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs) { 160 EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs
141 g_at_exit_manager_ = new base::AtExitManager(); 161 #if defined(OS_LINUX)
162 , NPPluginFuncs* plugin_funcs
163 #endif // OS_LINUX
164 ) {
165 g_at_exit_manager = new base::AtExitManager();
142 gpu::demos::g_browser = browser_funcs; 166 gpu::demos::g_browser = browser_funcs;
143 pglInitialize(); 167 pglInitialize();
168
169 #if defined(OS_LINUX)
170 NP_GetEntryPoints(plugin_funcs);
171 #endif // OS_LINUX
144 return NPERR_NO_ERROR; 172 return NPERR_NO_ERROR;
145 } 173 }
146 174
147 void API_CALL NP_Shutdown() { 175 EXPORT void API_CALL NP_Shutdown() {
148 pglTerminate(); 176 pglTerminate();
149 delete g_at_exit_manager_; 177 delete g_at_exit_manager;
150 } 178 }
179
180 #if defined(OS_LINUX)
181 EXPORT NPError API_CALL NP_GetValue(NPP instance, NPPVariable variable,
182 void* value) {
183 return gpu::demos::NPP_GetValue(instance, variable, value);
184 }
185
186 EXPORT const char* API_CALL NP_GetMIMEDescription() {
187 return "pepper-application/x-gpu-demo::Pepper GPU Demo";
188 }
189 #endif // OS_LINUX
151 } // extern "C" 190 } // extern "C"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698