1 /*
2  * Copyright (c) 2007, 2008, 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 D3DPaints_h_Included
27 #define D3DPaints_h_Included
28 
29 #include "sun_java2d_SunGraphics2D.h"
30 
31 #include "D3DContext.h"
32 #include "D3DSurfaceData.h"
33 
34 HRESULT D3DPaints_ResetPaint(D3DContext *d3dc);
35 HRESULT D3DPaints_SetColor(D3DContext *d3dc, jint pixel);
36 
37 /************************* GradientPaint support ****************************/
38 
39 /**
40  * Flags that can be bitwise-or'ed together to control how the shader
41  * source code is generated.
42  */
43 #define BASIC_GRAD_IS_CYCLIC (1 << 0)
44 #define BASIC_GRAD_USE_MASK  (1 << 1)
45 
46 HRESULT D3DPaints_SetGradientPaint(D3DContext *d3dc,
47                                 jboolean useMask, jboolean cyclic,
48                                 jdouble p0, jdouble p1, jdouble p3,
49                                 jint pixel1, jint pixel2);
50 
51 /************************** TexturePaint support ****************************/
52 
53 HRESULT D3DPaints_SetTexturePaint(D3DContext *d3dc,
54                                jboolean useMask,
55                                jlong pSrcOps, jboolean filter,
56                                jdouble xp0, jdouble xp1, jdouble xp3,
57                                jdouble yp0, jdouble yp1, jdouble yp3);
58 
59 /****************** Shared MultipleGradientPaint support ********************/
60 
61 /**
62  * These constants are identical to those defined in the
63  * MultipleGradientPaint.CycleMethod enum; they are copied here for
64  * convenience (ideally we would pull them directly from the Java level,
65  * but that entails more hassle than it is worth).
66  */
67 #define CYCLE_NONE    0
68 #define CYCLE_REFLECT 1
69 #define CYCLE_REPEAT  2
70 
71 /**
72  * The following constants are flags that can be bitwise-or'ed together
73  * to control how the MultipleGradientPaint shader source code is generated:
74  *
75  *   MULTI_GRAD_CYCLE_METHOD
76  *     Placeholder for the CycleMethod enum constant.
77  *
78  *   MULTI_GRAD_LARGE
79  *     If set, use the (slower) shader that supports a larger number of
80  *     gradient colors; otherwise, use the optimized codepath.  See
81  *     the MAX_FRACTIONS_SMALL/LARGE constants below for more details.
82  *
83  *   MULTI_GRAD_USE_MASK
84  *     If set, apply the alpha mask value from texture unit 1 to the
85  *     final color result (only used in the MaskFill case).
86  *
87  *   MULTI_GRAD_LINEAR_RGB
88  *     If set, convert the linear RGB result back into the sRGB color space.
89  */
90 #define MULTI_GRAD_CYCLE_METHOD (3 << 0)
91 #define MULTI_GRAD_LARGE        (1 << 2)
92 #define MULTI_GRAD_USE_MASK     (1 << 3)
93 #define MULTI_GRAD_LINEAR_RGB   (1 << 4)
94 
95 /**
96  * The maximum number of gradient colors supported by all of the gradient
97  * fragment shaders.  Note that this value must be a power of two, as it
98  * determines the size of the 1D texture created below.  It also must be
99  * greater than or equal to MAX_FRACTIONS (there is no strict requirement
100  * that the two values be equal).
101  */
102 #define MAX_MULTI_GRADIENT_COLORS 16
103 
104 /********************** LinearGradientPaint support *************************/
105 
106 HRESULT D3DPaints_SetLinearGradientPaint(D3DContext *d3dc, D3DSDOps *dstOps,
107                                          jboolean useMask, jboolean linear,
108                                          jint cycleMethod, jint numStops,
109                                          jfloat p0, jfloat p1, jfloat p3,
110                                          void *fractions, void *pixels);
111 
112 /********************** RadialGradientPaint support *************************/
113 
114 HRESULT D3DPaints_SetRadialGradientPaint(D3DContext *d3dc, D3DSDOps *dstOps,
115                                          jboolean useMask, jboolean linear,
116                                          jint cycleMethod, jint numStops,
117                                          jfloat m00, jfloat m01, jfloat m02,
118                                          jfloat m10, jfloat m11, jfloat m12,
119                                          jfloat focusX,
120                                          void *fractions, void *pixels);
121 
122 /************************ SunGraphics2D constants ***************************/
123 
124 #define PAINT_CUSTOM       sun_java2d_SunGraphics2D_PAINT_CUSTOM
125 #define PAINT_TEXTURE      sun_java2d_SunGraphics2D_PAINT_TEXTURE
126 #define PAINT_RAD_GRADIENT sun_java2d_SunGraphics2D_PAINT_RAD_GRADIENT
127 #define PAINT_LIN_GRADIENT sun_java2d_SunGraphics2D_PAINT_LIN_GRADIENT
128 #define PAINT_GRADIENT     sun_java2d_SunGraphics2D_PAINT_GRADIENT
129 #define PAINT_ALPHACOLOR   sun_java2d_SunGraphics2D_PAINT_ALPHACOLOR
130 #define PAINT_OPAQUECOLOR  sun_java2d_SunGraphics2D_PAINT_OPAQUECOLOR
131 
132 #endif /* D3DPaints_h_Included */
133