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