michael@0: /* michael@0: * Copyright (C) 2007 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef ANDROID_PIXELFLINGER_H michael@0: #define ANDROID_PIXELFLINGER_H michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include michael@0: michael@0: // GGL types michael@0: michael@0: typedef int8_t GGLbyte; // b michael@0: typedef int16_t GGLshort; // s michael@0: typedef int32_t GGLint; // i michael@0: typedef ssize_t GGLsizei; // i michael@0: typedef int32_t GGLfixed; // x michael@0: typedef int32_t GGLclampx; // x michael@0: typedef float GGLfloat; // f michael@0: typedef float GGLclampf; // f michael@0: typedef double GGLdouble; // d michael@0: typedef double GGLclampd; // d michael@0: typedef uint8_t GGLubyte; // ub michael@0: typedef uint8_t GGLboolean; // ub michael@0: typedef uint16_t GGLushort; // us michael@0: typedef uint32_t GGLuint; // ui michael@0: typedef unsigned int GGLenum; // ui michael@0: typedef unsigned int GGLbitfield; // ui michael@0: typedef void GGLvoid; michael@0: typedef int32_t GGLfixed32; michael@0: typedef int32_t GGLcolor; michael@0: typedef int32_t GGLcoord; michael@0: michael@0: // ---------------------------------------------------------------------------- michael@0: michael@0: #define GGL_MAX_VIEWPORT_DIMS 4096 michael@0: #define GGL_MAX_TEXTURE_SIZE 4096 michael@0: #define GGL_MAX_ALIASED_POINT_SIZE 0x7FFFFFF michael@0: #define GGL_MAX_SMOOTH_POINT_SIZE 2048 michael@0: #define GGL_MAX_SMOOTH_LINE_WIDTH 2048 michael@0: michael@0: // ---------------------------------------------------------------------------- michael@0: michael@0: // All these names are compatible with their OpenGL equivalents michael@0: // some of them are listed only for completeness michael@0: enum GGLNames { michael@0: GGL_FALSE = 0, michael@0: GGL_TRUE = 1, michael@0: michael@0: // enable/disable michael@0: GGL_SCISSOR_TEST = 0x0C11, michael@0: GGL_TEXTURE_2D = 0x0DE1, michael@0: GGL_ALPHA_TEST = 0x0BC0, michael@0: GGL_BLEND = 0x0BE2, michael@0: GGL_COLOR_LOGIC_OP = 0x0BF2, michael@0: GGL_DITHER = 0x0BD0, michael@0: GGL_STENCIL_TEST = 0x0B90, michael@0: GGL_DEPTH_TEST = 0x0B71, michael@0: GGL_AA = 0x80000001, michael@0: GGL_W_LERP = 0x80000004, michael@0: GGL_POINT_SMOOTH_NICE = 0x80000005, michael@0: michael@0: // buffers, pixel drawing/reading michael@0: GGL_COLOR = 0x1800, michael@0: michael@0: // fog michael@0: GGL_FOG = 0x0B60, michael@0: michael@0: // shade model michael@0: GGL_FLAT = 0x1D00, michael@0: GGL_SMOOTH = 0x1D01, michael@0: michael@0: // Texture parameter name michael@0: GGL_TEXTURE_MIN_FILTER = 0x2801, michael@0: GGL_TEXTURE_MAG_FILTER = 0x2800, michael@0: GGL_TEXTURE_WRAP_S = 0x2802, michael@0: GGL_TEXTURE_WRAP_T = 0x2803, michael@0: GGL_TEXTURE_WRAP_R = 0x2804, michael@0: michael@0: // Texture Filter michael@0: GGL_NEAREST = 0x2600, michael@0: GGL_LINEAR = 0x2601, michael@0: GGL_NEAREST_MIPMAP_NEAREST = 0x2700, michael@0: GGL_LINEAR_MIPMAP_NEAREST = 0x2701, michael@0: GGL_NEAREST_MIPMAP_LINEAR = 0x2702, michael@0: GGL_LINEAR_MIPMAP_LINEAR = 0x2703, michael@0: michael@0: // Texture Wrap Mode michael@0: GGL_CLAMP = 0x2900, michael@0: GGL_REPEAT = 0x2901, michael@0: GGL_CLAMP_TO_EDGE = 0x812F, michael@0: michael@0: // Texture Env Mode michael@0: GGL_REPLACE = 0x1E01, michael@0: GGL_MODULATE = 0x2100, michael@0: GGL_DECAL = 0x2101, michael@0: GGL_ADD = 0x0104, michael@0: michael@0: // Texture Env Parameter michael@0: GGL_TEXTURE_ENV_MODE = 0x2200, michael@0: GGL_TEXTURE_ENV_COLOR = 0x2201, michael@0: michael@0: // Texture Env Target michael@0: GGL_TEXTURE_ENV = 0x2300, michael@0: michael@0: // Texture coord generation michael@0: GGL_TEXTURE_GEN_MODE = 0x2500, michael@0: GGL_S = 0x2000, michael@0: GGL_T = 0x2001, michael@0: GGL_R = 0x2002, michael@0: GGL_Q = 0x2003, michael@0: GGL_ONE_TO_ONE = 0x80000002, michael@0: GGL_AUTOMATIC = 0x80000003, michael@0: michael@0: // AlphaFunction michael@0: GGL_NEVER = 0x0200, michael@0: GGL_LESS = 0x0201, michael@0: GGL_EQUAL = 0x0202, michael@0: GGL_LEQUAL = 0x0203, michael@0: GGL_GREATER = 0x0204, michael@0: GGL_NOTEQUAL = 0x0205, michael@0: GGL_GEQUAL = 0x0206, michael@0: GGL_ALWAYS = 0x0207, michael@0: michael@0: // LogicOp michael@0: GGL_CLEAR = 0x1500, // 0 michael@0: GGL_AND = 0x1501, // s & d michael@0: GGL_AND_REVERSE = 0x1502, // s & ~d michael@0: GGL_COPY = 0x1503, // s michael@0: GGL_AND_INVERTED = 0x1504, // ~s & d michael@0: GGL_NOOP = 0x1505, // d michael@0: GGL_XOR = 0x1506, // s ^ d michael@0: GGL_OR = 0x1507, // s | d michael@0: GGL_NOR = 0x1508, // ~(s | d) michael@0: GGL_EQUIV = 0x1509, // ~(s ^ d) michael@0: GGL_INVERT = 0x150A, // ~d michael@0: GGL_OR_REVERSE = 0x150B, // s | ~d michael@0: GGL_COPY_INVERTED = 0x150C, // ~s michael@0: GGL_OR_INVERTED = 0x150D, // ~s | d michael@0: GGL_NAND = 0x150E, // ~(s & d) michael@0: GGL_SET = 0x150F, // 1 michael@0: michael@0: // blending equation & function michael@0: GGL_ZERO = 0, // SD michael@0: GGL_ONE = 1, // SD michael@0: GGL_SRC_COLOR = 0x0300, // D michael@0: GGL_ONE_MINUS_SRC_COLOR = 0x0301, // D michael@0: GGL_SRC_ALPHA = 0x0302, // SD michael@0: GGL_ONE_MINUS_SRC_ALPHA = 0x0303, // SD michael@0: GGL_DST_ALPHA = 0x0304, // SD michael@0: GGL_ONE_MINUS_DST_ALPHA = 0x0305, // SD michael@0: GGL_DST_COLOR = 0x0306, // S michael@0: GGL_ONE_MINUS_DST_COLOR = 0x0307, // S michael@0: GGL_SRC_ALPHA_SATURATE = 0x0308, // S michael@0: michael@0: // clear bits michael@0: GGL_DEPTH_BUFFER_BIT = 0x00000100, michael@0: GGL_STENCIL_BUFFER_BIT = 0x00000400, michael@0: GGL_COLOR_BUFFER_BIT = 0x00004000, michael@0: michael@0: // errors michael@0: GGL_NO_ERROR = 0, michael@0: GGL_INVALID_ENUM = 0x0500, michael@0: GGL_INVALID_VALUE = 0x0501, michael@0: GGL_INVALID_OPERATION = 0x0502, michael@0: GGL_STACK_OVERFLOW = 0x0503, michael@0: GGL_STACK_UNDERFLOW = 0x0504, michael@0: GGL_OUT_OF_MEMORY = 0x0505 michael@0: }; michael@0: michael@0: // ---------------------------------------------------------------------------- michael@0: michael@0: typedef struct { michael@0: GGLsizei version; // always set to sizeof(GGLSurface) michael@0: GGLuint width; // width in pixels michael@0: GGLuint height; // height in pixels michael@0: GGLint stride; // stride in pixels michael@0: GGLubyte* data; // pointer to the bits michael@0: GGLubyte format; // pixel format michael@0: GGLubyte rfu[3]; // must be zero michael@0: // these values are dependent on the used format michael@0: union { michael@0: GGLint compressedFormat; michael@0: GGLint vstride; michael@0: }; michael@0: void* reserved; michael@0: } GGLSurface; michael@0: michael@0: michael@0: typedef struct { michael@0: // immediate rendering michael@0: void (*pointx)(void *con, const GGLcoord* v, GGLcoord r); michael@0: void (*linex)(void *con, michael@0: const GGLcoord* v0, const GGLcoord* v1, GGLcoord width); michael@0: void (*recti)(void* c, GGLint l, GGLint t, GGLint r, GGLint b); michael@0: void (*trianglex)(void* c, michael@0: GGLcoord const* v0, GGLcoord const* v1, GGLcoord const* v2); michael@0: michael@0: // scissor michael@0: void (*scissor)(void* c, GGLint x, GGLint y, GGLsizei width, GGLsizei height); michael@0: michael@0: // Set the textures and color buffers michael@0: void (*activeTexture)(void* c, GGLuint tmu); michael@0: void (*bindTexture)(void* c, const GGLSurface* surface); michael@0: void (*colorBuffer)(void* c, const GGLSurface* surface); michael@0: void (*readBuffer)(void* c, const GGLSurface* surface); michael@0: void (*depthBuffer)(void* c, const GGLSurface* surface); michael@0: void (*bindTextureLod)(void* c, GGLuint tmu, const GGLSurface* surface); michael@0: michael@0: // enable/disable features michael@0: void (*enable)(void* c, GGLenum name); michael@0: void (*disable)(void* c, GGLenum name); michael@0: void (*enableDisable)(void* c, GGLenum name, GGLboolean en); michael@0: michael@0: // specify the fragment's color michael@0: void (*shadeModel)(void* c, GGLenum mode); michael@0: void (*color4xv)(void* c, const GGLclampx* color); michael@0: // specify color iterators (16.16) michael@0: void (*colorGrad12xv)(void* c, const GGLcolor* grad); michael@0: michael@0: // specify Z coordinate iterators (0.32) michael@0: void (*zGrad3xv)(void* c, const GGLfixed32* grad); michael@0: michael@0: // specify W coordinate iterators (16.16) michael@0: void (*wGrad3xv)(void* c, const GGLfixed* grad); michael@0: michael@0: // specify fog iterator & color (16.16) michael@0: void (*fogGrad3xv)(void* c, const GGLfixed* grad); michael@0: void (*fogColor3xv)(void* c, const GGLclampx* color); michael@0: michael@0: // specify blending parameters michael@0: void (*blendFunc)(void* c, GGLenum src, GGLenum dst); michael@0: void (*blendFuncSeparate)(void* c, GGLenum src, GGLenum dst, michael@0: GGLenum srcAlpha, GGLenum dstAplha); michael@0: michael@0: // texture environnement (REPLACE / MODULATE / DECAL / BLEND) michael@0: void (*texEnvi)(void* c, GGLenum target, michael@0: GGLenum pname, michael@0: GGLint param); michael@0: michael@0: void (*texEnvxv)(void* c, GGLenum target, michael@0: GGLenum pname, const GGLfixed* params); michael@0: michael@0: // texture parameters (Wrapping, filter) michael@0: void (*texParameteri)(void* c, GGLenum target, michael@0: GGLenum pname, michael@0: GGLint param); michael@0: michael@0: // texture iterators (16.16) michael@0: void (*texCoord2i)(void* c, GGLint s, GGLint t); michael@0: void (*texCoord2x)(void* c, GGLfixed s, GGLfixed t); michael@0: michael@0: // s, dsdx, dsdy, scale, t, dtdx, dtdy, tscale michael@0: // This api uses block floating-point for S and T texture coordinates. michael@0: // All values are given in 16.16, scaled by 'scale'. In other words, michael@0: // set scale to 0, for 16.16 values. michael@0: void (*texCoordGradScale8xv)(void* c, GGLint tmu, const int32_t* grad8); michael@0: michael@0: void (*texGeni)(void* c, GGLenum coord, GGLenum pname, GGLint param); michael@0: michael@0: // masking michael@0: void (*colorMask)(void* c, GGLboolean red, michael@0: GGLboolean green, michael@0: GGLboolean blue, michael@0: GGLboolean alpha); michael@0: michael@0: void (*depthMask)(void* c, GGLboolean flag); michael@0: michael@0: void (*stencilMask)(void* c, GGLuint mask); michael@0: michael@0: // alpha func michael@0: void (*alphaFuncx)(void* c, GGLenum func, GGLclampx ref); michael@0: michael@0: // depth func michael@0: void (*depthFunc)(void* c, GGLenum func); michael@0: michael@0: // logic op michael@0: void (*logicOp)(void* c, GGLenum opcode); michael@0: michael@0: // clear michael@0: void (*clear)(void* c, GGLbitfield mask); michael@0: void (*clearColorx)(void* c, michael@0: GGLclampx r, GGLclampx g, GGLclampx b, GGLclampx a); michael@0: void (*clearDepthx)(void* c, GGLclampx depth); michael@0: void (*clearStencil)(void* c, GGLint s); michael@0: michael@0: // framebuffer operations michael@0: void (*copyPixels)(void* c, GGLint x, GGLint y, michael@0: GGLsizei width, GGLsizei height, GGLenum type); michael@0: void (*rasterPos2x)(void* c, GGLfixed x, GGLfixed y); michael@0: void (*rasterPos2i)(void* c, GGLint x, GGLint y); michael@0: } GGLContext; michael@0: michael@0: // ---------------------------------------------------------------------------- michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: // construct / destroy the context michael@0: ssize_t gglInit(GGLContext** context); michael@0: ssize_t gglUninit(GGLContext* context); michael@0: michael@0: GGLint gglBitBlti( michael@0: GGLContext* c, michael@0: int tmu, michael@0: GGLint crop[4], michael@0: GGLint where[4]); michael@0: michael@0: #ifdef __cplusplus michael@0: }; michael@0: #endif michael@0: michael@0: // ---------------------------------------------------------------------------- michael@0: michael@0: #endif // ANDROID_PIXELFLINGER_H