author | tdv |
Tue, 22 Jul 2008 11:24:32 -0700 | |
changeset 888 | c7009cf0001f |
parent 887 | 0aab8d3fa11a |
child 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
2 | 1 |
/* |
888
c7009cf0001f
6728492: typo in copyrights in some files touched by the d3d pipeline port
tdv
parents:
887
diff
changeset
|
2 |
* Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 | 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 OGLContext_h_Included |
|
27 |
#define OGLContext_h_Included |
|
28 |
||
29 |
#include "sun_java2d_pipe_BufferedContext.h" |
|
30 |
#include "sun_java2d_opengl_OGLContext.h" |
|
887 | 31 |
#include "sun_java2d_opengl_OGLContext_OGLContextCaps.h" |
2 | 32 |
|
33 |
#include "j2d_md.h" |
|
34 |
#include "J2D_GL/gl.h" |
|
35 |
#include "OGLSurfaceData.h" |
|
36 |
||
37 |
/** |
|
38 |
* The OGLBlendRule structure encapsulates the two enumerated values that |
|
39 |
* comprise a given Porter-Duff blending (compositing) rule. For example, |
|
40 |
* the "SrcOver" rule can be represented by: |
|
41 |
* rule.src = GL_ONE; |
|
42 |
* rule.dst = GL_ONE_MINUS_SRC_ALPHA; |
|
43 |
* |
|
44 |
* GLenum src; |
|
45 |
* The constant representing the source factor in this Porter-Duff rule. |
|
46 |
* |
|
47 |
* GLenum dst; |
|
48 |
* The constant representing the destination factor in this Porter-Duff rule. |
|
49 |
*/ |
|
50 |
typedef struct { |
|
51 |
GLenum src; |
|
52 |
GLenum dst; |
|
53 |
} OGLBlendRule; |
|
54 |
||
55 |
/** |
|
56 |
* The OGLContext structure contains cached state relevant to the native |
|
57 |
* OpenGL context stored within the native ctxInfo field. Each Java-level |
|
58 |
* OGLContext object is associated with a native-level OGLContext structure. |
|
59 |
* The caps field is a bitfield that expresses the capabilities of the |
|
60 |
* GraphicsConfig associated with this context (see OGLContext.java for |
|
61 |
* the definitions of each capability bit). The other fields are |
|
62 |
* simply cached values of various elements of the context state, typically |
|
63 |
* used in the OGLContext.set*() methods. |
|
64 |
* |
|
65 |
* Note that the textureFunction field is implicitly set to zero when the |
|
66 |
* OGLContext is created. The acceptable values (e.g. GL_MODULATE, |
|
67 |
* GL_REPLACE) for this field are never zero, which means we will always |
|
68 |
* validate the texture function state upon the first call to the |
|
69 |
* OGLC_UPDATE_TEXTURE_FUNCTION() macro. |
|
70 |
*/ |
|
71 |
typedef struct { |
|
72 |
void *ctxInfo; |
|
73 |
jint caps; |
|
74 |
jint compState; |
|
75 |
jfloat extraAlpha; |
|
76 |
jint xorPixel; |
|
77 |
jint pixel; |
|
78 |
jubyte r; |
|
79 |
jubyte g; |
|
80 |
jubyte b; |
|
81 |
jubyte a; |
|
82 |
jint paintState; |
|
83 |
jboolean useMask; |
|
84 |
GLdouble *xformMatrix; |
|
85 |
GLuint blitTextureID; |
|
86 |
GLint textureFunction; |
|
87 |
} OGLContext; |
|
88 |
||
89 |
/** |
|
90 |
* See BufferedContext.java for more on these flags... |
|
91 |
*/ |
|
92 |
#define OGLC_NO_CONTEXT_FLAGS \ |
|
93 |
sun_java2d_pipe_BufferedContext_NO_CONTEXT_FLAGS |
|
94 |
#define OGLC_SRC_IS_OPAQUE \ |
|
95 |
sun_java2d_pipe_BufferedContext_SRC_IS_OPAQUE |
|
96 |
#define OGLC_USE_MASK \ |
|
97 |
sun_java2d_pipe_BufferedContext_USE_MASK |
|
98 |
||
99 |
/** |
|
887 | 100 |
* See OGLContext.java for more on these flags. |
101 |
*/ |
|
102 |
#define CAPS_EMPTY \ |
|
103 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EMPTY |
|
104 |
#define CAPS_RT_PLAIN_ALPHA \ |
|
105 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_PLAIN_ALPHA |
|
106 |
#define CAPS_RT_TEXTURE_ALPHA \ |
|
107 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_TEXTURE_ALPHA |
|
108 |
#define CAPS_RT_TEXTURE_OPAQUE \ |
|
109 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_TEXTURE_OPAQUE |
|
110 |
#define CAPS_MULTITEXTURE \ |
|
111 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_MULTITEXTURE |
|
112 |
#define CAPS_TEXNONPOW2 \ |
|
113 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_TEXNONPOW2 |
|
114 |
#define CAPS_TEXNONSQUARE \ |
|
115 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_TEXNONSQUARE |
|
116 |
#define CAPS_PS20 \ |
|
117 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_PS20 |
|
118 |
#define CAPS_PS30 \ |
|
119 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_PS30 |
|
120 |
#define LAST_SHARED_CAP \ |
|
121 |
sun_java2d_opengl_OGLContext_OGLContextCaps_LAST_SHARED_CAP |
|
122 |
#define CAPS_EXT_FBOBJECT \ |
|
123 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_FBOBJECT |
|
124 |
#define CAPS_STORED_ALPHA \ |
|
125 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_STORED_ALPHA |
|
126 |
#define CAPS_DOUBLEBUFFERED \ |
|
127 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_DOUBLEBUFFERED |
|
128 |
#define CAPS_EXT_LCD_SHADER \ |
|
129 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_LCD_SHADER |
|
130 |
#define CAPS_EXT_BIOP_SHADER \ |
|
131 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_BIOP_SHADER |
|
132 |
#define CAPS_EXT_GRAD_SHADER \ |
|
133 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_GRAD_SHADER |
|
134 |
#define CAPS_EXT_TEXRECT \ |
|
135 |
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_TEXRECT |
|
136 |
||
137 |
/** |
|
2 | 138 |
* Evaluates to true if the given capability bitmask is present for the |
139 |
* given OGLContext. Note that only the constant name needs to be passed as |
|
140 |
* a parameter, as this macro will automatically prepend the full package |
|
141 |
* and class name to the constant name. |
|
142 |
*/ |
|
887 | 143 |
#define OGLC_IS_CAP_PRESENT(oglc, cap) (((oglc)->caps & (cap)) != 0) |
2 | 144 |
|
145 |
/** |
|
146 |
* At startup we will embed one of the following values in the caps field |
|
147 |
* of OGLContext. Later we can use this information to select |
|
148 |
* the codepath that offers the best performance for that vendor's |
|
149 |
* hardware and/or drivers. |
|
150 |
*/ |
|
151 |
#define OGLC_VENDOR_OTHER 0 |
|
152 |
#define OGLC_VENDOR_ATI 1 |
|
153 |
#define OGLC_VENDOR_NVIDIA 2 |
|
154 |
#define OGLC_VENDOR_SUN 3 |
|
155 |
||
156 |
#define OGLC_VCAP_MASK 0x3 |
|
157 |
#define OGLC_VCAP_OFFSET 24 |
|
158 |
||
159 |
#define OGLC_GET_VENDOR(oglc) \ |
|
160 |
(((oglc)->caps >> OGLC_VCAP_OFFSET) & OGLC_VCAP_MASK) |
|
161 |
||
162 |
/** |
|
163 |
* This constant determines the size of the shared tile texture used |
|
164 |
* by a number of image rendering methods. For example, the blit tile texture |
|
165 |
* will have dimensions with width OGLC_BLIT_TILE_SIZE and height |
|
166 |
* OGLC_BLIT_TILE_SIZE (the tile will always be square). |
|
167 |
*/ |
|
168 |
#define OGLC_BLIT_TILE_SIZE 128 |
|
169 |
||
170 |
/** |
|
171 |
* Helper macros that update the current texture function state only when |
|
172 |
* it needs to be changed, which helps reduce overhead for small texturing |
|
173 |
* operations. The filter state is set on a per-context (not per-texture) |
|
174 |
* basis; for example, if we apply one texture using GL_MODULATE followed by |
|
175 |
* another texture using GL_MODULATE (under the same context), there is no |
|
176 |
* need to set the texture function the second time, as that would be |
|
177 |
* redundant. |
|
178 |
*/ |
|
179 |
#define OGLC_INIT_TEXTURE_FUNCTION(oglc, func) \ |
|
180 |
do { \ |
|
181 |
j2d_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, (func)); \ |
|
182 |
(oglc)->textureFunction = (func); \ |
|
183 |
} while (0) |
|
184 |
||
185 |
#define OGLC_UPDATE_TEXTURE_FUNCTION(oglc, func) \ |
|
186 |
do { \ |
|
187 |
if ((oglc)->textureFunction != (func)) { \ |
|
188 |
OGLC_INIT_TEXTURE_FUNCTION(oglc, func); \ |
|
189 |
} \ |
|
190 |
} while (0) |
|
191 |
||
192 |
/** |
|
193 |
* Exported methods. |
|
194 |
*/ |
|
195 |
OGLContext *OGLContext_SetSurfaces(JNIEnv *env, jlong pSrc, jlong pDst); |
|
196 |
void OGLContext_ResetClip(OGLContext *oglc); |
|
197 |
void OGLContext_SetRectClip(OGLContext *oglc, OGLSDOps *dstOps, |
|
198 |
jint x1, jint y1, jint x2, jint y2); |
|
199 |
void OGLContext_BeginShapeClip(OGLContext *oglc); |
|
200 |
void OGLContext_EndShapeClip(OGLContext *oglc, OGLSDOps *dstOps); |
|
201 |
void OGLContext_SetExtraAlpha(jfloat ea); |
|
202 |
void OGLContext_ResetComposite(OGLContext *oglc); |
|
203 |
void OGLContext_SetAlphaComposite(OGLContext *oglc, |
|
204 |
jint rule, jfloat extraAlpha, jint flags); |
|
205 |
void OGLContext_SetXorComposite(OGLContext *oglc, jint xorPixel); |
|
206 |
void OGLContext_ResetTransform(OGLContext *oglc); |
|
207 |
void OGLContext_SetTransform(OGLContext *oglc, |
|
208 |
jdouble m00, jdouble m10, |
|
209 |
jdouble m01, jdouble m11, |
|
210 |
jdouble m02, jdouble m12); |
|
211 |
||
212 |
jboolean OGLContext_InitBlitTileTexture(OGLContext *oglc); |
|
213 |
GLuint OGLContext_CreateBlitTexture(GLenum internalFormat, GLenum pixelFormat, |
|
214 |
GLuint width, GLuint height); |
|
215 |
||
216 |
void OGLContext_DestroyContextResources(OGLContext *oglc); |
|
217 |
||
218 |
jboolean OGLContext_IsExtensionAvailable(const char *extString, char *extName); |
|
219 |
void OGLContext_GetExtensionInfo(JNIEnv *env, jint *caps); |
|
220 |
jboolean OGLContext_IsVersionSupported(const unsigned char *versionstr); |
|
221 |
||
222 |
GLhandleARB OGLContext_CreateFragmentProgram(const char *fragmentShaderSource); |
|
223 |
||
224 |
#endif /* OGLContext_h_Included */ |