1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/base/android/android_npapi.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,1150 @@ 1.4 +/* 1.5 + * Copyright 2009, The Android Open Source Project 1.6 + * 1.7 + * Redistribution and use in source and binary forms, with or without 1.8 + * modification, are permitted provided that the following conditions 1.9 + * are met: 1.10 + * * Redistributions of source code must retain the above copyright 1.11 + * notice, this list of conditions and the following disclaimer. 1.12 + * * Redistributions in binary form must reproduce the above copyright 1.13 + * notice, this list of conditions and the following disclaimer in the 1.14 + * documentation and/or other materials provided with the distribution. 1.15 + * 1.16 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 1.17 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1.18 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1.19 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 1.20 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.21 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.22 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.23 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 1.24 + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.25 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.26 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.27 + */ 1.28 + 1.29 +/* Defines the android-specific types and functions as part of npapi 1.30 + 1.31 + In particular, defines the window and event types that are passed to 1.32 + NPN_GetValue, NPP_SetWindow and NPP_HandleEvent. 1.33 + 1.34 + To minimize what native libraries the plugin links against, some 1.35 + functionality is provided via function-ptrs (e.g. time, sound) 1.36 + */ 1.37 + 1.38 +#ifndef android_npapi_H 1.39 +#define android_npapi_H 1.40 + 1.41 +#include <stdint.h> 1.42 +#include <jni.h> 1.43 +#include "npapi.h" 1.44 +#include "GLDefs.h" 1.45 + 1.46 +/////////////////////////////////////////////////////////////////////////////// 1.47 +// General types 1.48 + 1.49 +enum ANPBitmapFormats { 1.50 + kUnknown_ANPBitmapFormat = 0, 1.51 + kRGBA_8888_ANPBitmapFormat = 1, 1.52 + kRGB_565_ANPBitmapFormat = 2 1.53 +}; 1.54 +typedef int32_t ANPBitmapFormat; 1.55 + 1.56 +struct ANPPixelPacking { 1.57 + uint8_t AShift; 1.58 + uint8_t ABits; 1.59 + uint8_t RShift; 1.60 + uint8_t RBits; 1.61 + uint8_t GShift; 1.62 + uint8_t GBits; 1.63 + uint8_t BShift; 1.64 + uint8_t BBits; 1.65 +}; 1.66 + 1.67 +struct ANPBitmap { 1.68 + void* baseAddr; 1.69 + ANPBitmapFormat format; 1.70 + int32_t width; 1.71 + int32_t height; 1.72 + int32_t rowBytes; 1.73 +}; 1.74 + 1.75 +struct ANPRectF { 1.76 + float left; 1.77 + float top; 1.78 + float right; 1.79 + float bottom; 1.80 +}; 1.81 + 1.82 +struct ANPRectI { 1.83 + int32_t left; 1.84 + int32_t top; 1.85 + int32_t right; 1.86 + int32_t bottom; 1.87 +}; 1.88 + 1.89 +struct ANPCanvas; 1.90 +struct ANPMatrix; 1.91 +struct ANPPaint; 1.92 +struct ANPPath; 1.93 +struct ANPRegion; 1.94 +struct ANPTypeface; 1.95 + 1.96 +enum ANPMatrixFlags { 1.97 + kIdentity_ANPMatrixFlag = 0, 1.98 + kTranslate_ANPMatrixFlag = 0x01, 1.99 + kScale_ANPMatrixFlag = 0x02, 1.100 + kAffine_ANPMatrixFlag = 0x04, 1.101 + kPerspective_ANPMatrixFlag = 0x08, 1.102 +}; 1.103 +typedef uint32_t ANPMatrixFlag; 1.104 + 1.105 +/////////////////////////////////////////////////////////////////////////////// 1.106 +// NPN_GetValue 1.107 + 1.108 +/** queries for a specific ANPInterface. 1.109 + 1.110 + Maybe called with NULL for the NPP instance 1.111 + 1.112 + NPN_GetValue(inst, interface_enum, ANPInterface*) 1.113 + */ 1.114 +#define kLogInterfaceV0_ANPGetValue ((NPNVariable)1000) 1.115 +#define kAudioTrackInterfaceV0_ANPGetValue ((NPNVariable)1001) 1.116 +#define kCanvasInterfaceV0_ANPGetValue ((NPNVariable)1002) 1.117 +#define kMatrixInterfaceV0_ANPGetValue ((NPNVariable)1003) 1.118 +#define kPaintInterfaceV0_ANPGetValue ((NPNVariable)1004) 1.119 +#define kPathInterfaceV0_ANPGetValue ((NPNVariable)1005) 1.120 +#define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1006) 1.121 +#define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1007) 1.122 +#define kBitmapInterfaceV0_ANPGetValue ((NPNVariable)1008) 1.123 +#define kSurfaceInterfaceV0_ANPGetValue ((NPNVariable)1009) 1.124 +#define kSystemInterfaceV0_ANPGetValue ((NPNVariable)1010) 1.125 +#define kEventInterfaceV0_ANPGetValue ((NPNVariable)1011) 1.126 + 1.127 +#define kAudioTrackInterfaceV1_ANPGetValue ((NPNVariable)1012) 1.128 +#define kOpenGLInterfaceV0_ANPGetValue ((NPNVariable)1013) 1.129 +#define kWindowInterfaceV1_ANPGetValue ((NPNVariable)1014) 1.130 +#define kVideoInterfaceV0_ANPGetValue ((NPNVariable)1015) 1.131 +#define kSystemInterfaceV1_ANPGetValue ((NPNVariable)1016) 1.132 +#define kSystemInterfaceV2_ANPGetValue ((NPNVariable)1017) 1.133 +#define kWindowInterfaceV2_ANPGetValue ((NPNVariable)1018) 1.134 +#define kNativeWindowInterfaceV0_ANPGetValue ((NPNVariable)1019) 1.135 +#define kVideoInterfaceV1_ANPGetValue ((NPNVariable)1020) 1.136 + 1.137 +/** queries for the drawing models supported on this device. 1.138 + 1.139 + NPN_GetValue(inst, kSupportedDrawingModel_ANPGetValue, uint32_t* bits) 1.140 + */ 1.141 +#define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000) 1.142 + 1.143 +/** queries for the context (android.content.Context) of the plugin. If no 1.144 + instance is specified the application's context is returned. If the instance 1.145 + is given then the context returned is identical to the context used to 1.146 + create the webview in which that instance resides. 1.147 + 1.148 + NOTE: Holding onto a non-application context after your instance has been 1.149 + destroyed will cause a memory leak. Refer to the android documentation to 1.150 + determine what context is best suited for your particular scenario. 1.151 + 1.152 + NPN_GetValue(inst, kJavaContext_ANPGetValue, jobject context) 1.153 + */ 1.154 +#define kJavaContext_ANPGetValue ((NPNVariable)2001) 1.155 + 1.156 +/////////////////////////////////////////////////////////////////////////////// 1.157 +// NPN_SetValue 1.158 + 1.159 +/** Request to set the drawing model. SetValue will return false if the drawing 1.160 + model is not supported or has insufficient information for configuration. 1.161 + 1.162 + NPN_SetValue(inst, kRequestDrawingModel_ANPSetValue, (void*)foo_ANPDrawingModel) 1.163 + */ 1.164 +#define kRequestDrawingModel_ANPSetValue ((NPPVariable)1000) 1.165 + 1.166 +/** These are used as bitfields in ANPSupportedDrawingModels_EnumValue, 1.167 + and as-is in ANPRequestDrawingModel_EnumValue. The drawing model determines 1.168 + how to interpret the ANPDrawingContext provided in the Draw event and how 1.169 + to interpret the NPWindow->window field. 1.170 + */ 1.171 +enum ANPDrawingModels { 1.172 + /** Draw into a bitmap from the browser thread in response to a Draw event. 1.173 + NPWindow->window is reserved (ignore) 1.174 + */ 1.175 + kBitmap_ANPDrawingModel = 1 << 0, 1.176 + /** Draw into a surface (e.g. raster, openGL, etc.) using the Java surface 1.177 + interface. When this model is used the browser will invoke the Java 1.178 + class specified in the plugin's apk manifest. From that class the browser 1.179 + will invoke the appropriate method to return an an instance of a android 1.180 + Java View. The instance is then embedded in the html. The plugin can then 1.181 + manipulate the view as it would any normal Java View in android. 1.182 + 1.183 + Unlike the bitmap model, a surface model is opaque so no html content 1.184 + behind the plugin will be visible. Unless the plugin needs to be 1.185 + transparent the surface model should be chosen over the bitmap model as 1.186 + it will have better performance. 1.187 + 1.188 + Further, a plugin can manipulate some surfaces in native code using the 1.189 + ANPSurfaceInterface. This interface can be used to manipulate Java 1.190 + objects that extend Surface.class by allowing them to access the 1.191 + surface's underlying bitmap in native code. For instance, if a raster 1.192 + surface is used the plugin can lock, draw directly into the bitmap, and 1.193 + unlock the surface in native code without making JNI calls to the Java 1.194 + surface object. 1.195 + */ 1.196 + kSurface_ANPDrawingModel = 1 << 1, 1.197 + kOpenGL_ANPDrawingModel = 1 << 2, 1.198 +}; 1.199 +typedef int32_t ANPDrawingModel; 1.200 + 1.201 +/** Request to receive/disable events. If the pointer is NULL then all flags will 1.202 + be disabled. Otherwise, the event type will be enabled iff its corresponding 1.203 + bit in the EventFlags bit field is set. 1.204 + 1.205 + NPN_SetValue(inst, ANPAcceptEvents, (void*)EventFlags) 1.206 + */ 1.207 +#define kAcceptEvents_ANPSetValue ((NPPVariable)1001) 1.208 + 1.209 +/** The EventFlags are a set of bits used to determine which types of events the 1.210 + plugin wishes to receive. For example, if the value is 0x03 then both key 1.211 + and touch events will be provided to the plugin. 1.212 + */ 1.213 +enum ANPEventFlag { 1.214 + kKey_ANPEventFlag = 0x01, 1.215 + kTouch_ANPEventFlag = 0x02, 1.216 +}; 1.217 +typedef uint32_t ANPEventFlags; 1.218 + 1.219 +/////////////////////////////////////////////////////////////////////////////// 1.220 +// NPP_GetValue 1.221 + 1.222 +/** Requests that the plugin return a java surface to be displayed. This will 1.223 + only be used if the plugin has choosen the kSurface_ANPDrawingModel. 1.224 + 1.225 + NPP_GetValue(inst, kJavaSurface_ANPGetValue, jobject surface) 1.226 + */ 1.227 +#define kJavaSurface_ANPGetValue ((NPPVariable)2000) 1.228 + 1.229 + 1.230 +/////////////////////////////////////////////////////////////////////////////// 1.231 +// ANDROID INTERFACE DEFINITIONS 1.232 + 1.233 +/** Interfaces provide additional functionality to the plugin via function ptrs. 1.234 + Once an interface is retrieved, it is valid for the lifetime of the plugin 1.235 + (just like browserfuncs). 1.236 + 1.237 + All ANPInterfaces begin with an inSize field, which must be set by the 1.238 + caller (plugin) with the number of bytes allocated for the interface. 1.239 + e.g. SomeInterface si; si.inSize = sizeof(si); browser->getvalue(..., &si); 1.240 + */ 1.241 +struct ANPInterface { 1.242 + uint32_t inSize; // size (in bytes) of this struct 1.243 +}; 1.244 + 1.245 +enum ANPLogTypes { 1.246 + kError_ANPLogType = 0, // error 1.247 + kWarning_ANPLogType = 1, // warning 1.248 + kDebug_ANPLogType = 2 // debug only (informational) 1.249 +}; 1.250 +typedef int32_t ANPLogType; 1.251 + 1.252 +struct ANPLogInterfaceV0 : ANPInterface { 1.253 + /** dumps printf messages to the log file 1.254 + e.g. interface->log(instance, kWarning_ANPLogType, "value is %d", value); 1.255 + */ 1.256 + void (*log)(ANPLogType, const char format[], ...); 1.257 +}; 1.258 + 1.259 +struct ANPBitmapInterfaceV0 : ANPInterface { 1.260 + /** Returns true if the specified bitmap format is supported, and if packing 1.261 + is non-null, sets it to the packing info for that format. 1.262 + */ 1.263 + bool (*getPixelPacking)(ANPBitmapFormat, ANPPixelPacking* packing); 1.264 +}; 1.265 + 1.266 +struct ANPMatrixInterfaceV0 : ANPInterface { 1.267 + /** Return a new identity matrix 1.268 + */ 1.269 + ANPMatrix* (*newMatrix)(); 1.270 + /** Delete a matrix previously allocated by newMatrix() 1.271 + */ 1.272 + void (*deleteMatrix)(ANPMatrix*); 1.273 + 1.274 + ANPMatrixFlag (*getFlags)(const ANPMatrix*); 1.275 + 1.276 + void (*copy)(ANPMatrix* dst, const ANPMatrix* src); 1.277 + 1.278 + /** Return the matrix values in a float array (allcoated by the caller), 1.279 + where the values are treated as follows: 1.280 + w = x * [6] + y * [7] + [8]; 1.281 + x' = (x * [0] + y * [1] + [2]) / w; 1.282 + y' = (x * [3] + y * [4] + [5]) / w; 1.283 + */ 1.284 + void (*get3x3)(const ANPMatrix*, float[9]); 1.285 + /** Initialize the matrix from values in a float array, 1.286 + where the values are treated as follows: 1.287 + w = x * [6] + y * [7] + [8]; 1.288 + x' = (x * [0] + y * [1] + [2]) / w; 1.289 + y' = (x * [3] + y * [4] + [5]) / w; 1.290 + */ 1.291 + void (*set3x3)(ANPMatrix*, const float[9]); 1.292 + 1.293 + void (*setIdentity)(ANPMatrix*); 1.294 + void (*preTranslate)(ANPMatrix*, float tx, float ty); 1.295 + void (*postTranslate)(ANPMatrix*, float tx, float ty); 1.296 + void (*preScale)(ANPMatrix*, float sx, float sy); 1.297 + void (*postScale)(ANPMatrix*, float sx, float sy); 1.298 + void (*preSkew)(ANPMatrix*, float kx, float ky); 1.299 + void (*postSkew)(ANPMatrix*, float kx, float ky); 1.300 + void (*preRotate)(ANPMatrix*, float degrees); 1.301 + void (*postRotate)(ANPMatrix*, float degrees); 1.302 + void (*preConcat)(ANPMatrix*, const ANPMatrix*); 1.303 + void (*postConcat)(ANPMatrix*, const ANPMatrix*); 1.304 + 1.305 + /** Return true if src is invertible, and if so, return its inverse in dst. 1.306 + If src is not invertible, return false and ignore dst. 1.307 + */ 1.308 + bool (*invert)(ANPMatrix* dst, const ANPMatrix* src); 1.309 + 1.310 + /** Transform the x,y pairs in src[] by this matrix, and store the results 1.311 + in dst[]. The count parameter is treated as the number of pairs in the 1.312 + array. It is legal for src and dst to point to the same memory, but 1.313 + illegal for the two arrays to partially overlap. 1.314 + */ 1.315 + void (*mapPoints)(ANPMatrix*, float dst[], const float src[], 1.316 + int32_t count); 1.317 +}; 1.318 + 1.319 +struct ANPPathInterfaceV0 : ANPInterface { 1.320 + /** Return a new path */ 1.321 + ANPPath* (*newPath)(); 1.322 + 1.323 + /** Delete a path previously allocated by ANPPath() */ 1.324 + void (*deletePath)(ANPPath*); 1.325 + 1.326 + /** Make a deep copy of the src path, into the dst path (already allocated 1.327 + by the caller). 1.328 + */ 1.329 + void (*copy)(ANPPath* dst, const ANPPath* src); 1.330 + 1.331 + /** Returns true if the two paths are the same (i.e. have the same points) 1.332 + */ 1.333 + bool (*equal)(const ANPPath* path0, const ANPPath* path1); 1.334 + 1.335 + /** Remove any previous points, initializing the path back to empty. */ 1.336 + void (*reset)(ANPPath*); 1.337 + 1.338 + /** Return true if the path is empty (has no lines, quads or cubics). */ 1.339 + bool (*isEmpty)(const ANPPath*); 1.340 + 1.341 + /** Return the path's bounds in bounds. */ 1.342 + void (*getBounds)(const ANPPath*, ANPRectF* bounds); 1.343 + 1.344 + void (*moveTo)(ANPPath*, float x, float y); 1.345 + void (*lineTo)(ANPPath*, float x, float y); 1.346 + void (*quadTo)(ANPPath*, float x0, float y0, float x1, float y1); 1.347 + void (*cubicTo)(ANPPath*, float x0, float y0, float x1, float y1, 1.348 + float x2, float y2); 1.349 + void (*close)(ANPPath*); 1.350 + 1.351 + /** Offset the src path by [dx, dy]. If dst is null, apply the 1.352 + change directly to the src path. If dst is not null, write the 1.353 + changed path into dst, and leave the src path unchanged. In that case 1.354 + dst must have been previously allocated by the caller. 1.355 + */ 1.356 + void (*offset)(ANPPath* src, float dx, float dy, ANPPath* dst); 1.357 + 1.358 + /** Transform the path by the matrix. If dst is null, apply the 1.359 + change directly to the src path. If dst is not null, write the 1.360 + changed path into dst, and leave the src path unchanged. In that case 1.361 + dst must have been previously allocated by the caller. 1.362 + */ 1.363 + void (*transform)(ANPPath* src, const ANPMatrix*, ANPPath* dst); 1.364 +}; 1.365 + 1.366 +/** ANPColor is always defined to have the same packing on all platforms, and 1.367 + it is always unpremultiplied. 1.368 + 1.369 + This is in contrast to 32bit format(s) in bitmaps, which are premultiplied, 1.370 + and their packing may vary depending on the platform, hence the need for 1.371 + ANPBitmapInterface::getPixelPacking() 1.372 + */ 1.373 +typedef uint32_t ANPColor; 1.374 +#define ANPColor_ASHIFT 24 1.375 +#define ANPColor_RSHIFT 16 1.376 +#define ANPColor_GSHIFT 8 1.377 +#define ANPColor_BSHIFT 0 1.378 +#define ANP_MAKE_COLOR(a, r, g, b) \ 1.379 + (((a) << ANPColor_ASHIFT) | \ 1.380 + ((r) << ANPColor_RSHIFT) | \ 1.381 + ((g) << ANPColor_GSHIFT) | \ 1.382 + ((b) << ANPColor_BSHIFT)) 1.383 + 1.384 +enum ANPPaintFlag { 1.385 + kAntiAlias_ANPPaintFlag = 1 << 0, 1.386 + kFilterBitmap_ANPPaintFlag = 1 << 1, 1.387 + kDither_ANPPaintFlag = 1 << 2, 1.388 + kUnderlineText_ANPPaintFlag = 1 << 3, 1.389 + kStrikeThruText_ANPPaintFlag = 1 << 4, 1.390 + kFakeBoldText_ANPPaintFlag = 1 << 5, 1.391 +}; 1.392 +typedef uint32_t ANPPaintFlags; 1.393 + 1.394 +enum ANPPaintStyles { 1.395 + kFill_ANPPaintStyle = 0, 1.396 + kStroke_ANPPaintStyle = 1, 1.397 + kFillAndStroke_ANPPaintStyle = 2 1.398 +}; 1.399 +typedef int32_t ANPPaintStyle; 1.400 + 1.401 +enum ANPPaintCaps { 1.402 + kButt_ANPPaintCap = 0, 1.403 + kRound_ANPPaintCap = 1, 1.404 + kSquare_ANPPaintCap = 2 1.405 +}; 1.406 +typedef int32_t ANPPaintCap; 1.407 + 1.408 +enum ANPPaintJoins { 1.409 + kMiter_ANPPaintJoin = 0, 1.410 + kRound_ANPPaintJoin = 1, 1.411 + kBevel_ANPPaintJoin = 2 1.412 +}; 1.413 +typedef int32_t ANPPaintJoin; 1.414 + 1.415 +enum ANPPaintAligns { 1.416 + kLeft_ANPPaintAlign = 0, 1.417 + kCenter_ANPPaintAlign = 1, 1.418 + kRight_ANPPaintAlign = 2 1.419 +}; 1.420 +typedef int32_t ANPPaintAlign; 1.421 + 1.422 +enum ANPTextEncodings { 1.423 + kUTF8_ANPTextEncoding = 0, 1.424 + kUTF16_ANPTextEncoding = 1, 1.425 +}; 1.426 +typedef int32_t ANPTextEncoding; 1.427 + 1.428 +enum ANPTypefaceStyles { 1.429 + kBold_ANPTypefaceStyle = 1 << 0, 1.430 + kItalic_ANPTypefaceStyle = 1 << 1 1.431 +}; 1.432 +typedef uint32_t ANPTypefaceStyle; 1.433 + 1.434 +typedef uint32_t ANPFontTableTag; 1.435 + 1.436 +struct ANPFontMetrics { 1.437 + /** The greatest distance above the baseline for any glyph (will be <= 0) */ 1.438 + float fTop; 1.439 + /** The recommended distance above the baseline (will be <= 0) */ 1.440 + float fAscent; 1.441 + /** The recommended distance below the baseline (will be >= 0) */ 1.442 + float fDescent; 1.443 + /** The greatest distance below the baseline for any glyph (will be >= 0) */ 1.444 + float fBottom; 1.445 + /** The recommended distance to add between lines of text (will be >= 0) */ 1.446 + float fLeading; 1.447 +}; 1.448 + 1.449 +struct ANPTypefaceInterfaceV0 : ANPInterface { 1.450 + /** Return a new reference to the typeface that most closely matches the 1.451 + requested name and style. Pass null as the name to return 1.452 + the default font for the requested style. Will never return null 1.453 + 1.454 + The 5 generic font names "serif", "sans-serif", "monospace", "cursive", 1.455 + "fantasy" are recognized, and will be mapped to their logical font 1.456 + automatically by this call. 1.457 + 1.458 + @param name May be NULL. The name of the font family. 1.459 + @param style The style (normal, bold, italic) of the typeface. 1.460 + @return reference to the closest-matching typeface. Caller must call 1.461 + unref() when they are done with the typeface. 1.462 + */ 1.463 + ANPTypeface* (*createFromName)(const char name[], ANPTypefaceStyle); 1.464 + 1.465 + /** Return a new reference to the typeface that most closely matches the 1.466 + requested typeface and specified Style. Use this call if you want to 1.467 + pick a new style from the same family of the existing typeface. 1.468 + If family is NULL, this selects from the default font's family. 1.469 + 1.470 + @param family May be NULL. The name of the existing type face. 1.471 + @param s The style (normal, bold, italic) of the type face. 1.472 + @return reference to the closest-matching typeface. Call must call 1.473 + unref() when they are done. 1.474 + */ 1.475 + ANPTypeface* (*createFromTypeface)(const ANPTypeface* family, 1.476 + ANPTypefaceStyle); 1.477 + 1.478 + /** Return the owner count of the typeface. A newly created typeface has an 1.479 + owner count of 1. When the owner count is reaches 0, the typeface is 1.480 + deleted. 1.481 + */ 1.482 + int32_t (*getRefCount)(const ANPTypeface*); 1.483 + 1.484 + /** Increment the owner count on the typeface 1.485 + */ 1.486 + void (*ref)(ANPTypeface*); 1.487 + 1.488 + /** Decrement the owner count on the typeface. When the count goes to 0, 1.489 + the typeface is deleted. 1.490 + */ 1.491 + void (*unref)(ANPTypeface*); 1.492 + 1.493 + /** Return the style bits for the specified typeface 1.494 + */ 1.495 + ANPTypefaceStyle (*getStyle)(const ANPTypeface*); 1.496 + 1.497 + /** Some fonts are stored in files. If that is true for the fontID, then 1.498 + this returns the byte length of the full file path. If path is not null, 1.499 + then the full path is copied into path (allocated by the caller), up to 1.500 + length bytes. If index is not null, then it is set to the truetype 1.501 + collection index for this font, or 0 if the font is not in a collection. 1.502 + 1.503 + Note: getFontPath does not assume that path is a null-terminated string, 1.504 + so when it succeeds, it only copies the bytes of the file name and 1.505 + nothing else (i.e. it copies exactly the number of bytes returned by the 1.506 + function. If the caller wants to treat path[] as a C string, it must be 1.507 + sure that it is allocated at least 1 byte larger than the returned size, 1.508 + and it must copy in the terminating 0. 1.509 + 1.510 + If the fontID does not correspond to a file, then the function returns 1.511 + 0, and the path and index parameters are ignored. 1.512 + 1.513 + @param fontID The font whose file name is being queried 1.514 + @param path Either NULL, or storage for receiving up to length bytes 1.515 + of the font's file name. Allocated by the caller. 1.516 + @param length The maximum space allocated in path (by the caller). 1.517 + Ignored if path is NULL. 1.518 + @param index Either NULL, or receives the TTC index for this font. 1.519 + If the font is not a TTC, then will be set to 0. 1.520 + @return The byte length of th font's file name, or 0 if the font is not 1.521 + baked by a file. 1.522 + */ 1.523 + int32_t (*getFontPath)(const ANPTypeface*, char path[], int32_t length, 1.524 + int32_t* index); 1.525 + 1.526 + /** Return a UTF8 encoded path name for the font directory, or NULL if not 1.527 + supported. If returned, this string address will be valid for the life 1.528 + of the plugin instance. It will always end with a '/' character. 1.529 + */ 1.530 + const char* (*getFontDirectoryPath)(); 1.531 +}; 1.532 + 1.533 +struct ANPPaintInterfaceV0 : ANPInterface { 1.534 + /** Return a new paint object, which holds all of the color and style 1.535 + attributes that affect how things (geometry, text, bitmaps) are drawn 1.536 + in a ANPCanvas. 1.537 + 1.538 + The paint that is returned is not tied to any particular plugin 1.539 + instance, but it must only be accessed from one thread at a time. 1.540 + */ 1.541 + ANPPaint* (*newPaint)(); 1.542 + void (*deletePaint)(ANPPaint*); 1.543 + 1.544 + ANPPaintFlags (*getFlags)(const ANPPaint*); 1.545 + void (*setFlags)(ANPPaint*, ANPPaintFlags); 1.546 + 1.547 + ANPColor (*getColor)(const ANPPaint*); 1.548 + void (*setColor)(ANPPaint*, ANPColor); 1.549 + 1.550 + ANPPaintStyle (*getStyle)(const ANPPaint*); 1.551 + void (*setStyle)(ANPPaint*, ANPPaintStyle); 1.552 + 1.553 + float (*getStrokeWidth)(const ANPPaint*); 1.554 + float (*getStrokeMiter)(const ANPPaint*); 1.555 + ANPPaintCap (*getStrokeCap)(const ANPPaint*); 1.556 + ANPPaintJoin (*getStrokeJoin)(const ANPPaint*); 1.557 + void (*setStrokeWidth)(ANPPaint*, float); 1.558 + void (*setStrokeMiter)(ANPPaint*, float); 1.559 + void (*setStrokeCap)(ANPPaint*, ANPPaintCap); 1.560 + void (*setStrokeJoin)(ANPPaint*, ANPPaintJoin); 1.561 + 1.562 + ANPTextEncoding (*getTextEncoding)(const ANPPaint*); 1.563 + ANPPaintAlign (*getTextAlign)(const ANPPaint*); 1.564 + float (*getTextSize)(const ANPPaint*); 1.565 + float (*getTextScaleX)(const ANPPaint*); 1.566 + float (*getTextSkewX)(const ANPPaint*); 1.567 + void (*setTextEncoding)(ANPPaint*, ANPTextEncoding); 1.568 + void (*setTextAlign)(ANPPaint*, ANPPaintAlign); 1.569 + void (*setTextSize)(ANPPaint*, float); 1.570 + void (*setTextScaleX)(ANPPaint*, float); 1.571 + void (*setTextSkewX)(ANPPaint*, float); 1.572 + 1.573 + /** Return the typeface ine paint, or null if there is none. This does not 1.574 + modify the owner count of the returned typeface. 1.575 + */ 1.576 + ANPTypeface* (*getTypeface)(const ANPPaint*); 1.577 + 1.578 + /** Set the paint's typeface. If the paint already had a non-null typeface, 1.579 + its owner count is decremented. If the new typeface is non-null, its 1.580 + owner count is incremented. 1.581 + */ 1.582 + void (*setTypeface)(ANPPaint*, ANPTypeface*); 1.583 + 1.584 + /** Return the width of the text. If bounds is not null, return the bounds 1.585 + of the text in that rectangle. 1.586 + */ 1.587 + float (*measureText)(ANPPaint*, const void* text, uint32_t byteLength, 1.588 + ANPRectF* bounds); 1.589 + 1.590 + /** Return the number of unichars specifed by the text. 1.591 + If widths is not null, returns the array of advance widths for each 1.592 + unichar. 1.593 + If bounds is not null, returns the array of bounds for each unichar. 1.594 + */ 1.595 + int (*getTextWidths)(ANPPaint*, const void* text, uint32_t byteLength, 1.596 + float widths[], ANPRectF bounds[]); 1.597 + 1.598 + /** Return in metrics the spacing values for text, respecting the paint's 1.599 + typeface and pointsize, and return the spacing between lines 1.600 + (descent - ascent + leading). If metrics is NULL, it will be ignored. 1.601 + */ 1.602 + float (*getFontMetrics)(ANPPaint*, ANPFontMetrics* metrics); 1.603 +}; 1.604 + 1.605 +struct ANPCanvasInterfaceV0 : ANPInterface { 1.606 + /** Return a canvas that will draw into the specified bitmap. Note: the 1.607 + canvas copies the fields of the bitmap, so it need not persist after 1.608 + this call, but the canvas DOES point to the same pixel memory that the 1.609 + bitmap did, so the canvas should not be used after that pixel memory 1.610 + goes out of scope. In the case of creating a canvas to draw into the 1.611 + pixels provided by kDraw_ANPEventType, those pixels are only while 1.612 + handling that event. 1.613 + 1.614 + The canvas that is returned is not tied to any particular plugin 1.615 + instance, but it must only be accessed from one thread at a time. 1.616 + */ 1.617 + ANPCanvas* (*newCanvas)(const ANPBitmap*); 1.618 + void (*deleteCanvas)(ANPCanvas*); 1.619 + 1.620 + void (*save)(ANPCanvas*); 1.621 + void (*restore)(ANPCanvas*); 1.622 + void (*translate)(ANPCanvas*, float tx, float ty); 1.623 + void (*scale)(ANPCanvas*, float sx, float sy); 1.624 + void (*rotate)(ANPCanvas*, float degrees); 1.625 + void (*skew)(ANPCanvas*, float kx, float ky); 1.626 + void (*concat)(ANPCanvas*, const ANPMatrix*); 1.627 + void (*clipRect)(ANPCanvas*, const ANPRectF*); 1.628 + void (*clipPath)(ANPCanvas*, const ANPPath*); 1.629 + 1.630 + /** Return the current matrix on the canvas 1.631 + */ 1.632 + void (*getTotalMatrix)(ANPCanvas*, ANPMatrix*); 1.633 + /** Return the current clip bounds in local coordinates, expanding it to 1.634 + account for antialiasing edge effects if aa is true. If the 1.635 + current clip is empty, return false and ignore the bounds argument. 1.636 + */ 1.637 + bool (*getLocalClipBounds)(ANPCanvas*, ANPRectF* bounds, bool aa); 1.638 + /** Return the current clip bounds in device coordinates in bounds. If the 1.639 + current clip is empty, return false and ignore the bounds argument. 1.640 + */ 1.641 + bool (*getDeviceClipBounds)(ANPCanvas*, ANPRectI* bounds); 1.642 + 1.643 + void (*drawColor)(ANPCanvas*, ANPColor); 1.644 + void (*drawPaint)(ANPCanvas*, const ANPPaint*); 1.645 + void (*drawLine)(ANPCanvas*, float x0, float y0, float x1, float y1, 1.646 + const ANPPaint*); 1.647 + void (*drawRect)(ANPCanvas*, const ANPRectF*, const ANPPaint*); 1.648 + void (*drawOval)(ANPCanvas*, const ANPRectF*, const ANPPaint*); 1.649 + void (*drawPath)(ANPCanvas*, const ANPPath*, const ANPPaint*); 1.650 + void (*drawText)(ANPCanvas*, const void* text, uint32_t byteLength, 1.651 + float x, float y, const ANPPaint*); 1.652 + void (*drawPosText)(ANPCanvas*, const void* text, uint32_t byteLength, 1.653 + const float xy[], const ANPPaint*); 1.654 + void (*drawBitmap)(ANPCanvas*, const ANPBitmap*, float x, float y, 1.655 + const ANPPaint*); 1.656 + void (*drawBitmapRect)(ANPCanvas*, const ANPBitmap*, 1.657 + const ANPRectI* src, const ANPRectF* dst, 1.658 + const ANPPaint*); 1.659 +}; 1.660 + 1.661 +struct ANPWindowInterfaceV0 : ANPInterface { 1.662 + /** Registers a set of rectangles that the plugin would like to keep on 1.663 + screen. The rectangles are listed in order of priority with the highest 1.664 + priority rectangle in location rects[0]. The browser will attempt to keep 1.665 + as many of the rectangles on screen as possible and will scroll them into 1.666 + view in response to the invocation of this method and other various events. 1.667 + The count specifies how many rectangles are in the array. If the count is 1.668 + zero it signals the browser that any existing rectangles should be cleared 1.669 + and no rectangles will be tracked. 1.670 + */ 1.671 + void (*setVisibleRects)(NPP instance, const ANPRectI rects[], int32_t count); 1.672 + /** Clears any rectangles that are being tracked as a result of a call to 1.673 + setVisibleRects. This call is equivalent to setVisibleRect(inst, NULL, 0). 1.674 + */ 1.675 + void (*clearVisibleRects)(NPP instance); 1.676 + /** Given a boolean value of true the device will be requested to provide 1.677 + a keyboard. A value of false will result in a request to hide the 1.678 + keyboard. Further, the on-screen keyboard will not be displayed if a 1.679 + physical keyboard is active. 1.680 + */ 1.681 + void (*showKeyboard)(NPP instance, bool value); 1.682 + /** Called when a plugin wishes to enter into full screen mode. The plugin's 1.683 + Java class (defined in the plugin's apk manifest) will be called 1.684 + asynchronously to provide a View object to be displayed full screen. 1.685 + */ 1.686 + void (*requestFullScreen)(NPP instance); 1.687 + /** Called when a plugin wishes to exit from full screen mode. As a result, 1.688 + the plugin's full screen view will be discarded by the view system. 1.689 + */ 1.690 + void (*exitFullScreen)(NPP instance); 1.691 + /** Called when a plugin wishes to be zoomed and centered in the current view. 1.692 + */ 1.693 + void (*requestCenterFitZoom)(NPP instance); 1.694 +}; 1.695 + 1.696 +struct ANPWindowInterfaceV1 : ANPWindowInterfaceV0 { 1.697 + /** Returns a rectangle representing the visible area of the plugin on 1.698 + screen. The coordinates are relative to the size of the plugin in the 1.699 + document and therefore will never be negative or exceed the plugin's size. 1.700 + */ 1.701 + ANPRectI (*visibleRect)(NPP instance); 1.702 +}; 1.703 + 1.704 +enum ANPScreenOrientations { 1.705 + /** No preference specified: let the system decide the best orientation. 1.706 + */ 1.707 + kDefault_ANPScreenOrientation = 0, 1.708 + /** Would like to have the screen in a landscape orientation, but it will 1.709 + not allow for 180 degree rotations. 1.710 + */ 1.711 + kFixedLandscape_ANPScreenOrientation = 1, 1.712 + /** Would like to have the screen in a portrait orientation, but it will 1.713 + not allow for 180 degree rotations. 1.714 + */ 1.715 + kFixedPortrait_ANPScreenOrientation = 2, 1.716 + /** Would like to have the screen in landscape orientation, but can use the 1.717 + sensor to change which direction the screen is facing. 1.718 + */ 1.719 + kLandscape_ANPScreenOrientation = 3, 1.720 + /** Would like to have the screen in portrait orientation, but can use the 1.721 + sensor to change which direction the screen is facing. 1.722 + */ 1.723 + kPortrait_ANPScreenOrientation = 4 1.724 +}; 1.725 + 1.726 +typedef int32_t ANPScreenOrientation; 1.727 + 1.728 +struct ANPWindowInterfaceV2 : ANPWindowInterfaceV1 { 1.729 + /** Called when the plugin wants to specify a particular screen orientation 1.730 + when entering into full screen mode. The orientation must be set prior 1.731 + to entering into full screen. After entering full screen any subsequent 1.732 + changes will be updated the next time the plugin goes full screen. 1.733 + */ 1.734 + void (*requestFullScreenOrientation)(NPP instance, ANPScreenOrientation orientation); 1.735 +}; 1.736 + 1.737 +/////////////////////////////////////////////////////////////////////////////// 1.738 + 1.739 +enum ANPSampleFormats { 1.740 + kUnknown_ANPSamleFormat = 0, 1.741 + kPCM16Bit_ANPSampleFormat = 1, 1.742 + kPCM8Bit_ANPSampleFormat = 2 1.743 +}; 1.744 +typedef int32_t ANPSampleFormat; 1.745 + 1.746 +/** The audio buffer is passed to the callback proc to request more samples. 1.747 + It is owned by the system, and the callback may read it, but should not 1.748 + maintain a pointer to it outside of the scope of the callback proc. 1.749 + */ 1.750 +struct ANPAudioBuffer { 1.751 + // RO - repeat what was specified in newTrack() 1.752 + int32_t channelCount; 1.753 + // RO - repeat what was specified in newTrack() 1.754 + ANPSampleFormat format; 1.755 + /** This buffer is owned by the caller. Inside the callback proc, up to 1.756 + "size" bytes of sample data should be written into this buffer. The 1.757 + address is only valid for the scope of a single invocation of the 1.758 + callback proc. 1.759 + */ 1.760 + void* bufferData; 1.761 + /** On input, specifies the maximum number of bytes that can be written 1.762 + to "bufferData". On output, specifies the actual number of bytes that 1.763 + the callback proc wrote into "bufferData". 1.764 + */ 1.765 + uint32_t size; 1.766 +}; 1.767 + 1.768 +enum ANPAudioEvents { 1.769 + /** This event is passed to the callback proc when the audio-track needs 1.770 + more sample data written to the provided buffer parameter. 1.771 + */ 1.772 + kMoreData_ANPAudioEvent = 0, 1.773 + /** This event is passed to the callback proc if the audio system runs out 1.774 + of sample data. In this event, no buffer parameter will be specified 1.775 + (i.e. NULL will be passed to the 3rd parameter). 1.776 + */ 1.777 + kUnderRun_ANPAudioEvent = 1 1.778 +}; 1.779 +typedef int32_t ANPAudioEvent; 1.780 + 1.781 +/** Called to feed sample data to the track. This will be called in a separate 1.782 + thread. However, you may call trackStop() from the callback (but you 1.783 + cannot delete the track). 1.784 + 1.785 + For example, when you have written the last chunk of sample data, you can 1.786 + immediately call trackStop(). This will take effect after the current 1.787 + buffer has been played. 1.788 + 1.789 + The "user" parameter is the same value that was passed to newTrack() 1.790 + */ 1.791 +typedef void (*ANPAudioCallbackProc)(ANPAudioEvent event, void* user, 1.792 + ANPAudioBuffer* buffer); 1.793 + 1.794 +struct ANPAudioTrack; // abstract type for audio tracks 1.795 + 1.796 +struct ANPAudioTrackInterfaceV0 : ANPInterface { 1.797 + /** Create a new audio track, or NULL on failure. The track is initially in 1.798 + the stopped state and therefore ANPAudioCallbackProc will not be called 1.799 + until the track is started. 1.800 + */ 1.801 + ANPAudioTrack* (*newTrack)(uint32_t sampleRate, // sampling rate in Hz 1.802 + ANPSampleFormat, 1.803 + int channelCount, // MONO=1, STEREO=2 1.804 + ANPAudioCallbackProc, 1.805 + void* user); 1.806 + /** Deletes a track that was created using newTrack. The track can be 1.807 + deleted in any state and it waits for the ANPAudioCallbackProc thread 1.808 + to exit before returning. 1.809 + */ 1.810 + void (*deleteTrack)(ANPAudioTrack*); 1.811 + 1.812 + void (*start)(ANPAudioTrack*); 1.813 + void (*pause)(ANPAudioTrack*); 1.814 + void (*stop)(ANPAudioTrack*); 1.815 + /** Returns true if the track is not playing (e.g. pause or stop was called, 1.816 + or start was never called. 1.817 + */ 1.818 + bool (*isStopped)(ANPAudioTrack*); 1.819 +}; 1.820 + 1.821 +struct ANPAudioTrackInterfaceV1 : ANPAudioTrackInterfaceV0 { 1.822 + /** Returns the track's latency in milliseconds. */ 1.823 + uint32_t (*trackLatency)(ANPAudioTrack*); 1.824 +}; 1.825 + 1.826 + 1.827 +/////////////////////////////////////////////////////////////////////////////// 1.828 +// DEFINITION OF VALUES PASSED THROUGH NPP_HandleEvent 1.829 + 1.830 +enum ANPEventTypes { 1.831 + kNull_ANPEventType = 0, 1.832 + kKey_ANPEventType = 1, 1.833 + /** Mouse events are triggered by either clicking with the navigational pad 1.834 + or by tapping the touchscreen (if the kDown_ANPTouchAction is handled by 1.835 + the plugin then no mouse event is generated). The kKey_ANPEventFlag has 1.836 + to be set to true in order to receive these events. 1.837 + */ 1.838 + kMouse_ANPEventType = 2, 1.839 + /** Touch events are generated when the user touches on the screen. The 1.840 + kTouch_ANPEventFlag has to be set to true in order to receive these 1.841 + events. 1.842 + */ 1.843 + kTouch_ANPEventType = 3, 1.844 + /** Only triggered by a plugin using the kBitmap_ANPDrawingModel. This event 1.845 + signals that the plugin needs to redraw itself into the provided bitmap. 1.846 + */ 1.847 + kDraw_ANPEventType = 4, 1.848 + kLifecycle_ANPEventType = 5, 1.849 + 1.850 + /** This event type is completely defined by the plugin. 1.851 + When creating an event, the caller must always set the first 1.852 + two fields, the remaining data is optional. 1.853 + ANPEvent evt; 1.854 + evt.inSize = sizeof(ANPEvent); 1.855 + evt.eventType = kCustom_ANPEventType 1.856 + // other data slots are optional 1.857 + evt.other[] = ...; 1.858 + To post a copy of the event, call 1.859 + eventInterface->postEvent(myNPPInstance, &evt); 1.860 + That call makes a copy of the event struct, and post that on the event 1.861 + queue for the plugin. 1.862 + */ 1.863 + kCustom_ANPEventType = 6, 1.864 +}; 1.865 +typedef int32_t ANPEventType; 1.866 + 1.867 +enum ANPKeyActions { 1.868 + kDown_ANPKeyAction = 0, 1.869 + kUp_ANPKeyAction = 1, 1.870 +}; 1.871 +typedef int32_t ANPKeyAction; 1.872 + 1.873 +#include "ANPKeyCodes.h" 1.874 +typedef int32_t ANPKeyCode; 1.875 + 1.876 +enum ANPKeyModifiers { 1.877 + kAlt_ANPKeyModifier = 1 << 0, 1.878 + kShift_ANPKeyModifier = 1 << 1, 1.879 +}; 1.880 +// bit-field containing some number of ANPKeyModifier bits 1.881 +typedef uint32_t ANPKeyModifier; 1.882 + 1.883 +enum ANPMouseActions { 1.884 + kDown_ANPMouseAction = 0, 1.885 + kUp_ANPMouseAction = 1, 1.886 +}; 1.887 +typedef int32_t ANPMouseAction; 1.888 + 1.889 +enum ANPTouchActions { 1.890 + /** This occurs when the user first touches on the screen. As such, this 1.891 + action will always occur prior to any of the other touch actions. If 1.892 + the plugin chooses to not handle this action then no other events 1.893 + related to that particular touch gesture will be generated. 1.894 + */ 1.895 + kDown_ANPTouchAction = 0, 1.896 + kUp_ANPTouchAction = 1, 1.897 + kMove_ANPTouchAction = 2, 1.898 + kCancel_ANPTouchAction = 3, 1.899 + // The web view will ignore the return value from the following actions 1.900 + kLongPress_ANPTouchAction = 4, 1.901 + kDoubleTap_ANPTouchAction = 5, 1.902 +}; 1.903 +typedef int32_t ANPTouchAction; 1.904 + 1.905 +enum ANPLifecycleActions { 1.906 + /** The web view containing this plugin has been paused. See documentation 1.907 + on the android activity lifecycle for more information. 1.908 + */ 1.909 + kPause_ANPLifecycleAction = 0, 1.910 + /** The web view containing this plugin has been resumed. See documentation 1.911 + on the android activity lifecycle for more information. 1.912 + */ 1.913 + kResume_ANPLifecycleAction = 1, 1.914 + /** The plugin has focus and is now the recipient of input events (e.g. key, 1.915 + touch, etc.) 1.916 + */ 1.917 + kGainFocus_ANPLifecycleAction = 2, 1.918 + /** The plugin has lost focus and will not receive any input events until it 1.919 + regains focus. This event is always preceded by a GainFocus action. 1.920 + */ 1.921 + kLoseFocus_ANPLifecycleAction = 3, 1.922 + /** The browser is running low on available memory and is requesting that 1.923 + the plugin free any unused/inactive resources to prevent a performance 1.924 + degradation. 1.925 + */ 1.926 + kFreeMemory_ANPLifecycleAction = 4, 1.927 + /** The page has finished loading. This happens when the page's top level 1.928 + frame reports that it has completed loading. 1.929 + */ 1.930 + kOnLoad_ANPLifecycleAction = 5, 1.931 + /** The browser is honoring the plugin's request to go full screen. Upon 1.932 + returning from this event the browser will resize the plugin's java 1.933 + surface to full-screen coordinates. 1.934 + */ 1.935 + kEnterFullScreen_ANPLifecycleAction = 6, 1.936 + /** The browser has exited from full screen mode. Immediately prior to 1.937 + sending this event the browser has resized the plugin's java surface to 1.938 + its original coordinates. 1.939 + */ 1.940 + kExitFullScreen_ANPLifecycleAction = 7, 1.941 + /** The plugin is visible to the user on the screen. This event will always 1.942 + occur after a kOffScreen_ANPLifecycleAction event. 1.943 + */ 1.944 + kOnScreen_ANPLifecycleAction = 8, 1.945 + /** The plugin is no longer visible to the user on the screen. This event 1.946 + will always occur prior to an kOnScreen_ANPLifecycleAction event. 1.947 + */ 1.948 + kOffScreen_ANPLifecycleAction = 9, 1.949 +}; 1.950 +typedef uint32_t ANPLifecycleAction; 1.951 + 1.952 +/* This is what is passed to NPP_HandleEvent() */ 1.953 +struct ANPEvent { 1.954 + uint32_t inSize; // size of this struct in bytes 1.955 + ANPEventType eventType; 1.956 + // use based on the value in eventType 1.957 + union { 1.958 + struct { 1.959 + ANPKeyAction action; 1.960 + ANPKeyCode nativeCode; 1.961 + int32_t virtualCode; // windows virtual key code 1.962 + ANPKeyModifier modifiers; 1.963 + int32_t repeatCount; // 0 for initial down (or up) 1.964 + int32_t unichar; // 0 if there is no value 1.965 + } key; 1.966 + struct { 1.967 + ANPMouseAction action; 1.968 + int32_t x; // relative to your "window" (0...width) 1.969 + int32_t y; // relative to your "window" (0...height) 1.970 + } mouse; 1.971 + struct { 1.972 + ANPTouchAction action; 1.973 + ANPKeyModifier modifiers; 1.974 + int32_t x; // relative to your "window" (0...width) 1.975 + int32_t y; // relative to your "window" (0...height) 1.976 + } touch; 1.977 + struct { 1.978 + ANPLifecycleAction action; 1.979 + } lifecycle; 1.980 + struct { 1.981 + ANPDrawingModel model; 1.982 + // relative to (0,0) in top-left of your plugin 1.983 + ANPRectI clip; 1.984 + // use based on the value in model 1.985 + union { 1.986 + ANPBitmap bitmap; 1.987 + struct { 1.988 + int32_t width; 1.989 + int32_t height; 1.990 + } surfaceSize; 1.991 + } data; 1.992 + } draw; 1.993 + } data; 1.994 +}; 1.995 + 1.996 + 1.997 +struct ANPEventInterfaceV0 : ANPInterface { 1.998 + /** Post a copy of the specified event to the plugin. The event will be 1.999 + delivered to the plugin in its main thread (the thread that receives 1.1000 + other ANPEvents). If, after posting before delivery, the NPP instance 1.1001 + is torn down, the event will be discarded. 1.1002 + */ 1.1003 + void (*postEvent)(NPP inst, const ANPEvent* event); 1.1004 +}; 1.1005 + 1.1006 +struct ANPSystemInterfaceV0 : ANPInterface { 1.1007 + /** Return the path name for the current Application's plugin data directory, 1.1008 + or NULL if not supported 1.1009 + */ 1.1010 + const char* (*getApplicationDataDirectory)(); 1.1011 + 1.1012 + /** A helper function to load java classes from the plugin's apk. The 1.1013 + function looks for a class given the fully qualified and null terminated 1.1014 + string representing the className. For example, 1.1015 + 1.1016 + const char* className = "com.android.mypackage.MyClass"; 1.1017 + 1.1018 + If the class cannot be found or there is a problem loading the class 1.1019 + NULL will be returned. 1.1020 + */ 1.1021 + jclass (*loadJavaClass)(NPP instance, const char* className); 1.1022 +}; 1.1023 + 1.1024 +struct ANPSurfaceInterfaceV0 : ANPInterface { 1.1025 + /** Locks the surface from manipulation by other threads and provides a bitmap 1.1026 + to be written to. The dirtyRect param specifies which portion of the 1.1027 + bitmap will be written to. If the dirtyRect is NULL then the entire 1.1028 + surface will be considered dirty. If the lock was successful the function 1.1029 + will return true and the bitmap will be set to point to a valid bitmap. 1.1030 + If not the function will return false and the bitmap will be set to NULL. 1.1031 + */ 1.1032 + bool (*lock)(JNIEnv* env, jobject surface, ANPBitmap* bitmap, ANPRectI* dirtyRect); 1.1033 + /** Given a locked surface handle (i.e. result of a successful call to lock) 1.1034 + the surface is unlocked and the contents of the bitmap, specifically 1.1035 + those inside the dirtyRect are written to the screen. 1.1036 + */ 1.1037 + void (*unlock)(JNIEnv* env, jobject surface); 1.1038 +}; 1.1039 + 1.1040 +/** 1.1041 + * TODO should we not use EGL and GL data types for ABI safety? 1.1042 + */ 1.1043 +struct ANPTextureInfo { 1.1044 + GLuint textureId; 1.1045 + uint32_t width; 1.1046 + uint32_t height; 1.1047 + GLenum internalFormat; 1.1048 +}; 1.1049 + 1.1050 +typedef void* ANPEGLContext; 1.1051 + 1.1052 +struct ANPOpenGLInterfaceV0 : ANPInterface { 1.1053 + ANPEGLContext (*acquireContext)(NPP instance); 1.1054 + 1.1055 + ANPTextureInfo (*lockTexture)(NPP instance); 1.1056 + 1.1057 + void (*releaseTexture)(NPP instance, const ANPTextureInfo*); 1.1058 + 1.1059 + /** 1.1060 + * Invert the contents of the plugin on the y-axis. 1.1061 + * default is to not be inverted (i.e. use OpenGL coordinates) 1.1062 + */ 1.1063 + void (*invertPluginContent)(NPP instance, bool isContentInverted); 1.1064 +}; 1.1065 + 1.1066 +enum ANPPowerStates { 1.1067 + kDefault_ANPPowerState = 0, 1.1068 + kScreenOn_ANPPowerState = 1 1.1069 +}; 1.1070 +typedef int32_t ANPPowerState; 1.1071 + 1.1072 +struct ANPSystemInterfaceV1 : ANPSystemInterfaceV0 { 1.1073 + void (*setPowerState)(NPP instance, ANPPowerState powerState); 1.1074 +}; 1.1075 + 1.1076 +struct ANPSystemInterfaceV2 : ANPInterface { 1.1077 + /** Return the path name for the current Application's plugin data directory, 1.1078 + or NULL if not supported. This directory will change depending on whether 1.1079 + or not the plugin is found within an incognito tab. 1.1080 + */ 1.1081 + const char* (*getApplicationDataDirectory)(NPP instance); 1.1082 + 1.1083 + // redeclaration of existing features 1.1084 + jclass (*loadJavaClass)(NPP instance, const char* className); 1.1085 + void (*setPowerState)(NPP instance, ANPPowerState powerState); 1.1086 +}; 1.1087 + 1.1088 +typedef void* ANPNativeWindow; 1.1089 + 1.1090 +struct ANPVideoInterfaceV0 : ANPInterface { 1.1091 + 1.1092 + /** 1.1093 + * Constructs a new native window to be used for rendering video content. 1.1094 + * 1.1095 + * Subsequent calls will produce new windows, but may also return NULL after 1.1096 + * n attempts if the browser has reached it's limit. Further, if the browser 1.1097 + * is unable to acquire the window quickly it may also return NULL in order 1.1098 + * to not prevent the plugin from executing. A subsequent call will then 1.1099 + * return the window if it is avaiable. 1.1100 + * 1.1101 + * NOTE: The hardware may fail if you try to decode more than the allowable 1.1102 + * number of videos supported on that device. 1.1103 + */ 1.1104 + ANPNativeWindow (*acquireNativeWindow)(NPP instance); 1.1105 + 1.1106 + /** 1.1107 + * Sets the rectangle that specifies where the video content is to be drawn. 1.1108 + * The dimensions are in document space. Further, if the rect is NULL the 1.1109 + * browser will not attempt to draw the window, therefore do not set the 1.1110 + * dimensions until you queue the first buffer in the window. 1.1111 + */ 1.1112 + void (*setWindowDimensions)(NPP instance, const ANPNativeWindow window, const ANPRectF* dimensions); 1.1113 + 1.1114 + /** 1.1115 + */ 1.1116 + void (*releaseNativeWindow)(NPP instance, ANPNativeWindow window); 1.1117 +}; 1.1118 + 1.1119 +/** Called to notify the plugin that a video frame has been composited by the 1.1120 +* browser for display. This will be called in a separate thread and as such 1.1121 +* you cannot call releaseNativeWindow from the callback. 1.1122 +* 1.1123 +* The timestamp is in nanoseconds, and is monotonically increasing. 1.1124 +*/ 1.1125 +typedef void (*ANPVideoFrameCallbackProc)(ANPNativeWindow* window, int64_t timestamp); 1.1126 + 1.1127 +struct ANPVideoInterfaceV1 : ANPVideoInterfaceV0 { 1.1128 + /** Set a callback to be notified when an ANPNativeWindow is composited by 1.1129 + * the browser. 1.1130 + */ 1.1131 + void (*setFramerateCallback)(NPP instance, const ANPNativeWindow window, ANPVideoFrameCallbackProc); 1.1132 +}; 1.1133 + 1.1134 +struct ANPNativeWindowInterfaceV0 : ANPInterface { 1.1135 + /** 1.1136 + * Constructs a new native window to be used for rendering plugin content. 1.1137 + * 1.1138 + * Subsequent calls will return the original constructed window. Further, if 1.1139 + * the browser is unable to acquire the window quickly it may return NULL in 1.1140 + * order to not block the plugin indefinitely. A subsequent call will then 1.1141 + * return the window if it is available. 1.1142 + */ 1.1143 + ANPNativeWindow (*acquireNativeWindow)(NPP instance); 1.1144 + 1.1145 + /** 1.1146 + * Invert the contents of the plugin on the y-axis. 1.1147 + * default is to not be inverted (e.g. use OpenGL coordinates) 1.1148 + */ 1.1149 + void (*invertPluginContent)(NPP instance, bool isContentInverted); 1.1150 +}; 1.1151 + 1.1152 + 1.1153 +#endif