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