1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
|
/* Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef _NP_EXTENSIONS_H_
#define _NP_EXTENSIONS_H_
// Use the shorter include path here so that this file can be used in non-
// Chromium projects, such as the Native Client SDK.
#include "npapi.h"
/*
* A fake "enum" value for getting browser-implemented Pepper extensions.
* The variable returns a pointer to an NPNExtensions structure. */
#define NPNVPepperExtensions ((NPNVariable) 4000)
/*
* A fake "enum" value for getting plugin-implemented Pepper extensions.
* The variable returns a pointer to an NPPExtensions structure. */
#define NPPVPepperExtensions ((NPPVariable) 4001)
typedef void NPDeviceConfig;
typedef void NPDeviceContext;
typedef void NPUserData;
/* unique id for each device interface */
typedef int32_t NPDeviceID;
/* Events -------------------------------------------------------------------*/
typedef enum {
NPMouseButton_None = -1,
NPMouseButton_Left = 0,
NPMouseButton_Middle = 1,
NPMouseButton_Right = 2
} NPMouseButtons;
typedef enum {
NPEventType_Undefined = -1,
NPEventType_MouseDown = 0,
NPEventType_MouseUp = 1,
NPEventType_MouseMove = 2,
NPEventType_MouseEnter = 3,
NPEventType_MouseLeave = 4,
NPEventType_MouseWheel = 5,
NPEventType_RawKeyDown = 6,
NPEventType_KeyDown = 7,
NPEventType_KeyUp = 8,
NPEventType_Char = 9,
NPEventType_Minimize = 10,
NPEventType_Focus = 11,
NPEventType_Device = 12
} NPEventTypes;
typedef enum {
NPEventModifier_ShiftKey = 1 << 0,
NPEventModifier_ControlKey = 1 << 1,
NPEventModifier_AltKey = 1 << 2,
NPEventModifier_MetaKey = 1 << 3,
NPEventModifier_IsKeyPad = 1 << 4,
NPEventModifier_IsAutoRepeat = 1 << 5,
NPEventModifier_LeftButtonDown = 1 << 6,
NPEventModifier_MiddleButtonDown = 1 << 7,
NPEventModifier_RightButtonDown = 1 << 8
} NPEventModifiers;
typedef struct _NPKeyEvent
{
uint32_t modifier;
uint32_t normalizedKeyCode;
} NPKeyEvent;
typedef struct _NPCharacterEvent
{
uint32_t modifier;
uint16_t text[4];
uint16_t unmodifiedText[4];
} NPCharacterEvent;
typedef struct _NPMouseEvent
{
uint32_t modifier;
int32_t button;
int32_t x;
int32_t y;
int32_t clickCount;
} NPMouseEvent;
typedef struct _NPMouseWheelEvent
{
uint32_t modifier;
float deltaX;
float deltaY;
float wheelTicksX;
float wheelTicksY;
uint32_t scrollByPage;
} NPMouseWheelEvent;
typedef struct _NPDeviceEvent {
uint32_t device_uid;
uint32_t subtype;
/* uint8_t generic[0]; */
} NPDeviceEvent;
typedef struct _NPMinimizeEvent {
int32_t value;
} NPMinimizeEvent;
typedef struct _NPFocusEvent {
int32_t value;
} NPFocusEvent;
typedef struct _NPPepperEvent
{
uint32_t size;
int32_t type;
double timeStampSeconds;
union {
NPKeyEvent key;
NPCharacterEvent character;
NPMouseEvent mouse;
NPMouseWheelEvent wheel;
NPMinimizeEvent minimize;
NPFocusEvent focus;
NPDeviceEvent device;
} u;
} NPPepperEvent;
/* 2D -----------------------------------------------------------------------*/
#define NPPepper2DDevice 1
typedef struct _NPDeviceContext2DConfig {
} NPDeviceContext2DConfig;
typedef struct _NPDeviceContext2D
{
/* Internal value used by the browser to identify this device. */
void* reserved;
/* A pointer to the pixel data. This data is 8-bit values in BGRA order in
* memory. Each row will start |stride| bytes after the previous one.
*
* THIS DATA USES PREMULTIPLIED ALPHA. This means that each color channel has
* been multiplied with the corresponding alpha, which makes compositing
* easier. If any color channels have a value greater than the alpha value,
* you'll likely get crazy colors and weird artifacts. */
void* region;
/* Length of each row of pixels in bytes. This may be larger than width * 4
* if there is padding at the end of each row to help with alignment. */
int32_t stride;
/* The dirty region that the plugin has painted into the buffer. This
* will be initialized to the size of the plugin image in
* initializeContextPtr. The plugin can change the values to only
* update portions of the image. */
struct {
int32_t left;
int32_t top;
int32_t right;
int32_t bottom;
} dirty;
} NPDeviceContext2D;
typedef struct _NPDeviceBuffer {
void* ptr;
size_t size;
} NPDeviceBuffer;
/* completion callback for flush device */
typedef void (*NPDeviceFlushContextCallbackPtr)(
NPP instance,
NPDeviceContext* context,
NPError err,
NPUserData* userData);
/* query single capabilities of device */
typedef NPError (
*NPDeviceQueryCapabilityPtr)(NPP instance,
int32_t capability,
int32_t *value);
/* query config (configuration == a set of capabilities) */
typedef NPError (
*NPDeviceQueryConfigPtr)(NPP instance,
const NPDeviceConfig* request,
NPDeviceConfig* obtain);
/* device initialization */
typedef NPError (*NPDeviceInitializeContextPtr)(
NPP instance,
const NPDeviceConfig* config,
NPDeviceContext* context);
/* peek at device state */
typedef NPError (*NPDeviceGetStateContextPtr) (
NPP instance,
NPDeviceContext* context,
int32_t state,
intptr_t* value);
/* poke device state */
typedef NPError (*NPDeviceSetStateContextPtr) (
NPP instance,
NPDeviceContext* context,
int32_t state,
intptr_t value);
/* flush context, if callback, userData are NULL */
/* this becomes a blocking call */
typedef NPError (*NPDeviceFlushContextPtr)(
NPP instance,
NPDeviceContext* context,
NPDeviceFlushContextCallbackPtr callback,
void* userData);
/* destroy device context. Application responsible for */
/* freeing context, if applicable */
typedef NPError (*NPDeviceDestroyContextPtr)(
NPP instance,
NPDeviceContext* context);
/* Create a buffer associated with a particular context. The usage of the */
/* buffer is device specific. The lifetime of the buffer is scoped with the */
/* lifetime of the context. */
typedef NPError (*NPDeviceCreateBufferPtr)(
NPP instance,
NPDeviceContext* context,
size_t size,
int32_t* id);
/* Destroy a buffer associated with a particular context. */
typedef NPError (*NPDeviceDestroyBufferPtr)(
NPP instance,
NPDeviceContext* context,
int32_t id);
/* Map a buffer id to its address. */
typedef NPError (*NPDeviceMapBufferPtr)(
NPP instance,
NPDeviceContext* context,
int32_t id,
NPDeviceBuffer* buffer);
/* forward decl typdef structs */
typedef struct NPDevice NPDevice;
typedef struct NPNExtensions NPNExtensions;
// DEPRECATED: this typedef is just for the NaCl code until they switch to NPNExtensions.
// PLEASE REMOVE THIS WHEN THE NACL CODE IS UPDATED.
typedef struct NPNExtensions NPExtensions;
/* New experimental device API. */
/* Mode for calls to NPDeviceSynchronizeContext. */
typedef enum {
/* Get or set locally cached state without synchronizing or communicating */
/* with the service process (or thread). */
NPDeviceSynchronizationMode_Cached,
/* Exchanges state with service process (or thread). Does not wait for any */
/* progress before returning. */
NPDeviceSynchronizationMode_Immediate,
/* Exchanges state with service process (or thread). Blocks caller until */
/* further progress can be made. */
NPDeviceSynchronizationMode_Flush
} NPDeviceSynchronizationMode;
/* Get the number of configs supported by a given device. */
typedef NPError (*NPDeviceGetNumConfigsPtr)(NPP instance,
int32_t* numConfigs);
/* Get attribute values from a config. NPDeviceGetConfigs might return */
/* multiple configs. This function can be used to examine them to */
/* find the most suitable. For example, NPDeviceGetConfigs might return one */
/* config with antialiasing enabled and one without. This can be determined */
/* using this function. */
/* Inputs: */
/* config: The config index to extract the attributes from. */
/* attribList: Array of input config attribute / value pairs */
/* terminated with NPAttrib_End. */
/* Outputs: */
/* attribList: The values paired up with each attribute are filled in */
/* on return. */
typedef NPError (*NPDeviceGetConfigAttribsPtr)(NPP instance,
int32_t config,
int32_t* attribList);
/* Create a device context based on a particular device configuration and a */
/* list config input attributes. */
/* Inputs: */
/* config: The device configuration to use. */
/* attribList: NULL or an array of context specific attribute / value */
/* pairs terminated with NPAttrib_End. */
/* Outputs: */
/* context: The created context. */
typedef NPError (*NPDeviceCreateContextPtr)(NPP instance,
int32_t config,
const int32_t* attribList,
NPDeviceContext** context);
/* Destroy a context. */
/* Inputs: */
/* context: The context to destroy. */
/*typedef NPError (*NPDestroyContext)(NPP instance, */
/* NPDeviceContext* context); */
/* This type should be cast to the type associated with the particular */
/* callback type */
typedef void (*NPDeviceGenericCallbackPtr)(void);
/* Register a callback with a context. Callbacks are never invoked after the */
/* associated context has been destroyed. The semantics of the particular */
/* callback type determine which thread the callback is invoked on. It might */
/* be the plugin thread, the thread RegisterCallback is invoked on or a */
/* special thread created for servicing callbacks, such as an audio thread */
/* Inputs: */
/* callbackType: The device specific callback type */
/* callback: The callback to invoke. The signature varies by type. Use */
/* NULL to unregister the callback for a particular type. */
/* callbackData: A value that is passed to the callback function. Other */
/* callback arguments vary by type. */
typedef NPError (*NPDeviceRegisterCallbackPtr)(
NPP instance,
NPDeviceContext* context,
int32_t callbackType,
NPDeviceGenericCallbackPtr callback,
void* callbackData);
/* Callback for NPDeviceSynchronizeContext. */
/* Inputs: */
/* instance: The associated plugin instance. */
/* context: The context that was flushed. */
/* error: Indicates success of flush operation. */
/* data: The completion callback data that was passed to */
/* NPDeviceSynchronizeContext. */
typedef void (*NPDeviceSynchronizeContextCallbackPtr)(
NPP instance,
NPDeviceContext* context,
NPError error,
void* data);
/* Synchronize the state of a device context. Takes lists of input and output */
/* attributes. Generally, the input attributes are copied into the context */
/* and the output attributes are filled in the state of the context either */
/* after (before) the synchronization depending on whether it is synchronous */
/* (asynchronous). The get the state of the context after an asynchronous */
/* synchronization, call this function a second time with Cached mode after */
/* the callback has been invoked. */
/* Inputs: */
/* context: The context to synchronize. */
/* mode: The type of synchronization to perform. */
/* inputAttribList: NULL or an array of input synchronization attribute / */
/* value pairs terminated with NPAttrib_End. */
/* outputAttribList: NULL or an array of output synchronization */
/* attributes / uninitialized value pairs terminated */
/* with NPAttrib_End. */
/* callback: NULL for synchronous operation or completion callback function */
/* for asynchronous operation. */
/* callbackData: Argument passed to callback function. */
/* Outputs: */
/* outputAttribList: The values paired up with each attribute are filled */
/* in on return for synchronous operation. */
typedef NPError (*NPDeviceSynchronizeContextPtr)(
NPP instance,
NPDeviceContext* context,
NPDeviceSynchronizationMode mode,
const int32_t* inputAttribList,
int32_t* outputAttribList,
NPDeviceSynchronizeContextCallbackPtr callback,
void* callbackData);
/* All attributes shared between devices, with the exception of */
/* NPDeviceContextAttrib_End, have bit 31 set. Device specific attributes */
/* have the bit clear. */
enum {
/* Used to terminate arrays of attribute / value pairs. */
NPAttrib_End = 0,
/* Error status of context. Non-zero means error. Shared by all devices, */
/* though error values are device specific. */
NPAttrib_Error = 0x80000000
};
/* generic device interface */
struct NPDevice {
NPDeviceQueryCapabilityPtr queryCapability;
NPDeviceQueryConfigPtr queryConfig;
NPDeviceInitializeContextPtr initializeContext;
NPDeviceSetStateContextPtr setStateContext;
NPDeviceGetStateContextPtr getStateContext;
NPDeviceFlushContextPtr flushContext;
NPDeviceDestroyContextPtr destroyContext;
NPDeviceCreateBufferPtr createBuffer;
NPDeviceDestroyBufferPtr destroyBuffer;
NPDeviceMapBufferPtr mapBuffer;
/* Experimental device API */
NPDeviceGetNumConfigsPtr getNumConfigs;
NPDeviceGetConfigAttribsPtr getConfigAttribs;
NPDeviceCreateContextPtr createContext;
/* NPDeviceDestroyContextPtr destroyContext; */
NPDeviceRegisterCallbackPtr registerCallback;
NPDeviceSynchronizeContextPtr synchronizeContext;
/* NPDeviceCreateBufferPtr createBuffer; */
/* NPDeviceDestroyBufferPtr destroyBuffer; */
/* NPDeviceMapBufferPtr mapBuffer; */
};
/* returns NULL if deviceID unavailable / unrecognized */
typedef NPDevice* (*NPAcquireDevicePtr)(
NPP instance,
NPDeviceID device);
/* Copy UTF-8 string into clipboard */
typedef void (*NPCopyTextToClipboardPtr)(
NPP instance,
const char* content);
/* Updates the number of find results for the current search term. If
* there are no matches 0 should be passed in. Only when the plugin has
* finished searching should it pass in the final count with finalResult set to
* true. */
typedef void (*NPNumberOfFindResultsChangedPtr)(
NPP instance,
int total,
bool finalResult);
/* Updates the index of the currently selected search item. */
typedef void (*NPSelectedFindResultChangedPtr)(
NPP instance,
int index);
/* Theming -----------------------------------------------------------------*/
typedef int32_t NPWidgetID;
typedef enum {
NPWidgetTypeScrollbar = 0
} NPWidgetType;
typedef struct _NPScrollbarCreateParams {
bool vertical;
} NPScrollbarCreateParams;
typedef struct _NPRect32
{
uint32_t top;
uint32_t left;
uint32_t bottom;
uint32_t right;
} NPRect32;
typedef struct _NPScrollbarTickMarks {
uint32_t count;
NPRect32* tickmarks;
} NPScrollbarTickMarks;
typedef enum {
NPWidgetPropertyLocation = 0, // variable is NPRect*.
NPWidgetPropertyDirtyRect = 1, // Get only. variable is NPRec*.
NPWidgetPropertyScrollbarThickness = 2, // Get only. variable is int32_t*.
NPWidgetPropertyScrollbarValue = 3, // variable is int32_t*.
NPWidgetPropertyScrollbarDocumentSize = 4, // Set only. variable is int32_t*.
// Set only. variable is NPScrollbarTickMarks*.
NPWidgetPropertyScrollbarTickMarks = 5,
// Set only. variable is bool* (true for forward, false for backward).
NPWidgetPropertyScrollbarScrollByLine = 6,
// Set only. variable is bool* (true for forward, false for backward).
NPWidgetPropertyScrollbarScrollByPage = 7,
// Set only. variable is bool* (true for forward, false for backward).
NPWidgetPropertyScrollbarScrollByDocument = 8,
// Set only. variable is int32_t* (positive forward, negative backward).
NPWidgetPropertyScrollbarScrollByPixels = 9
} NPWidgetProperty;
// Creates a widget. If it returns NPERR_NO_ERROR then id will contain a unique
// identifer for the widget that's used for the next functions.
typedef NPError (*NPCreateWidgetPtr) (
NPP instance,
NPWidgetType type,
void* params, // Widget specific.
NPWidgetID* id);
// Destroys a widget.
typedef NPError (*NPDestroyWidgetPtr) (
NPP instance,
NPWidgetID id);
// Paint the dirty rectangle of the given widget into context.
typedef NPError (*NPPaintWidgetPtr) (
NPP instance,
NPWidgetID id,
NPDeviceContext2D* context,
NPRect* dirty);
// Pass in a pepper event to a plugin. It'll return true iff it uses it.
typedef bool (*NPHandleWidgetEventPtr) (
NPP instance,
NPWidgetID id,
NPPepperEvent* event);
// Gets a property of the widget. "value" varies depending on the variable.
typedef NPError (*NPGetWidgetPropertyPtr) (
NPP instance,
NPWidgetID id,
NPWidgetProperty property,
void* value);
// Sets a property of the widget.
typedef NPError (*NPSetWidgetPropertyPtr) (
NPP instance,
NPWidgetID id,
NPWidgetProperty property,
void* value);
typedef struct _NPWidgetExtensions {
NPCreateWidgetPtr createWidget;
NPDestroyWidgetPtr destroyWidget;
NPPaintWidgetPtr paintWidget;
NPHandleWidgetEventPtr handleWidgetEvent;
NPGetWidgetPropertyPtr getWidgetProperty;
NPSetWidgetPropertyPtr setWidgetProperty;
} NPWidgetExtensions;
typedef NPWidgetExtensions* (*NPGetWidgetExtensionsPtr)(
NPP instance);
/* Supports opening files anywhere on the system after prompting the user to
* pick one.
*
* This API is asynchronous. It will return immediately and the user will be
* prompted in parallel to pick a file. The plugin may continue to receive
* events while the open file dialog is up, and may continue to paint. Plugins
* may want to ignore input events between the call and the callback to avoid
* reentrant behavior. If the return value is not NPERR_NO_ERROR, the callback
* will NOT be executed.
*
* It is an error to call BrowseForFile before a previous call has executed
* the callback.
*
* Setting the flags to "Open" requires that the file exist to allow picking.
* Setting the flags to "Save" allows selecting nonexistant files (which will
* then be created), and will prompt the user if they want to overwrite an
* existing file if it exists.
*
* The plugin may specify a comma-separated list of possible mime types in
* the "extensions" parameter. If no extensions are specified, the dialog box
* will default to allowing all extensions. The first extension in the list
* will be the default.
*
* TODO(brettw) On Windows the extensions traditionally include a text
* description with the extension in the popup, do we want to allow this?
* We should probably also allow the ability to put "All files" in the
* list on Windows.
*
* Once the user has picked a file or has canceled the dialog box, the given
* callback will be called with the results of the operation and the passed in
* "user data" pointer. If the user successfully picked a file, the filename
* will be non-NULL and will contain a pointer to an array of strings, one for
* each file picked (the first file will be file_paths[0]). This buffer will
* become invalid as soon as the call completes, so it is the plugin's
* responsibility to copy the filename(sp if it needs future access to them.
* A NULL file_paths in the callback means the user canceled the dialog box.
*
* The filename will be in UTF-8. It may not actually correspond to the actual
* file on disk on a Linux system, because we'll do our best to convert it from
* the filesystem's locale to UTF-8. Instead, the string will be appropriate for
* displaying to the user which file they picked.
* */
typedef enum {
NPChooseFile_Open = 1,
NPChooseFile_OpenMultiple = 2,
NPChooseFile_Save = 3
} NPChooseFileMode;
typedef void (*NPChooseFileCallback)(const char** filePaths,
uint32_t pathCount,
void* userData);
typedef NPError (*NPChooseFilePtr)(
NPP instance,
const char* mimeTypes,
NPChooseFileMode mode,
NPChooseFileCallback callback,
void* userData);
typedef enum {
NPCursorTypePointer = 0,
NPCursorTypeCross = 1,
NPCursorTypeHand = 2,
NPCursorTypeIBeam = 3,
NPCursorTypeWait = 4,
NPCursorTypeHelp = 5,
NPCursorTypeEastResize = 6,
NPCursorTypeNorthResize = 7,
NPCursorTypeNorthEastResize = 8,
NPCursorTypeNorthWestResize = 9,
NPCursorTypeSouthResize = 10,
NPCursorTypeSouthEastResize = 11,
NPCursorTypeSouthWestResize = 12,
NPCursorTypeWestResize = 13,
NPCursorTypeNorthSouthResize = 14,
NPCursorTypeEastWestResize = 15,
NPCursorTypeNorthEastSouthWestResize = 16,
NPCursorTypeNorthWestSouthEastResize = 17,
NPCursorTypeColumnResize = 18,
NPCursorTypeRowResize = 19,
NPCursorTypeMiddlePanning = 20,
NPCursorTypeEastPanning = 21,
NPCursorTypeNorthPanning = 22,
NPCursorTypeNorthEastPanning = 23,
NPCursorTypeNorthWestPanning = 24,
NPCursorTypeSouthPanning = 25,
NPCursorTypeSouthEastPanning = 26,
NPCursorTypeSouthWestPanning = 27,
NPCursorTypeWestPanning = 28,
NPCursorTypeMove = 29,
NPCursorTypeVerticalText = 30,
NPCursorTypeCell = 31,
NPCursorTypeContextMenu = 32,
NPCursorTypeAlias = 33,
NPCursorTypeProgress = 34,
NPCursorTypeNoDrop = 35,
NPCursorTypeCopy = 36,
NPCursorTypeNone = 37,
NPCursorTypeNotAllowed = 38,
NPCursorTypeZoomIn = 39,
NPCursorTypeZoomOut = 40,
} NPCursorType;
// Temporary SetCursor API.
typedef NPError (*NPSetCursorPtr)(
NPP instance,
NPCursorType type);
/* Pepper extensions */
struct NPNExtensions {
/* Device interface acquisition */
NPAcquireDevicePtr acquireDevice;
/* Clipboard functionality */
NPCopyTextToClipboardPtr copyTextToClipboard;
/* Find */
NPNumberOfFindResultsChangedPtr numberOfFindResultsChanged;
NPSelectedFindResultChangedPtr selectedFindResultChanged;
/* File I/O extensions */
NPChooseFilePtr chooseFile;
/* Widget */
NPGetWidgetExtensionsPtr getWidgetExtensions;
/* Cursor */
NPSetCursorPtr setCursor;
};
/* 3D -----------------------------------------------------------------------*/
#define NPPepper3DDevice 2
typedef struct _NPDeviceContext3DConfig {
int32_t commandBufferSize;
} NPDeviceContext3DConfig;
typedef enum _NPDeviceContext3DError {
// No error has ocurred.
NPDeviceContext3DError_NoError,
// The size of a command was invalid.
NPDeviceContext3DError_InvalidSize,
// An offset was out of bounds.
NPDeviceContext3DError_OutOfBounds,
// A command was not recognized.
NPDeviceContext3DError_UnknownCommand,
// The arguments to a command were invalid.
NPDeviceContext3DError_InvalidArguments,
// The 3D context was lost, for example due to a power management event. The
// context must be destroyed and a new one created.
NPDeviceContext3DError_LostContext,
// Any other error.
NPDeviceContext3DError_GenericError
} NPDeviceContext3DError;
typedef struct _NPDeviceContext3D NPDeviceContext3D;
typedef void (*NPDeviceContext3DRepaintPtr)(NPP npp,
NPDeviceContext3D* context);
// TODO(apatrick): this need not be exposed when we switch over to the new
// device API. It's layout can also be implementation dependent.
typedef struct _NPDeviceContext3D
{
void* reserved;
// If true, then a flush will only complete once the get offset has advanced
// on the GPU thread. If false, then the get offset might have changed but
// the GPU thread will respond as quickly as possible without guaranteeing
// having made any progress in executing pending commands. Set to true
// to ensure that progress is made or when flushing in a loop waiting for the
// GPU to reach a certain state, for example in advancing beyond a particular
// token. Set to false when flushing to query the current state, for example
// whether an error has occurred.
bool waitForProgress;
// Buffer in which commands are stored.
void* commandBuffer;
int32_t commandBufferSize;
// Offset in command buffer reader has reached. Synchronized on flush.
int32_t getOffset;
// Offset in command buffer writer has reached. Synchronized on flush.
int32_t putOffset;
// Last processed token. Synchronized on flush.
int32_t token;
// Callback invoked on the main thread when the context must be repainted.
// TODO(apatrick): move this out of the context struct like the rest of the
// fields.
NPDeviceContext3DRepaintPtr repaintCallback;
// Error status. Synchronized on flush.
NPDeviceContext3DError error;
} NPDeviceContext3D;
/* Begin 3D specific portion of experimental device API */
/* Device buffer ID reserved for command buffer */
enum {
NP3DCommandBufferId = 0
};
/* 3D attributes */
enum {
/* Example GetConfigAttribs attributes. See EGL 1.4 spec. */
/* These may be passed to GetConfigAttribs. */
NP3DAttrib_BufferSize = 0x3020,
NP3DAttrib_AlphaSize = 0x3021,
NP3DAttrib_BlueSize = 0x3022,
NP3DAttrib_GreenSize = 0x3023,
NP3DAttrib_RedSize = 0x3024,
NP3DAttrib_DepthSize = 0x3025,
NP3DAttrib_StencilSize = 0x3026,
NP3DAttrib_SurfaceType = 0x3033,
/* Example CreateContext attributes. See EGL 1.4 spec. */
/* These may be passed to CreateContext. */
NP3DAttrib_SwapBehavior = 0x3093,
NP3DAttrib_MultisampleResolve = 0x3099,
/* Size of command buffer in 32-bit entries. */
/* This may be passed to CreateContext as an input or SynchronizeContext as */
/* an output. */
NP3DAttrib_CommandBufferSize = 0x10000000,
/* These may be passed to SynchronizeContext. */
/* Offset in command buffer writer has reached. In / out.*/
NP3DAttrib_PutOffset,
/* Offset in command buffer reader has reached. Out only. */
NP3DAttrib_GetOffset,
/* Last processed token. Out only. */
NP3DAttrib_Token
};
/* 3D callbacks */
enum {
/* This callback is invoked whenever the plugin must repaint everything. */
/* This might be because the window manager must repaint a window or */
/* the context has been lost, for example a power management event. */
NP3DCallback_Repaint = 1
};
/* Flags for NPConfig3DOutAttrib_SurfaceType */
enum {
NP3DSurfaceType_MultisampleResolveBox = 0x0200,
NP3DSurfaceType_SwapBehaviorPreserved = 0x0400
};
/* Values for NPConfig3DInAttrib_SwapBehavior */
enum {
NP3DSwapBehavior_Preserved = 0x3094,
NP3DSwapBehavior_Destroyed = 0x3095
};
/* Values for NPConfig3DInAttrib_MultisampleResolve */
enum {
NP3DMultisampleResolve_Default = 0x309A,
NP3DMultisampleResolve_Box = 0x309B
};
/* End 3D specific API */
/* Audio --------------------------------------------------------------------*/
#define NPPepperAudioDevice 3
/* min & max sample frame count */
typedef enum {
NPAudioMinSampleFrameCount = 64,
NPAudioMaxSampleFrameCount = 32768
} NPAudioSampleFrameCounts;
/* supported sample rates */
typedef enum {
NPAudioSampleRate44100Hz = 44100,
NPAudioSampleRate48000Hz = 48000,
NPAudioSampleRate96000Hz = 96000
} NPAudioSampleRates;
/* supported sample formats */
typedef enum {
NPAudioSampleTypeInt16 = 0,
NPAudioSampleTypeFloat32 = 1
} NPAudioSampleTypes;
/* supported channel layouts */
/* there is code that depends on these being the actual number of channels */
typedef enum {
NPAudioChannelNone = 0,
NPAudioChannelMono = 1,
NPAudioChannelStereo = 2,
NPAudioChannelThree = 3,
NPAudioChannelFour = 4,
NPAudioChannelFive = 5,
NPAudioChannelFiveOne = 6,
NPAudioChannelSeven = 7,
NPAudioChannelSevenOne = 8
} NPAudioChannels;
/* audio context states */
typedef enum {
NPAudioContextStateCallback = 0,
NPAudioContextStateUnderrunCounter = 1
} NPAudioContextStates;
/* audio context state values */
typedef enum {
NPAudioCallbackStop = 0,
NPAudioCallbackStart = 1
} NPAudioContextStateValues;
/* audio query capabilities */
typedef enum {
NPAudioCapabilitySampleRate = 0,
NPAudioCapabilitySampleType = 1,
NPAudioCapabilitySampleFrameCount = 2,
NPAudioCapabilitySampleFrameCount44100Hz = 3,
NPAudioCapabilitySampleFrameCount48000Hz = 4,
NPAudioCapabilitySampleFrameCount96000Hz = 5,
NPAudioCapabilityOutputChannelMap = 6,
NPAudioCapabilityInputChannelMap = 7
} NPAudioCapabilities;
typedef struct _NPDeviceContextAudio NPDeviceContextAudio;
/* user supplied callback function */
typedef void (*NPAudioCallback)(NPDeviceContextAudio *context);
typedef struct _NPDeviceContextAudioConfig {
int32_t sampleRate;
int32_t sampleType;
int32_t outputChannelMap;
int32_t inputChannelMap;
int32_t sampleFrameCount;
uint32_t startThread;
uint32_t flags;
NPAudioCallback callback;
void *userData;
} NPDeviceContextAudioConfig;
struct _NPDeviceContextAudio {
NPDeviceContextAudioConfig config;
void *outBuffer;
void *inBuffer;
void *reserved;
};
/* Printing related APIs ---------------------------------------------------*/
/* Being a print operation. Returns the total number of pages to print at the
* given printableArea size and DPI. printableArea is in points (a point is 1/72
* of an inch). The plugin is expected to remember the values of printableArea
* and printerDPI for use in subsequent print interface calls. These values
* should be cleared in printEnd. */
typedef NPError (*NPPPrintBeginPtr) (
NPP instance,
NPRect* printableArea,
int32_t printerDPI,
int32_t* numPages);
/* Returns the required raster dimensions for the given page. */
typedef NPError (*NPPGetRasterDimensionsPtr) (
NPP instance,
int32_t pageNumber,
int32_t* widthInPixels,
int32_t* heightInPixels);
/* Prints the specified page This allows the plugin to print a raster output. */
typedef NPError (*NPPPrintPageRasterPtr) (
NPP instance,
int32_t pageNumber,
NPDeviceContext2D* printSurface);
/* Ends the print operation */
typedef NPError (*NPPPrintEndPtr) (NPP instance);
/* TODO(sanjeevr) : Provide a vector interface for printing. We need to decide
* on a vector format that can support embedded fonts. A vector format will
* greatly reduce the size of the required output buffer. */
typedef struct _NPPPrintExtensions {
NPPPrintBeginPtr printBegin;
NPPGetRasterDimensionsPtr getRasterDimensions;
NPPPrintPageRasterPtr printPageRaster;
NPPPrintEndPtr printEnd;
} NPPPrintExtensions;
/* Returns NULL if the plugin does not support print extensions */
typedef NPPPrintExtensions* (*NPPGetPrintExtensionsPtr)(NPP instance);
/* Find ---------------------------------------------------------------------*/
/* Finds the given UTF-8 text starting at the current selection. The number of
* results will be updated asynchronously via numberOfFindResultsChanged. Note
* that multiple StartFind calls can happen before StopFind is called in the
* case of the search term changing. */
typedef NPError (*NPPStartFindPtr) (
NPP instance,
const char* text,
bool caseSensitive);
/* Go to the next/previous result. */
typedef NPError (*NPPSelectFindResultPtr) (
NPP instance,
bool forward);
/* Tells the plugin that the find operation has stopped, so it should clear
* any highlighting. */
typedef NPError (*NPPStopFindPtr) (
NPP instance);
typedef struct _NPPFindExtensions {
NPPStartFindPtr startFind;
NPPSelectFindResultPtr selectFindResult;
NPPStopFindPtr stopFind;
} NPPFindExtensions;
/* Returns NULL if the plugin does not support find extensions. */
typedef NPPFindExtensions* (*NPPGetFindExtensionsPtr)(NPP instance);
/* Zooms plugins. 0 means reset, -1 means zoom out, and +1 means zoom in. */
typedef NPError (*NPPZoomPtr) (
NPP instance,
int factor);
typedef NPError (*NPPWidgetPropertyChangedPtr) (
NPP instance,
NPWidgetID id,
NPWidgetProperty property);
/* Tells the plugin to copy the selected text */
typedef NPError (*NPPCopyPtr) (
NPP instance);
typedef struct _NPPExtensions {
NPPGetPrintExtensionsPtr getPrintExtensions;
NPPGetFindExtensionsPtr getFindExtensions;
NPPZoomPtr zoom;
NPPWidgetPropertyChangedPtr widgetPropertyChanged;
NPPCopyPtr copy;
} NPPExtensions;
#endif /* _NP_EXTENSIONS_H_ */
|