1 /* 2 * Copyright 2008, The Android Open Source Project 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 /* Defines the android-specific types and functions as part of npapi 27 28 In particular, defines the window and event types that are passed to 29 NPN_GetValue, NPP_SetWindow and NPP_HandleEvent. 30 31 To minimize what native libraries the plugin links against, some 32 functionality is provided via function-ptrs (e.g. time, sound) 33 */ 34 35 #ifndef android_npapi_H 36 #define android_npapi_H 37 38 #include <stdint.h> 39 40 #include "npapi.h" 41 42 /////////////////////////////////////////////////////////////////////////////// 43 // General types 44 45 enum ANPBitmapFormats { 46 kUnknown_ANPBitmapFormat = 0, 47 kRGBA_8888_ANPBitmapFormat = 1, 48 kRGB_565_ANPBitmapFormat = 2 49 }; 50 typedef int32_t ANPBitmapFormat; 51 52 struct ANPBitmap { 53 void* baseAddr; 54 ANPBitmapFormat format; 55 int32_t width; 56 int32_t height; 57 int32_t rowBytes; 58 }; 59 60 struct ANPRectF { 61 float left; 62 float top; 63 float right; 64 float bottom; 65 }; 66 67 struct ANPRectI { 68 int32_t left; 69 int32_t top; 70 int32_t right; 71 int32_t bottom; 72 }; 73 74 struct ANPCanvas; 75 struct ANPMatrix; 76 struct ANPPaint; 77 struct ANPPath; 78 struct ANPRegion; 79 struct ANPTypeface; 80 81 enum ANPMatrixFlags { 82 kIdentity_ANPMatrixFlag = 0, 83 kTranslate_ANPMatrixFlag = 0x01, 84 kScale_ANPMatrixFlag = 0x02, 85 kAffine_ANPMatrixFlag = 0x04, 86 kPerspective_ANPMatrixFlag = 0x08, 87 }; 88 typedef uint32_t ANPMatrixFlag; 89 90 /////////////////////////////////////////////////////////////////////////////// 91 // NPN_GetValue 92 93 /* queries for a specific ANPInterface. 94 95 Maybe called with NULL for the NPP instance 96 97 NPN_GetValue(inst, interface_enum, ANPInterface*) 98 */ 99 #define kLogInterfaceV0_ANPGetValue ((NPNVariable)1000) 100 #define kAudioTrackInterfaceV0_ANPGetValue ((NPNVariable)1001) 101 #define kCanvasInterfaceV0_ANPGetValue ((NPNVariable)1002) 102 #define kMatrixInterfaceV0_ANPGetValue ((NPNVariable)1003) 103 #define kPaintInterfaceV0_ANPGetValue ((NPNVariable)1004) 104 #define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1005) 105 #define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1006) 106 107 /* queries for which drawing model is desired (for the draw event) 108 109 Should be called inside NPP_New(...) 110 111 NPN_GetValue(inst, ANPSupportedDrawingModel_EnumValue, uint32_t* bits) 112 */ 113 #define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000) 114 115 /////////////////////////////////////////////////////////////////////////////// 116 // NPN_GetValue 117 118 /** Reqeust to set the drawing model. 119 120 NPN_SetValue(inst, ANPRequestDrawingModel_EnumValue, (void*)foo_DrawingModel) 121 */ 122 #define kRequestDrawingModel_ANPSetValue ((NPPVariable)1000) 123 124 /* These are used as bitfields in ANPSupportedDrawingModels_EnumValue, 125 and as-is in ANPRequestDrawingModel_EnumValue. The drawing model determines 126 how to interpret the ANPDrawingContext provided in the Draw event and how 127 to interpret the NPWindow->window field. 128 */ 129 enum ANPDrawingModels { 130 /** Draw into a bitmap from the browser thread in response to a Draw event. 131 NPWindow->window is reserved (ignore) 132 */ 133 kBitmap_ANPDrawingModel = 0, 134 }; 135 typedef int32_t ANPDrawingModel; 136 137 /* Interfaces provide additional functionality to the plugin via function ptrs. 138 Once an interface is retrived, it is valid for the lifetime of the plugin 139 (just like browserfuncs). 140 141 All ANPInterfaces begin with an inSize field, which must be set by the 142 caller (plugin) with the number of bytes allocated for the interface. 143 e.g. SomeInterface si; si.inSize = sizeof(si); browser->getvalue(..., &si); 144 */ 145 struct ANPInterface { 146 uint32_t inSize; // size (in bytes) of this struct 147 }; 148 149 enum ANPLogTypes { 150 kError_ANPLogType = 0, // error 151 kWarning_ANPLogType = 1, // warning 152 kDebug_ANPLogType = 2 // debug only (informational) 153 }; 154 typedef int32_t ANPLogType; 155 156 struct ANPLogInterfaceV0 : ANPInterface { 157 // dumps printf messages to the log file 158 // e.g. interface->log(instance, kWarning_ANPLogType, "value is %d", value); 159 void (*log)(NPP instance, ANPLogType, const char format[], ...); 160 }; 161 162 struct ANPMatrixInterfaceV0 : ANPInterface { 163 /* Return a new identity matrix 164 */ 165 ANPMatrix* (*newMatrix)(); 166 /* Delete a matrix previously allocated by newMatrix() 167 */ 168 void (*deleteMatrix)(ANPMatrix*); 169 170 ANPMatrixFlag (*getFlags)(const ANPMatrix*); 171 172 void (*copy)(ANPMatrix* dst, const ANPMatrix* src); 173 174 /* Return the matrix values in a float array (allcoated by the caller), 175 where the values are treated as follows: 176 w = x * [6] + y * [7] + [8]; 177 x' = (x * [0] + y * [1] + [2]) / w; 178 y' = (x * [3] + y * [4] + [5]) / w; 179 */ 180 void (*get3x3)(const ANPMatrix*, float[9]); 181 /* Initialize the matrix from values in a float array, 182 where the values are treated as follows: 183 w = x * [6] + y * [7] + [8]; 184 x' = (x * [0] + y * [1] + [2]) / w; 185 y' = (x * [3] + y * [4] + [5]) / w; 186 */ 187 void (*set3x3)(ANPMatrix*, const float[9]); 188 189 void (*setIdentity)(ANPMatrix*); 190 void (*preTranslate)(ANPMatrix*, float tx, float ty); 191 void (*postTranslate)(ANPMatrix*, float tx, float ty); 192 void (*preScale)(ANPMatrix*, float sx, float sy); 193 void (*postScale)(ANPMatrix*, float sx, float sy); 194 void (*preSkew)(ANPMatrix*, float kx, float ky); 195 void (*postSkew)(ANPMatrix*, float kx, float ky); 196 void (*preRotate)(ANPMatrix*, float degrees); 197 void (*postRotate)(ANPMatrix*, float degrees); 198 void (*preConcat)(ANPMatrix*, const ANPMatrix*); 199 void (*postConcat)(ANPMatrix*, const ANPMatrix*); 200 201 /* Return true if src is invertible, and if so, return its inverse in dst. 202 If src is not invertible, return false and ignore dst. 203 */ 204 bool (*invert)(ANPMatrix* dst, const ANPMatrix* src); 205 206 /* Transform the x,y pairs in src[] by this matrix, and store the results 207 in dst[]. The count parameter is treated as the number of pairs in the 208 array. It is legal for src and dst to point to the same memory, but 209 illegal for the two arrays to partially overlap. 210 */ 211 void (*mapPoints)(ANPMatrix*, float dst[], const float src[], 212 int32_t count); 213 }; 214 215 typedef uint32_t ANPColor; 216 #define ANP_MAKE_COLOR(a, r, g, b) \ 217 (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) 218 219 enum ANPPaintFlag { 220 kAntiAlias_ANPPaintFlag = 1 << 0, 221 kFilterBitmap_ANPPaintFlag = 1 << 1, 222 kDither_ANPPaintFlag = 1 << 2, 223 kUnderlineText_ANPPaintFlag = 1 << 3, 224 kStrikeThruText_ANPPaintFlag = 1 << 4, 225 kFakeBoldText_ANPPaintFlag = 1 << 5, 226 }; 227 typedef uint32_t ANPPaintFlags; 228 229 enum ANPPaintStyles { 230 kFill_ANPPaintStyle = 0, 231 kStroke_ANPPaintStyle = 1, 232 kFillAndStroke_ANPPaintStyle = 2 233 }; 234 typedef int32_t ANPPaintStyle; 235 236 enum ANPPaintCaps { 237 kButt_ANPPaintCap = 0, 238 kRound_ANPPaintCap = 1, 239 kSquare_ANPPaintCap = 2 240 }; 241 typedef int32_t ANPPaintCap; 242 243 enum ANPPaintJoins { 244 kMiter_ANPPaintJoin = 0, 245 kRound_ANPPaintJoin = 1, 246 kBevel_ANPPaintJoin = 2 247 }; 248 typedef int32_t ANPPaintJoin; 249 250 enum ANPPaintAligns { 251 kLeft_ANPPaintAlign = 0, 252 kCenter_ANPPaintAlign = 1, 253 kRight_ANPPaintAlign = 2 254 }; 255 typedef int32_t ANPPaintAlign; 256 257 enum ANPTextEncodings { 258 kUTF8_ANPTextEncoding = 0, 259 kUTF16_ANPTextEncoding = 1, 260 }; 261 typedef int32_t ANPTextEncoding; 262 263 enum ANPTypefaceStyles { 264 kBold_ANPTypefaceStyle = 1 << 0, 265 kItalic_ANPTypefaceStyle = 1 << 1 266 }; 267 typedef uint32_t ANPTypefaceStyle; 268 269 struct ANPFontMetrics { 270 //! The greatest distance above the baseline for any glyph (will be <= 0) 271 float fTop; 272 //! The recommended distance above the baseline (will be <= 0) 273 float fAscent; 274 //! The recommended distance below the baseline (will be >= 0) 275 float fDescent; 276 //! The greatest distance below the baseline for any glyph (will be >= 0) 277 float fBottom; 278 //! The recommended distance to add between lines of text (will be >= 0) 279 float fLeading; 280 }; 281 282 struct ANPTypefaceInterfaceV0 : ANPInterface { 283 /** Return a new reference to the typeface that most closely matches the 284 requested name and style. Pass null as the name to return 285 the default font for the requested style. Will never return null 286 287 @param name May be NULL. The name of the font family. 288 @param style The style (normal, bold, italic) of the typeface. 289 @return reference to the closest-matching typeface. Caller must call 290 unref() when they are done with the typeface. 291 */ 292 ANPTypeface* (*createFromName)(const char name[], ANPTypefaceStyle); 293 294 /** Return a new reference to the typeface that most closely matches the 295 requested typeface and specified Style. Use this call if you want to 296 pick a new style from the same family of the existing typeface. 297 If family is NULL, this selects from the default font's family. 298 299 @param family May be NULL. The name of the existing type face. 300 @param s The style (normal, bold, italic) of the type face. 301 @return reference to the closest-matching typeface. Call must call 302 unref() when they are done. 303 */ 304 ANPTypeface* (*createFromTypeface)(const ANPTypeface* family, 305 ANPTypefaceStyle); 306 307 /** Return the owner count of the typeface. A newly created typeface has an 308 owner count of 1. When the owner count is reaches 0, the typeface is 309 deleted. 310 */ 311 int32_t (*getRefCount)(const ANPTypeface*); 312 313 /** Increment the owner count on the typeface 314 */ 315 void (*ref)(ANPTypeface*); 316 317 /** Decrement the owner count on the typeface. When the count goes to 0, 318 the typeface is deleted. 319 */ 320 void (*unref)(ANPTypeface*); 321 322 /** Return the style bits for the specified typeface 323 */ 324 ANPTypefaceStyle (*getStyle)(const ANPTypeface*); 325 }; 326 327 struct ANPPaintInterfaceV0 : ANPInterface { 328 /* Return a new paint object, which holds all of the color and style 329 attributes that affect how things (geometry, text, bitmaps) are drawn 330 in a ANPCanvas. 331 332 The paint that is returned is not tied to any particular plugin 333 instance, but it must only be accessed from one thread at a time. 334 */ 335 ANPPaint* (*newPaint)(); 336 void (*deletePaint)(ANPPaint*); 337 338 ANPPaintFlags (*getFlags)(const ANPPaint*); 339 void (*setFlags)(ANPPaint*, ANPPaintFlags); 340 341 ANPColor (*getColor)(const ANPPaint*); 342 void (*setColor)(ANPPaint*, ANPColor); 343 344 ANPPaintStyle (*getStyle)(const ANPPaint*); 345 void (*setStyle)(ANPPaint*, ANPPaintStyle); 346 347 float (*getStrokeWidth)(const ANPPaint*); 348 float (*getStrokeMiter)(const ANPPaint*); 349 ANPPaintCap (*getStrokeCap)(const ANPPaint*); 350 ANPPaintJoin (*getStrokeJoin)(const ANPPaint*); 351 void (*setStrokeWidth)(ANPPaint*, float); 352 void (*setStrokeMiter)(ANPPaint*, float); 353 void (*setStrokeCap)(ANPPaint*, ANPPaintCap); 354 void (*setStrokeJoin)(ANPPaint*, ANPPaintJoin); 355 356 ANPTextEncoding (*getTextEncoding)(const ANPPaint*); 357 ANPPaintAlign (*getTextAlign)(const ANPPaint*); 358 float (*getTextSize)(const ANPPaint*); 359 float (*getTextScaleX)(const ANPPaint*); 360 float (*getTextSkewX)(const ANPPaint*); 361 void (*setTextEncoding)(ANPPaint*, ANPTextEncoding); 362 void (*setTextAlign)(ANPPaint*, ANPPaintAlign); 363 void (*setTextSize)(ANPPaint*, float); 364 void (*setTextScaleX)(ANPPaint*, float); 365 void (*setTextSkewX)(ANPPaint*, float); 366 367 /** Return the typeface ine paint, or null if there is none. This does not 368 modify the owner count of the returned typeface. 369 */ 370 ANPTypeface* (*getTypeface)(const ANPPaint*); 371 372 /** Set the paint's typeface. If the paint already had a non-null typeface, 373 its owner count is decremented. If the new typeface is non-null, its 374 owner count is incremented. 375 */ 376 void (*setTypeface)(ANPPaint*, ANPTypeface*); 377 378 /** Return the width of the text. If bounds is not null, return the bounds 379 of the text in that rectangle. 380 */ 381 float (*measureText)(ANPPaint*, const void* text, uint32_t byteLength, 382 ANPRectF* bounds); 383 384 /** Return the number of unichars specifed by the text. 385 If widths is not null, returns the array of advance widths for each 386 unichar. 387 If bounds is not null, returns the array of bounds for each unichar. 388 */ 389 int (*getTextWidths)(ANPPaint*, const void* text, uint32_t byteLength, 390 float widths[], ANPRectF bounds[]); 391 392 /** Return in metrics the spacing values for text, respecting the paint's 393 typeface and pointsize, and return the spacing between lines 394 (descent - ascent + leading). If metrics is NULL, it will be ignored. 395 */ 396 float (*getFontMetrics)(ANPPaint*, ANPFontMetrics* metrics); 397 }; 398 399 struct ANPCanvasInterfaceV0 : ANPInterface { 400 /* Return a canvas that will draw into the specified bitmap. Note: the 401 canvas copies the fields of the bitmap, so it need not persist after 402 this call, but the canvas DOES point to the same pixel memory that the 403 bitmap did, so the canvas should not be used after that pixel memory 404 goes out of scope. In the case of creating a canvas to draw into the 405 pixels provided by kDraw_ANPEventType, those pixels are only while 406 handling that event. 407 408 The canvas that is returned is not tied to any particular plugin 409 instance, but it must only be accessed from one thread at a time. 410 */ 411 ANPCanvas* (*newCanvas)(const ANPBitmap*); 412 void (*deleteCanvas)(ANPCanvas*); 413 414 void (*save)(ANPCanvas*); 415 void (*restore)(ANPCanvas*); 416 void (*translate)(ANPCanvas*, float tx, float ty); 417 void (*scale)(ANPCanvas*, float sx, float sy); 418 void (*rotate)(ANPCanvas*, float degrees); 419 void (*skew)(ANPCanvas*, float kx, float ky); 420 void (*concat)(ANPCanvas*, const ANPMatrix*); 421 void (*clipRect)(ANPCanvas*, const ANPRectF*); 422 void (*clipPath)(ANPCanvas*, const ANPPath*); 423 424 /* Return the current matrix on the canvas 425 */ 426 void (*getTotalMatrix)(ANPCanvas*, ANPMatrix*); 427 /* Return the current clip bounds in local coordinates, expanding it to 428 account for antialiasing edge effects if aa is true. If the 429 current clip is empty, return false and ignore the bounds argument. 430 */ 431 bool (*getLocalClipBounds)(ANPCanvas*, ANPRectF* bounds, bool aa); 432 /* Return the current clip bounds in device coordinates in bounds. If the 433 current clip is empty, return false and ignore the bounds argument. 434 */ 435 bool (*getDeviceClipBounds)(ANPCanvas*, ANPRectI* bounds); 436 437 void (*drawColor)(ANPCanvas*, ANPColor); 438 void (*drawPaint)(ANPCanvas*, const ANPPaint*); 439 void (*drawRect)(ANPCanvas*, const ANPRectF*, const ANPPaint*); 440 void (*drawOval)(ANPCanvas*, const ANPRectF*, const ANPPaint*); 441 void (*drawPath)(ANPCanvas*, const ANPPath*, const ANPPaint*); 442 void (*drawText)(ANPCanvas*, const void* text, uint32_t byteLength, 443 float x, float y, const ANPPaint*); 444 void (*drawPosText)(ANPCanvas*, const void* text, uint32_t byteLength, 445 const float xy[], const ANPPaint*); 446 void (*drawBitmap)(ANPCanvas*, const ANPBitmap*, float x, float y, 447 const ANPPaint*); 448 void (*drawBitmapRect)(ANPCanvas*, const ANPBitmap*, 449 const ANPRectI* src, const ANPRectF* dst, 450 const ANPPaint*); 451 }; 452 453 struct ANPWindowInterfaceV0 : ANPInterface { 454 /** Given the window field from the NPWindow struct, and an optional rect 455 describing the subset of the window that will be drawn to (may be null) 456 return true if the bitmap for that window can be accessed, and if so, 457 fill out the specified ANPBitmap to point to the window's pixels. 458 459 When drawing is complete, call unlock(window) 460 */ 461 bool (*lockRect)(void* window, const ANPRectI* inval, ANPBitmap*); 462 /** The same as lockRect, but takes a region instead of a rect to specify 463 the area that will be changed/drawn. 464 */ 465 bool (*lockRegion)(void* window, const ANPRegion* inval, ANPBitmap*); 466 /** Given a successful call to lock(window, inval, &bitmap), call unlock 467 to release access to the pixels, and allow the browser to display the 468 results. If lock returned false, unlock should not be called. 469 */ 470 void (*unlock)(void* window); 471 }; 472 473 /////////////////////////////////////////////////////////////////////////////// 474 475 enum ANPSampleFormats { 476 kUnknown_ANPSamleFormat = 0, 477 kPCM16Bit_ANPSampleFormat = 1, 478 kPCM8Bit_ANPSampleFormat = 2 479 }; 480 typedef int32_t ANPSampleFormat; 481 482 /** The audio buffer is passed to the callback proc to request more samples. 483 It is owned by the system, and the callback may read it, but should not 484 maintain a pointer to it outside of the scope of the callback proc. 485 */ 486 struct ANPAudioBuffer { 487 // RO - repeat what was specified in newTrack() 488 int32_t channelCount; 489 // RO - repeat what was specified in newTrack() 490 ANPSampleFormat format; 491 /** This buffer is owned by the caller. Inside the callback proc, up to 492 "size" bytes of sample data should be written into this buffer. The 493 address is only valid for the scope of a single invocation of the 494 callback proc. 495 */ 496 void* bufferData; 497 /** On input, specifies the maximum number of bytes that can be written 498 to "bufferData". On output, specifies the actual number of bytes that 499 the callback proc wrote into "bufferData". 500 */ 501 uint32_t size; 502 }; 503 504 enum ANPAudioEvents { 505 /** This event is passed to the callback proc when the audio-track needs 506 more sample data written to the provided buffer parameter. 507 */ 508 kMoreData_ANPAudioEvent = 0, 509 /** This event is passed to the callback proc if the audio system runs out 510 of sample data. In this event, no buffer parameter will be specified 511 (i.e. NULL will be passed to the 3rd parameter). 512 */ 513 kUnderRun_ANPAudioEvent = 1 514 }; 515 typedef int32_t ANPAudioEvent; 516 517 /** Called to feed sample data to the track. This will be called in a separate 518 thread. However, you may call trackStop() from the callback (but you 519 cannot delete the track). 520 521 For example, when you have written the last chunk of sample data, you can 522 immediately call trackStop(). This will take effect after the current 523 buffer has been played. 524 525 The "user" parameter is the same value that was passed to newTrack() 526 */ 527 typedef void (*ANPAudioCallbackProc)(ANPAudioEvent event, void* user, 528 ANPAudioBuffer* buffer); 529 530 struct ANPAudioTrack; // abstract type for audio tracks 531 532 struct ANPAudioTrackInterfaceV0 : ANPInterface { 533 /* Create a new audio track, or NULL on failure. 534 */ 535 ANPAudioTrack* (*newTrack)(uint32_t sampleRate, // sampling rate in Hz 536 ANPSampleFormat, 537 int channelCount, // MONO=1, STEREO=2 538 ANPAudioCallbackProc, 539 void* user); 540 void (*deleteTrack)(ANPAudioTrack*); 541 542 void (*start)(ANPAudioTrack*); 543 void (*pause)(ANPAudioTrack*); 544 void (*stop)(ANPAudioTrack*); 545 /** Returns true if the track is not playing (e.g. pause or stop was called, 546 or start was never called. 547 */ 548 bool (*isStopped)(ANPAudioTrack*); 549 }; 550 551 /////////////////////////////////////////////////////////////////////////////// 552 // HandleEvent 553 554 enum ANPEventTypes { 555 kNull_ANPEventType = 0, 556 kKey_ANPEventType = 1, 557 kTouch_ANPEventType = 2, 558 kDraw_ANPEventType = 3, 559 }; 560 typedef int32_t ANPEventType; 561 562 enum ANPKeyActions { 563 kDown_ANPKeyAction = 0, 564 kUp_ANPKeyAction = 1, 565 }; 566 typedef int32_t ANPKeyAction; 567 568 #include "ANPKeyCodes.h" 569 typedef int32_t ANPKeyCode; 570 571 enum ANPKeyModifiers { 572 kAlt_ANPKeyModifier = 1 << 0, 573 kShift_ANPKeyModifier = 1 << 1, 574 }; 575 // bit-field containing some number of ANPKeyModifier bits 576 typedef uint32_t ANPKeyModifier; 577 578 enum ANPTouchActions { 579 kDown_ANPTouchAction = 0, 580 kUp_ANPTouchAction = 1, 581 }; 582 typedef int32_t ANPTouchAction; 583 584 struct ANPDrawContext { 585 ANPDrawingModel model; 586 // relative to (0,0) in top-left of your plugin 587 ANPRectI clip; 588 // use based on the value in model 589 union { 590 ANPBitmap bitmap; 591 } data; 592 }; 593 594 /* This is what is passed to NPP_HandleEvent() */ 595 struct ANPEvent { 596 uint32_t inSize; // size of this struct in bytes 597 ANPEventType eventType; 598 // use based on the value in eventType 599 union { 600 struct { 601 ANPKeyAction action; 602 ANPKeyCode nativeCode; 603 int32_t virtualCode; // windows virtual key code 604 ANPKeyModifier modifiers; 605 int32_t repeatCount; // 0 for initial down (or up) 606 int32_t unichar; // 0 if there is no value 607 } key; 608 struct { 609 ANPTouchAction action; 610 ANPKeyModifier modifiers; 611 int32_t x; // relative to your "window" (0...width) 612 int32_t y; // relative to your "window" (0...height) 613 } touch; 614 ANPDrawContext drawContext; 615 int32_t other[8]; 616 } data; 617 }; 618 619 #endif 620 621