| OLD | NEW |
| 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 "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 "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "third_party/npapi/bindings/npapi_extensions.h" | 10 #include "third_party/npapi/bindings/npapi_extensions.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 int32 buffer_id, | 270 int32 buffer_id, |
| 271 NPDeviceBuffer* buffer) { | 271 NPDeviceBuffer* buffer) { |
| 272 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 272 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 273 if (plugin) { | 273 if (plugin) { |
| 274 return plugin->webplugin()->delegate()->Device3DMapBuffer( | 274 return plugin->webplugin()->delegate()->Device3DMapBuffer( |
| 275 static_cast<NPDeviceContext3D*>(context), buffer_id, buffer); | 275 static_cast<NPDeviceContext3D*>(context), buffer_id, buffer); |
| 276 } | 276 } |
| 277 return NPERR_GENERIC_ERROR; | 277 return NPERR_GENERIC_ERROR; |
| 278 } | 278 } |
| 279 | 279 |
| 280 // Experimental 3D device API -------------------------------------------------- |
| 281 |
| 282 static NPError Device3DGetNumConfigs(NPP id, int32* num_configs) { |
| 283 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 284 if (plugin) { |
| 285 return plugin->webplugin()->delegate()->Device3DGetNumConfigs(num_configs); |
| 286 } |
| 287 return NPERR_GENERIC_ERROR; |
| 288 } |
| 289 |
| 290 static NPError Device3DGetConfigAttribs(NPP id, |
| 291 int32 config, |
| 292 int32* attrib_list) { |
| 293 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 294 if (plugin) { |
| 295 return plugin->webplugin()->delegate()->Device3DGetConfigAttribs( |
| 296 config, |
| 297 attrib_list); |
| 298 } |
| 299 return NPERR_GENERIC_ERROR; |
| 300 } |
| 301 |
| 302 static NPError Device3DCreateContext(NPP id, |
| 303 int32 config, |
| 304 const int32* attrib_list, |
| 305 NPDeviceContext** context) { |
| 306 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 307 if (plugin) { |
| 308 return plugin->webplugin()->delegate()->Device3DCreateContext( |
| 309 config, |
| 310 attrib_list, |
| 311 reinterpret_cast<NPDeviceContext3D**>(context)); |
| 312 } |
| 313 return NPERR_GENERIC_ERROR; |
| 314 } |
| 315 |
| 316 static NPError Device3DSynchronizeContext( |
| 317 NPP id, |
| 318 NPDeviceContext* context, |
| 319 NPDeviceSynchronizationMode mode, |
| 320 const int32* input_attrib_list, |
| 321 int32* output_attrib_list, |
| 322 NPDeviceSynchronizeContextCallbackPtr callback, |
| 323 void* callback_data) { |
| 324 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 325 if (plugin) { |
| 326 return plugin->webplugin()->delegate()->Device3DSynchronizeContext( |
| 327 id, |
| 328 static_cast<NPDeviceContext3D*>(context), |
| 329 mode, |
| 330 input_attrib_list, |
| 331 output_attrib_list, |
| 332 callback, |
| 333 callback_data); |
| 334 } |
| 335 return NPERR_GENERIC_ERROR; |
| 336 } |
| 337 |
| 338 static NPError Device3DRegisterCallback( |
| 339 NPP id, |
| 340 NPDeviceContext* context, |
| 341 int32 callback_type, |
| 342 NPDeviceGenericCallbackPtr callback, |
| 343 void* callback_data) { |
| 344 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 345 if (plugin) { |
| 346 return plugin->webplugin()->delegate()->Device3DRegisterCallback( |
| 347 id, |
| 348 static_cast<NPDeviceContext3D*>(context), |
| 349 callback_type, |
| 350 callback, |
| 351 callback_data); |
| 352 } |
| 353 return NPERR_GENERIC_ERROR; |
| 354 } |
| 355 |
| 280 // Audio device API ------------------------------------------------------------ | 356 // Audio device API ------------------------------------------------------------ |
| 281 | 357 |
| 282 static NPError DeviceAudioQueryCapability(NPP id, int32 capability, | 358 static NPError DeviceAudioQueryCapability(NPP id, int32 capability, |
| 283 int32* value) { | 359 int32* value) { |
| 284 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 360 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 285 if (plugin) { | 361 if (plugin) { |
| 286 plugin->webplugin()->delegate()->DeviceAudioQueryCapability(capability, | 362 plugin->webplugin()->delegate()->DeviceAudioQueryCapability(capability, |
| 287 value); | 363 value); |
| 288 return NPERR_NO_ERROR; | 364 return NPERR_NO_ERROR; |
| 289 } else { | 365 } else { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 Device2DInitializeContext, | 436 Device2DInitializeContext, |
| 361 Device2DSetStateContext, | 437 Device2DSetStateContext, |
| 362 Device2DGetStateContext, | 438 Device2DGetStateContext, |
| 363 Device2DFlushContext, | 439 Device2DFlushContext, |
| 364 Device2DDestroyContext, | 440 Device2DDestroyContext, |
| 365 Device2DCreateBuffer, | 441 Device2DCreateBuffer, |
| 366 Device2DDestroyBuffer, | 442 Device2DDestroyBuffer, |
| 367 Device2DMapBuffer, | 443 Device2DMapBuffer, |
| 368 Device2DThemeGetSize, | 444 Device2DThemeGetSize, |
| 369 Device2DThemePaint, | 445 Device2DThemePaint, |
| 446 NULL, |
| 447 NULL, |
| 448 NULL, |
| 449 NULL, |
| 450 NULL, |
| 370 }; | 451 }; |
| 371 static NPDevice device_3d = { | 452 static NPDevice device_3d = { |
| 372 Device3DQueryCapability, | 453 Device3DQueryCapability, |
| 373 Device3DQueryConfig, | 454 Device3DQueryConfig, |
| 374 Device3DInitializeContext, | 455 Device3DInitializeContext, |
| 375 Device3DSetStateContext, | 456 Device3DSetStateContext, |
| 376 Device3DGetStateContext, | 457 Device3DGetStateContext, |
| 377 Device3DFlushContext, | 458 Device3DFlushContext, |
| 378 Device3DDestroyContext, | 459 Device3DDestroyContext, |
| 379 Device3DCreateBuffer, | 460 Device3DCreateBuffer, |
| 380 Device3DDestroyBuffer, | 461 Device3DDestroyBuffer, |
| 381 Device3DMapBuffer, | 462 Device3DMapBuffer, |
| 382 NULL, | 463 NULL, |
| 383 NULL, | 464 NULL, |
| 465 Device3DGetNumConfigs, |
| 466 Device3DGetConfigAttribs, |
| 467 Device3DCreateContext, |
| 468 Device3DRegisterCallback, |
| 469 Device3DSynchronizeContext, |
| 384 }; | 470 }; |
| 385 static NPDevice device_audio = { | 471 static NPDevice device_audio = { |
| 386 DeviceAudioQueryCapability, | 472 DeviceAudioQueryCapability, |
| 387 DeviceAudioQueryConfig, | 473 DeviceAudioQueryConfig, |
| 388 DeviceAudioInitializeContext, | 474 DeviceAudioInitializeContext, |
| 389 DeviceAudioSetStateContext, | 475 DeviceAudioSetStateContext, |
| 390 DeviceAudioGetStateContext, | 476 DeviceAudioGetStateContext, |
| 391 DeviceAudioFlushContext, | 477 DeviceAudioFlushContext, |
| 392 DeviceAudioDestroyContext, | 478 DeviceAudioDestroyContext, |
| 393 NULL, | 479 NULL, |
| 394 NULL, | 480 NULL, |
| 395 NULL, | 481 NULL, |
| 396 NULL, | 482 NULL, |
| 397 NULL, | 483 NULL, |
| 484 NULL, |
| 485 NULL, |
| 486 NULL, |
| 487 NULL, |
| 488 NULL, |
| 398 }; | 489 }; |
| 399 | 490 |
| 400 switch (device_id) { | 491 switch (device_id) { |
| 401 case NPPepper2DDevice: | 492 case NPPepper2DDevice: |
| 402 return const_cast<NPDevice*>(&device_2d); | 493 return const_cast<NPDevice*>(&device_2d); |
| 403 case NPPepper3DDevice: | 494 case NPPepper3DDevice: |
| 404 return const_cast<NPDevice*>(&device_3d); | 495 return const_cast<NPDevice*>(&device_3d); |
| 405 case NPPepperAudioDevice: | 496 case NPPepperAudioDevice: |
| 406 return const_cast<NPDevice*>(&device_audio); | 497 return const_cast<NPDevice*>(&device_audio); |
| 407 default: | 498 default: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 }; | 548 }; |
| 458 | 549 |
| 459 // Return a pointer to the canonical function table. | 550 // Return a pointer to the canonical function table. |
| 460 NPNExtensions* extensions = const_cast<NPNExtensions*>(&kExtensions); | 551 NPNExtensions* extensions = const_cast<NPNExtensions*>(&kExtensions); |
| 461 NPNExtensions** exts = reinterpret_cast<NPNExtensions**>(value); | 552 NPNExtensions** exts = reinterpret_cast<NPNExtensions**>(value); |
| 462 *exts = extensions; | 553 *exts = extensions; |
| 463 return NPERR_NO_ERROR; | 554 return NPERR_NO_ERROR; |
| 464 } | 555 } |
| 465 | 556 |
| 466 } // namespace NPAPI | 557 } // namespace NPAPI |
| OLD | NEW |