1 /* Copyright (c) 2006-2009 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.
6 #ifndef _NP_EXTENSIONS_H_
7 #define _NP_EXTENSIONS_H_
9 // Use the shorter include path here so that this file can be used in non-
10 // Chromium projects, such as the Native Client SDK.
13 #include <stddef.h> // For size_t
16 * A fake "enum" value for getting browser-implemented Pepper extensions.
17 * The variable returns a pointer to an NPNExtensions structure. */
18 #define NPNVPepperExtensions ((NPNVariable) 4000)
21 * A fake "enum" value for getting plugin-implemented Pepper extensions.
22 * The variable returns a pointer to an NPPExtensions structure. */
23 #define NPPVPepperExtensions ((NPPVariable) 4001)
25 typedef void NPDeviceConfig
;
26 typedef void NPDeviceContext
;
27 typedef void NPUserData
;
29 /* unique id for each device interface */
30 typedef int32_t NPDeviceID
;
32 /* Events -------------------------------------------------------------------*/
35 NPMouseButton_None
= -1,
36 NPMouseButton_Left
= 0,
37 NPMouseButton_Middle
= 1,
38 NPMouseButton_Right
= 2
42 NPEventType_Undefined
= -1,
43 NPEventType_MouseDown
= 0,
44 NPEventType_MouseUp
= 1,
45 NPEventType_MouseMove
= 2,
46 NPEventType_MouseEnter
= 3,
47 NPEventType_MouseLeave
= 4,
48 NPEventType_MouseWheel
= 5,
49 NPEventType_RawKeyDown
= 6,
50 NPEventType_KeyDown
= 7,
51 NPEventType_KeyUp
= 8,
53 NPEventType_Minimize
= 10,
54 NPEventType_Focus
= 11,
55 NPEventType_Device
= 12
59 NPEventModifier_ShiftKey
= 1 << 0,
60 NPEventModifier_ControlKey
= 1 << 1,
61 NPEventModifier_AltKey
= 1 << 2,
62 NPEventModifier_MetaKey
= 1 << 3,
63 NPEventModifier_IsKeyPad
= 1 << 4,
64 NPEventModifier_IsAutoRepeat
= 1 << 5,
65 NPEventModifier_LeftButtonDown
= 1 << 6,
66 NPEventModifier_MiddleButtonDown
= 1 << 7,
67 NPEventModifier_RightButtonDown
= 1 << 8
70 typedef struct _NPKeyEvent
73 uint32_t normalizedKeyCode
;
76 typedef struct _NPCharacterEvent
80 uint16_t unmodifiedText
[4];
83 typedef struct _NPMouseEvent
92 typedef struct _NPMouseWheelEvent
99 uint32_t scrollByPage
;
102 typedef struct _NPDeviceEvent
{
105 /* uint8_t generic[0]; */
108 typedef struct _NPMinimizeEvent
{
112 typedef struct _NPFocusEvent
{
116 typedef struct _NPPepperEvent
120 double timeStampSeconds
;
123 NPCharacterEvent character
;
125 NPMouseWheelEvent wheel
;
126 NPMinimizeEvent minimize
;
128 NPDeviceEvent device
;
132 /* 2D -----------------------------------------------------------------------*/
134 #define NPPepper2DDevice 1
136 typedef struct _NPDeviceContext2DConfig
{
137 } NPDeviceContext2DConfig
;
139 typedef struct _NPDeviceContext2D
141 /* Internal value used by the browser to identify this device. */
144 /* A pointer to the pixel data. This data is 8-bit values in BGRA order in
145 * memory. Each row will start |stride| bytes after the previous one.
147 * THIS DATA USES PREMULTIPLIED ALPHA. This means that each color channel has
148 * been multiplied with the corresponding alpha, which makes compositing
149 * easier. If any color channels have a value greater than the alpha value,
150 * you'll likely get crazy colors and weird artifacts. */
153 /* Length of each row of pixels in bytes. This may be larger than width * 4
154 * if there is padding at the end of each row to help with alignment. */
157 /* The dirty region that the plugin has painted into the buffer. This
158 * will be initialized to the size of the plugin image in
159 * initializeContextPtr. The plugin can change the values to only
160 * update portions of the image. */
169 typedef struct _NPDeviceBuffer
{
174 /* completion callback for flush device */
175 typedef void (*NPDeviceFlushContextCallbackPtr
)(
177 NPDeviceContext
* context
,
179 NPUserData
* userData
);
181 /* query single capabilities of device */
183 *NPDeviceQueryCapabilityPtr
)(NPP instance
,
186 /* query config (configuration == a set of capabilities) */
188 *NPDeviceQueryConfigPtr
)(NPP instance
,
189 const NPDeviceConfig
* request
,
190 NPDeviceConfig
* obtain
);
191 /* device initialization */
192 typedef NPError (*NPDeviceInitializeContextPtr
)(
194 const NPDeviceConfig
* config
,
195 NPDeviceContext
* context
);
196 /* peek at device state */
197 typedef NPError (*NPDeviceGetStateContextPtr
) (
199 NPDeviceContext
* context
,
202 /* poke device state */
203 typedef NPError (*NPDeviceSetStateContextPtr
) (
205 NPDeviceContext
* context
,
208 /* flush context, if callback, userData are NULL */
209 /* this becomes a blocking call */
210 typedef NPError (*NPDeviceFlushContextPtr
)(
212 NPDeviceContext
* context
,
213 NPDeviceFlushContextCallbackPtr callback
,
215 /* destroy device context. Application responsible for */
216 /* freeing context, if applicable */
217 typedef NPError (*NPDeviceDestroyContextPtr
)(
219 NPDeviceContext
* context
);
220 /* Create a buffer associated with a particular context. The usage of the */
221 /* buffer is device specific. The lifetime of the buffer is scoped with the */
222 /* lifetime of the context. */
223 typedef NPError (*NPDeviceCreateBufferPtr
)(
225 NPDeviceContext
* context
,
228 /* Destroy a buffer associated with a particular context. */
229 typedef NPError (*NPDeviceDestroyBufferPtr
)(
231 NPDeviceContext
* context
,
233 /* Map a buffer id to its address. */
234 typedef NPError (*NPDeviceMapBufferPtr
)(
236 NPDeviceContext
* context
,
238 NPDeviceBuffer
* buffer
);
241 /* forward decl typdef structs */
242 typedef struct NPDevice NPDevice
;
243 typedef struct NPNExtensions NPNExtensions
;
245 // DEPRECATED: this typedef is just for the NaCl code until they switch to NPNExtensions.
246 // PLEASE REMOVE THIS WHEN THE NACL CODE IS UPDATED.
247 typedef struct NPNExtensions NPExtensions
;
250 /* New experimental device API. */
252 /* Mode for calls to NPDeviceSynchronizeContext. */
254 /* Get or set locally cached state without synchronizing or communicating */
255 /* with the service process (or thread). */
256 NPDeviceSynchronizationMode_Cached
,
258 /* Exchanges state with service process (or thread). Does not wait for any */
259 /* progress before returning. */
260 NPDeviceSynchronizationMode_Immediate
,
262 /* Exchanges state with service process (or thread). Blocks caller until */
263 /* further progress can be made. */
264 NPDeviceSynchronizationMode_Flush
265 } NPDeviceSynchronizationMode
;
267 /* Get the number of configs supported by a given device. */
268 typedef NPError (*NPDeviceGetNumConfigsPtr
)(NPP instance
,
269 int32_t* numConfigs
);
271 /* Get attribute values from a config. NPDeviceGetConfigs might return */
272 /* multiple configs. This function can be used to examine them to */
273 /* find the most suitable. For example, NPDeviceGetConfigs might return one */
274 /* config with antialiasing enabled and one without. This can be determined */
275 /* using this function. */
277 /* config: The config index to extract the attributes from. */
278 /* attribList: Array of input config attribute / value pairs */
279 /* terminated with NPAttrib_End. */
281 /* attribList: The values paired up with each attribute are filled in */
283 typedef NPError (*NPDeviceGetConfigAttribsPtr
)(NPP instance
,
285 int32_t* attribList
);
287 /* Create a device context based on a particular device configuration and a */
288 /* list config input attributes. */
290 /* config: The device configuration to use. */
291 /* attribList: NULL or an array of context specific attribute / value */
292 /* pairs terminated with NPAttrib_End. */
294 /* context: The created context. */
295 typedef NPError (*NPDeviceCreateContextPtr
)(NPP instance
,
297 const int32_t* attribList
,
298 NPDeviceContext
** context
);
300 /* Destroy a context. */
302 /* context: The context to destroy. */
303 /*typedef NPError (*NPDestroyContext)(NPP instance, */
304 /* NPDeviceContext* context); */
306 /* This type should be cast to the type associated with the particular */
308 typedef void (*NPDeviceGenericCallbackPtr
)(void);
310 /* Register a callback with a context. Callbacks are never invoked after the */
311 /* associated context has been destroyed. The semantics of the particular */
312 /* callback type determine which thread the callback is invoked on. It might */
313 /* be the plugin thread, the thread RegisterCallback is invoked on or a */
314 /* special thread created for servicing callbacks, such as an audio thread */
316 /* callbackType: The device specific callback type */
317 /* callback: The callback to invoke. The signature varies by type. Use */
318 /* NULL to unregister the callback for a particular type. */
319 /* callbackData: A value that is passed to the callback function. Other */
320 /* callback arguments vary by type. */
321 typedef NPError (*NPDeviceRegisterCallbackPtr
)(
323 NPDeviceContext
* context
,
324 int32_t callbackType
,
325 NPDeviceGenericCallbackPtr callback
,
328 /* Callback for NPDeviceSynchronizeContext. */
330 /* instance: The associated plugin instance. */
331 /* context: The context that was flushed. */
332 /* error: Indicates success of flush operation. */
333 /* data: The completion callback data that was passed to */
334 /* NPDeviceSynchronizeContext. */
335 typedef void (*NPDeviceSynchronizeContextCallbackPtr
)(
337 NPDeviceContext
* context
,
341 /* Synchronize the state of a device context. Takes lists of input and output */
342 /* attributes. Generally, the input attributes are copied into the context */
343 /* and the output attributes are filled in the state of the context either */
344 /* after (before) the synchronization depending on whether it is synchronous */
345 /* (asynchronous). The get the state of the context after an asynchronous */
346 /* synchronization, call this function a second time with Cached mode after */
347 /* the callback has been invoked. */
349 /* context: The context to synchronize. */
350 /* mode: The type of synchronization to perform. */
351 /* inputAttribList: NULL or an array of input synchronization attribute / */
352 /* value pairs terminated with NPAttrib_End. */
353 /* outputAttribList: NULL or an array of output synchronization */
354 /* attributes / uninitialized value pairs terminated */
355 /* with NPAttrib_End. */
356 /* callback: NULL for synchronous operation or completion callback function */
357 /* for asynchronous operation. */
358 /* callbackData: Argument passed to callback function. */
360 /* outputAttribList: The values paired up with each attribute are filled */
361 /* in on return for synchronous operation. */
362 typedef NPError (*NPDeviceSynchronizeContextPtr
)(
364 NPDeviceContext
* context
,
365 NPDeviceSynchronizationMode mode
,
366 const int32_t* inputAttribList
,
367 int32_t* outputAttribList
,
368 NPDeviceSynchronizeContextCallbackPtr callback
,
371 /* All attributes shared between devices, with the exception of */
372 /* NPDeviceContextAttrib_End, have bit 31 set. Device specific attributes */
373 /* have the bit clear. */
375 /* Used to terminate arrays of attribute / value pairs. */
378 /* Error status of context. Non-zero means error. Shared by all devices, */
379 /* though error values are device specific. */
380 NPAttrib_Error
= 0x80000000
383 /* generic device interface */
385 NPDeviceQueryCapabilityPtr queryCapability
;
386 NPDeviceQueryConfigPtr queryConfig
;
387 NPDeviceInitializeContextPtr initializeContext
;
388 NPDeviceSetStateContextPtr setStateContext
;
389 NPDeviceGetStateContextPtr getStateContext
;
390 NPDeviceFlushContextPtr flushContext
;
391 NPDeviceDestroyContextPtr destroyContext
;
392 NPDeviceCreateBufferPtr createBuffer
;
393 NPDeviceDestroyBufferPtr destroyBuffer
;
394 NPDeviceMapBufferPtr mapBuffer
;
396 /* Experimental device API */
397 NPDeviceGetNumConfigsPtr getNumConfigs
;
398 NPDeviceGetConfigAttribsPtr getConfigAttribs
;
399 NPDeviceCreateContextPtr createContext
;
400 /* NPDeviceDestroyContextPtr destroyContext; */
401 NPDeviceRegisterCallbackPtr registerCallback
;
402 NPDeviceSynchronizeContextPtr synchronizeContext
;
403 /* NPDeviceCreateBufferPtr createBuffer; */
404 /* NPDeviceDestroyBufferPtr destroyBuffer; */
405 /* NPDeviceMapBufferPtr mapBuffer; */
408 /* returns NULL if deviceID unavailable / unrecognized */
409 typedef NPDevice
* (*NPAcquireDevicePtr
)(
413 /* Updates the number of find results for the current search term. If
414 * there are no matches 0 should be passed in. Only when the plugin has
415 * finished searching should it pass in the final count with finalResult set to
417 typedef void (*NPNumberOfFindResultsChangedPtr
)(
422 /* Updates the index of the currently selected search item. */
423 typedef void (*NPSelectedFindResultChangedPtr
)(
427 /* Theming -----------------------------------------------------------------*/
428 typedef int32_t NPWidgetID
;
431 NPWidgetTypeScrollbar
= 0
434 typedef struct _NPScrollbarCreateParams
{
436 } NPScrollbarCreateParams
;
438 typedef struct _NPRect32
446 typedef struct _NPScrollbarTickMarks
{
449 } NPScrollbarTickMarks
;
452 NPWidgetPropertyLocation
= 0, // variable is NPRect*.
453 NPWidgetPropertyDirtyRect
= 1, // Get only. variable is NPRec*.
454 NPWidgetPropertyScrollbarThickness
= 2, // Get only. variable is int32_t*.
455 NPWidgetPropertyScrollbarValue
= 3, // variable is int32_t*.
456 NPWidgetPropertyScrollbarDocumentSize
= 4, // Set only. variable is int32_t*.
457 // Set only. variable is NPScrollbarTickMarks*.
458 NPWidgetPropertyScrollbarTickMarks
= 5,
459 // Set only. variable is bool* (true for forward, false for backward).
460 NPWidgetPropertyScrollbarScrollByLine
= 6,
461 // Set only. variable is bool* (true for forward, false for backward).
462 NPWidgetPropertyScrollbarScrollByPage
= 7,
463 // Set only. variable is bool* (true for forward, false for backward).
464 NPWidgetPropertyScrollbarScrollByDocument
= 8,
465 // Set only. variable is int32_t* (positive forward, negative backward).
466 NPWidgetPropertyScrollbarScrollByPixels
= 9
469 // Creates a widget. If it returns NPERR_NO_ERROR then id will contain a unique
470 // identifer for the widget that's used for the next functions.
471 typedef NPError (*NPCreateWidgetPtr
) (
474 void* params
, // Widget specific.
477 // Destroys a widget.
478 typedef NPError (*NPDestroyWidgetPtr
) (
482 // Paint the dirty rectangle of the given widget into context.
483 typedef NPError (*NPPaintWidgetPtr
) (
486 NPDeviceContext2D
* context
,
489 // Pass in a pepper event to a plugin. It'll return true iff it uses it.
490 typedef bool (*NPHandleWidgetEventPtr
) (
493 NPPepperEvent
* event
);
495 // Gets a property of the widget. "value" varies depending on the variable.
496 typedef NPError (*NPGetWidgetPropertyPtr
) (
499 NPWidgetProperty property
,
502 // Sets a property of the widget.
503 typedef NPError (*NPSetWidgetPropertyPtr
) (
506 NPWidgetProperty property
,
509 typedef struct _NPWidgetExtensions
{
510 NPCreateWidgetPtr createWidget
;
511 NPDestroyWidgetPtr destroyWidget
;
512 NPPaintWidgetPtr paintWidget
;
513 NPHandleWidgetEventPtr handleWidgetEvent
;
514 NPGetWidgetPropertyPtr getWidgetProperty
;
515 NPSetWidgetPropertyPtr setWidgetProperty
;
516 } NPWidgetExtensions
;
518 typedef NPWidgetExtensions
* (*NPGetWidgetExtensionsPtr
)(
522 /* Supports opening files anywhere on the system after prompting the user to
525 * This API is asynchronous. It will return immediately and the user will be
526 * prompted in parallel to pick a file. The plugin may continue to receive
527 * events while the open file dialog is up, and may continue to paint. Plugins
528 * may want to ignore input events between the call and the callback to avoid
529 * reentrant behavior. If the return value is not NPERR_NO_ERROR, the callback
530 * will NOT be executed.
532 * It is an error to call BrowseForFile before a previous call has executed
535 * Setting the flags to "Open" requires that the file exist to allow picking.
536 * Setting the flags to "Save" allows selecting nonexistant files (which will
537 * then be created), and will prompt the user if they want to overwrite an
538 * existing file if it exists.
540 * The plugin may specify a comma-separated list of possible mime types in
541 * the "extensions" parameter. If no extensions are specified, the dialog box
542 * will default to allowing all extensions. The first extension in the list
543 * will be the default.
545 * TODO(brettw) On Windows the extensions traditionally include a text
546 * description with the extension in the popup, do we want to allow this?
547 * We should probably also allow the ability to put "All files" in the
550 * Once the user has picked a file or has canceled the dialog box, the given
551 * callback will be called with the results of the operation and the passed in
552 * "user data" pointer. If the user successfully picked a file, the filename
553 * will be non-NULL and will contain a pointer to an array of strings, one for
554 * each file picked (the first file will be file_paths[0]). This buffer will
555 * become invalid as soon as the call completes, so it is the plugin's
556 * responsibility to copy the filename(sp if it needs future access to them.
557 * A NULL file_paths in the callback means the user canceled the dialog box.
559 * The filename will be in UTF-8. It may not actually correspond to the actual
560 * file on disk on a Linux system, because we'll do our best to convert it from
561 * the filesystem's locale to UTF-8. Instead, the string will be appropriate for
562 * displaying to the user which file they picked.
565 NPChooseFile_Open
= 1,
566 NPChooseFile_OpenMultiple
= 2,
567 NPChooseFile_Save
= 3
569 typedef void (*NPChooseFileCallback
)(const char** filePaths
,
572 typedef NPError (*NPChooseFilePtr
)(
574 const char* mimeTypes
,
575 NPChooseFileMode mode
,
576 NPChooseFileCallback callback
,
580 NPCursorTypePointer
= 0,
581 NPCursorTypeCross
= 1,
582 NPCursorTypeHand
= 2,
583 NPCursorTypeIBeam
= 3,
584 NPCursorTypeWait
= 4,
585 NPCursorTypeHelp
= 5,
586 NPCursorTypeEastResize
= 6,
587 NPCursorTypeNorthResize
= 7,
588 NPCursorTypeNorthEastResize
= 8,
589 NPCursorTypeNorthWestResize
= 9,
590 NPCursorTypeSouthResize
= 10,
591 NPCursorTypeSouthEastResize
= 11,
592 NPCursorTypeSouthWestResize
= 12,
593 NPCursorTypeWestResize
= 13,
594 NPCursorTypeNorthSouthResize
= 14,
595 NPCursorTypeEastWestResize
= 15,
596 NPCursorTypeNorthEastSouthWestResize
= 16,
597 NPCursorTypeNorthWestSouthEastResize
= 17,
598 NPCursorTypeColumnResize
= 18,
599 NPCursorTypeRowResize
= 19,
600 NPCursorTypeMiddlePanning
= 20,
601 NPCursorTypeEastPanning
= 21,
602 NPCursorTypeNorthPanning
= 22,
603 NPCursorTypeNorthEastPanning
= 23,
604 NPCursorTypeNorthWestPanning
= 24,
605 NPCursorTypeSouthPanning
= 25,
606 NPCursorTypeSouthEastPanning
= 26,
607 NPCursorTypeSouthWestPanning
= 27,
608 NPCursorTypeWestPanning
= 28,
609 NPCursorTypeMove
= 29,
610 NPCursorTypeVerticalText
= 30,
611 NPCursorTypeCell
= 31,
612 NPCursorTypeContextMenu
= 32,
613 NPCursorTypeAlias
= 33,
614 NPCursorTypeProgress
= 34,
615 NPCursorTypeNoDrop
= 35,
616 NPCursorTypeCopy
= 36,
617 NPCursorTypeNone
= 37,
618 NPCursorTypeNotAllowed
= 38,
619 NPCursorTypeZoomIn
= 39,
620 NPCursorTypeZoomOut
= 40
623 // Temporary SetCursor API.
624 typedef NPError (*NPSetCursorPtr
)(
628 /* unique id for each font */
629 typedef int NPFontID
;
633 NPCharsetDefault
= 1,
636 NPCharsetShiftJIS
= 128,
637 NPCharsetHangul
= 129,
638 NPCharsetJohab
= 130,
639 NPCharsetGB2312
=134,
640 NPCharsetChineseBIG5
= 136,
641 NPCharsetGreek
= 161,
642 NPCharsetTurkish
= 162,
643 NPCharsetVietnamese
= 163,
644 NPCharsetHebrew
= 177,
645 NPCharsetArabic
= 178,
646 NPCharsetBaltic
= 186,
647 NPCharsetRussian
= 204,
649 NPCharsetEastEurope
= 238,
664 typedef struct _NPFontDescription
{
673 // Return a font which best matches the given properties.
674 typedef NPError (*NPMatchFontWithFallbackPtr
) (
676 const NPFontDescription
* description
,
679 // Loads a specified font table for the given font.
680 // table: the table in *big-endian* format, or 0 for the whole font file.
681 // output: a buffer of size output_length that gets the data. can be 0, in
682 // which case output_length will be set to the required size in bytes.
683 // output_length: size of output, if it's not 0.
684 typedef NPError (*GetFontTablePtr
) (
689 size_t* output_length
);
692 typedef NPError (*NPDestroyFontPtr
) (
696 typedef struct _NPFontExtensions
{
697 NPMatchFontWithFallbackPtr matchFontWithFallback
;
698 GetFontTablePtr getFontTable
;
699 NPDestroyFontPtr destroyFont
;
702 typedef NPFontExtensions
* (*NPGetFontExtensionsPtr
)(
705 /* Pepper extensions */
706 struct NPNExtensions
{
707 /* Device interface acquisition */
708 NPAcquireDevicePtr acquireDevice
;
710 NPNumberOfFindResultsChangedPtr numberOfFindResultsChanged
;
711 NPSelectedFindResultChangedPtr selectedFindResultChanged
;
712 /* File I/O extensions */
713 NPChooseFilePtr chooseFile
;
715 NPGetWidgetExtensionsPtr getWidgetExtensions
;
717 NPSetCursorPtr setCursor
;
719 NPGetFontExtensionsPtr getFontExtensions
;
722 /* 3D -----------------------------------------------------------------------*/
724 #define NPPepper3DDevice 2
726 typedef struct _NPDeviceContext3DConfig
{
727 int32_t commandBufferSize
;
728 } NPDeviceContext3DConfig
;
730 typedef enum _NPDeviceContext3DError
{
731 // No error has ocurred.
732 NPDeviceContext3DError_NoError
,
734 // The size of a command was invalid.
735 NPDeviceContext3DError_InvalidSize
,
737 // An offset was out of bounds.
738 NPDeviceContext3DError_OutOfBounds
,
740 // A command was not recognized.
741 NPDeviceContext3DError_UnknownCommand
,
743 // The arguments to a command were invalid.
744 NPDeviceContext3DError_InvalidArguments
,
746 // The 3D context was lost, for example due to a power management event. The
747 // context must be destroyed and a new one created.
748 NPDeviceContext3DError_LostContext
,
751 NPDeviceContext3DError_GenericError
752 } NPDeviceContext3DError
;
754 typedef struct _NPDeviceContext3D NPDeviceContext3D
;
756 typedef void (*NPDeviceContext3DRepaintPtr
)(NPP npp
,
757 NPDeviceContext3D
* context
);
759 // TODO(apatrick): this need not be exposed when we switch over to the new
760 // device API. It's layout can also be implementation dependent.
761 typedef struct _NPDeviceContext3D
765 // If true, then a flush will only complete once the get offset has advanced
766 // on the GPU thread. If false, then the get offset might have changed but
767 // the GPU thread will respond as quickly as possible without guaranteeing
768 // having made any progress in executing pending commands. Set to true
769 // to ensure that progress is made or when flushing in a loop waiting for the
770 // GPU to reach a certain state, for example in advancing beyond a particular
771 // token. Set to false when flushing to query the current state, for example
772 // whether an error has occurred.
773 bool waitForProgress
;
775 // Buffer in which commands are stored.
777 int32_t commandBufferSize
;
779 // Offset in command buffer reader has reached. Synchronized on flush.
782 // Offset in command buffer writer has reached. Synchronized on flush.
785 // Last processed token. Synchronized on flush.
788 // Callback invoked on the main thread when the context must be repainted.
789 // TODO(apatrick): move this out of the context struct like the rest of the
791 NPDeviceContext3DRepaintPtr repaintCallback
;
793 // Error status. Synchronized on flush.
794 NPDeviceContext3DError error
;
798 /* Begin 3D specific portion of experimental device API */
800 /* Device buffer ID reserved for command buffer */
802 NP3DCommandBufferId
= 0
807 /* Example GetConfigAttribs attributes. See EGL 1.4 spec. */
808 /* These may be passed to GetConfigAttribs. */
809 NP3DAttrib_BufferSize
= 0x3020,
810 NP3DAttrib_AlphaSize
= 0x3021,
811 NP3DAttrib_BlueSize
= 0x3022,
812 NP3DAttrib_GreenSize
= 0x3023,
813 NP3DAttrib_RedSize
= 0x3024,
814 NP3DAttrib_DepthSize
= 0x3025,
815 NP3DAttrib_StencilSize
= 0x3026,
816 NP3DAttrib_SurfaceType
= 0x3033,
818 /* Example CreateContext attributes. See EGL 1.4 spec. */
819 /* These may be passed to CreateContext. */
820 NP3DAttrib_SwapBehavior
= 0x3093,
821 NP3DAttrib_MultisampleResolve
= 0x3099,
823 /* Size of command buffer in 32-bit entries. */
824 /* This may be passed to CreateContext as an input or SynchronizeContext as */
826 NP3DAttrib_CommandBufferSize
= 0x10000000,
828 /* These may be passed to SynchronizeContext. */
830 /* Offset in command buffer writer has reached. In / out.*/
831 NP3DAttrib_PutOffset
,
833 /* Offset in command buffer reader has reached. Out only. */
834 NP3DAttrib_GetOffset
,
836 /* Last processed token. Out only. */
842 /* This callback is invoked whenever the plugin must repaint everything. */
843 /* This might be because the window manager must repaint a window or */
844 /* the context has been lost, for example a power management event. */
845 NP3DCallback_Repaint
= 1
848 /* Flags for NPConfig3DOutAttrib_SurfaceType */
850 NP3DSurfaceType_MultisampleResolveBox
= 0x0200,
851 NP3DSurfaceType_SwapBehaviorPreserved
= 0x0400
854 /* Values for NPConfig3DInAttrib_SwapBehavior */
856 NP3DSwapBehavior_Preserved
= 0x3094,
857 NP3DSwapBehavior_Destroyed
= 0x3095
860 /* Values for NPConfig3DInAttrib_MultisampleResolve */
862 NP3DMultisampleResolve_Default
= 0x309A,
863 NP3DMultisampleResolve_Box
= 0x309B
866 /* End 3D specific API */
868 /* Audio --------------------------------------------------------------------*/
870 #define NPPepperAudioDevice 3
872 /* min & max sample frame count */
874 NPAudioMinSampleFrameCount
= 64,
875 NPAudioMaxSampleFrameCount
= 32768
876 } NPAudioSampleFrameCounts
;
878 /* supported sample rates */
880 NPAudioSampleRate44100Hz
= 44100,
881 NPAudioSampleRate48000Hz
= 48000,
882 NPAudioSampleRate96000Hz
= 96000
883 } NPAudioSampleRates
;
885 /* supported sample formats */
887 NPAudioSampleTypeInt16
= 0,
888 NPAudioSampleTypeFloat32
= 1
889 } NPAudioSampleTypes
;
891 /* supported channel layouts */
892 /* there is code that depends on these being the actual number of channels */
894 NPAudioChannelNone
= 0,
895 NPAudioChannelMono
= 1,
896 NPAudioChannelStereo
= 2,
897 NPAudioChannelThree
= 3,
898 NPAudioChannelFour
= 4,
899 NPAudioChannelFive
= 5,
900 NPAudioChannelFiveOne
= 6,
901 NPAudioChannelSeven
= 7,
902 NPAudioChannelSevenOne
= 8
905 /* audio context states */
907 NPAudioContextStateCallback
= 0,
908 NPAudioContextStateUnderrunCounter
= 1
909 } NPAudioContextStates
;
911 /* audio context state values */
913 NPAudioCallbackStop
= 0,
914 NPAudioCallbackStart
= 1
915 } NPAudioContextStateValues
;
917 /* audio query capabilities */
919 NPAudioCapabilitySampleRate
= 0,
920 NPAudioCapabilitySampleType
= 1,
921 NPAudioCapabilitySampleFrameCount
= 2,
922 NPAudioCapabilitySampleFrameCount44100Hz
= 3,
923 NPAudioCapabilitySampleFrameCount48000Hz
= 4,
924 NPAudioCapabilitySampleFrameCount96000Hz
= 5,
925 NPAudioCapabilityOutputChannelMap
= 6,
926 NPAudioCapabilityInputChannelMap
= 7
927 } NPAudioCapabilities
;
929 typedef struct _NPDeviceContextAudio NPDeviceContextAudio
;
931 /* user supplied callback function */
932 typedef void (*NPAudioCallback
)(NPDeviceContextAudio
*context
);
934 typedef struct _NPDeviceContextAudioConfig
{
937 int32_t outputChannelMap
;
938 int32_t inputChannelMap
;
939 int32_t sampleFrameCount
;
940 uint32_t startThread
;
942 NPAudioCallback callback
;
944 } NPDeviceContextAudioConfig
;
946 struct _NPDeviceContextAudio
{
947 NPDeviceContextAudioConfig config
;
953 /* Printing related APIs ---------------------------------------------------*/
955 /* Defines a contiguous range of pages to be printed. Page numbers use a
956 * zero-based index. */
957 typedef struct _NPPrintPageNumberRange
{
958 int32_t firstPageNumber
;
959 int32_t lastPageNumber
;
960 } NPPrintPageNumberRange
;
962 /* Being a print operation. Returns the total number of pages to print at the
963 * given printableArea size and DPI. printableArea is in points (a point is 1/72
964 * of an inch). The plugin is expected to remember the values of printableArea
965 * and printerDPI for use in subsequent print interface calls. These values
966 * should be cleared in printEnd. */
967 typedef NPError (*NPPPrintBeginPtr
) (
969 NPRect
* printableArea
,
972 /* Returns the required raster dimensions for the given page. */
973 typedef NPError (*NPPGetRasterDimensionsPtr
) (
976 int32_t* widthInPixels
,
977 int32_t* heightInPixels
);
978 /* Prints the specified page This allows the plugin to print a raster output. */
979 typedef NPError (*NPPPrintPageRasterPtr
) (
982 NPDeviceContext2D
* printSurface
);
983 /* Ends the print operation */
984 typedef NPError (*NPPPrintEndPtr
) (NPP instance
);
985 /* Prints the specified pages as PDF. The plugin allocates the output buffer
986 * pointed to by pdf_output using the browser-supplied NPN_MemAlloc function.
987 * The caller is expected to free the output buffer upon success.*/
988 typedef NPError (*NPPrintPagesAsPDFPtr
)(NPP instance
,
989 NPPrintPageNumberRange
* page_ranges
,
990 int32_t page_range_count
,
991 unsigned char** pdf_output
,
992 int32_t* output_size
);
995 /* TODO(sanjeevr) : Provide a vector interface for printing. We need to decide
996 * on a vector format that can support embedded fonts. A vector format will
997 * greatly reduce the size of the required output buffer. */
999 typedef struct _NPPPrintExtensions
{
1000 NPPPrintBeginPtr printBegin
;
1001 NPPGetRasterDimensionsPtr getRasterDimensions
;
1002 NPPPrintPageRasterPtr printPageRaster
;
1003 NPPPrintEndPtr printEnd
;
1004 NPPrintPagesAsPDFPtr printPagesAsPDF
;
1005 } NPPPrintExtensions
;
1007 /* Returns NULL if the plugin does not support print extensions */
1008 typedef NPPPrintExtensions
* (*NPPGetPrintExtensionsPtr
)(NPP instance
);
1010 /* Find ---------------------------------------------------------------------*/
1012 /* Finds the given UTF-8 text starting at the current selection. The number of
1013 * results will be updated asynchronously via numberOfFindResultsChanged. Note
1014 * that multiple StartFind calls can happen before StopFind is called in the
1015 * case of the search term changing. */
1016 typedef NPError (*NPPStartFindPtr
) (
1019 bool caseSensitive
);
1021 /* Go to the next/previous result. */
1022 typedef NPError (*NPPSelectFindResultPtr
) (
1026 /* Tells the plugin that the find operation has stopped, so it should clear
1027 * any highlighting. */
1028 typedef NPError (*NPPStopFindPtr
) (
1031 typedef struct _NPPFindExtensions
{
1032 NPPStartFindPtr startFind
;
1033 NPPSelectFindResultPtr selectFindResult
;
1034 NPPStopFindPtr stopFind
;
1035 } NPPFindExtensions
;
1037 /* Returns NULL if the plugin does not support find extensions. */
1038 typedef NPPFindExtensions
* (*NPPGetFindExtensionsPtr
)(NPP instance
);
1040 /* Zooms a plugin to the given factor. If text_only is true, then only the text
1041 * should be zoomed. */
1042 typedef NPError (*NPPZoomPtr
) (
1047 typedef NPError (*NPPWidgetPropertyChangedPtr
) (
1050 NPWidgetProperty property
);
1052 /* type of selection */
1054 NPSelectionTypeAny
= 0,
1055 NPSelectionTypePlainText
= 1,
1056 NPSelectionTypeHTML
= 2
1059 /* Gets the selection. NPERR_GENERIC_ERROR is returned if nothing is selected.
1060 * 'type' is both an input and output parameter. The caller can request a
1061 * specific type, and if the plugin can't provide it, it will return
1062 * NPERR_GENERIC_ERROR. Or the caller can specify NPSelectionTypeAny to let the
1063 * plugin pick the best format for the data. The result is returned in a buffer
1064 * that's owned by the caller and which is allocated using NPN_MemAlloc. If no
1065 * data is available, NPERR_GENERIC_ERROR is returned. */
1066 typedef NPError (*NPPGetSelectionPtr
) (
1068 NPSelectionType
* type
,
1071 typedef struct _NPPExtensions
{
1072 NPPGetPrintExtensionsPtr getPrintExtensions
;
1073 NPPGetFindExtensionsPtr getFindExtensions
;
1075 NPPWidgetPropertyChangedPtr widgetPropertyChanged
;
1076 NPPGetSelectionPtr getSelection
;
1079 #endif /* _NP_EXTENSIONS_H_ */