diff options
Diffstat (limited to 'WebKit/android/plugins/android_npapi.h')
| -rw-r--r-- | WebKit/android/plugins/android_npapi.h | 311 |
1 files changed, 268 insertions, 43 deletions
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index f64c8ce..e50f031 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -24,10 +24,10 @@ */ /* Defines the android-specific types and functions as part of npapi - + In particular, defines the window and event types that are passed to NPN_GetValue, NPP_SetWindow and NPP_HandleEvent. - + To minimize what native libraries the plugin links against, some functionality is provided via function-ptrs (e.g. time, sound) */ @@ -49,6 +49,17 @@ enum ANPBitmapFormats { }; typedef int32_t ANPBitmapFormat; +struct ANPPixelPacking { + uint8_t AShift; + uint8_t ABits; + uint8_t RShift; + uint8_t RBits; + uint8_t GShift; + uint8_t GBits; + uint8_t BShift; + uint8_t BBits; +}; + struct ANPBitmap { void* baseAddr; ANPBitmapFormat format; @@ -91,9 +102,9 @@ typedef uint32_t ANPMatrixFlag; // NPN_GetValue /* queries for a specific ANPInterface. - + Maybe called with NULL for the NPP instance - + NPN_GetValue(inst, interface_enum, ANPInterface*) */ #define kLogInterfaceV0_ANPGetValue ((NPNVariable)1000) @@ -101,22 +112,25 @@ typedef uint32_t ANPMatrixFlag; #define kCanvasInterfaceV0_ANPGetValue ((NPNVariable)1002) #define kMatrixInterfaceV0_ANPGetValue ((NPNVariable)1003) #define kPaintInterfaceV0_ANPGetValue ((NPNVariable)1004) -#define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1005) -#define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1006) +#define kPathInterfaceV0_ANPGetValue ((NPNVariable)1005) +#define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1006) +#define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1007) +#define kBitmapInterfaceV0_ANPGetValue ((NPNVariable)1008) +#define kSurfaceInterfaceV0_ANPGetValue ((NPNVariable)1009) /* queries for which drawing model is desired (for the draw event) - + Should be called inside NPP_New(...) - + NPN_GetValue(inst, ANPSupportedDrawingModel_EnumValue, uint32_t* bits) */ #define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000) /////////////////////////////////////////////////////////////////////////////// -// NPN_GetValue +// NPN_SetValue + +/** Request to set the drawing model. -/** Reqeust to set the drawing model. - NPN_SetValue(inst, ANPRequestDrawingModel_EnumValue, (void*)foo_DrawingModel) */ #define kRequestDrawingModel_ANPSetValue ((NPPVariable)1000) @@ -130,14 +144,33 @@ enum ANPDrawingModels { /** Draw into a bitmap from the browser thread in response to a Draw event. NPWindow->window is reserved (ignore) */ - kBitmap_ANPDrawingModel = 0, + kBitmap_ANPDrawingModel = 0, + kSurface_ANPDrawingModel = 1, }; typedef int32_t ANPDrawingModel; +/** Request to receive/disable events. If the pointer is NULL then all input will + be disabled. Otherwise, the input type will be enabled iff its corresponding + bit in the EventFlags bit field is set. + + NPN_SetValue(inst, ANPAcceptEvents, (void*)EventFlags) + */ +#define kAcceptEvents_ANPSetValue ((NPPVariable)1001) + +/* The EventFlags are a set of bits used to determine which types of input the + plugin wishes to receive. For example, if the value is 0x03 then both key + and touch events will be provided to the plugin. + */ +enum ANPEventFlag { + kKey_ANPEventFlag = 0x01, + kTouch_ANPEventFlag = 0x02, +}; +typedef uint32_t ANPEventFlags; + /* Interfaces provide additional functionality to the plugin via function ptrs. Once an interface is retrived, it is valid for the lifetime of the plugin (just like browserfuncs). - + All ANPInterfaces begin with an inSize field, which must be set by the caller (plugin) with the number of bytes allocated for the interface. e.g. SomeInterface si; si.inSize = sizeof(si); browser->getvalue(..., &si); @@ -159,6 +192,50 @@ struct ANPLogInterfaceV0 : ANPInterface { void (*log)(NPP instance, ANPLogType, const char format[], ...); }; +struct ANPBitmapInterfaceV0 : ANPInterface { + /** Returns true if the specified bitmap format is supported, and if packing + is non-null, sets it to the packing info for that format. + */ + bool (*getPixelPacking)(ANPBitmapFormat, ANPPixelPacking* packing); +}; + +/** The surfaceType is the mechanism by which the plugin informs the native + libraries which type of surface view it wishes to use. + */ +enum ANPSurfaceTypes { + kRGBA_ANPSurfaceType = 0 +}; +typedef int32_t ANPSurfaceType; + +/** The ANPSurface acts as a handle between the plugin and the native libraries + that render the surface to the screen. + */ +struct ANPSurface; + +struct ANPSurfaceInterfaceV0 : ANPInterface { + /** Creates a new surface handle based on the given surface type. If the + given surface type is not supported then NULL is returned. + */ + ANPSurface* (*newSurface)(NPP instance, ANPSurfaceType); + /** Given a valid surface handle (i.e. one created by calling newSurface) + the underlying surface is removed and the pointer is set to NULL. + */ + void (*deleteSurface)(ANPSurface* surface); + /** Locks the surface from manipulation by other threads and provides a bitmap + to be written to. The dirtyRect param specifies which portion of the + bitmap will be written to. If the dirtyRect is NULL then the entire + surface will be considered dirty. If the lock was successful the function + will return true and the bitmap will be set to point to a valid bitmap. + If not the function will return false and the bitmap will be set to NULL. + */ + bool (*lock)(ANPSurface* surface, ANPBitmap* bitmap, ANPRectI* dirtyRect); + /** Given a locked surface handle (i.e. result of a successful call to lock) + the surface is unlocked and the contents of the bitmap, specifically + those inside the dirtyRect are written to the screen. + */ + void (*unlock)(ANPSurface* surface); +}; + struct ANPMatrixInterfaceV0 : ANPInterface { /* Return a new identity matrix */ @@ -212,9 +289,70 @@ struct ANPMatrixInterfaceV0 : ANPInterface { int32_t count); }; +struct ANPPathInterfaceV0 : ANPInterface { + /* Return a new path */ + ANPPath* (*newPath)(); + + /* Delete a path previously allocated by ANPPath() */ + void (*deletePath)(ANPPath*); + + /* Make a deep copy of the src path, into the dst path (already allocated + by the caller). + */ + void (*copy)(ANPPath* dst, const ANPPath* src); + + /* Returns true if the two paths are the same (i.e. have the same points) + */ + bool (*equal)(const ANPPath* path0, const ANPPath* path1); + + /* Remove any previous points, initializing the path back to empty. */ + void (*reset)(ANPPath*); + + /* Return true if the path is empty (has no lines, quads or cubics). */ + bool (*isEmpty)(const ANPPath*); + + /* Return the path's bounds in bounds. */ + void (*getBounds)(const ANPPath*, ANPRectF* bounds); + + void (*moveTo)(ANPPath*, float x, float y); + void (*lineTo)(ANPPath*, float x, float y); + void (*quadTo)(ANPPath*, float x0, float y0, float x1, float y1); + void (*cubicTo)(ANPPath*, float x0, float y0, float x1, float y1, + float x2, float y2); + void (*close)(ANPPath*); + + /* Offset the src path by [dx, dy]. If dst is null, apply the + change directly to the src path. If dst is not null, write the + changed path into dst, and leave the src path unchanged. In that case + dst must have been previously allocated by the caller. + */ + void (*offset)(ANPPath* src, float dx, float dy, ANPPath* dst); + + /* Transform the path by the matrix. If dst is null, apply the + change directly to the src path. If dst is not null, write the + changed path into dst, and leave the src path unchanged. In that case + dst must have been previously allocated by the caller. + */ + void (*transform)(ANPPath* src, const ANPMatrix*, ANPPath* dst); +}; + +/** ANPColor is always defined to have the same packing on all platforms, and + it is always unpremultiplied. + + This is in contrast to 32bit format(s) in bitmaps, which are premultiplied, + and their packing may vary depending on the platform, hence the need for + ANPBitmapInterface::getPixelPacking() + */ typedef uint32_t ANPColor; +#define ANPColor_ASHIFT 24 +#define ANPColor_RSHIFT 16 +#define ANPColor_GSHIFT 8 +#define ANPColor_BSHIFT 0 #define ANP_MAKE_COLOR(a, r, g, b) \ - (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) + (((a) << ANPColor_ASHIFT) | \ + ((r) << ANPColor_RSHIFT) | \ + ((g) << ANPColor_GSHIFT) | \ + ((b) << ANPColor_BSHIFT)) enum ANPPaintFlag { kAntiAlias_ANPPaintFlag = 1 << 0, @@ -266,6 +404,8 @@ enum ANPTypefaceStyles { }; typedef uint32_t ANPTypefaceStyle; +typedef uint32_t ANPFontTableTag; + struct ANPFontMetrics { //! The greatest distance above the baseline for any glyph (will be <= 0) float fTop; @@ -303,7 +443,7 @@ struct ANPTypefaceInterfaceV0 : ANPInterface { */ ANPTypeface* (*createFromTypeface)(const ANPTypeface* family, ANPTypefaceStyle); - + /** Return the owner count of the typeface. A newly created typeface has an owner count of 1. When the owner count is reaches 0, the typeface is deleted. @@ -318,29 +458,33 @@ struct ANPTypefaceInterfaceV0 : ANPInterface { the typeface is deleted. */ void (*unref)(ANPTypeface*); - + /** Return the style bits for the specified typeface */ ANPTypefaceStyle (*getStyle)(const ANPTypeface*); + + /** Return the path name for the font directory, or NULL if not supported + */ + const char* (*getFontDirectoryPath)(); }; struct ANPPaintInterfaceV0 : ANPInterface { /* Return a new paint object, which holds all of the color and style attributes that affect how things (geometry, text, bitmaps) are drawn in a ANPCanvas. - + The paint that is returned is not tied to any particular plugin instance, but it must only be accessed from one thread at a time. */ ANPPaint* (*newPaint)(); void (*deletePaint)(ANPPaint*); - + ANPPaintFlags (*getFlags)(const ANPPaint*); void (*setFlags)(ANPPaint*, ANPPaintFlags); - + ANPColor (*getColor)(const ANPPaint*); void (*setColor)(ANPPaint*, ANPColor); - + ANPPaintStyle (*getStyle)(const ANPPaint*); void (*setStyle)(ANPPaint*, ANPPaintStyle); @@ -352,7 +496,7 @@ struct ANPPaintInterfaceV0 : ANPInterface { void (*setStrokeMiter)(ANPPaint*, float); void (*setStrokeCap)(ANPPaint*, ANPPaintCap); void (*setStrokeJoin)(ANPPaint*, ANPPaintJoin); - + ANPTextEncoding (*getTextEncoding)(const ANPPaint*); ANPPaintAlign (*getTextAlign)(const ANPPaint*); float (*getTextSize)(const ANPPaint*); @@ -380,7 +524,7 @@ struct ANPPaintInterfaceV0 : ANPInterface { */ float (*measureText)(ANPPaint*, const void* text, uint32_t byteLength, ANPRectF* bounds); - + /** Return the number of unichars specifed by the text. If widths is not null, returns the array of advance widths for each unichar. @@ -388,7 +532,7 @@ struct ANPPaintInterfaceV0 : ANPInterface { */ int (*getTextWidths)(ANPPaint*, const void* text, uint32_t byteLength, float widths[], ANPRectF bounds[]); - + /** Return in metrics the spacing values for text, respecting the paint's typeface and pointsize, and return the spacing between lines (descent - ascent + leading). If metrics is NULL, it will be ignored. @@ -404,7 +548,7 @@ struct ANPCanvasInterfaceV0 : ANPInterface { goes out of scope. In the case of creating a canvas to draw into the pixels provided by kDraw_ANPEventType, those pixels are only while handling that event. - + The canvas that is returned is not tied to any particular plugin instance, but it must only be accessed from one thread at a time. */ @@ -433,9 +577,11 @@ struct ANPCanvasInterfaceV0 : ANPInterface { current clip is empty, return false and ignore the bounds argument. */ bool (*getDeviceClipBounds)(ANPCanvas*, ANPRectI* bounds); - + void (*drawColor)(ANPCanvas*, ANPColor); void (*drawPaint)(ANPCanvas*, const ANPPaint*); + void (*drawLine)(ANPCanvas*, float x0, float y0, float x1, float y1, + const ANPPaint*); void (*drawRect)(ANPCanvas*, const ANPRectF*, const ANPPaint*); void (*drawOval)(ANPCanvas*, const ANPRectF*, const ANPPaint*); void (*drawPath)(ANPCanvas*, const ANPPath*, const ANPPaint*); @@ -455,7 +601,7 @@ struct ANPWindowInterfaceV0 : ANPInterface { describing the subset of the window that will be drawn to (may be null) return true if the bitmap for that window can be accessed, and if so, fill out the specified ANPBitmap to point to the window's pixels. - + When drawing is complete, call unlock(window) */ bool (*lockRect)(void* window, const ANPRectI* inval, ANPBitmap*); @@ -468,6 +614,26 @@ struct ANPWindowInterfaceV0 : ANPInterface { results. If lock returned false, unlock should not be called. */ void (*unlock)(void* window); + /** Registers a set of rectangles that the plugin would like to keep on + screen. The rectangles are listed in order of priority with the highest + priority rectangle in location rects[0]. The browser will attempt to keep + as many of the rectangles on screen as possible and will scroll them into + view in response to the invocation of this method and other various events. + The count specifies how many rectangles are in the array. If the count is + zero it signals the browser that any existing rectangles should be cleared + and no rectangles will be tracked. + */ + void (*setVisibleRects)(NPP instance, const ANPRectI rects[], int32_t count); + /** Clears any rectangles that are being tracked as a result of a call to + setVisibleRects. This call is equivalent to setVisibleRect(inst, NULL, 0). + */ + void (*clearVisibleRects)(NPP instance); + /** Given a boolean value of true the device will be requested to provide + a keyboard. A value of false will result in a request to hide the + keyboard. Further, the on-screen keyboard will not be displayed if a + physical keyboard is active. + */ + void (*showKeyboard)(NPP instance, bool value); }; /////////////////////////////////////////////////////////////////////////////// @@ -517,11 +683,11 @@ typedef int32_t ANPAudioEvent; /** Called to feed sample data to the track. This will be called in a separate thread. However, you may call trackStop() from the callback (but you cannot delete the track). - + For example, when you have written the last chunk of sample data, you can immediately call trackStop(). This will take effect after the current buffer has been played. - + The "user" parameter is the same value that was passed to newTrack() */ typedef void (*ANPAudioCallbackProc)(ANPAudioEvent event, void* user, @@ -552,10 +718,13 @@ struct ANPAudioTrackInterfaceV0 : ANPInterface { // HandleEvent enum ANPEventTypes { - kNull_ANPEventType = 0, - kKey_ANPEventType = 1, - kTouch_ANPEventType = 2, - kDraw_ANPEventType = 3, + kNull_ANPEventType = 0, + kKey_ANPEventType = 1, + kMouse_ANPEventType = 2, + kTouch_ANPEventType = 3, + kDraw_ANPEventType = 4, + kLifecycle_ANPEventType = 5, + kSurface_ANPEventType = 6, }; typedef int32_t ANPEventType; @@ -575,21 +744,45 @@ enum ANPKeyModifiers { // bit-field containing some number of ANPKeyModifier bits typedef uint32_t ANPKeyModifier; +enum ANPMouseActions { + kDown_ANPMouseAction = 0, + kUp_ANPMouseAction = 1, +}; +typedef int32_t ANPMouseAction; + enum ANPTouchActions { - kDown_ANPTouchAction = 0, - kUp_ANPTouchAction = 1, + kDown_ANPTouchAction = 0, + kUp_ANPTouchAction = 1, + kMove_ANPTouchAction = 2, + kCancel_ANPTouchAction = 3, }; typedef int32_t ANPTouchAction; -struct ANPDrawContext { - ANPDrawingModel model; - // relative to (0,0) in top-left of your plugin - ANPRectI clip; - // use based on the value in model - union { - ANPBitmap bitmap; - } data; +enum ANPLifecycleActions { + kPause_ANPLifecycleAction = 0, + kResume_ANPLifecycleAction = 1, + kGainFocus_ANPLifecycleAction = 2, + kLoseFocus_ANPLifecycleAction = 3, + kFreeMemory_ANPLifecycleAction = 4, +}; +typedef uint32_t ANPLifecycleAction; + +enum ANPSurfaceActions { + /** The surface has been created and is ready to be used. Any calls to + lock/unlock before this action will fail. + */ + kCreated_ANPSurfaceAction = 0, + /** The surface's dimension has changed. + */ + kChanged_ANPSurfaceAction = 1, + /** The surface has been destroyed. This happens when the view system has + remove the surface (possibly due to the plugin being offscreen). Calls + to lock/unlock will fail after this action and before + kCreate_ANPSurfaceAction. + */ + kDestroyed_ANPSurfaceAction = 2, }; +typedef uint32_t ANPSurfaceAction; /* This is what is passed to NPP_HandleEvent() */ struct ANPEvent { @@ -606,12 +799,44 @@ struct ANPEvent { int32_t unichar; // 0 if there is no value } key; struct { + ANPMouseAction action; + int32_t x; // relative to your "window" (0...width) + int32_t y; // relative to your "window" (0...height) + } mouse; + struct { ANPTouchAction action; ANPKeyModifier modifiers; int32_t x; // relative to your "window" (0...width) int32_t y; // relative to your "window" (0...height) } touch; - ANPDrawContext drawContext; + struct { + ANPLifecycleAction action; + } lifecycle; + struct { + ANPDrawingModel model; + // relative to (0,0) in top-left of your plugin + ANPRectI clip; + // use based on the value in model + union { + ANPBitmap bitmap; + } data; + } draw; + struct { + ANPSurfaceAction action; + /** This union is based on the value of action and contains data + specific to the given action. + */ + union { + /** This struct is filled in only during the + kChanged_ANPSurfaceAction action. For all other actions, + this struct is undefined. + */ + struct { + int32_t width; + int32_t height; + } changed; + } data; + } surface; int32_t other[8]; } data; }; |
