aboutsummaryrefslogtreecommitdiff
path: root/src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h
blob: 0249dae34685d5a8f00ee6b924e1781dcd71ae34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
/*
 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

#ifndef GraphicsPrimitiveMgr_h_Included
#define GraphicsPrimitiveMgr_h_Included

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>

#include "java_awt_AlphaComposite.h"

#include "SurfaceData.h"
#include "SpanIterator.h"

#include "j2d_md.h"

#include "AlphaMath.h"
#include "GlyphImageRef.h"

/*
 * This structure contains all of the information about a particular
 * type of GraphicsPrimitive, such as a FillRect, a MaskFill, or a Blit.
 *
 * A global collection of these structures is declared and initialized
 * to contain the necessary Java (JNI) information so that appropriate
 * Java GraphicsPrimitive objects can be quickly constructed for a set
 * of native loops simply by referencing the necessary entry from that
 * collection for the type of primitive being registered.
 *
 * See PrimitiveTypes.{Blit,BlitBg,FillRect,...} below.
 */
typedef struct _PrimitiveType {
    char                *ClassName;
    jint                srcflags;
    jint                dstflags;
    jclass              ClassObject;
    jmethodID           Constructor;
} PrimitiveType;

/* The integer constants to identify the compositing rule being defined. */
#define RULE_Xor        (java_awt_AlphaComposite_MIN_RULE - 1)
#define RULE_Clear      java_awt_AlphaComposite_CLEAR
#define RULE_Src        java_awt_AlphaComposite_SRC
#define RULE_SrcOver    java_awt_AlphaComposite_SRC_OVER
#define RULE_DstOver    java_awt_AlphaComposite_DST_OVER
#define RULE_SrcIn      java_awt_AlphaComposite_SRC_IN
#define RULE_DstIn      java_awt_AlphaComposite_DST_IN
#define RULE_SrcOut     java_awt_AlphaComposite_SRC_OUT
#define RULE_DstOut     java_awt_AlphaComposite_DST_OUT

/*
 * This structure holds the information retrieved from a Java
 * Composite object for easy transfer to various C functions
 * that implement the inner loop for a native primitive.
 *
 * Currently only AlphaComposite and XORComposite are supported.
 */
typedef struct _CompositeInfo {
    jint        rule;           /* See RULE_* constants above */
    union {
        jfloat  extraAlpha;     /* from AlphaComposite */
        jint    xorPixel;       /* from XORComposite */
    } details;
    juint       alphaMask;      /* from XORComposite */
} CompositeInfo;

/*
 * This structure is the common header for the two native structures
 * that hold information about a particular SurfaceType or CompositeType.
 *
 * A global collection of these structures is declared and initialized
 * to contain the necessary Java (JNI) information so that appropriate
 * Java GraphicsPrimitive objects can be quickly constructed for a set
 * of native loops simply by referencing the necessary entry from that
 * collection for the type of composite or surface being implemented.
 *
 * See SurfaceTypes.{OpaqueColor,IntArgb,ByteGray,...} below.
 * See CompositeTypes.{Xor,AnyAlpha,...} below.
 */
typedef struct _SurfCompHdr {
    char                *Name;
    jobject             Object;
} SurfCompHdr;

/*
 * The definitions for the SurfaceType structure described above.
 */

/*
 * The signature for a function that returns the specific integer
 * format pixel for a given ARGB color value for a particular
 * SurfaceType implementation.
 * This function is valid only after GetRasInfo call for the
 * associated surface.
 */
typedef jint (PixelForFunc)(SurfaceDataRasInfo *pRasInfo, jint rgb);

/*
 * The additional information needed to manipulate a surface:
 * - The pixelFor function for translating ARGB values.
 *   Valid only after GetRasInfo call for this surface.
 * - The additional flags needed when reading from this surface.
 * - The additional flags needed when writing to this surface.
 */
typedef struct _SurfaceType {
    SurfCompHdr         hdr;
    PixelForFunc        *pixelFor;
    jint                readflags;
    jint                writeflags;
} SurfaceType;

/*
 * The definitions for the CompositeType structure described above.
 */

/*
 * The signature for a function that fills in a CompositeInfo
 * structure from the information present in a given Java Composite
 * object.
 */
typedef void (JNICALL CompInfoFunc)(JNIEnv *env,
                                    CompositeInfo *pCompInfo,
                                    jobject Composite);

/*
 * The additional information needed to implement a primitive that
 * performs a particular composite operation:
 * - The getCompInfo function for filling in a CompositeInfo structure.
 * - The additional flags needed for locking the destination surface.
 */
typedef struct _CompositeType {
    SurfCompHdr         hdr;
    CompInfoFunc        *getCompInfo;
    jint                dstflags;
} CompositeType;

/*
 * The signature of the native functions that register a set of
 * related native GraphicsPrimitive functions.
 */
typedef jboolean (RegisterFunc)(JNIEnv *env);

struct _NativePrimitive;        /* forward reference for function typedefs */

/*
 * This empty function signature represents an "old pre-ANSI style"
 * function declaration which makes no claims about the argument list
 * other than that the types of the arguments will undergo argument
 * promotion in the calling conventions.
 * (See section A7.3.2 in K&R 2nd edition.)
 *
 * When trying to statically initialize the function pointer field of
 * a NativePrimitive structure, which is a union of all possible
 * inner loop function signatures, the initializer constant must be
 * compatible with the first field in the union.  This generic function
 * type allows us to assign any function pointer to that union as long
 * as it meets the requirements specified above (i.e. all arguments
 * are compatible with their promoted values according to the old
 * style argument promotion calling semantics).
 *
 * Note: This means that you cannot define an argument to any of
 * these native functions which is a byte or a short as that value
 * would not be passed in the same way for an ANSI-style full prototype
 * calling convention and an old-style argument promotion calling
 * convention.
 */
typedef void (AnyFunc)();

/*
 * The signature of the inner loop function for a "Blit".
 */
typedef void (BlitFunc)(void *pSrc, void *pDst,
                        juint width, juint height,
                        SurfaceDataRasInfo *pSrcInfo,
                        SurfaceDataRasInfo *pDstInfo,
                        struct _NativePrimitive *pPrim,
                        CompositeInfo *pCompInfo);

/*
 * The signature of the inner loop function for a "BlitBg".
 */
typedef void (BlitBgFunc)(void *pSrc, void *pDst,
                          juint width, juint height, jint bgpixel,
                          SurfaceDataRasInfo *pSrcInfo,
                          SurfaceDataRasInfo *pDstInfo,
                          struct _NativePrimitive *pPrim,
                          CompositeInfo *pCompInfo);

/*
 * The signature of the inner loop function for a "ScaleBlit".
 */
typedef void (ScaleBlitFunc)(void *pSrc, void *pDst,
                             juint dstwidth, juint dstheight,
                             jint sxloc, jint syloc,
                             jint sxinc, jint syinc, jint scale,
                             SurfaceDataRasInfo *pSrcInfo,
                             SurfaceDataRasInfo *pDstInfo,
                             struct _NativePrimitive *pPrim,
                             CompositeInfo *pCompInfo);

/*
 * The signature of the inner loop function for a "FillRect".
 */
typedef void (FillRectFunc)(SurfaceDataRasInfo *pRasInfo,
                            jint lox, jint loy,
                            jint hix, jint hiy,
                            jint pixel, struct _NativePrimitive *pPrim,
                            CompositeInfo *pCompInfo);

/*
 * The signature of the inner loop function for a "FillSpans".
 */
typedef void (FillSpansFunc)(SurfaceDataRasInfo *pRasInfo,
                             SpanIteratorFuncs *pSpanFuncs, void *siData,
                             jint pixel, struct _NativePrimitive *pPrim,
                             CompositeInfo *pCompInfo);

/*
 * The signature of the inner loop function for a "DrawLine".
 * Note that this same inner loop is used for native DrawRect
 * and DrawPolygons primitives.
 */
typedef void (DrawLineFunc)(SurfaceDataRasInfo *pRasInfo,
                            jint x1, jint y1, jint pixel,
                            jint steps, jint error,
                            jint bumpmajormask, jint errmajor,
                            jint bumpminormask, jint errminor,
                            struct _NativePrimitive *pPrim,
                            CompositeInfo *pCompInfo);

/*
 * The signature of the inner loop function for a "MaskFill".
 */
typedef void (MaskFillFunc)(void *pRas,
                            unsigned char *pMask, jint maskOff, jint maskScan,
                            jint width, jint height,
                            jint fgColor,
                            SurfaceDataRasInfo *pRasInfo,
                            struct _NativePrimitive *pPrim,
                            CompositeInfo *pCompInfo);

/*
 * The signature of the inner loop function for a "MaskBlit".
 */
typedef void (MaskBlitFunc)(void *pDst, void *pSrc,
                            unsigned char *pMask, jint maskOff, jint maskScan,
                            jint width, jint height,
                            SurfaceDataRasInfo *pDstInfo,
                            SurfaceDataRasInfo *pSrcInfo,
                            struct _NativePrimitive *pPrim,
                            CompositeInfo *pCompInfo);
/*
 * The signature of the inner loop function for a "DrawGlyphList".
 */
typedef void (DrawGlyphListFunc)(SurfaceDataRasInfo *pRasInfo,
                                 ImageRef *glyphs,
                                 jint totalGlyphs,
                                 jint fgpixel, jint fgcolor,
                                 jint cx1, jint cy1,
                                 jint cx2, jint cy2,
                                 struct _NativePrimitive *pPrim,
                                 CompositeInfo *pCompInfo);

/*
 * The signature of the inner loop function for a "DrawGlyphListAA".
 */
typedef void (DrawGlyphListAAFunc)(SurfaceDataRasInfo *pRasInfo,
                                   ImageRef *glyphs,
                                   jint totalGlyphs,
                                   jint fgpixel, jint fgcolor,
                                   jint cx1, jint cy1,
                                   jint cx2, jint cy2,
                                   struct _NativePrimitive *pPrim,
                                   CompositeInfo *pCompInfo);

/*
 * The signature of the inner loop function for a "DrawGlyphListLCD".
 * rgbOrder is a jint rather than a jboolean so that this typedef matches
 * AnyFunc which is the first element in a union in NativePrimitive's
 * initialiser. See the comments alongside declaration of the AnyFunc type for
 * a full explanation.
 */
typedef void (DrawGlyphListLCDFunc)(SurfaceDataRasInfo *pRasInfo,
                                    ImageRef *glyphs,
                                    jint totalGlyphs,
                                    jint fgpixel, jint fgcolor,
                                    jint cx1, jint cy1,
                                    jint cx2, jint cy2,
                                    jint rgbOrder,
                                    unsigned char *gammaLut,
                                    unsigned char *invGammaLut,
                                    struct _NativePrimitive *pPrim,
                                    CompositeInfo *pCompInfo);

/*
 * The signature of the inner loop functions for a "TransformHelper".
 */
typedef void (TransformHelperFunc)(SurfaceDataRasInfo *pSrcInfo,
                                   jint *pRGB, jint numpix,
                                   jlong xlong, jlong dxlong,
                                   jlong ylong, jlong dylong);

typedef struct {
    TransformHelperFunc         *nnHelper;
    TransformHelperFunc         *blHelper;
    TransformHelperFunc         *bcHelper;
} TransformHelperFuncs;

typedef void (TransformInterpFunc)(jint *pRGBbase, jint numpix,
                                   jint xfract, jint dxfract,
                                   jint yfract, jint dyfract);

/*
 * The signature of the inner loop function for a "FillParallelogram"
 * Note that this same inner loop is used for native DrawParallelogram
 * primitives.
 * Note that these functions are paired with equivalent DrawLine
 * inner loop functions to facilitate nicer looking and faster thin
 * transformed drawrect calls.
 */
typedef void (FillParallelogramFunc)(SurfaceDataRasInfo *pRasInfo,
                                     jint lox, jint loy, jint hix, jint hiy,
                                     jlong leftx, jlong dleftx,
                                     jlong rightx, jlong drightx,
                                     jint pixel, struct _NativePrimitive *pPrim,
                                     CompositeInfo *pCompInfo);

typedef struct {
    FillParallelogramFunc       *fillpgram;
    DrawLineFunc                *drawline;
} DrawParallelogramFuncs;

/*
 * This structure contains all information for defining a single
 * native GraphicsPrimitive, including:
 * - The information about the type of the GraphicsPrimitive subclass.
 * - The information about the type of the source surface.
 * - The information about the type of the compositing operation.
 * - The information about the type of the destination surface.
 * - A pointer to the function that performs the actual inner loop work.
 * - Extra flags needed for locking the source and destination surfaces
 *   above and beyond the flags specified in the Primitive, Composite
 *   and SurfaceType structures.  (For most native primitives these
 *   flags can be calculated automatically from information stored in
 *   the PrimitiveType, SurfaceType, and CompositeType structures.)
 */
typedef struct _NativePrimitive {
    PrimitiveType       *pPrimType;
    SurfaceType         *pSrcType;
    CompositeType       *pCompType;
    SurfaceType         *pDstType;
    /* See declaration of AnyFunc type above for comments explaining why
     * only AnyFunc is used by the initializers for these union fields
     * and consequent type restrictions.
     */
    union {
        AnyFunc                 *initializer;
        BlitFunc                *blit;
        BlitBgFunc              *blitbg;
        ScaleBlitFunc           *scaledblit;
        FillRectFunc            *fillrect;
        FillSpansFunc           *fillspans;
        FillParallelogramFunc   *fillparallelogram;
        DrawParallelogramFuncs  *drawparallelogram;
        DrawLineFunc            *drawline;
        MaskFillFunc            *maskfill;
        MaskBlitFunc            *maskblit;
        DrawGlyphListFunc       *drawglyphlist;
        DrawGlyphListFunc       *drawglyphlistaa;
        DrawGlyphListLCDFunc    *drawglyphlistlcd;
        TransformHelperFuncs    *transformhelpers;
    } funcs, funcs_c;
    jint                srcflags;
    jint                dstflags;
} NativePrimitive;

/*
 * This function should be defined to return a pointer to
 * an accelerated version of a primitive function 'func_c'
 * if it exists and to return a copy of the input parameter
 * otherwise.
 */
extern AnyFunc* MapAccelFunction(AnyFunc *func_c);

/*
 * The global collection of all primitive types.  Specific NativePrimitive
 * structures can be statically initialized by pointing to these structures.
 */
extern struct _PrimitiveTypes {
    PrimitiveType       Blit;
    PrimitiveType       BlitBg;
    PrimitiveType       ScaledBlit;
    PrimitiveType       FillRect;
    PrimitiveType       FillSpans;
    PrimitiveType       FillParallelogram;
    PrimitiveType       DrawParallelogram;
    PrimitiveType       DrawLine;
    PrimitiveType       DrawRect;
    PrimitiveType       DrawPolygons;
    PrimitiveType       DrawPath;
    PrimitiveType       FillPath;
    PrimitiveType       MaskBlit;
    PrimitiveType       MaskFill;
    PrimitiveType       DrawGlyphList;
    PrimitiveType       DrawGlyphListAA;
    PrimitiveType       DrawGlyphListLCD;
    PrimitiveType       TransformHelper;
} PrimitiveTypes;

/*
 * The global collection of all surface types.  Specific NativePrimitive
 * structures can be statically initialized by pointing to these structures.
 */
extern struct _SurfaceTypes {
    SurfaceType         OpaqueColor;
    SurfaceType         AnyColor;
    SurfaceType         AnyByte;
    SurfaceType         ByteBinary1Bit;
    SurfaceType         ByteBinary2Bit;
    SurfaceType         ByteBinary4Bit;
    SurfaceType         ByteIndexed;
    SurfaceType         ByteIndexedBm;
    SurfaceType         ByteGray;
    SurfaceType         Index8Gray;
    SurfaceType         Index12Gray;
    SurfaceType         AnyShort;
    SurfaceType         Ushort555Rgb;
    SurfaceType         Ushort555Rgbx;
    SurfaceType         Ushort565Rgb;
    SurfaceType         Ushort4444Argb;
    SurfaceType         UshortGray;
    SurfaceType         UshortIndexed;
    SurfaceType         Any3Byte;
    SurfaceType         ThreeByteBgr;
    SurfaceType         AnyInt;
    SurfaceType         IntArgb;
    SurfaceType         IntArgbPre;
    SurfaceType         IntArgbBm;
    SurfaceType         IntRgb;
    SurfaceType         IntBgr;
    SurfaceType         IntRgbx;
    SurfaceType         Any4Byte;
    SurfaceType         FourByteAbgr;
    SurfaceType         FourByteAbgrPre;
} SurfaceTypes;

/*
 * The global collection of all composite types.  Specific NativePrimitive
 * structures can be statically initialized by pointing to these structures.
 */
extern struct _CompositeTypes {
    CompositeType       SrcNoEa;
    CompositeType       SrcOverNoEa;
    CompositeType       SrcOverBmNoEa;
    CompositeType       Src;
    CompositeType       SrcOver;
    CompositeType       Xor;
    CompositeType       AnyAlpha;
} CompositeTypes;

#define ArraySize(A)    (sizeof(A) / sizeof(A[0]))

#define PtrAddBytes(p, b)               ((void *) (((intptr_t) (p)) + (b)))
#define PtrCoord(p, x, xinc, y, yinc)   PtrAddBytes(p, \
                                                    ((ptrdiff_t)(y))*(yinc) + \
                                                    ((ptrdiff_t)(x))*(xinc))

/*
 * The function to call with an array of NativePrimitive structures
 * to register them with the Java GraphicsPrimitiveMgr.
 */
extern jboolean RegisterPrimitives(JNIEnv *env,
                                   NativePrimitive *pPrim,
                                   jint NumPrimitives);

/*
 * The utility function to retrieve the NativePrimitive structure
 * from a given Java GraphicsPrimitive object.
 */
extern JNIEXPORT NativePrimitive * JNICALL
GetNativePrim(JNIEnv *env, jobject gp);

/*
 * Utility functions to get values from a Java SunGraphics2D or Color object.
 */
extern JNIEXPORT void JNICALL
GrPrim_Sg2dGetCompInfo(JNIEnv *env, jobject sg2d,
                       NativePrimitive *pPrim,
                       CompositeInfo *pCompInfo);
extern JNIEXPORT jint JNICALL
GrPrim_CompGetXorColor(JNIEnv *env, jobject comp);
extern JNIEXPORT void JNICALL
GrPrim_CompGetXorInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp);
extern JNIEXPORT void JNICALL
GrPrim_CompGetAlphaInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp);

extern JNIEXPORT void JNICALL
GrPrim_Sg2dGetClip(JNIEnv *env, jobject sg2d,
                   SurfaceDataBounds *bounds);

extern JNIEXPORT jint JNICALL
GrPrim_Sg2dGetPixel(JNIEnv *env, jobject sg2d);
extern JNIEXPORT jint JNICALL
GrPrim_Sg2dGetEaRGB(JNIEnv *env, jobject sg2d);
extern JNIEXPORT jint JNICALL
GrPrim_Sg2dGetLCDTextContrast(JNIEnv *env, jobject sg2d);

/*
 * Data structure and functions to retrieve and use
 * AffineTransform objects from the native level.
 */
typedef struct {
    jdouble dxdx;       /* dx in dest space for each dx in src space */
    jdouble dxdy;       /* dx in dest space for each dy in src space */
    jdouble tx;
    jdouble dydx;       /* dy in dest space for each dx in src space */
    jdouble dydy;       /* dy in dest space for each dy in src space */
    jdouble ty;
} TransformInfo;

extern JNIEXPORT void JNICALL
Transform_GetInfo(JNIEnv *env, jobject txform, TransformInfo *pTxInfo);
extern JNIEXPORT void JNICALL
Transform_transform(TransformInfo *pTxInfo, jdouble *pX, jdouble *pY);

void GrPrim_RefineBounds(SurfaceDataBounds *bounds, jint transX, jint transY,
                         jfloat *coords,  jint maxCoords);

extern jfieldID path2DTypesID;
extern jfieldID path2DNumTypesID;
extern jfieldID path2DWindingRuleID;
extern jfieldID path2DFloatCoordsID;
extern jfieldID sg2dStrokeHintID;
extern jint sunHints_INTVAL_STROKE_PURE;
extern jint graphicsPrimitive_traceflags;

/*
 * Macros for using jlong variables as 32bits.32bits fractional values
 */
#define LongOneHalf     (((jlong) 1) << 31)
#define IntToLong(i)    (((jlong) (i)) << 32)
#define DblToLong(d)    ((jlong) ((d) * IntToLong(1)))
#define LongToDbl(l)    (((jdouble) l) / IntToLong(1))
#define WholeOfLong(l)  ((jint) ((l) >> 32))
#define FractOfLong(l)  ((jint) (l))
#define URShift(i, n)   (((juint) (i)) >> (n))

/*
 * Macros to help in defining arrays of NativePrimitive structures.
 *
 * These macros are the very base macros.  More specific macros are
 * defined in LoopMacros.h.
 *
 * Note that the DrawLine, DrawRect, and DrawPolygons primitives are
 * all registered together from a single shared native function pointer.
 */

#define REGISTER_PRIMITIVE(TYPE, SRC, COMP, DST, FUNC) \
    { \
        & PrimitiveTypes.TYPE, \
        & SurfaceTypes.SRC, \
        & CompositeTypes.COMP, \
        & SurfaceTypes.DST, \
        {FUNC}, \
        {FUNC}, \
        0,   \
        0   \
    }

#define REGISTER_PRIMITIVE_FLAGS(TYPE, SRC, COMP, DST, FUNC, SFLAGS, DFLAGS) \
    { \
        & PrimitiveTypes.TYPE, \
        & SurfaceTypes.SRC, \
        & CompositeTypes.COMP, \
        & SurfaceTypes.DST, \
        {FUNC}, \
        {FUNC}, \
        SFLAGS, \
        DFLAGS, \
    }

#define REGISTER_BLIT(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(Blit, SRC, COMP, DST, FUNC)

#define REGISTER_BLIT_FLAGS(SRC, COMP, DST, FUNC, SFLAGS, DFLAGS) \
    REGISTER_PRIMITIVE_FLAGS(Blit, SRC, COMP, DST, FUNC, SFLAGS, DFLAGS)

#define REGISTER_SCALEBLIT(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(ScaledBlit, SRC, COMP, DST, FUNC)

#define REGISTER_SCALEBLIT_FLAGS(SRC, COMP, DST, FUNC, SFLAGS, DFLAGS) \
    REGISTER_PRIMITIVE_FLAGS(ScaledBlit, SRC, COMP, DST, FUNC, SFLAGS, DFLAGS)

#define REGISTER_BLITBG(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(BlitBg, SRC, COMP, DST, FUNC)

#define REGISTER_FILLRECT(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(FillRect, SRC, COMP, DST, FUNC)

#define REGISTER_FILLSPANS(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(FillSpans, SRC, COMP, DST, FUNC)

#define REGISTER_FILLPGRAM(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(FillParallelogram, SRC, COMP, DST, FUNC), \
    REGISTER_PRIMITIVE(DrawParallelogram, SRC, COMP, DST, FUNC)

#define REGISTER_LINE_PRIMITIVES(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(DrawLine, SRC, COMP, DST, FUNC), \
    REGISTER_PRIMITIVE(DrawRect, SRC, COMP, DST, FUNC), \
    REGISTER_PRIMITIVE(DrawPolygons, SRC, COMP, DST, FUNC), \
    REGISTER_PRIMITIVE(DrawPath, SRC, COMP, DST, FUNC), \
    REGISTER_PRIMITIVE(FillPath, SRC, COMP, DST, FUNC)

#define REGISTER_MASKBLIT(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(MaskBlit, SRC, COMP, DST, FUNC)

#define REGISTER_MASKFILL(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(MaskFill, SRC, COMP, DST, FUNC)

#define REGISTER_DRAWGLYPHLIST(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(DrawGlyphList, SRC, COMP, DST, FUNC)

#define REGISTER_DRAWGLYPHLISTAA(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(DrawGlyphListAA, SRC, COMP, DST, FUNC)

#define REGISTER_DRAWGLYPHLISTLCD(SRC, COMP, DST, FUNC) \
    REGISTER_PRIMITIVE(DrawGlyphListLCD, SRC, COMP, DST, FUNC)

#ifdef __cplusplus
};
#endif

#endif /* GraphicsPrimitiveMgr_h_Included */