0N/A/*
2362N/A * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#ifndef OGLContext_h_Included
0N/A#define OGLContext_h_Included
0N/A
0N/A#include "sun_java2d_pipe_BufferedContext.h"
0N/A#include "sun_java2d_opengl_OGLContext.h"
430N/A#include "sun_java2d_opengl_OGLContext_OGLContextCaps.h"
0N/A
0N/A#include "j2d_md.h"
0N/A#include "J2D_GL/gl.h"
0N/A#include "OGLSurfaceData.h"
0N/A
0N/A/**
0N/A * The OGLBlendRule structure encapsulates the two enumerated values that
0N/A * comprise a given Porter-Duff blending (compositing) rule. For example,
0N/A * the "SrcOver" rule can be represented by:
0N/A * rule.src = GL_ONE;
0N/A * rule.dst = GL_ONE_MINUS_SRC_ALPHA;
0N/A *
0N/A * GLenum src;
0N/A * The constant representing the source factor in this Porter-Duff rule.
0N/A *
0N/A * GLenum dst;
0N/A * The constant representing the destination factor in this Porter-Duff rule.
0N/A */
0N/Atypedef struct {
0N/A GLenum src;
0N/A GLenum dst;
0N/A} OGLBlendRule;
0N/A
0N/A/**
0N/A * The OGLContext structure contains cached state relevant to the native
0N/A * OpenGL context stored within the native ctxInfo field. Each Java-level
0N/A * OGLContext object is associated with a native-level OGLContext structure.
0N/A * The caps field is a bitfield that expresses the capabilities of the
0N/A * GraphicsConfig associated with this context (see OGLContext.java for
0N/A * the definitions of each capability bit). The other fields are
0N/A * simply cached values of various elements of the context state, typically
0N/A * used in the OGLContext.set*() methods.
0N/A *
0N/A * Note that the textureFunction field is implicitly set to zero when the
0N/A * OGLContext is created. The acceptable values (e.g. GL_MODULATE,
0N/A * GL_REPLACE) for this field are never zero, which means we will always
0N/A * validate the texture function state upon the first call to the
0N/A * OGLC_UPDATE_TEXTURE_FUNCTION() macro.
0N/A */
0N/Atypedef struct {
0N/A void *ctxInfo;
0N/A jint caps;
0N/A jint compState;
0N/A jfloat extraAlpha;
0N/A jint xorPixel;
0N/A jint pixel;
0N/A jubyte r;
0N/A jubyte g;
0N/A jubyte b;
0N/A jubyte a;
0N/A jint paintState;
0N/A jboolean useMask;
0N/A GLdouble *xformMatrix;
0N/A GLuint blitTextureID;
0N/A GLint textureFunction;
5040N/A jboolean vertexCacheEnabled;
0N/A} OGLContext;
0N/A
0N/A/**
0N/A * See BufferedContext.java for more on these flags...
0N/A */
0N/A#define OGLC_NO_CONTEXT_FLAGS \
0N/A sun_java2d_pipe_BufferedContext_NO_CONTEXT_FLAGS
0N/A#define OGLC_SRC_IS_OPAQUE \
0N/A sun_java2d_pipe_BufferedContext_SRC_IS_OPAQUE
0N/A#define OGLC_USE_MASK \
0N/A sun_java2d_pipe_BufferedContext_USE_MASK
0N/A
0N/A/**
430N/A * See OGLContext.java for more on these flags.
430N/A */
430N/A#define CAPS_EMPTY \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EMPTY
430N/A#define CAPS_RT_PLAIN_ALPHA \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_PLAIN_ALPHA
430N/A#define CAPS_RT_TEXTURE_ALPHA \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_TEXTURE_ALPHA
430N/A#define CAPS_RT_TEXTURE_OPAQUE \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_TEXTURE_OPAQUE
430N/A#define CAPS_MULTITEXTURE \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_MULTITEXTURE
430N/A#define CAPS_TEXNONPOW2 \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_TEXNONPOW2
430N/A#define CAPS_TEXNONSQUARE \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_TEXNONSQUARE
430N/A#define CAPS_PS20 \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_PS20
430N/A#define CAPS_PS30 \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_PS30
430N/A#define LAST_SHARED_CAP \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_LAST_SHARED_CAP
430N/A#define CAPS_EXT_FBOBJECT \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_FBOBJECT
430N/A#define CAPS_STORED_ALPHA \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_STORED_ALPHA
430N/A#define CAPS_DOUBLEBUFFERED \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_DOUBLEBUFFERED
430N/A#define CAPS_EXT_LCD_SHADER \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_LCD_SHADER
430N/A#define CAPS_EXT_BIOP_SHADER \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_BIOP_SHADER
430N/A#define CAPS_EXT_GRAD_SHADER \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_GRAD_SHADER
430N/A#define CAPS_EXT_TEXRECT \
430N/A sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_TEXRECT
430N/A
430N/A/**
0N/A * Evaluates to true if the given capability bitmask is present for the
0N/A * given OGLContext. Note that only the constant name needs to be passed as
0N/A * a parameter, as this macro will automatically prepend the full package
0N/A * and class name to the constant name.
0N/A */
430N/A#define OGLC_IS_CAP_PRESENT(oglc, cap) (((oglc)->caps & (cap)) != 0)
0N/A
0N/A/**
0N/A * At startup we will embed one of the following values in the caps field
0N/A * of OGLContext. Later we can use this information to select
0N/A * the codepath that offers the best performance for that vendor's
0N/A * hardware and/or drivers.
0N/A */
0N/A#define OGLC_VENDOR_OTHER 0
0N/A#define OGLC_VENDOR_ATI 1
0N/A#define OGLC_VENDOR_NVIDIA 2
0N/A#define OGLC_VENDOR_SUN 3
0N/A
0N/A#define OGLC_VCAP_MASK 0x3
0N/A#define OGLC_VCAP_OFFSET 24
0N/A
0N/A#define OGLC_GET_VENDOR(oglc) \
0N/A (((oglc)->caps >> OGLC_VCAP_OFFSET) & OGLC_VCAP_MASK)
0N/A
0N/A/**
0N/A * This constant determines the size of the shared tile texture used
0N/A * by a number of image rendering methods. For example, the blit tile texture
0N/A * will have dimensions with width OGLC_BLIT_TILE_SIZE and height
0N/A * OGLC_BLIT_TILE_SIZE (the tile will always be square).
0N/A */
0N/A#define OGLC_BLIT_TILE_SIZE 128
0N/A
0N/A/**
0N/A * Helper macros that update the current texture function state only when
0N/A * it needs to be changed, which helps reduce overhead for small texturing
0N/A * operations. The filter state is set on a per-context (not per-texture)
0N/A * basis; for example, if we apply one texture using GL_MODULATE followed by
0N/A * another texture using GL_MODULATE (under the same context), there is no
0N/A * need to set the texture function the second time, as that would be
0N/A * redundant.
0N/A */
0N/A#define OGLC_INIT_TEXTURE_FUNCTION(oglc, func) \
0N/A do { \
0N/A j2d_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, (func)); \
0N/A (oglc)->textureFunction = (func); \
0N/A } while (0)
0N/A
0N/A#define OGLC_UPDATE_TEXTURE_FUNCTION(oglc, func) \
0N/A do { \
0N/A if ((oglc)->textureFunction != (func)) { \
0N/A OGLC_INIT_TEXTURE_FUNCTION(oglc, func); \
0N/A } \
0N/A } while (0)
0N/A
0N/A/**
0N/A * Exported methods.
0N/A */
0N/AOGLContext *OGLContext_SetSurfaces(JNIEnv *env, jlong pSrc, jlong pDst);
0N/Avoid OGLContext_ResetClip(OGLContext *oglc);
0N/Avoid OGLContext_SetRectClip(OGLContext *oglc, OGLSDOps *dstOps,
0N/A jint x1, jint y1, jint x2, jint y2);
0N/Avoid OGLContext_BeginShapeClip(OGLContext *oglc);
0N/Avoid OGLContext_EndShapeClip(OGLContext *oglc, OGLSDOps *dstOps);
0N/Avoid OGLContext_SetExtraAlpha(jfloat ea);
0N/Avoid OGLContext_ResetComposite(OGLContext *oglc);
0N/Avoid OGLContext_SetAlphaComposite(OGLContext *oglc,
0N/A jint rule, jfloat extraAlpha, jint flags);
0N/Avoid OGLContext_SetXorComposite(OGLContext *oglc, jint xorPixel);
0N/Avoid OGLContext_ResetTransform(OGLContext *oglc);
0N/Avoid OGLContext_SetTransform(OGLContext *oglc,
0N/A jdouble m00, jdouble m10,
0N/A jdouble m01, jdouble m11,
0N/A jdouble m02, jdouble m12);
0N/A
0N/Ajboolean OGLContext_InitBlitTileTexture(OGLContext *oglc);
0N/AGLuint OGLContext_CreateBlitTexture(GLenum internalFormat, GLenum pixelFormat,
0N/A GLuint width, GLuint height);
0N/A
0N/Avoid OGLContext_DestroyContextResources(OGLContext *oglc);
0N/A
0N/Ajboolean OGLContext_IsExtensionAvailable(const char *extString, char *extName);
0N/Avoid OGLContext_GetExtensionInfo(JNIEnv *env, jint *caps);
0N/Ajboolean OGLContext_IsVersionSupported(const unsigned char *versionstr);
0N/A
0N/AGLhandleARB OGLContext_CreateFragmentProgram(const char *fragmentShaderSource);
0N/A
0N/A#endif /* OGLContext_h_Included */