michael@0: /* michael@0: * Copyright 2009, The Android Open Source Project michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions michael@0: * are met: michael@0: * * Redistributions of source code must retain the above copyright michael@0: * notice, this list of conditions and the following disclaimer. michael@0: * * Redistributions in binary form must reproduce the above copyright michael@0: * notice, this list of conditions and the following disclaimer in the michael@0: * documentation and/or other materials provided with the distribution. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY michael@0: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE michael@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR michael@0: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR michael@0: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, michael@0: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, michael@0: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR michael@0: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY michael@0: * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT michael@0: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE michael@0: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: */ michael@0: michael@0: /* Defines the android-specific types and functions as part of npapi michael@0: michael@0: In particular, defines the window and event types that are passed to michael@0: NPN_GetValue, NPP_SetWindow and NPP_HandleEvent. michael@0: michael@0: To minimize what native libraries the plugin links against, some michael@0: functionality is provided via function-ptrs (e.g. time, sound) michael@0: */ michael@0: michael@0: #ifndef android_npapi_H michael@0: #define android_npapi_H michael@0: michael@0: #include michael@0: #include michael@0: #include "npapi.h" michael@0: #include "GLDefs.h" michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: // General types michael@0: michael@0: enum ANPBitmapFormats { michael@0: kUnknown_ANPBitmapFormat = 0, michael@0: kRGBA_8888_ANPBitmapFormat = 1, michael@0: kRGB_565_ANPBitmapFormat = 2 michael@0: }; michael@0: typedef int32_t ANPBitmapFormat; michael@0: michael@0: struct ANPPixelPacking { michael@0: uint8_t AShift; michael@0: uint8_t ABits; michael@0: uint8_t RShift; michael@0: uint8_t RBits; michael@0: uint8_t GShift; michael@0: uint8_t GBits; michael@0: uint8_t BShift; michael@0: uint8_t BBits; michael@0: }; michael@0: michael@0: struct ANPBitmap { michael@0: void* baseAddr; michael@0: ANPBitmapFormat format; michael@0: int32_t width; michael@0: int32_t height; michael@0: int32_t rowBytes; michael@0: }; michael@0: michael@0: struct ANPRectF { michael@0: float left; michael@0: float top; michael@0: float right; michael@0: float bottom; michael@0: }; michael@0: michael@0: struct ANPRectI { michael@0: int32_t left; michael@0: int32_t top; michael@0: int32_t right; michael@0: int32_t bottom; michael@0: }; michael@0: michael@0: struct ANPCanvas; michael@0: struct ANPMatrix; michael@0: struct ANPPaint; michael@0: struct ANPPath; michael@0: struct ANPRegion; michael@0: struct ANPTypeface; michael@0: michael@0: enum ANPMatrixFlags { michael@0: kIdentity_ANPMatrixFlag = 0, michael@0: kTranslate_ANPMatrixFlag = 0x01, michael@0: kScale_ANPMatrixFlag = 0x02, michael@0: kAffine_ANPMatrixFlag = 0x04, michael@0: kPerspective_ANPMatrixFlag = 0x08, michael@0: }; michael@0: typedef uint32_t ANPMatrixFlag; michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: // NPN_GetValue michael@0: michael@0: /** queries for a specific ANPInterface. michael@0: michael@0: Maybe called with NULL for the NPP instance michael@0: michael@0: NPN_GetValue(inst, interface_enum, ANPInterface*) michael@0: */ michael@0: #define kLogInterfaceV0_ANPGetValue ((NPNVariable)1000) michael@0: #define kAudioTrackInterfaceV0_ANPGetValue ((NPNVariable)1001) michael@0: #define kCanvasInterfaceV0_ANPGetValue ((NPNVariable)1002) michael@0: #define kMatrixInterfaceV0_ANPGetValue ((NPNVariable)1003) michael@0: #define kPaintInterfaceV0_ANPGetValue ((NPNVariable)1004) michael@0: #define kPathInterfaceV0_ANPGetValue ((NPNVariable)1005) michael@0: #define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1006) michael@0: #define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1007) michael@0: #define kBitmapInterfaceV0_ANPGetValue ((NPNVariable)1008) michael@0: #define kSurfaceInterfaceV0_ANPGetValue ((NPNVariable)1009) michael@0: #define kSystemInterfaceV0_ANPGetValue ((NPNVariable)1010) michael@0: #define kEventInterfaceV0_ANPGetValue ((NPNVariable)1011) michael@0: michael@0: #define kAudioTrackInterfaceV1_ANPGetValue ((NPNVariable)1012) michael@0: #define kOpenGLInterfaceV0_ANPGetValue ((NPNVariable)1013) michael@0: #define kWindowInterfaceV1_ANPGetValue ((NPNVariable)1014) michael@0: #define kVideoInterfaceV0_ANPGetValue ((NPNVariable)1015) michael@0: #define kSystemInterfaceV1_ANPGetValue ((NPNVariable)1016) michael@0: #define kSystemInterfaceV2_ANPGetValue ((NPNVariable)1017) michael@0: #define kWindowInterfaceV2_ANPGetValue ((NPNVariable)1018) michael@0: #define kNativeWindowInterfaceV0_ANPGetValue ((NPNVariable)1019) michael@0: #define kVideoInterfaceV1_ANPGetValue ((NPNVariable)1020) michael@0: michael@0: /** queries for the drawing models supported on this device. michael@0: michael@0: NPN_GetValue(inst, kSupportedDrawingModel_ANPGetValue, uint32_t* bits) michael@0: */ michael@0: #define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000) michael@0: michael@0: /** queries for the context (android.content.Context) of the plugin. If no michael@0: instance is specified the application's context is returned. If the instance michael@0: is given then the context returned is identical to the context used to michael@0: create the webview in which that instance resides. michael@0: michael@0: NOTE: Holding onto a non-application context after your instance has been michael@0: destroyed will cause a memory leak. Refer to the android documentation to michael@0: determine what context is best suited for your particular scenario. michael@0: michael@0: NPN_GetValue(inst, kJavaContext_ANPGetValue, jobject context) michael@0: */ michael@0: #define kJavaContext_ANPGetValue ((NPNVariable)2001) michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: // NPN_SetValue michael@0: michael@0: /** Request to set the drawing model. SetValue will return false if the drawing michael@0: model is not supported or has insufficient information for configuration. michael@0: michael@0: NPN_SetValue(inst, kRequestDrawingModel_ANPSetValue, (void*)foo_ANPDrawingModel) michael@0: */ michael@0: #define kRequestDrawingModel_ANPSetValue ((NPPVariable)1000) michael@0: michael@0: /** These are used as bitfields in ANPSupportedDrawingModels_EnumValue, michael@0: and as-is in ANPRequestDrawingModel_EnumValue. The drawing model determines michael@0: how to interpret the ANPDrawingContext provided in the Draw event and how michael@0: to interpret the NPWindow->window field. michael@0: */ michael@0: enum ANPDrawingModels { michael@0: /** Draw into a bitmap from the browser thread in response to a Draw event. michael@0: NPWindow->window is reserved (ignore) michael@0: */ michael@0: kBitmap_ANPDrawingModel = 1 << 0, michael@0: /** Draw into a surface (e.g. raster, openGL, etc.) using the Java surface michael@0: interface. When this model is used the browser will invoke the Java michael@0: class specified in the plugin's apk manifest. From that class the browser michael@0: will invoke the appropriate method to return an an instance of a android michael@0: Java View. The instance is then embedded in the html. The plugin can then michael@0: manipulate the view as it would any normal Java View in android. michael@0: michael@0: Unlike the bitmap model, a surface model is opaque so no html content michael@0: behind the plugin will be visible. Unless the plugin needs to be michael@0: transparent the surface model should be chosen over the bitmap model as michael@0: it will have better performance. michael@0: michael@0: Further, a plugin can manipulate some surfaces in native code using the michael@0: ANPSurfaceInterface. This interface can be used to manipulate Java michael@0: objects that extend Surface.class by allowing them to access the michael@0: surface's underlying bitmap in native code. For instance, if a raster michael@0: surface is used the plugin can lock, draw directly into the bitmap, and michael@0: unlock the surface in native code without making JNI calls to the Java michael@0: surface object. michael@0: */ michael@0: kSurface_ANPDrawingModel = 1 << 1, michael@0: kOpenGL_ANPDrawingModel = 1 << 2, michael@0: }; michael@0: typedef int32_t ANPDrawingModel; michael@0: michael@0: /** Request to receive/disable events. If the pointer is NULL then all flags will michael@0: be disabled. Otherwise, the event type will be enabled iff its corresponding michael@0: bit in the EventFlags bit field is set. michael@0: michael@0: NPN_SetValue(inst, ANPAcceptEvents, (void*)EventFlags) michael@0: */ michael@0: #define kAcceptEvents_ANPSetValue ((NPPVariable)1001) michael@0: michael@0: /** The EventFlags are a set of bits used to determine which types of events the michael@0: plugin wishes to receive. For example, if the value is 0x03 then both key michael@0: and touch events will be provided to the plugin. michael@0: */ michael@0: enum ANPEventFlag { michael@0: kKey_ANPEventFlag = 0x01, michael@0: kTouch_ANPEventFlag = 0x02, michael@0: }; michael@0: typedef uint32_t ANPEventFlags; michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: // NPP_GetValue michael@0: michael@0: /** Requests that the plugin return a java surface to be displayed. This will michael@0: only be used if the plugin has choosen the kSurface_ANPDrawingModel. michael@0: michael@0: NPP_GetValue(inst, kJavaSurface_ANPGetValue, jobject surface) michael@0: */ michael@0: #define kJavaSurface_ANPGetValue ((NPPVariable)2000) michael@0: michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: // ANDROID INTERFACE DEFINITIONS michael@0: michael@0: /** Interfaces provide additional functionality to the plugin via function ptrs. michael@0: Once an interface is retrieved, it is valid for the lifetime of the plugin michael@0: (just like browserfuncs). michael@0: michael@0: All ANPInterfaces begin with an inSize field, which must be set by the michael@0: caller (plugin) with the number of bytes allocated for the interface. michael@0: e.g. SomeInterface si; si.inSize = sizeof(si); browser->getvalue(..., &si); michael@0: */ michael@0: struct ANPInterface { michael@0: uint32_t inSize; // size (in bytes) of this struct michael@0: }; michael@0: michael@0: enum ANPLogTypes { michael@0: kError_ANPLogType = 0, // error michael@0: kWarning_ANPLogType = 1, // warning michael@0: kDebug_ANPLogType = 2 // debug only (informational) michael@0: }; michael@0: typedef int32_t ANPLogType; michael@0: michael@0: struct ANPLogInterfaceV0 : ANPInterface { michael@0: /** dumps printf messages to the log file michael@0: e.g. interface->log(instance, kWarning_ANPLogType, "value is %d", value); michael@0: */ michael@0: void (*log)(ANPLogType, const char format[], ...); michael@0: }; michael@0: michael@0: struct ANPBitmapInterfaceV0 : ANPInterface { michael@0: /** Returns true if the specified bitmap format is supported, and if packing michael@0: is non-null, sets it to the packing info for that format. michael@0: */ michael@0: bool (*getPixelPacking)(ANPBitmapFormat, ANPPixelPacking* packing); michael@0: }; michael@0: michael@0: struct ANPMatrixInterfaceV0 : ANPInterface { michael@0: /** Return a new identity matrix michael@0: */ michael@0: ANPMatrix* (*newMatrix)(); michael@0: /** Delete a matrix previously allocated by newMatrix() michael@0: */ michael@0: void (*deleteMatrix)(ANPMatrix*); michael@0: michael@0: ANPMatrixFlag (*getFlags)(const ANPMatrix*); michael@0: michael@0: void (*copy)(ANPMatrix* dst, const ANPMatrix* src); michael@0: michael@0: /** Return the matrix values in a float array (allcoated by the caller), michael@0: where the values are treated as follows: michael@0: w = x * [6] + y * [7] + [8]; michael@0: x' = (x * [0] + y * [1] + [2]) / w; michael@0: y' = (x * [3] + y * [4] + [5]) / w; michael@0: */ michael@0: void (*get3x3)(const ANPMatrix*, float[9]); michael@0: /** Initialize the matrix from values in a float array, michael@0: where the values are treated as follows: michael@0: w = x * [6] + y * [7] + [8]; michael@0: x' = (x * [0] + y * [1] + [2]) / w; michael@0: y' = (x * [3] + y * [4] + [5]) / w; michael@0: */ michael@0: void (*set3x3)(ANPMatrix*, const float[9]); michael@0: michael@0: void (*setIdentity)(ANPMatrix*); michael@0: void (*preTranslate)(ANPMatrix*, float tx, float ty); michael@0: void (*postTranslate)(ANPMatrix*, float tx, float ty); michael@0: void (*preScale)(ANPMatrix*, float sx, float sy); michael@0: void (*postScale)(ANPMatrix*, float sx, float sy); michael@0: void (*preSkew)(ANPMatrix*, float kx, float ky); michael@0: void (*postSkew)(ANPMatrix*, float kx, float ky); michael@0: void (*preRotate)(ANPMatrix*, float degrees); michael@0: void (*postRotate)(ANPMatrix*, float degrees); michael@0: void (*preConcat)(ANPMatrix*, const ANPMatrix*); michael@0: void (*postConcat)(ANPMatrix*, const ANPMatrix*); michael@0: michael@0: /** Return true if src is invertible, and if so, return its inverse in dst. michael@0: If src is not invertible, return false and ignore dst. michael@0: */ michael@0: bool (*invert)(ANPMatrix* dst, const ANPMatrix* src); michael@0: michael@0: /** Transform the x,y pairs in src[] by this matrix, and store the results michael@0: in dst[]. The count parameter is treated as the number of pairs in the michael@0: array. It is legal for src and dst to point to the same memory, but michael@0: illegal for the two arrays to partially overlap. michael@0: */ michael@0: void (*mapPoints)(ANPMatrix*, float dst[], const float src[], michael@0: int32_t count); michael@0: }; michael@0: michael@0: struct ANPPathInterfaceV0 : ANPInterface { michael@0: /** Return a new path */ michael@0: ANPPath* (*newPath)(); michael@0: michael@0: /** Delete a path previously allocated by ANPPath() */ michael@0: void (*deletePath)(ANPPath*); michael@0: michael@0: /** Make a deep copy of the src path, into the dst path (already allocated michael@0: by the caller). michael@0: */ michael@0: void (*copy)(ANPPath* dst, const ANPPath* src); michael@0: michael@0: /** Returns true if the two paths are the same (i.e. have the same points) michael@0: */ michael@0: bool (*equal)(const ANPPath* path0, const ANPPath* path1); michael@0: michael@0: /** Remove any previous points, initializing the path back to empty. */ michael@0: void (*reset)(ANPPath*); michael@0: michael@0: /** Return true if the path is empty (has no lines, quads or cubics). */ michael@0: bool (*isEmpty)(const ANPPath*); michael@0: michael@0: /** Return the path's bounds in bounds. */ michael@0: void (*getBounds)(const ANPPath*, ANPRectF* bounds); michael@0: michael@0: void (*moveTo)(ANPPath*, float x, float y); michael@0: void (*lineTo)(ANPPath*, float x, float y); michael@0: void (*quadTo)(ANPPath*, float x0, float y0, float x1, float y1); michael@0: void (*cubicTo)(ANPPath*, float x0, float y0, float x1, float y1, michael@0: float x2, float y2); michael@0: void (*close)(ANPPath*); michael@0: michael@0: /** Offset the src path by [dx, dy]. If dst is null, apply the michael@0: change directly to the src path. If dst is not null, write the michael@0: changed path into dst, and leave the src path unchanged. In that case michael@0: dst must have been previously allocated by the caller. michael@0: */ michael@0: void (*offset)(ANPPath* src, float dx, float dy, ANPPath* dst); michael@0: michael@0: /** Transform the path by the matrix. If dst is null, apply the michael@0: change directly to the src path. If dst is not null, write the michael@0: changed path into dst, and leave the src path unchanged. In that case michael@0: dst must have been previously allocated by the caller. michael@0: */ michael@0: void (*transform)(ANPPath* src, const ANPMatrix*, ANPPath* dst); michael@0: }; michael@0: michael@0: /** ANPColor is always defined to have the same packing on all platforms, and michael@0: it is always unpremultiplied. michael@0: michael@0: This is in contrast to 32bit format(s) in bitmaps, which are premultiplied, michael@0: and their packing may vary depending on the platform, hence the need for michael@0: ANPBitmapInterface::getPixelPacking() michael@0: */ michael@0: typedef uint32_t ANPColor; michael@0: #define ANPColor_ASHIFT 24 michael@0: #define ANPColor_RSHIFT 16 michael@0: #define ANPColor_GSHIFT 8 michael@0: #define ANPColor_BSHIFT 0 michael@0: #define ANP_MAKE_COLOR(a, r, g, b) \ michael@0: (((a) << ANPColor_ASHIFT) | \ michael@0: ((r) << ANPColor_RSHIFT) | \ michael@0: ((g) << ANPColor_GSHIFT) | \ michael@0: ((b) << ANPColor_BSHIFT)) michael@0: michael@0: enum ANPPaintFlag { michael@0: kAntiAlias_ANPPaintFlag = 1 << 0, michael@0: kFilterBitmap_ANPPaintFlag = 1 << 1, michael@0: kDither_ANPPaintFlag = 1 << 2, michael@0: kUnderlineText_ANPPaintFlag = 1 << 3, michael@0: kStrikeThruText_ANPPaintFlag = 1 << 4, michael@0: kFakeBoldText_ANPPaintFlag = 1 << 5, michael@0: }; michael@0: typedef uint32_t ANPPaintFlags; michael@0: michael@0: enum ANPPaintStyles { michael@0: kFill_ANPPaintStyle = 0, michael@0: kStroke_ANPPaintStyle = 1, michael@0: kFillAndStroke_ANPPaintStyle = 2 michael@0: }; michael@0: typedef int32_t ANPPaintStyle; michael@0: michael@0: enum ANPPaintCaps { michael@0: kButt_ANPPaintCap = 0, michael@0: kRound_ANPPaintCap = 1, michael@0: kSquare_ANPPaintCap = 2 michael@0: }; michael@0: typedef int32_t ANPPaintCap; michael@0: michael@0: enum ANPPaintJoins { michael@0: kMiter_ANPPaintJoin = 0, michael@0: kRound_ANPPaintJoin = 1, michael@0: kBevel_ANPPaintJoin = 2 michael@0: }; michael@0: typedef int32_t ANPPaintJoin; michael@0: michael@0: enum ANPPaintAligns { michael@0: kLeft_ANPPaintAlign = 0, michael@0: kCenter_ANPPaintAlign = 1, michael@0: kRight_ANPPaintAlign = 2 michael@0: }; michael@0: typedef int32_t ANPPaintAlign; michael@0: michael@0: enum ANPTextEncodings { michael@0: kUTF8_ANPTextEncoding = 0, michael@0: kUTF16_ANPTextEncoding = 1, michael@0: }; michael@0: typedef int32_t ANPTextEncoding; michael@0: michael@0: enum ANPTypefaceStyles { michael@0: kBold_ANPTypefaceStyle = 1 << 0, michael@0: kItalic_ANPTypefaceStyle = 1 << 1 michael@0: }; michael@0: typedef uint32_t ANPTypefaceStyle; michael@0: michael@0: typedef uint32_t ANPFontTableTag; michael@0: michael@0: struct ANPFontMetrics { michael@0: /** The greatest distance above the baseline for any glyph (will be <= 0) */ michael@0: float fTop; michael@0: /** The recommended distance above the baseline (will be <= 0) */ michael@0: float fAscent; michael@0: /** The recommended distance below the baseline (will be >= 0) */ michael@0: float fDescent; michael@0: /** The greatest distance below the baseline for any glyph (will be >= 0) */ michael@0: float fBottom; michael@0: /** The recommended distance to add between lines of text (will be >= 0) */ michael@0: float fLeading; michael@0: }; michael@0: michael@0: struct ANPTypefaceInterfaceV0 : ANPInterface { michael@0: /** Return a new reference to the typeface that most closely matches the michael@0: requested name and style. Pass null as the name to return michael@0: the default font for the requested style. Will never return null michael@0: michael@0: The 5 generic font names "serif", "sans-serif", "monospace", "cursive", michael@0: "fantasy" are recognized, and will be mapped to their logical font michael@0: automatically by this call. michael@0: michael@0: @param name May be NULL. The name of the font family. michael@0: @param style The style (normal, bold, italic) of the typeface. michael@0: @return reference to the closest-matching typeface. Caller must call michael@0: unref() when they are done with the typeface. michael@0: */ michael@0: ANPTypeface* (*createFromName)(const char name[], ANPTypefaceStyle); michael@0: michael@0: /** Return a new reference to the typeface that most closely matches the michael@0: requested typeface and specified Style. Use this call if you want to michael@0: pick a new style from the same family of the existing typeface. michael@0: If family is NULL, this selects from the default font's family. michael@0: michael@0: @param family May be NULL. The name of the existing type face. michael@0: @param s The style (normal, bold, italic) of the type face. michael@0: @return reference to the closest-matching typeface. Call must call michael@0: unref() when they are done. michael@0: */ michael@0: ANPTypeface* (*createFromTypeface)(const ANPTypeface* family, michael@0: ANPTypefaceStyle); michael@0: michael@0: /** Return the owner count of the typeface. A newly created typeface has an michael@0: owner count of 1. When the owner count is reaches 0, the typeface is michael@0: deleted. michael@0: */ michael@0: int32_t (*getRefCount)(const ANPTypeface*); michael@0: michael@0: /** Increment the owner count on the typeface michael@0: */ michael@0: void (*ref)(ANPTypeface*); michael@0: michael@0: /** Decrement the owner count on the typeface. When the count goes to 0, michael@0: the typeface is deleted. michael@0: */ michael@0: void (*unref)(ANPTypeface*); michael@0: michael@0: /** Return the style bits for the specified typeface michael@0: */ michael@0: ANPTypefaceStyle (*getStyle)(const ANPTypeface*); michael@0: michael@0: /** Some fonts are stored in files. If that is true for the fontID, then michael@0: this returns the byte length of the full file path. If path is not null, michael@0: then the full path is copied into path (allocated by the caller), up to michael@0: length bytes. If index is not null, then it is set to the truetype michael@0: collection index for this font, or 0 if the font is not in a collection. michael@0: michael@0: Note: getFontPath does not assume that path is a null-terminated string, michael@0: so when it succeeds, it only copies the bytes of the file name and michael@0: nothing else (i.e. it copies exactly the number of bytes returned by the michael@0: function. If the caller wants to treat path[] as a C string, it must be michael@0: sure that it is allocated at least 1 byte larger than the returned size, michael@0: and it must copy in the terminating 0. michael@0: michael@0: If the fontID does not correspond to a file, then the function returns michael@0: 0, and the path and index parameters are ignored. michael@0: michael@0: @param fontID The font whose file name is being queried michael@0: @param path Either NULL, or storage for receiving up to length bytes michael@0: of the font's file name. Allocated by the caller. michael@0: @param length The maximum space allocated in path (by the caller). michael@0: Ignored if path is NULL. michael@0: @param index Either NULL, or receives the TTC index for this font. michael@0: If the font is not a TTC, then will be set to 0. michael@0: @return The byte length of th font's file name, or 0 if the font is not michael@0: baked by a file. michael@0: */ michael@0: int32_t (*getFontPath)(const ANPTypeface*, char path[], int32_t length, michael@0: int32_t* index); michael@0: michael@0: /** Return a UTF8 encoded path name for the font directory, or NULL if not michael@0: supported. If returned, this string address will be valid for the life michael@0: of the plugin instance. It will always end with a '/' character. michael@0: */ michael@0: const char* (*getFontDirectoryPath)(); michael@0: }; michael@0: michael@0: struct ANPPaintInterfaceV0 : ANPInterface { michael@0: /** Return a new paint object, which holds all of the color and style michael@0: attributes that affect how things (geometry, text, bitmaps) are drawn michael@0: in a ANPCanvas. michael@0: michael@0: The paint that is returned is not tied to any particular plugin michael@0: instance, but it must only be accessed from one thread at a time. michael@0: */ michael@0: ANPPaint* (*newPaint)(); michael@0: void (*deletePaint)(ANPPaint*); michael@0: michael@0: ANPPaintFlags (*getFlags)(const ANPPaint*); michael@0: void (*setFlags)(ANPPaint*, ANPPaintFlags); michael@0: michael@0: ANPColor (*getColor)(const ANPPaint*); michael@0: void (*setColor)(ANPPaint*, ANPColor); michael@0: michael@0: ANPPaintStyle (*getStyle)(const ANPPaint*); michael@0: void (*setStyle)(ANPPaint*, ANPPaintStyle); michael@0: michael@0: float (*getStrokeWidth)(const ANPPaint*); michael@0: float (*getStrokeMiter)(const ANPPaint*); michael@0: ANPPaintCap (*getStrokeCap)(const ANPPaint*); michael@0: ANPPaintJoin (*getStrokeJoin)(const ANPPaint*); michael@0: void (*setStrokeWidth)(ANPPaint*, float); michael@0: void (*setStrokeMiter)(ANPPaint*, float); michael@0: void (*setStrokeCap)(ANPPaint*, ANPPaintCap); michael@0: void (*setStrokeJoin)(ANPPaint*, ANPPaintJoin); michael@0: michael@0: ANPTextEncoding (*getTextEncoding)(const ANPPaint*); michael@0: ANPPaintAlign (*getTextAlign)(const ANPPaint*); michael@0: float (*getTextSize)(const ANPPaint*); michael@0: float (*getTextScaleX)(const ANPPaint*); michael@0: float (*getTextSkewX)(const ANPPaint*); michael@0: void (*setTextEncoding)(ANPPaint*, ANPTextEncoding); michael@0: void (*setTextAlign)(ANPPaint*, ANPPaintAlign); michael@0: void (*setTextSize)(ANPPaint*, float); michael@0: void (*setTextScaleX)(ANPPaint*, float); michael@0: void (*setTextSkewX)(ANPPaint*, float); michael@0: michael@0: /** Return the typeface ine paint, or null if there is none. This does not michael@0: modify the owner count of the returned typeface. michael@0: */ michael@0: ANPTypeface* (*getTypeface)(const ANPPaint*); michael@0: michael@0: /** Set the paint's typeface. If the paint already had a non-null typeface, michael@0: its owner count is decremented. If the new typeface is non-null, its michael@0: owner count is incremented. michael@0: */ michael@0: void (*setTypeface)(ANPPaint*, ANPTypeface*); michael@0: michael@0: /** Return the width of the text. If bounds is not null, return the bounds michael@0: of the text in that rectangle. michael@0: */ michael@0: float (*measureText)(ANPPaint*, const void* text, uint32_t byteLength, michael@0: ANPRectF* bounds); michael@0: michael@0: /** Return the number of unichars specifed by the text. michael@0: If widths is not null, returns the array of advance widths for each michael@0: unichar. michael@0: If bounds is not null, returns the array of bounds for each unichar. michael@0: */ michael@0: int (*getTextWidths)(ANPPaint*, const void* text, uint32_t byteLength, michael@0: float widths[], ANPRectF bounds[]); michael@0: michael@0: /** Return in metrics the spacing values for text, respecting the paint's michael@0: typeface and pointsize, and return the spacing between lines michael@0: (descent - ascent + leading). If metrics is NULL, it will be ignored. michael@0: */ michael@0: float (*getFontMetrics)(ANPPaint*, ANPFontMetrics* metrics); michael@0: }; michael@0: michael@0: struct ANPCanvasInterfaceV0 : ANPInterface { michael@0: /** Return a canvas that will draw into the specified bitmap. Note: the michael@0: canvas copies the fields of the bitmap, so it need not persist after michael@0: this call, but the canvas DOES point to the same pixel memory that the michael@0: bitmap did, so the canvas should not be used after that pixel memory michael@0: goes out of scope. In the case of creating a canvas to draw into the michael@0: pixels provided by kDraw_ANPEventType, those pixels are only while michael@0: handling that event. michael@0: michael@0: The canvas that is returned is not tied to any particular plugin michael@0: instance, but it must only be accessed from one thread at a time. michael@0: */ michael@0: ANPCanvas* (*newCanvas)(const ANPBitmap*); michael@0: void (*deleteCanvas)(ANPCanvas*); michael@0: michael@0: void (*save)(ANPCanvas*); michael@0: void (*restore)(ANPCanvas*); michael@0: void (*translate)(ANPCanvas*, float tx, float ty); michael@0: void (*scale)(ANPCanvas*, float sx, float sy); michael@0: void (*rotate)(ANPCanvas*, float degrees); michael@0: void (*skew)(ANPCanvas*, float kx, float ky); michael@0: void (*concat)(ANPCanvas*, const ANPMatrix*); michael@0: void (*clipRect)(ANPCanvas*, const ANPRectF*); michael@0: void (*clipPath)(ANPCanvas*, const ANPPath*); michael@0: michael@0: /** Return the current matrix on the canvas michael@0: */ michael@0: void (*getTotalMatrix)(ANPCanvas*, ANPMatrix*); michael@0: /** Return the current clip bounds in local coordinates, expanding it to michael@0: account for antialiasing edge effects if aa is true. If the michael@0: current clip is empty, return false and ignore the bounds argument. michael@0: */ michael@0: bool (*getLocalClipBounds)(ANPCanvas*, ANPRectF* bounds, bool aa); michael@0: /** Return the current clip bounds in device coordinates in bounds. If the michael@0: current clip is empty, return false and ignore the bounds argument. michael@0: */ michael@0: bool (*getDeviceClipBounds)(ANPCanvas*, ANPRectI* bounds); michael@0: michael@0: void (*drawColor)(ANPCanvas*, ANPColor); michael@0: void (*drawPaint)(ANPCanvas*, const ANPPaint*); michael@0: void (*drawLine)(ANPCanvas*, float x0, float y0, float x1, float y1, michael@0: const ANPPaint*); michael@0: void (*drawRect)(ANPCanvas*, const ANPRectF*, const ANPPaint*); michael@0: void (*drawOval)(ANPCanvas*, const ANPRectF*, const ANPPaint*); michael@0: void (*drawPath)(ANPCanvas*, const ANPPath*, const ANPPaint*); michael@0: void (*drawText)(ANPCanvas*, const void* text, uint32_t byteLength, michael@0: float x, float y, const ANPPaint*); michael@0: void (*drawPosText)(ANPCanvas*, const void* text, uint32_t byteLength, michael@0: const float xy[], const ANPPaint*); michael@0: void (*drawBitmap)(ANPCanvas*, const ANPBitmap*, float x, float y, michael@0: const ANPPaint*); michael@0: void (*drawBitmapRect)(ANPCanvas*, const ANPBitmap*, michael@0: const ANPRectI* src, const ANPRectF* dst, michael@0: const ANPPaint*); michael@0: }; michael@0: michael@0: struct ANPWindowInterfaceV0 : ANPInterface { michael@0: /** Registers a set of rectangles that the plugin would like to keep on michael@0: screen. The rectangles are listed in order of priority with the highest michael@0: priority rectangle in location rects[0]. The browser will attempt to keep michael@0: as many of the rectangles on screen as possible and will scroll them into michael@0: view in response to the invocation of this method and other various events. michael@0: The count specifies how many rectangles are in the array. If the count is michael@0: zero it signals the browser that any existing rectangles should be cleared michael@0: and no rectangles will be tracked. michael@0: */ michael@0: void (*setVisibleRects)(NPP instance, const ANPRectI rects[], int32_t count); michael@0: /** Clears any rectangles that are being tracked as a result of a call to michael@0: setVisibleRects. This call is equivalent to setVisibleRect(inst, NULL, 0). michael@0: */ michael@0: void (*clearVisibleRects)(NPP instance); michael@0: /** Given a boolean value of true the device will be requested to provide michael@0: a keyboard. A value of false will result in a request to hide the michael@0: keyboard. Further, the on-screen keyboard will not be displayed if a michael@0: physical keyboard is active. michael@0: */ michael@0: void (*showKeyboard)(NPP instance, bool value); michael@0: /** Called when a plugin wishes to enter into full screen mode. The plugin's michael@0: Java class (defined in the plugin's apk manifest) will be called michael@0: asynchronously to provide a View object to be displayed full screen. michael@0: */ michael@0: void (*requestFullScreen)(NPP instance); michael@0: /** Called when a plugin wishes to exit from full screen mode. As a result, michael@0: the plugin's full screen view will be discarded by the view system. michael@0: */ michael@0: void (*exitFullScreen)(NPP instance); michael@0: /** Called when a plugin wishes to be zoomed and centered in the current view. michael@0: */ michael@0: void (*requestCenterFitZoom)(NPP instance); michael@0: }; michael@0: michael@0: struct ANPWindowInterfaceV1 : ANPWindowInterfaceV0 { michael@0: /** Returns a rectangle representing the visible area of the plugin on michael@0: screen. The coordinates are relative to the size of the plugin in the michael@0: document and therefore will never be negative or exceed the plugin's size. michael@0: */ michael@0: ANPRectI (*visibleRect)(NPP instance); michael@0: }; michael@0: michael@0: enum ANPScreenOrientations { michael@0: /** No preference specified: let the system decide the best orientation. michael@0: */ michael@0: kDefault_ANPScreenOrientation = 0, michael@0: /** Would like to have the screen in a landscape orientation, but it will michael@0: not allow for 180 degree rotations. michael@0: */ michael@0: kFixedLandscape_ANPScreenOrientation = 1, michael@0: /** Would like to have the screen in a portrait orientation, but it will michael@0: not allow for 180 degree rotations. michael@0: */ michael@0: kFixedPortrait_ANPScreenOrientation = 2, michael@0: /** Would like to have the screen in landscape orientation, but can use the michael@0: sensor to change which direction the screen is facing. michael@0: */ michael@0: kLandscape_ANPScreenOrientation = 3, michael@0: /** Would like to have the screen in portrait orientation, but can use the michael@0: sensor to change which direction the screen is facing. michael@0: */ michael@0: kPortrait_ANPScreenOrientation = 4 michael@0: }; michael@0: michael@0: typedef int32_t ANPScreenOrientation; michael@0: michael@0: struct ANPWindowInterfaceV2 : ANPWindowInterfaceV1 { michael@0: /** Called when the plugin wants to specify a particular screen orientation michael@0: when entering into full screen mode. The orientation must be set prior michael@0: to entering into full screen. After entering full screen any subsequent michael@0: changes will be updated the next time the plugin goes full screen. michael@0: */ michael@0: void (*requestFullScreenOrientation)(NPP instance, ANPScreenOrientation orientation); michael@0: }; michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: enum ANPSampleFormats { michael@0: kUnknown_ANPSamleFormat = 0, michael@0: kPCM16Bit_ANPSampleFormat = 1, michael@0: kPCM8Bit_ANPSampleFormat = 2 michael@0: }; michael@0: typedef int32_t ANPSampleFormat; michael@0: michael@0: /** The audio buffer is passed to the callback proc to request more samples. michael@0: It is owned by the system, and the callback may read it, but should not michael@0: maintain a pointer to it outside of the scope of the callback proc. michael@0: */ michael@0: struct ANPAudioBuffer { michael@0: // RO - repeat what was specified in newTrack() michael@0: int32_t channelCount; michael@0: // RO - repeat what was specified in newTrack() michael@0: ANPSampleFormat format; michael@0: /** This buffer is owned by the caller. Inside the callback proc, up to michael@0: "size" bytes of sample data should be written into this buffer. The michael@0: address is only valid for the scope of a single invocation of the michael@0: callback proc. michael@0: */ michael@0: void* bufferData; michael@0: /** On input, specifies the maximum number of bytes that can be written michael@0: to "bufferData". On output, specifies the actual number of bytes that michael@0: the callback proc wrote into "bufferData". michael@0: */ michael@0: uint32_t size; michael@0: }; michael@0: michael@0: enum ANPAudioEvents { michael@0: /** This event is passed to the callback proc when the audio-track needs michael@0: more sample data written to the provided buffer parameter. michael@0: */ michael@0: kMoreData_ANPAudioEvent = 0, michael@0: /** This event is passed to the callback proc if the audio system runs out michael@0: of sample data. In this event, no buffer parameter will be specified michael@0: (i.e. NULL will be passed to the 3rd parameter). michael@0: */ michael@0: kUnderRun_ANPAudioEvent = 1 michael@0: }; michael@0: typedef int32_t ANPAudioEvent; michael@0: michael@0: /** Called to feed sample data to the track. This will be called in a separate michael@0: thread. However, you may call trackStop() from the callback (but you michael@0: cannot delete the track). michael@0: michael@0: For example, when you have written the last chunk of sample data, you can michael@0: immediately call trackStop(). This will take effect after the current michael@0: buffer has been played. michael@0: michael@0: The "user" parameter is the same value that was passed to newTrack() michael@0: */ michael@0: typedef void (*ANPAudioCallbackProc)(ANPAudioEvent event, void* user, michael@0: ANPAudioBuffer* buffer); michael@0: michael@0: struct ANPAudioTrack; // abstract type for audio tracks michael@0: michael@0: struct ANPAudioTrackInterfaceV0 : ANPInterface { michael@0: /** Create a new audio track, or NULL on failure. The track is initially in michael@0: the stopped state and therefore ANPAudioCallbackProc will not be called michael@0: until the track is started. michael@0: */ michael@0: ANPAudioTrack* (*newTrack)(uint32_t sampleRate, // sampling rate in Hz michael@0: ANPSampleFormat, michael@0: int channelCount, // MONO=1, STEREO=2 michael@0: ANPAudioCallbackProc, michael@0: void* user); michael@0: /** Deletes a track that was created using newTrack. The track can be michael@0: deleted in any state and it waits for the ANPAudioCallbackProc thread michael@0: to exit before returning. michael@0: */ michael@0: void (*deleteTrack)(ANPAudioTrack*); michael@0: michael@0: void (*start)(ANPAudioTrack*); michael@0: void (*pause)(ANPAudioTrack*); michael@0: void (*stop)(ANPAudioTrack*); michael@0: /** Returns true if the track is not playing (e.g. pause or stop was called, michael@0: or start was never called. michael@0: */ michael@0: bool (*isStopped)(ANPAudioTrack*); michael@0: }; michael@0: michael@0: struct ANPAudioTrackInterfaceV1 : ANPAudioTrackInterfaceV0 { michael@0: /** Returns the track's latency in milliseconds. */ michael@0: uint32_t (*trackLatency)(ANPAudioTrack*); michael@0: }; michael@0: michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: // DEFINITION OF VALUES PASSED THROUGH NPP_HandleEvent michael@0: michael@0: enum ANPEventTypes { michael@0: kNull_ANPEventType = 0, michael@0: kKey_ANPEventType = 1, michael@0: /** Mouse events are triggered by either clicking with the navigational pad michael@0: or by tapping the touchscreen (if the kDown_ANPTouchAction is handled by michael@0: the plugin then no mouse event is generated). The kKey_ANPEventFlag has michael@0: to be set to true in order to receive these events. michael@0: */ michael@0: kMouse_ANPEventType = 2, michael@0: /** Touch events are generated when the user touches on the screen. The michael@0: kTouch_ANPEventFlag has to be set to true in order to receive these michael@0: events. michael@0: */ michael@0: kTouch_ANPEventType = 3, michael@0: /** Only triggered by a plugin using the kBitmap_ANPDrawingModel. This event michael@0: signals that the plugin needs to redraw itself into the provided bitmap. michael@0: */ michael@0: kDraw_ANPEventType = 4, michael@0: kLifecycle_ANPEventType = 5, michael@0: michael@0: /** This event type is completely defined by the plugin. michael@0: When creating an event, the caller must always set the first michael@0: two fields, the remaining data is optional. michael@0: ANPEvent evt; michael@0: evt.inSize = sizeof(ANPEvent); michael@0: evt.eventType = kCustom_ANPEventType michael@0: // other data slots are optional michael@0: evt.other[] = ...; michael@0: To post a copy of the event, call michael@0: eventInterface->postEvent(myNPPInstance, &evt); michael@0: That call makes a copy of the event struct, and post that on the event michael@0: queue for the plugin. michael@0: */ michael@0: kCustom_ANPEventType = 6, michael@0: }; michael@0: typedef int32_t ANPEventType; michael@0: michael@0: enum ANPKeyActions { michael@0: kDown_ANPKeyAction = 0, michael@0: kUp_ANPKeyAction = 1, michael@0: }; michael@0: typedef int32_t ANPKeyAction; michael@0: michael@0: #include "ANPKeyCodes.h" michael@0: typedef int32_t ANPKeyCode; michael@0: michael@0: enum ANPKeyModifiers { michael@0: kAlt_ANPKeyModifier = 1 << 0, michael@0: kShift_ANPKeyModifier = 1 << 1, michael@0: }; michael@0: // bit-field containing some number of ANPKeyModifier bits michael@0: typedef uint32_t ANPKeyModifier; michael@0: michael@0: enum ANPMouseActions { michael@0: kDown_ANPMouseAction = 0, michael@0: kUp_ANPMouseAction = 1, michael@0: }; michael@0: typedef int32_t ANPMouseAction; michael@0: michael@0: enum ANPTouchActions { michael@0: /** This occurs when the user first touches on the screen. As such, this michael@0: action will always occur prior to any of the other touch actions. If michael@0: the plugin chooses to not handle this action then no other events michael@0: related to that particular touch gesture will be generated. michael@0: */ michael@0: kDown_ANPTouchAction = 0, michael@0: kUp_ANPTouchAction = 1, michael@0: kMove_ANPTouchAction = 2, michael@0: kCancel_ANPTouchAction = 3, michael@0: // The web view will ignore the return value from the following actions michael@0: kLongPress_ANPTouchAction = 4, michael@0: kDoubleTap_ANPTouchAction = 5, michael@0: }; michael@0: typedef int32_t ANPTouchAction; michael@0: michael@0: enum ANPLifecycleActions { michael@0: /** The web view containing this plugin has been paused. See documentation michael@0: on the android activity lifecycle for more information. michael@0: */ michael@0: kPause_ANPLifecycleAction = 0, michael@0: /** The web view containing this plugin has been resumed. See documentation michael@0: on the android activity lifecycle for more information. michael@0: */ michael@0: kResume_ANPLifecycleAction = 1, michael@0: /** The plugin has focus and is now the recipient of input events (e.g. key, michael@0: touch, etc.) michael@0: */ michael@0: kGainFocus_ANPLifecycleAction = 2, michael@0: /** The plugin has lost focus and will not receive any input events until it michael@0: regains focus. This event is always preceded by a GainFocus action. michael@0: */ michael@0: kLoseFocus_ANPLifecycleAction = 3, michael@0: /** The browser is running low on available memory and is requesting that michael@0: the plugin free any unused/inactive resources to prevent a performance michael@0: degradation. michael@0: */ michael@0: kFreeMemory_ANPLifecycleAction = 4, michael@0: /** The page has finished loading. This happens when the page's top level michael@0: frame reports that it has completed loading. michael@0: */ michael@0: kOnLoad_ANPLifecycleAction = 5, michael@0: /** The browser is honoring the plugin's request to go full screen. Upon michael@0: returning from this event the browser will resize the plugin's java michael@0: surface to full-screen coordinates. michael@0: */ michael@0: kEnterFullScreen_ANPLifecycleAction = 6, michael@0: /** The browser has exited from full screen mode. Immediately prior to michael@0: sending this event the browser has resized the plugin's java surface to michael@0: its original coordinates. michael@0: */ michael@0: kExitFullScreen_ANPLifecycleAction = 7, michael@0: /** The plugin is visible to the user on the screen. This event will always michael@0: occur after a kOffScreen_ANPLifecycleAction event. michael@0: */ michael@0: kOnScreen_ANPLifecycleAction = 8, michael@0: /** The plugin is no longer visible to the user on the screen. This event michael@0: will always occur prior to an kOnScreen_ANPLifecycleAction event. michael@0: */ michael@0: kOffScreen_ANPLifecycleAction = 9, michael@0: }; michael@0: typedef uint32_t ANPLifecycleAction; michael@0: michael@0: /* This is what is passed to NPP_HandleEvent() */ michael@0: struct ANPEvent { michael@0: uint32_t inSize; // size of this struct in bytes michael@0: ANPEventType eventType; michael@0: // use based on the value in eventType michael@0: union { michael@0: struct { michael@0: ANPKeyAction action; michael@0: ANPKeyCode nativeCode; michael@0: int32_t virtualCode; // windows virtual key code michael@0: ANPKeyModifier modifiers; michael@0: int32_t repeatCount; // 0 for initial down (or up) michael@0: int32_t unichar; // 0 if there is no value michael@0: } key; michael@0: struct { michael@0: ANPMouseAction action; michael@0: int32_t x; // relative to your "window" (0...width) michael@0: int32_t y; // relative to your "window" (0...height) michael@0: } mouse; michael@0: struct { michael@0: ANPTouchAction action; michael@0: ANPKeyModifier modifiers; michael@0: int32_t x; // relative to your "window" (0...width) michael@0: int32_t y; // relative to your "window" (0...height) michael@0: } touch; michael@0: struct { michael@0: ANPLifecycleAction action; michael@0: } lifecycle; michael@0: struct { michael@0: ANPDrawingModel model; michael@0: // relative to (0,0) in top-left of your plugin michael@0: ANPRectI clip; michael@0: // use based on the value in model michael@0: union { michael@0: ANPBitmap bitmap; michael@0: struct { michael@0: int32_t width; michael@0: int32_t height; michael@0: } surfaceSize; michael@0: } data; michael@0: } draw; michael@0: } data; michael@0: }; michael@0: michael@0: michael@0: struct ANPEventInterfaceV0 : ANPInterface { michael@0: /** Post a copy of the specified event to the plugin. The event will be michael@0: delivered to the plugin in its main thread (the thread that receives michael@0: other ANPEvents). If, after posting before delivery, the NPP instance michael@0: is torn down, the event will be discarded. michael@0: */ michael@0: void (*postEvent)(NPP inst, const ANPEvent* event); michael@0: }; michael@0: michael@0: struct ANPSystemInterfaceV0 : ANPInterface { michael@0: /** Return the path name for the current Application's plugin data directory, michael@0: or NULL if not supported michael@0: */ michael@0: const char* (*getApplicationDataDirectory)(); michael@0: michael@0: /** A helper function to load java classes from the plugin's apk. The michael@0: function looks for a class given the fully qualified and null terminated michael@0: string representing the className. For example, michael@0: michael@0: const char* className = "com.android.mypackage.MyClass"; michael@0: michael@0: If the class cannot be found or there is a problem loading the class michael@0: NULL will be returned. michael@0: */ michael@0: jclass (*loadJavaClass)(NPP instance, const char* className); michael@0: }; michael@0: michael@0: struct ANPSurfaceInterfaceV0 : ANPInterface { michael@0: /** Locks the surface from manipulation by other threads and provides a bitmap michael@0: to be written to. The dirtyRect param specifies which portion of the michael@0: bitmap will be written to. If the dirtyRect is NULL then the entire michael@0: surface will be considered dirty. If the lock was successful the function michael@0: will return true and the bitmap will be set to point to a valid bitmap. michael@0: If not the function will return false and the bitmap will be set to NULL. michael@0: */ michael@0: bool (*lock)(JNIEnv* env, jobject surface, ANPBitmap* bitmap, ANPRectI* dirtyRect); michael@0: /** Given a locked surface handle (i.e. result of a successful call to lock) michael@0: the surface is unlocked and the contents of the bitmap, specifically michael@0: those inside the dirtyRect are written to the screen. michael@0: */ michael@0: void (*unlock)(JNIEnv* env, jobject surface); michael@0: }; michael@0: michael@0: /** michael@0: * TODO should we not use EGL and GL data types for ABI safety? michael@0: */ michael@0: struct ANPTextureInfo { michael@0: GLuint textureId; michael@0: uint32_t width; michael@0: uint32_t height; michael@0: GLenum internalFormat; michael@0: }; michael@0: michael@0: typedef void* ANPEGLContext; michael@0: michael@0: struct ANPOpenGLInterfaceV0 : ANPInterface { michael@0: ANPEGLContext (*acquireContext)(NPP instance); michael@0: michael@0: ANPTextureInfo (*lockTexture)(NPP instance); michael@0: michael@0: void (*releaseTexture)(NPP instance, const ANPTextureInfo*); michael@0: michael@0: /** michael@0: * Invert the contents of the plugin on the y-axis. michael@0: * default is to not be inverted (i.e. use OpenGL coordinates) michael@0: */ michael@0: void (*invertPluginContent)(NPP instance, bool isContentInverted); michael@0: }; michael@0: michael@0: enum ANPPowerStates { michael@0: kDefault_ANPPowerState = 0, michael@0: kScreenOn_ANPPowerState = 1 michael@0: }; michael@0: typedef int32_t ANPPowerState; michael@0: michael@0: struct ANPSystemInterfaceV1 : ANPSystemInterfaceV0 { michael@0: void (*setPowerState)(NPP instance, ANPPowerState powerState); michael@0: }; michael@0: michael@0: struct ANPSystemInterfaceV2 : ANPInterface { michael@0: /** Return the path name for the current Application's plugin data directory, michael@0: or NULL if not supported. This directory will change depending on whether michael@0: or not the plugin is found within an incognito tab. michael@0: */ michael@0: const char* (*getApplicationDataDirectory)(NPP instance); michael@0: michael@0: // redeclaration of existing features michael@0: jclass (*loadJavaClass)(NPP instance, const char* className); michael@0: void (*setPowerState)(NPP instance, ANPPowerState powerState); michael@0: }; michael@0: michael@0: typedef void* ANPNativeWindow; michael@0: michael@0: struct ANPVideoInterfaceV0 : ANPInterface { michael@0: michael@0: /** michael@0: * Constructs a new native window to be used for rendering video content. michael@0: * michael@0: * Subsequent calls will produce new windows, but may also return NULL after michael@0: * n attempts if the browser has reached it's limit. Further, if the browser michael@0: * is unable to acquire the window quickly it may also return NULL in order michael@0: * to not prevent the plugin from executing. A subsequent call will then michael@0: * return the window if it is avaiable. michael@0: * michael@0: * NOTE: The hardware may fail if you try to decode more than the allowable michael@0: * number of videos supported on that device. michael@0: */ michael@0: ANPNativeWindow (*acquireNativeWindow)(NPP instance); michael@0: michael@0: /** michael@0: * Sets the rectangle that specifies where the video content is to be drawn. michael@0: * The dimensions are in document space. Further, if the rect is NULL the michael@0: * browser will not attempt to draw the window, therefore do not set the michael@0: * dimensions until you queue the first buffer in the window. michael@0: */ michael@0: void (*setWindowDimensions)(NPP instance, const ANPNativeWindow window, const ANPRectF* dimensions); michael@0: michael@0: /** michael@0: */ michael@0: void (*releaseNativeWindow)(NPP instance, ANPNativeWindow window); michael@0: }; michael@0: michael@0: /** Called to notify the plugin that a video frame has been composited by the michael@0: * browser for display. This will be called in a separate thread and as such michael@0: * you cannot call releaseNativeWindow from the callback. michael@0: * michael@0: * The timestamp is in nanoseconds, and is monotonically increasing. michael@0: */ michael@0: typedef void (*ANPVideoFrameCallbackProc)(ANPNativeWindow* window, int64_t timestamp); michael@0: michael@0: struct ANPVideoInterfaceV1 : ANPVideoInterfaceV0 { michael@0: /** Set a callback to be notified when an ANPNativeWindow is composited by michael@0: * the browser. michael@0: */ michael@0: void (*setFramerateCallback)(NPP instance, const ANPNativeWindow window, ANPVideoFrameCallbackProc); michael@0: }; michael@0: michael@0: struct ANPNativeWindowInterfaceV0 : ANPInterface { michael@0: /** michael@0: * Constructs a new native window to be used for rendering plugin content. michael@0: * michael@0: * Subsequent calls will return the original constructed window. Further, if michael@0: * the browser is unable to acquire the window quickly it may return NULL in michael@0: * order to not block the plugin indefinitely. A subsequent call will then michael@0: * return the window if it is available. michael@0: */ michael@0: ANPNativeWindow (*acquireNativeWindow)(NPP instance); michael@0: michael@0: /** michael@0: * Invert the contents of the plugin on the y-axis. michael@0: * default is to not be inverted (e.g. use OpenGL coordinates) michael@0: */ michael@0: void (*invertPluginContent)(NPP instance, bool isContentInverted); michael@0: }; michael@0: michael@0: michael@0: #endif