J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | #ifndef GraphicsPrimitiveMgr_h_Included |
| 27 | #define GraphicsPrimitiveMgr_h_Included |
| 28 | |
| 29 | #ifdef __cplusplus |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
| 33 | #include "java_awt_AlphaComposite.h" |
| 34 | |
| 35 | #include "SurfaceData.h" |
| 36 | #include "SpanIterator.h" |
| 37 | |
| 38 | #include "j2d_md.h" |
| 39 | |
| 40 | #include "AlphaMath.h" |
| 41 | #include "GlyphImageRef.h" |
| 42 | |
| 43 | /* |
| 44 | * This structure contains all of the information about a particular |
| 45 | * type of GraphicsPrimitive, such as a FillRect, a MaskFill, or a Blit. |
| 46 | * |
| 47 | * A global collection of these structures is declared and initialized |
| 48 | * to contain the necessary Java (JNI) information so that appropriate |
| 49 | * Java GraphicsPrimitive objects can be quickly constructed for a set |
| 50 | * of native loops simply by referencing the necessary entry from that |
| 51 | * collection for the type of primitive being registered. |
| 52 | * |
| 53 | * See PrimitiveTypes.{Blit,BlitBg,FillRect,...} below. |
| 54 | */ |
| 55 | typedef struct _PrimitiveType { |
| 56 | char *ClassName; |
| 57 | jint srcflags; |
| 58 | jint dstflags; |
| 59 | jclass ClassObject; |
| 60 | jmethodID Constructor; |
| 61 | } PrimitiveType; |
| 62 | |
| 63 | /* The integer constants to identify the compositing rule being defined. */ |
| 64 | #define RULE_Xor (java_awt_AlphaComposite_MIN_RULE - 1) |
| 65 | #define RULE_Clear java_awt_AlphaComposite_CLEAR |
| 66 | #define RULE_Src java_awt_AlphaComposite_SRC |
| 67 | #define RULE_SrcOver java_awt_AlphaComposite_SRC_OVER |
| 68 | #define RULE_DstOver java_awt_AlphaComposite_DST_OVER |
| 69 | #define RULE_SrcIn java_awt_AlphaComposite_SRC_IN |
| 70 | #define RULE_DstIn java_awt_AlphaComposite_DST_IN |
| 71 | #define RULE_SrcOut java_awt_AlphaComposite_SRC_OUT |
| 72 | #define RULE_DstOut java_awt_AlphaComposite_DST_OUT |
| 73 | |
| 74 | /* |
| 75 | * This structure holds the information retrieved from a Java |
| 76 | * Composite object for easy transfer to various C functions |
| 77 | * that implement the inner loop for a native primitive. |
| 78 | * |
| 79 | * Currently only AlphaComposite and XORComposite are supported. |
| 80 | */ |
| 81 | typedef struct _CompositeInfo { |
| 82 | jint rule; /* See RULE_* constants above */ |
| 83 | union { |
| 84 | jfloat extraAlpha; /* from AlphaComposite */ |
| 85 | jint xorPixel; /* from XORComposite */ |
| 86 | } details; |
| 87 | juint alphaMask; /* from XORComposite */ |
| 88 | } CompositeInfo; |
| 89 | |
| 90 | /* |
| 91 | * This structure is the common header for the two native structures |
| 92 | * that hold information about a particular SurfaceType or CompositeType. |
| 93 | * |
| 94 | * A global collection of these structures is declared and initialized |
| 95 | * to contain the necessary Java (JNI) information so that appropriate |
| 96 | * Java GraphicsPrimitive objects can be quickly constructed for a set |
| 97 | * of native loops simply by referencing the necessary entry from that |
| 98 | * collection for the type of composite or surface being implemented. |
| 99 | * |
| 100 | * See SurfaceTypes.{OpaqueColor,IntArgb,ByteGray,...} below. |
| 101 | * See CompositeTypes.{Xor,AnyAlpha,...} below. |
| 102 | */ |
| 103 | typedef struct _SurfCompHdr { |
| 104 | char *Name; |
| 105 | jobject Object; |
| 106 | } SurfCompHdr; |
| 107 | |
| 108 | /* |
| 109 | * The definitions for the SurfaceType structure described above. |
| 110 | */ |
| 111 | |
| 112 | /* |
| 113 | * The signature for a function that returns the specific integer |
| 114 | * format pixel for a given ARGB color value for a particular |
| 115 | * SurfaceType implementation. |
| 116 | * This function is valid only after GetRasInfo call for the |
| 117 | * associated surface. |
| 118 | */ |
| 119 | typedef jint (PixelForFunc)(SurfaceDataRasInfo *pRasInfo, jint rgb); |
| 120 | |
| 121 | /* |
| 122 | * The additional information needed to manipulate a surface: |
| 123 | * - The pixelFor function for translating ARGB values. |
| 124 | * Valid only after GetRasInfo call for this surface. |
| 125 | * - The additional flags needed when reading from this surface. |
| 126 | * - The additional flags needed when writing to this surface. |
| 127 | */ |
| 128 | typedef struct _SurfaceType { |
| 129 | SurfCompHdr hdr; |
| 130 | PixelForFunc *pixelFor; |
| 131 | jint readflags; |
| 132 | jint writeflags; |
| 133 | } SurfaceType; |
| 134 | |
| 135 | /* |
| 136 | * The definitions for the CompositeType structure described above. |
| 137 | */ |
| 138 | |
| 139 | /* |
| 140 | * The signature for a function that fills in a CompositeInfo |
| 141 | * structure from the information present in a given Java Composite |
| 142 | * object. |
| 143 | */ |
| 144 | typedef JNIEXPORT void (JNICALL CompInfoFunc)(JNIEnv *env, |
| 145 | CompositeInfo *pCompInfo, |
| 146 | jobject Composite); |
| 147 | |
| 148 | /* |
| 149 | * The additional information needed to implement a primitive that |
| 150 | * performs a particular composite operation: |
| 151 | * - The getCompInfo function for filling in a CompositeInfo structure. |
| 152 | * - The additional flags needed for locking the destination surface. |
| 153 | */ |
| 154 | typedef struct _CompositeType { |
| 155 | SurfCompHdr hdr; |
| 156 | CompInfoFunc *getCompInfo; |
| 157 | jint dstflags; |
| 158 | } CompositeType; |
| 159 | |
| 160 | /* |
| 161 | * The signature of the native functions that register a set of |
| 162 | * related native GraphicsPrimitive functions. |
| 163 | */ |
| 164 | typedef jboolean (RegisterFunc)(JNIEnv *env); |
| 165 | |
| 166 | struct _NativePrimitive; /* forward reference for function typedefs */ |
| 167 | |
| 168 | /* |
| 169 | * This empty function signature represents an "old pre-ANSI style" |
| 170 | * function declaration which makes no claims about the argument list |
| 171 | * other than that the types of the arguments will undergo argument |
| 172 | * promotion in the calling conventions. |
| 173 | * (See section A7.3.2 in K&R 2nd edition.) |
| 174 | * |
| 175 | * When trying to statically initialize the function pointer field of |
| 176 | * a NativePrimitive structure, which is a union of all possible |
| 177 | * inner loop function signatures, the initializer constant must be |
| 178 | * compatible with the first field in the union. This generic function |
| 179 | * type allows us to assign any function pointer to that union as long |
| 180 | * as it meets the requirements specified above (i.e. all arguments |
| 181 | * are compatible with their promoted values according to the old |
| 182 | * style argument promotion calling semantics). |
| 183 | * |
| 184 | * Note: This means that you cannot define an argument to any of |
| 185 | * these native functions which is a byte or a short as that value |
| 186 | * would not be passed in the same way for an ANSI-style full prototype |
| 187 | * calling convention and an old-style argument promotion calling |
| 188 | * convention. |
| 189 | */ |
| 190 | typedef void (AnyFunc)(); |
| 191 | |
| 192 | /* |
| 193 | * The signature of the inner loop function for a "Blit". |
| 194 | */ |
| 195 | typedef void (BlitFunc)(void *pSrc, void *pDst, |
| 196 | juint width, juint height, |
| 197 | SurfaceDataRasInfo *pSrcInfo, |
| 198 | SurfaceDataRasInfo *pDstInfo, |
| 199 | struct _NativePrimitive *pPrim, |
| 200 | CompositeInfo *pCompInfo); |
| 201 | |
| 202 | /* |
| 203 | * The signature of the inner loop function for a "BlitBg". |
| 204 | */ |
| 205 | typedef void (BlitBgFunc)(void *pSrc, void *pDst, |
| 206 | juint width, juint height, jint bgpixel, |
| 207 | SurfaceDataRasInfo *pSrcInfo, |
| 208 | SurfaceDataRasInfo *pDstInfo, |
| 209 | struct _NativePrimitive *pPrim, |
| 210 | CompositeInfo *pCompInfo); |
| 211 | |
| 212 | /* |
| 213 | * The signature of the inner loop function for a "ScaleBlit". |
| 214 | */ |
| 215 | typedef void (ScaleBlitFunc)(void *pSrc, void *pDst, |
| 216 | juint dstwidth, juint dstheight, |
| 217 | jint sxloc, jint syloc, |
| 218 | jint sxinc, jint syinc, jint scale, |
| 219 | SurfaceDataRasInfo *pSrcInfo, |
| 220 | SurfaceDataRasInfo *pDstInfo, |
| 221 | struct _NativePrimitive *pPrim, |
| 222 | CompositeInfo *pCompInfo); |
| 223 | |
| 224 | /* |
| 225 | * The signature of the inner loop function for a "FillRect". |
| 226 | */ |
| 227 | typedef void (FillRectFunc)(SurfaceDataRasInfo *pRasInfo, |
| 228 | jint lox, jint loy, |
| 229 | jint hix, jint hiy, |
| 230 | jint pixel, struct _NativePrimitive *pPrim, |
| 231 | CompositeInfo *pCompInfo); |
| 232 | |
| 233 | /* |
| 234 | * The signature of the inner loop function for a "FillSpans". |
| 235 | */ |
| 236 | typedef void (FillSpansFunc)(SurfaceDataRasInfo *pRasInfo, |
| 237 | SpanIteratorFuncs *pSpanFuncs, void *siData, |
| 238 | jint pixel, struct _NativePrimitive *pPrim, |
| 239 | CompositeInfo *pCompInfo); |
| 240 | |
| 241 | /* |
| 242 | * The signature of the inner loop function for a "DrawLine". |
| 243 | * Note that this same inner loop is used for native DrawRect |
| 244 | * and DrawPolygons primitives. |
| 245 | */ |
| 246 | typedef void (DrawLineFunc)(SurfaceDataRasInfo *pRasInfo, |
| 247 | jint x1, jint y1, jint pixel, |
| 248 | jint steps, jint error, |
| 249 | jint bumpmajormask, jint errmajor, |
| 250 | jint bumpminormask, jint errminor, |
| 251 | struct _NativePrimitive *pPrim, |
| 252 | CompositeInfo *pCompInfo); |
| 253 | |
| 254 | /* |
| 255 | * The signature of the inner loop function for a "MaskFill". |
| 256 | */ |
| 257 | typedef void (MaskFillFunc)(void *pRas, |
| 258 | unsigned char *pMask, jint maskOff, jint maskScan, |
| 259 | jint width, jint height, |
| 260 | jint fgColor, |
| 261 | SurfaceDataRasInfo *pRasInfo, |
| 262 | struct _NativePrimitive *pPrim, |
| 263 | CompositeInfo *pCompInfo); |
| 264 | |
| 265 | /* |
| 266 | * The signature of the inner loop function for a "MaskBlit". |
| 267 | */ |
| 268 | typedef void (MaskBlitFunc)(void *pDst, void *pSrc, |
| 269 | unsigned char *pMask, jint maskOff, jint maskScan, |
| 270 | jint width, jint height, |
| 271 | SurfaceDataRasInfo *pDstInfo, |
| 272 | SurfaceDataRasInfo *pSrcInfo, |
| 273 | struct _NativePrimitive *pPrim, |
| 274 | CompositeInfo *pCompInfo); |
| 275 | /* |
| 276 | * The signature of the inner loop function for a "DrawGlyphList". |
| 277 | */ |
| 278 | typedef void (DrawGlyphListFunc)(SurfaceDataRasInfo *pRasInfo, |
| 279 | ImageRef *glyphs, |
| 280 | jint totalGlyphs, |
| 281 | jint fgpixel, jint fgcolor, |
| 282 | jint cx1, jint cy1, |
| 283 | jint cx2, jint cy2, |
| 284 | struct _NativePrimitive *pPrim, |
| 285 | CompositeInfo *pCompInfo); |
| 286 | |
| 287 | /* |
| 288 | * The signature of the inner loop function for a "DrawGlyphListAA". |
| 289 | */ |
| 290 | typedef void (DrawGlyphListAAFunc)(SurfaceDataRasInfo *pRasInfo, |
| 291 | ImageRef *glyphs, |
| 292 | jint totalGlyphs, |
| 293 | jint fgpixel, jint fgcolor, |
| 294 | jint cx1, jint cy1, |
| 295 | jint cx2, jint cy2, |
| 296 | struct _NativePrimitive *pPrim, |
| 297 | CompositeInfo *pCompInfo); |
| 298 | |
| 299 | /* |
| 300 | * The signature of the inner loop function for a "DrawGlyphListLCD". |
| 301 | * rgbOrder is a jint rather than a jboolean so that this typedef matches |
| 302 | * AnyFunc which is the first element in a union in NativePrimitive's |
| 303 | * initialiser. See the comments alongside declaration of the AnyFunc type for |
| 304 | * a full explanation. |
| 305 | */ |
| 306 | typedef void (DrawGlyphListLCDFunc)(SurfaceDataRasInfo *pRasInfo, |
| 307 | ImageRef *glyphs, |
| 308 | jint totalGlyphs, |
| 309 | jint fgpixel, jint fgcolor, |
| 310 | jint cx1, jint cy1, |
| 311 | jint cx2, jint cy2, |
| 312 | jint rgbOrder, |
| 313 | unsigned char *gammaLut, |
| 314 | unsigned char *invGammaLut, |
| 315 | struct _NativePrimitive *pPrim, |
| 316 | CompositeInfo *pCompInfo); |
| 317 | |
| 318 | /* |
| 319 | * The signature of the inner loop functions for a "TransformHelper". |
| 320 | */ |
| 321 | typedef void (TransformHelperFunc)(SurfaceDataRasInfo *pSrcInfo, |
| 322 | jint *pRGB, jint numpix, |
| 323 | jlong xlong, jlong dxlong, |
| 324 | jlong ylong, jlong dylong); |
| 325 | |
| 326 | typedef struct { |
| 327 | TransformHelperFunc *nnHelper; |
| 328 | TransformHelperFunc *blHelper; |
| 329 | TransformHelperFunc *bcHelper; |
| 330 | } TransformHelperFuncs; |
| 331 | |
| 332 | typedef void (TransformInterpFunc)(jint *pRGBbase, jint numpix, |
| 333 | jint xfract, jint dxfract, |
| 334 | jint yfract, jint dyfract); |
| 335 | |
| 336 | /* |
| 337 | * This structure contains all information for defining a single |
| 338 | * native GraphicsPrimitive, including: |
| 339 | * - The information about the type of the GraphicsPrimitive subclass. |
| 340 | * - The information about the type of the source surface. |
| 341 | * - The information about the type of the compositing operation. |
| 342 | * - The information about the type of the destination surface. |
| 343 | * - A pointer to the function that performs the actual inner loop work. |
| 344 | * - Extra flags needed for locking the source and destination surfaces |
| 345 | * above and beyond the flags specified in the Primitive, Composite |
| 346 | * and SurfaceType structures. (For most native primitives these |
| 347 | * flags can be calculated automatically from information stored in |
| 348 | * the PrimitiveType, SurfaceType, and CompositeType structures.) |
| 349 | */ |
| 350 | typedef struct _NativePrimitive { |
| 351 | PrimitiveType *pPrimType; |
| 352 | SurfaceType *pSrcType; |
| 353 | CompositeType *pCompType; |
| 354 | SurfaceType *pDstType; |
| 355 | /* See declaration of AnyFunc type above for comments explaining why |
| 356 | * only AnyFunc is used by the initializers for these union fields |
| 357 | * and consequent type restrictions. |
| 358 | */ |
| 359 | union { |
| 360 | AnyFunc *initializer; |
| 361 | BlitFunc *blit; |
| 362 | BlitBgFunc *blitbg; |
| 363 | ScaleBlitFunc *scaledblit; |
| 364 | FillRectFunc *fillrect; |
| 365 | FillSpansFunc *fillspans; |
| 366 | DrawLineFunc *drawline; |
| 367 | MaskFillFunc *maskfill; |
| 368 | MaskBlitFunc *maskblit; |
| 369 | DrawGlyphListFunc *drawglyphlist; |
| 370 | DrawGlyphListFunc *drawglyphlistaa; |
| 371 | DrawGlyphListLCDFunc *drawglyphlistlcd; |
| 372 | TransformHelperFuncs *transformhelpers; |
| 373 | } funcs, funcs_c; |
| 374 | jint srcflags; |
| 375 | jint dstflags; |
| 376 | } NativePrimitive; |
| 377 | |
| 378 | /* |
| 379 | * This function should be defined to return a pointer to |
| 380 | * an accelerated version of a primitive function 'func_c' |
| 381 | * if it exists and to return a copy of the input parameter |
| 382 | * otherwise. |
| 383 | */ |
| 384 | extern AnyFunc* MapAccelFunction(AnyFunc *func_c); |
| 385 | |
| 386 | /* |
| 387 | * The global collection of all primitive types. Specific NativePrimitive |
| 388 | * structures can be statically initialized by pointing to these structures. |
| 389 | */ |
| 390 | extern struct _PrimitiveTypes { |
| 391 | PrimitiveType Blit; |
| 392 | PrimitiveType BlitBg; |
| 393 | PrimitiveType ScaledBlit; |
| 394 | PrimitiveType FillRect; |
| 395 | PrimitiveType FillSpans; |
| 396 | PrimitiveType DrawLine; |
| 397 | PrimitiveType DrawRect; |
| 398 | PrimitiveType DrawPolygons; |
| 399 | PrimitiveType DrawPath; |
| 400 | PrimitiveType FillPath; |
| 401 | PrimitiveType MaskBlit; |
| 402 | PrimitiveType MaskFill; |
| 403 | PrimitiveType DrawGlyphList; |
| 404 | PrimitiveType DrawGlyphListAA; |
| 405 | PrimitiveType DrawGlyphListLCD; |
| 406 | PrimitiveType TransformHelper; |
| 407 | } PrimitiveTypes; |
| 408 | |
| 409 | /* |
| 410 | * The global collection of all surface types. Specific NativePrimitive |
| 411 | * structures can be statically initialized by pointing to these structures. |
| 412 | */ |
| 413 | extern struct _SurfaceTypes { |
| 414 | SurfaceType OpaqueColor; |
| 415 | SurfaceType AnyColor; |
| 416 | SurfaceType AnyByte; |
| 417 | SurfaceType ByteBinary1Bit; |
| 418 | SurfaceType ByteBinary2Bit; |
| 419 | SurfaceType ByteBinary4Bit; |
| 420 | SurfaceType ByteIndexed; |
| 421 | SurfaceType ByteIndexedBm; |
| 422 | SurfaceType ByteGray; |
| 423 | SurfaceType Index8Gray; |
| 424 | SurfaceType Index12Gray; |
| 425 | SurfaceType AnyShort; |
| 426 | SurfaceType Ushort555Rgb; |
| 427 | SurfaceType Ushort555Rgbx; |
| 428 | SurfaceType Ushort565Rgb; |
| 429 | SurfaceType Ushort4444Argb; |
| 430 | SurfaceType UshortGray; |
| 431 | SurfaceType UshortIndexed; |
| 432 | SurfaceType Any3Byte; |
| 433 | SurfaceType ThreeByteBgr; |
| 434 | SurfaceType AnyInt; |
| 435 | SurfaceType IntArgb; |
| 436 | SurfaceType IntArgbPre; |
| 437 | SurfaceType IntArgbBm; |
| 438 | SurfaceType IntRgb; |
| 439 | SurfaceType IntBgr; |
| 440 | SurfaceType IntRgbx; |
| 441 | SurfaceType Any4Byte; |
| 442 | SurfaceType FourByteAbgr; |
| 443 | SurfaceType FourByteAbgrPre; |
| 444 | } SurfaceTypes; |
| 445 | |
| 446 | /* |
| 447 | * The global collection of all composite types. Specific NativePrimitive |
| 448 | * structures can be statically initialized by pointing to these structures. |
| 449 | */ |
| 450 | extern struct _CompositeTypes { |
| 451 | CompositeType SrcNoEa; |
| 452 | CompositeType SrcOverNoEa; |
| 453 | CompositeType SrcOverBmNoEa; |
| 454 | CompositeType Src; |
| 455 | CompositeType SrcOver; |
| 456 | CompositeType Xor; |
| 457 | CompositeType AnyAlpha; |
| 458 | } CompositeTypes; |
| 459 | |
| 460 | #define ArraySize(A) (sizeof(A) / sizeof(A[0])) |
| 461 | |
| 462 | #define PtrAddBytes(p, b) ((void *) (((intptr_t) (p)) + (b))) |
| 463 | #define PtrCoord(p, x, xinc, y, yinc) PtrAddBytes(p, (y)*(yinc) + (x)*(xinc)) |
| 464 | |
| 465 | /* |
| 466 | * The function to call with an array of NativePrimitive structures |
| 467 | * to register them with the Java GraphicsPrimitiveMgr. |
| 468 | */ |
| 469 | extern jboolean RegisterPrimitives(JNIEnv *env, |
| 470 | NativePrimitive *pPrim, |
| 471 | jint NumPrimitives); |
| 472 | |
| 473 | /* |
| 474 | * The utility function to retrieve the NativePrimitive structure |
| 475 | * from a given Java GraphicsPrimitive object. |
| 476 | */ |
| 477 | extern JNIEXPORT NativePrimitive * JNICALL |
| 478 | GetNativePrim(JNIEnv *env, jobject gp); |
| 479 | |
| 480 | /* |
| 481 | * Utility functions to get values from a Java SunGraphics2D or Color object. |
| 482 | */ |
| 483 | extern JNIEXPORT void JNICALL |
| 484 | GrPrim_Sg2dGetCompInfo(JNIEnv *env, jobject sg2d, |
| 485 | NativePrimitive *pPrim, |
| 486 | CompositeInfo *pCompInfo); |
| 487 | extern JNIEXPORT jint JNICALL |
| 488 | GrPrim_CompGetXorColor(JNIEnv *env, jobject comp); |
| 489 | extern JNIEXPORT void JNICALL |
| 490 | GrPrim_CompGetXorInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp); |
| 491 | extern JNIEXPORT void JNICALL |
| 492 | GrPrim_CompGetAlphaInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp); |
| 493 | |
| 494 | extern JNIEXPORT void JNICALL |
| 495 | GrPrim_Sg2dGetClip(JNIEnv *env, jobject sg2d, |
| 496 | SurfaceDataBounds *bounds); |
| 497 | |
| 498 | extern JNIEXPORT jint JNICALL |
| 499 | GrPrim_Sg2dGetPixel(JNIEnv *env, jobject sg2d); |
| 500 | extern JNIEXPORT jint JNICALL |
| 501 | GrPrim_Sg2dGetEaRGB(JNIEnv *env, jobject sg2d); |
| 502 | extern JNIEXPORT jint JNICALL |
| 503 | GrPrim_Sg2dGetLCDTextContrast(JNIEnv *env, jobject sg2d); |
| 504 | extern jint GrPrim_ColorGetRGB(JNIEnv *env, jobject color); |
| 505 | |
| 506 | /* |
| 507 | * Data structure and functions to retrieve and use |
| 508 | * AffineTransform objects from the native level. |
| 509 | */ |
| 510 | typedef struct { |
| 511 | jdouble dxdx; /* dx in dest space for each dx in src space */ |
| 512 | jdouble dxdy; /* dx in dest space for each dy in src space */ |
| 513 | jdouble tx; |
| 514 | jdouble dydx; /* dy in dest space for each dx in src space */ |
| 515 | jdouble dydy; /* dy in dest space for each dy in src space */ |
| 516 | jdouble ty; |
| 517 | } TransformInfo; |
| 518 | |
| 519 | extern JNIEXPORT void JNICALL |
| 520 | Transform_GetInfo(JNIEnv *env, jobject txform, TransformInfo *pTxInfo); |
| 521 | extern JNIEXPORT void JNICALL |
| 522 | Transform_transform(TransformInfo *pTxInfo, jdouble *pX, jdouble *pY); |
| 523 | |
| 524 | void GrPrim_RefineBounds(SurfaceDataBounds *bounds, jint transX, jint transY, |
| 525 | jfloat *coords, jint maxCoords); |
| 526 | |
| 527 | extern jfieldID path2DTypesID; |
| 528 | extern jfieldID path2DNumTypesID; |
| 529 | extern jfieldID path2DWindingRuleID; |
| 530 | extern jfieldID path2DFloatCoordsID; |
| 531 | extern jfieldID sg2dStrokeHintID; |
| 532 | extern jint sunHints_INTVAL_STROKE_PURE; |
| 533 | |
| 534 | /* |
| 535 | * Macros for using jlong variables as 32bits.32bits fractional values |
| 536 | */ |
| 537 | #define LongOneHalf (((jlong) 1) << 31) |
| 538 | #define IntToLong(i) (((jlong) (i)) << 32) |
| 539 | #define DblToLong(d) ((jlong) ((d) * IntToLong(1))) |
| 540 | #define WholeOfLong(l) ((jint) ((l) >> 32)) |
| 541 | #define FractOfLong(l) ((jint) (l)) |
| 542 | #define URShift(i, n) (((juint) (i)) >> (n)) |
| 543 | |
| 544 | /* |
| 545 | * Macros to help in defining arrays of NativePrimitive structures. |
| 546 | * |
| 547 | * These macros are the very base macros. More specific macros are |
| 548 | * defined in LoopMacros.h. |
| 549 | * |
| 550 | * Note that the DrawLine, DrawRect, and DrawPolygons primitives are |
| 551 | * all registered together from a single shared native function pointer. |
| 552 | */ |
| 553 | |
| 554 | #define REGISTER_PRIMITIVE(TYPE, SRC, COMP, DST, FUNC) \ |
| 555 | { \ |
| 556 | & PrimitiveTypes.TYPE, \ |
| 557 | & SurfaceTypes.SRC, \ |
| 558 | & CompositeTypes.COMP, \ |
| 559 | & SurfaceTypes.DST, \ |
| 560 | {FUNC}, \ |
| 561 | {FUNC}, \ |
| 562 | 0, \ |
| 563 | 0 \ |
| 564 | } |
| 565 | |
| 566 | #define REGISTER_PRIMITIVE_FLAGS(TYPE, SRC, COMP, DST, FUNC, SFLAGS, DFLAGS) \ |
| 567 | { \ |
| 568 | & PrimitiveTypes.TYPE, \ |
| 569 | & SurfaceTypes.SRC, \ |
| 570 | & CompositeTypes.COMP, \ |
| 571 | & SurfaceTypes.DST, \ |
| 572 | {FUNC}, \ |
| 573 | {FUNC}, \ |
| 574 | SFLAGS, \ |
| 575 | DFLAGS, \ |
| 576 | } |
| 577 | |
| 578 | #define REGISTER_BLIT(SRC, COMP, DST, FUNC) \ |
| 579 | REGISTER_PRIMITIVE(Blit, SRC, COMP, DST, FUNC) |
| 580 | |
| 581 | #define REGISTER_BLIT_FLAGS(SRC, COMP, DST, FUNC, SFLAGS, DFLAGS) \ |
| 582 | REGISTER_PRIMITIVE_FLAGS(Blit, SRC, COMP, DST, FUNC, SFLAGS, DFLAGS) |
| 583 | |
| 584 | #define REGISTER_SCALEBLIT(SRC, COMP, DST, FUNC) \ |
| 585 | REGISTER_PRIMITIVE(ScaledBlit, SRC, COMP, DST, FUNC) |
| 586 | |
| 587 | #define REGISTER_SCALEBLIT_FLAGS(SRC, COMP, DST, FUNC, SFLAGS, DFLAGS) \ |
| 588 | REGISTER_PRIMITIVE_FLAGS(ScaledBlit, SRC, COMP, DST, FUNC, SFLAGS, DFLAGS) |
| 589 | |
| 590 | #define REGISTER_BLITBG(SRC, COMP, DST, FUNC) \ |
| 591 | REGISTER_PRIMITIVE(BlitBg, SRC, COMP, DST, FUNC) |
| 592 | |
| 593 | #define REGISTER_FILLRECT(SRC, COMP, DST, FUNC) \ |
| 594 | REGISTER_PRIMITIVE(FillRect, SRC, COMP, DST, FUNC) |
| 595 | |
| 596 | #define REGISTER_FILLSPANS(SRC, COMP, DST, FUNC) \ |
| 597 | REGISTER_PRIMITIVE(FillSpans, SRC, COMP, DST, FUNC) |
| 598 | |
| 599 | #define REGISTER_LINE_PRIMITIVES(SRC, COMP, DST, FUNC) \ |
| 600 | REGISTER_PRIMITIVE(DrawLine, SRC, COMP, DST, FUNC), \ |
| 601 | REGISTER_PRIMITIVE(DrawRect, SRC, COMP, DST, FUNC), \ |
| 602 | REGISTER_PRIMITIVE(DrawPolygons, SRC, COMP, DST, FUNC), \ |
| 603 | REGISTER_PRIMITIVE(DrawPath, SRC, COMP, DST, FUNC), \ |
| 604 | REGISTER_PRIMITIVE(FillPath, SRC, COMP, DST, FUNC) |
| 605 | |
| 606 | #define REGISTER_MASKBLIT(SRC, COMP, DST, FUNC) \ |
| 607 | REGISTER_PRIMITIVE(MaskBlit, SRC, COMP, DST, FUNC) |
| 608 | |
| 609 | #define REGISTER_MASKFILL(SRC, COMP, DST, FUNC) \ |
| 610 | REGISTER_PRIMITIVE(MaskFill, SRC, COMP, DST, FUNC) |
| 611 | |
| 612 | #define REGISTER_DRAWGLYPHLIST(SRC, COMP, DST, FUNC) \ |
| 613 | REGISTER_PRIMITIVE(DrawGlyphList, SRC, COMP, DST, FUNC) |
| 614 | |
| 615 | #define REGISTER_DRAWGLYPHLISTAA(SRC, COMP, DST, FUNC) \ |
| 616 | REGISTER_PRIMITIVE(DrawGlyphListAA, SRC, COMP, DST, FUNC) |
| 617 | |
| 618 | #define REGISTER_DRAWGLYPHLISTLCD(SRC, COMP, DST, FUNC) \ |
| 619 | REGISTER_PRIMITIVE(DrawGlyphListLCD, SRC, COMP, DST, FUNC) |
| 620 | |
| 621 | #ifdef __cplusplus |
| 622 | }; |
| 623 | #endif |
| 624 | |
| 625 | #endif /* GraphicsPrimitiveMgr_h_Included */ |