Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/java2d/opengl/OGLContext.h
38918 views
/*1* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef OGLContext_h_Included26#define OGLContext_h_Included2728#include "sun_java2d_pipe_BufferedContext.h"29#include "sun_java2d_opengl_OGLContext.h"30#include "sun_java2d_opengl_OGLContext_OGLContextCaps.h"3132#include "j2d_md.h"33#include "J2D_GL/gl.h"34#include "OGLSurfaceData.h"3536/**37* The OGLBlendRule structure encapsulates the two enumerated values that38* comprise a given Porter-Duff blending (compositing) rule. For example,39* the "SrcOver" rule can be represented by:40* rule.src = GL_ONE;41* rule.dst = GL_ONE_MINUS_SRC_ALPHA;42*43* GLenum src;44* The constant representing the source factor in this Porter-Duff rule.45*46* GLenum dst;47* The constant representing the destination factor in this Porter-Duff rule.48*/49typedef struct {50GLenum src;51GLenum dst;52} OGLBlendRule;5354/**55* The OGLContext structure contains cached state relevant to the native56* OpenGL context stored within the native ctxInfo field. Each Java-level57* OGLContext object is associated with a native-level OGLContext structure.58* The caps field is a bitfield that expresses the capabilities of the59* GraphicsConfig associated with this context (see OGLContext.java for60* the definitions of each capability bit). The other fields are61* simply cached values of various elements of the context state, typically62* used in the OGLContext.set*() methods.63*64* Note that the textureFunction field is implicitly set to zero when the65* OGLContext is created. The acceptable values (e.g. GL_MODULATE,66* GL_REPLACE) for this field are never zero, which means we will always67* validate the texture function state upon the first call to the68* OGLC_UPDATE_TEXTURE_FUNCTION() macro.69*/70typedef struct {71void *ctxInfo;72jint caps;73jint compState;74jfloat extraAlpha;75jint xorPixel;76jint pixel;77jubyte r;78jubyte g;79jubyte b;80jubyte a;81jint paintState;82jboolean useMask;83GLdouble *xformMatrix;84GLuint blitTextureID;85GLint textureFunction;86jboolean vertexCacheEnabled;87} OGLContext;8889/**90* See BufferedContext.java for more on these flags...91*/92#define OGLC_NO_CONTEXT_FLAGS \93sun_java2d_pipe_BufferedContext_NO_CONTEXT_FLAGS94#define OGLC_SRC_IS_OPAQUE \95sun_java2d_pipe_BufferedContext_SRC_IS_OPAQUE96#define OGLC_USE_MASK \97sun_java2d_pipe_BufferedContext_USE_MASK9899/**100* See OGLContext.java for more on these flags.101*/102#define CAPS_EMPTY \103sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EMPTY104#define CAPS_RT_PLAIN_ALPHA \105sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_PLAIN_ALPHA106#define CAPS_RT_TEXTURE_ALPHA \107sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_TEXTURE_ALPHA108#define CAPS_RT_TEXTURE_OPAQUE \109sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_TEXTURE_OPAQUE110#define CAPS_MULTITEXTURE \111sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_MULTITEXTURE112#define CAPS_TEXNONPOW2 \113sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_TEXNONPOW2114#define CAPS_TEXNONSQUARE \115sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_TEXNONSQUARE116#define CAPS_PS20 \117sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_PS20118#define CAPS_PS30 \119sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_PS30120#define LAST_SHARED_CAP \121sun_java2d_opengl_OGLContext_OGLContextCaps_LAST_SHARED_CAP122#define CAPS_EXT_FBOBJECT \123sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_FBOBJECT124#define CAPS_STORED_ALPHA \125sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_STORED_ALPHA126#define CAPS_DOUBLEBUFFERED \127sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_DOUBLEBUFFERED128#define CAPS_EXT_LCD_SHADER \129sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_LCD_SHADER130#define CAPS_EXT_BIOP_SHADER \131sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_BIOP_SHADER132#define CAPS_EXT_GRAD_SHADER \133sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_GRAD_SHADER134#define CAPS_EXT_TEXRECT \135sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_TEXRECT136#define CAPS_EXT_TEXBARRIER \137sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_TEXBARRIER138139/**140* Evaluates to true if the given capability bitmask is present for the141* given OGLContext. Note that only the constant name needs to be passed as142* a parameter, as this macro will automatically prepend the full package143* and class name to the constant name.144*/145#define OGLC_IS_CAP_PRESENT(oglc, cap) (((oglc)->caps & (cap)) != 0)146147/**148* At startup we will embed one of the following values in the caps field149* of OGLContext. Later we can use this information to select150* the codepath that offers the best performance for that vendor's151* hardware and/or drivers.152*/153#define OGLC_VENDOR_OTHER 0154#define OGLC_VENDOR_ATI 1155#define OGLC_VENDOR_NVIDIA 2156#define OGLC_VENDOR_INTEL 3157158#define OGLC_VCAP_MASK 0x3159#define OGLC_VCAP_OFFSET 24160161#define OGLC_GET_VENDOR(oglc) \162(((oglc)->caps >> OGLC_VCAP_OFFSET) & OGLC_VCAP_MASK)163164/**165* This constant determines the size of the shared tile texture used166* by a number of image rendering methods. For example, the blit tile texture167* will have dimensions with width OGLC_BLIT_TILE_SIZE and height168* OGLC_BLIT_TILE_SIZE (the tile will always be square).169*/170#define OGLC_BLIT_TILE_SIZE 128171172/**173* Helper macros that update the current texture function state only when174* it needs to be changed, which helps reduce overhead for small texturing175* operations. The filter state is set on a per-context (not per-texture)176* basis; for example, if we apply one texture using GL_MODULATE followed by177* another texture using GL_MODULATE (under the same context), there is no178* need to set the texture function the second time, as that would be179* redundant.180*/181#define OGLC_INIT_TEXTURE_FUNCTION(oglc, func) \182do { \183j2d_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, (func)); \184(oglc)->textureFunction = (func); \185} while (0)186187#define OGLC_UPDATE_TEXTURE_FUNCTION(oglc, func) \188do { \189if ((oglc)->textureFunction != (func)) { \190OGLC_INIT_TEXTURE_FUNCTION(oglc, func); \191} \192} while (0)193194/**195* Exported methods.196*/197OGLContext *OGLContext_SetSurfaces(JNIEnv *env, jlong pSrc, jlong pDst);198void OGLContext_ResetClip(OGLContext *oglc);199void OGLContext_SetRectClip(OGLContext *oglc, OGLSDOps *dstOps,200jint x1, jint y1, jint x2, jint y2);201void OGLContext_BeginShapeClip(OGLContext *oglc);202void OGLContext_EndShapeClip(OGLContext *oglc, OGLSDOps *dstOps);203void OGLContext_SetExtraAlpha(jfloat ea);204void OGLContext_ResetComposite(OGLContext *oglc);205void OGLContext_SetAlphaComposite(OGLContext *oglc,206jint rule, jfloat extraAlpha, jint flags);207void OGLContext_SetXorComposite(OGLContext *oglc, jint xorPixel);208void OGLContext_ResetTransform(OGLContext *oglc);209void OGLContext_SetTransform(OGLContext *oglc,210jdouble m00, jdouble m10,211jdouble m01, jdouble m11,212jdouble m02, jdouble m12);213214jboolean OGLContext_InitBlitTileTexture(OGLContext *oglc);215GLuint OGLContext_CreateBlitTexture(GLenum internalFormat, GLenum pixelFormat,216GLuint width, GLuint height);217218void OGLContext_DestroyContextResources(OGLContext *oglc);219220jboolean OGLContext_IsExtensionAvailable(const char *extString, char *extName);221void OGLContext_GetExtensionInfo(JNIEnv *env, jint *caps);222jboolean OGLContext_IsVersionSupported(const unsigned char *versionstr);223224GLhandleARB OGLContext_CreateFragmentProgram(const char *fragmentShaderSource);225226#endif /* OGLContext_h_Included */227228229