OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "webkit/glue/plugins/npapi_extension_thunk.h" | 5 #include "webkit/glue/plugins/npapi_extension_thunk.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/npapi/bindings/npapi_extensions.h" | 8 #include "third_party/npapi/bindings/npapi_extensions.h" |
9 #include "webkit/glue/plugins/plugin_instance.h" | 9 #include "webkit/glue/plugins/plugin_instance.h" |
10 #include "webkit/glue/webplugin.h" | 10 #include "webkit/glue/webplugin.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 static NPError Device2DDestroyContext(NPP id, | 107 static NPError Device2DDestroyContext(NPP id, |
108 NPDeviceContext* context) { | 108 NPDeviceContext* context) { |
109 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 109 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
110 if (plugin) { | 110 if (plugin) { |
111 return plugin->webplugin()->delegate()->Device2DDestroyContext( | 111 return plugin->webplugin()->delegate()->Device2DDestroyContext( |
112 static_cast<NPDeviceContext2D*>(context)); | 112 static_cast<NPDeviceContext2D*>(context)); |
113 } | 113 } |
114 return NPERR_GENERIC_ERROR; | 114 return NPERR_GENERIC_ERROR; |
115 } | 115 } |
116 | 116 |
| 117 static NPError Device2DCreateBuffer(NPP id, |
| 118 NPDeviceContext* context, |
| 119 size_t size, |
| 120 int32* buffer_id) { |
| 121 return NPERR_GENERIC_ERROR; |
| 122 } |
| 123 |
| 124 static NPError Device2DDestroyBuffer(NPP id, |
| 125 NPDeviceContext* context, |
| 126 int32 buffer_id) { |
| 127 return NPERR_GENERIC_ERROR; |
| 128 } |
| 129 |
| 130 static NPError Device2DMapBuffer(NPP id, |
| 131 NPDeviceContext* context, |
| 132 int32 buffer_id, |
| 133 NPDeviceBuffer* buffer) { |
| 134 return NPERR_GENERIC_ERROR; |
| 135 } |
| 136 |
117 // 3D device API --------------------------------------------------------------- | 137 // 3D device API --------------------------------------------------------------- |
118 | 138 |
119 static NPError Device3DQueryCapability(NPP id, int32 capability, int32* value) { | 139 static NPError Device3DQueryCapability(NPP id, int32 capability, int32* value) { |
120 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 140 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
121 if (plugin) { | 141 if (plugin) { |
122 plugin->webplugin()->delegate()->Device3DQueryCapability(capability, value); | 142 plugin->webplugin()->delegate()->Device3DQueryCapability(capability, value); |
123 return NPERR_NO_ERROR; | 143 return NPERR_NO_ERROR; |
124 } else { | 144 } else { |
125 return NPERR_GENERIC_ERROR; | 145 return NPERR_GENERIC_ERROR; |
126 } | 146 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 static NPError Device3DDestroyContext(NPP id, | 209 static NPError Device3DDestroyContext(NPP id, |
190 NPDeviceContext* context) { | 210 NPDeviceContext* context) { |
191 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 211 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
192 if (plugin) { | 212 if (plugin) { |
193 return plugin->webplugin()->delegate()->Device3DDestroyContext( | 213 return plugin->webplugin()->delegate()->Device3DDestroyContext( |
194 static_cast<NPDeviceContext3D*>(context)); | 214 static_cast<NPDeviceContext3D*>(context)); |
195 } | 215 } |
196 return NPERR_GENERIC_ERROR; | 216 return NPERR_GENERIC_ERROR; |
197 } | 217 } |
198 | 218 |
| 219 static NPError Device3DCreateBuffer(NPP id, |
| 220 NPDeviceContext* context, |
| 221 size_t size, |
| 222 int32* buffer_id) { |
| 223 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 224 if (plugin) { |
| 225 return plugin->webplugin()->delegate()->Device3DCreateBuffer( |
| 226 static_cast<NPDeviceContext3D*>(context), size, buffer_id); |
| 227 } |
| 228 return NPERR_GENERIC_ERROR; |
| 229 } |
| 230 |
| 231 static NPError Device3DDestroyBuffer(NPP id, |
| 232 NPDeviceContext* context, |
| 233 int32 buffer_id) { |
| 234 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 235 if (plugin) { |
| 236 return plugin->webplugin()->delegate()->Device3DDestroyBuffer( |
| 237 static_cast<NPDeviceContext3D*>(context), buffer_id); |
| 238 } |
| 239 return NPERR_GENERIC_ERROR; |
| 240 } |
| 241 |
| 242 static NPError Device3DMapBuffer(NPP id, |
| 243 NPDeviceContext* context, |
| 244 int32 buffer_id, |
| 245 NPDeviceBuffer* buffer) { |
| 246 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 247 if (plugin) { |
| 248 return plugin->webplugin()->delegate()->Device3DMapBuffer( |
| 249 static_cast<NPDeviceContext3D*>(context), buffer_id, buffer); |
| 250 } |
| 251 return NPERR_GENERIC_ERROR; |
| 252 } |
| 253 |
199 // ----------------------------------------------------------------------------- | 254 // ----------------------------------------------------------------------------- |
200 | 255 |
201 static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) { | 256 static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) { |
202 static NPDevice device_2d = { | 257 static NPDevice device_2d = { |
203 Device2DQueryCapability, | 258 Device2DQueryCapability, |
204 Device2DQueryConfig, | 259 Device2DQueryConfig, |
205 Device2DInitializeContext, | 260 Device2DInitializeContext, |
206 Device2DSetStateContext, | 261 Device2DSetStateContext, |
207 Device2DGetStateContext, | 262 Device2DGetStateContext, |
208 Device2DFlushContext, | 263 Device2DFlushContext, |
209 Device2DDestroyContext, | 264 Device2DDestroyContext, |
| 265 Device2DCreateBuffer, |
| 266 Device2DDestroyBuffer, |
| 267 Device2DMapBuffer, |
210 }; | 268 }; |
211 static NPDevice device_3d = { | 269 static NPDevice device_3d = { |
212 Device3DQueryCapability, | 270 Device3DQueryCapability, |
213 Device3DQueryConfig, | 271 Device3DQueryConfig, |
214 Device3DInitializeContext, | 272 Device3DInitializeContext, |
215 Device3DSetStateContext, | 273 Device3DSetStateContext, |
216 Device3DGetStateContext, | 274 Device3DGetStateContext, |
217 Device3DFlushContext, | 275 Device3DFlushContext, |
218 Device3DDestroyContext, | 276 Device3DDestroyContext, |
| 277 Device3DCreateBuffer, |
| 278 Device3DDestroyBuffer, |
| 279 Device3DMapBuffer, |
219 }; | 280 }; |
220 | 281 |
221 switch (device_id) { | 282 switch (device_id) { |
222 case NPPepper2DDevice: | 283 case NPPepper2DDevice: |
223 return const_cast<NPDevice*>(&device_2d); | 284 return const_cast<NPDevice*>(&device_2d); |
224 case NPPepper3DDevice: | 285 case NPPepper3DDevice: |
225 return const_cast<NPDevice*>(&device_3d); | 286 return const_cast<NPDevice*>(&device_3d); |
226 default: | 287 default: |
227 return NULL; | 288 return NULL; |
228 } | 289 } |
229 } | 290 } |
230 | 291 |
231 namespace NPAPI { | 292 namespace NPAPI { |
232 | 293 |
233 NPError GetPepperExtensionsFunctions(void* value) { | 294 NPError GetPepperExtensionsFunctions(void* value) { |
234 static const NPExtensions kExtensions = { | 295 static const NPExtensions kExtensions = { |
235 &AcquireDevice, | 296 &AcquireDevice, |
236 }; | 297 }; |
237 | 298 |
238 // Return a pointer to the canonical function table. | 299 // Return a pointer to the canonical function table. |
239 NPExtensions* extensions = const_cast<NPExtensions*>(&kExtensions); | 300 NPExtensions* extensions = const_cast<NPExtensions*>(&kExtensions); |
240 NPExtensions** exts = reinterpret_cast<NPExtensions**>(value); | 301 NPExtensions** exts = reinterpret_cast<NPExtensions**>(value); |
241 *exts = extensions; | 302 *exts = extensions; |
242 return NPERR_NO_ERROR; | 303 return NPERR_NO_ERROR; |
243 } | 304 } |
244 | 305 |
245 } // namespace NPAPI | 306 } // namespace NPAPI |
OLD | NEW |