aboutsummaryrefslogtreecommitdiffstats
path: root/include/pixelflinger
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commit4f6e8d7a00cbeda1e70cc15be9c4af1018bdad53 (patch)
tree54fd1b2695a591d2306d41264df67c53077b752c /include/pixelflinger
downloadsystem_core-4f6e8d7a00cbeda1e70cc15be9c4af1018bdad53.zip
system_core-4f6e8d7a00cbeda1e70cc15be9c4af1018bdad53.tar.gz
system_core-4f6e8d7a00cbeda1e70cc15be9c4af1018bdad53.tar.bz2
Initial Contribution
Diffstat (limited to 'include/pixelflinger')
-rw-r--r--include/pixelflinger/format.h126
-rw-r--r--include/pixelflinger/pixelflinger.h330
2 files changed, 456 insertions, 0 deletions
diff --git a/include/pixelflinger/format.h b/include/pixelflinger/format.h
new file mode 100644
index 0000000..ad0d29d
--- /dev/null
+++ b/include/pixelflinger/format.h
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2005 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_PIXELFLINGER_FORMAT_H
+#define ANDROID_PIXELFLINGER_FORMAT_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+enum GGLPixelFormat {
+ // these constants need to match those
+ // in graphics/PixelFormat.java, ui/PixelFormat.h, BlitHardware.h
+ GGL_PIXEL_FORMAT_UNKNOWN = 0,
+ GGL_PIXEL_FORMAT_NONE = 0,
+
+ GGL_PIXEL_FORMAT_RGBA_8888 = 1, // 4x8-bit ARGB
+ GGL_PIXEL_FORMAT_RGBX_8888 = 2, // 3x8-bit RGB stored in 32-bit chunks
+ GGL_PIXEL_FORMAT_RGB_888 = 3, // 3x8-bit RGB
+ GGL_PIXEL_FORMAT_RGB_565 = 4, // 16-bit RGB
+ GGL_PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit RGBA
+ GGL_PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit RGBA
+
+ GGL_PIXEL_FORMAT_A_8 = 8, // 8-bit A
+ GGL_PIXEL_FORMAT_L_8 = 9, // 8-bit L (R=G=B = L)
+ GGL_PIXEL_FORMAT_LA_88 = 0xA, // 16-bit LA
+ GGL_PIXEL_FORMAT_RGB_332 = 0xB, // 8-bit RGB (non paletted)
+
+ // YCbCr formats
+ GGL_PIXEL_FORMAT_YCbCr_422_SP= 0x10,
+ GGL_PIXEL_FORMAT_YCbCr_420_SP= 0x11,
+
+ // reserved/special formats
+ GGL_PIXEL_FORMAT_Z_16 = 0x18,
+ GGL_PIXEL_FORMAT_S_8 = 0x19,
+ GGL_PIXEL_FORMAT_SZ_24 = 0x1A,
+ GGL_PIXEL_FORMAT_SZ_8 = 0x1B,
+};
+
+enum GGLFormatComponents {
+ GGL_STENCIL_INDEX = 0x1901,
+ GGL_DEPTH_COMPONENT = 0x1902,
+ GGL_ALPHA = 0x1906,
+ GGL_RGB = 0x1907,
+ GGL_RGBA = 0x1908,
+ GGL_LUMINANCE = 0x1909,
+ GGL_LUMINANCE_ALPHA = 0x190A,
+ GGL_Y_CB_CR = 0x8000,
+};
+
+enum GGLFormatComponentIndex {
+ GGL_INDEX_ALPHA = 0,
+ GGL_INDEX_RED = 1,
+ GGL_INDEX_GREEN = 2,
+ GGL_INDEX_BLUE = 3,
+ GGL_INDEX_STENCIL = 0,
+ GGL_INDEX_DEPTH = 1,
+ GGL_INDEX_Y = 0,
+ GGL_INDEX_CB = 1,
+ GGL_INDEX_CR = 2,
+};
+
+typedef struct {
+#ifdef __cplusplus
+ enum {
+ ALPHA = GGL_INDEX_ALPHA,
+ RED = GGL_INDEX_RED,
+ GREEN = GGL_INDEX_GREEN,
+ BLUE = GGL_INDEX_BLUE,
+ STENCIL = GGL_INDEX_STENCIL,
+ DEPTH = GGL_INDEX_DEPTH,
+ LUMA = GGL_INDEX_Y,
+ CHROMAB = GGL_INDEX_CB,
+ CHROMAR = GGL_INDEX_CR,
+ };
+ inline uint32_t mask(int i) const {
+ return ((1<<(c[i].h-c[i].l))-1)<<c[i].l;
+ }
+ inline uint32_t bits(int i) const {
+ return c[i].h - c[i].l;
+ }
+#endif
+ uint8_t size; // bytes per pixel
+ uint8_t bitsPerPixel;
+ union {
+ struct {
+ uint8_t ah; // alpha high bit position + 1
+ uint8_t al; // alpha low bit position
+ uint8_t rh; // red high bit position + 1
+ uint8_t rl; // red low bit position
+ uint8_t gh; // green high bit position + 1
+ uint8_t gl; // green low bit position
+ uint8_t bh; // blue high bit position + 1
+ uint8_t bl; // blue low bit position
+ };
+ struct {
+ uint8_t h;
+ uint8_t l;
+ } __attribute__((__packed__)) c[4];
+ } __attribute__((__packed__));
+ uint16_t components; // GGLFormatComponents
+} GGLFormat;
+
+
+#ifdef __cplusplus
+extern "C" const GGLFormat* gglGetPixelFormatTable(size_t* numEntries = 0);
+#else
+const GGLFormat* gglGetPixelFormatTable(size_t* numEntries);
+#endif
+
+
+// ----------------------------------------------------------------------------
+
+#endif // ANDROID_PIXELFLINGER_FORMAT_H
diff --git a/include/pixelflinger/pixelflinger.h b/include/pixelflinger/pixelflinger.h
new file mode 100644
index 0000000..dca0b90
--- /dev/null
+++ b/include/pixelflinger/pixelflinger.h
@@ -0,0 +1,330 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_PIXELFLINGER_H
+#define ANDROID_PIXELFLINGER_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <pixelflinger/format.h>
+
+// GGL types
+
+typedef int8_t GGLbyte; // b
+typedef int16_t GGLshort; // s
+typedef int32_t GGLint; // i
+typedef ssize_t GGLsizei; // i
+typedef int32_t GGLfixed; // x
+typedef int32_t GGLclampx; // x
+typedef float GGLfloat; // f
+typedef float GGLclampf; // f
+typedef double GGLdouble; // d
+typedef double GGLclampd; // d
+typedef uint8_t GGLubyte; // ub
+typedef uint8_t GGLboolean; // ub
+typedef uint16_t GGLushort; // us
+typedef uint32_t GGLuint; // ui
+typedef unsigned int GGLenum; // ui
+typedef unsigned int GGLbitfield; // ui
+typedef void GGLvoid;
+typedef int32_t GGLfixed32;
+typedef int32_t GGLcolor;
+typedef int32_t GGLcoord;
+
+// ----------------------------------------------------------------------------
+
+#define GGL_MAX_VIEWPORT_DIMS 4096
+#define GGL_MAX_TEXTURE_SIZE 4096
+#define GGL_MAX_ALIASED_POINT_SIZE 0x7FFFFFF
+#define GGL_MAX_SMOOTH_POINT_SIZE 2048
+#define GGL_MAX_SMOOTH_LINE_WIDTH 2048
+
+// ----------------------------------------------------------------------------
+
+// All these names are compatible with their OpenGL equivalents
+// some of them are listed only for completeness
+enum GGLNames {
+ GGL_FALSE = 0,
+ GGL_TRUE = 1,
+
+ // enable/disable
+ GGL_SCISSOR_TEST = 0x0C11,
+ GGL_TEXTURE_2D = 0x0DE1,
+ GGL_ALPHA_TEST = 0x0BC0,
+ GGL_BLEND = 0x0BE2,
+ GGL_COLOR_LOGIC_OP = 0x0BF2,
+ GGL_DITHER = 0x0BD0,
+ GGL_STENCIL_TEST = 0x0B90,
+ GGL_DEPTH_TEST = 0x0B71,
+ GGL_AA = 0x80000001,
+ GGL_W_LERP = 0x80000004,
+ GGL_POINT_SMOOTH_NICE = 0x80000005,
+
+ // buffers, pixel drawing/reading
+ GGL_COLOR = 0x1800,
+
+ // fog
+ GGL_FOG = 0x0B60,
+
+ // shade model
+ GGL_FLAT = 0x1D00,
+ GGL_SMOOTH = 0x1D01,
+
+ // Texture parameter name
+ GGL_TEXTURE_MIN_FILTER = 0x2801,
+ GGL_TEXTURE_MAG_FILTER = 0x2800,
+ GGL_TEXTURE_WRAP_S = 0x2802,
+ GGL_TEXTURE_WRAP_T = 0x2803,
+ GGL_TEXTURE_WRAP_R = 0x2804,
+
+ // Texture Filter
+ GGL_NEAREST = 0x2600,
+ GGL_LINEAR = 0x2601,
+ GGL_NEAREST_MIPMAP_NEAREST = 0x2700,
+ GGL_LINEAR_MIPMAP_NEAREST = 0x2701,
+ GGL_NEAREST_MIPMAP_LINEAR = 0x2702,
+ GGL_LINEAR_MIPMAP_LINEAR = 0x2703,
+
+ // Texture Wrap Mode
+ GGL_CLAMP = 0x2900,
+ GGL_REPEAT = 0x2901,
+ GGL_CLAMP_TO_EDGE = 0x812F,
+
+ // Texture Env Mode
+ GGL_REPLACE = 0x1E01,
+ GGL_MODULATE = 0x2100,
+ GGL_DECAL = 0x2101,
+ GGL_ADD = 0x0104,
+
+ // Texture Env Parameter
+ GGL_TEXTURE_ENV_MODE = 0x2200,
+ GGL_TEXTURE_ENV_COLOR = 0x2201,
+
+ // Texture Env Target
+ GGL_TEXTURE_ENV = 0x2300,
+
+ // Texture coord generation
+ GGL_TEXTURE_GEN_MODE = 0x2500,
+ GGL_S = 0x2000,
+ GGL_T = 0x2001,
+ GGL_R = 0x2002,
+ GGL_Q = 0x2003,
+ GGL_ONE_TO_ONE = 0x80000002,
+ GGL_AUTOMATIC = 0x80000003,
+
+ // AlphaFunction
+ GGL_NEVER = 0x0200,
+ GGL_LESS = 0x0201,
+ GGL_EQUAL = 0x0202,
+ GGL_LEQUAL = 0x0203,
+ GGL_GREATER = 0x0204,
+ GGL_NOTEQUAL = 0x0205,
+ GGL_GEQUAL = 0x0206,
+ GGL_ALWAYS = 0x0207,
+
+ // LogicOp
+ GGL_CLEAR = 0x1500, // 0
+ GGL_AND = 0x1501, // s & d
+ GGL_AND_REVERSE = 0x1502, // s & ~d
+ GGL_COPY = 0x1503, // s
+ GGL_AND_INVERTED = 0x1504, // ~s & d
+ GGL_NOOP = 0x1505, // d
+ GGL_XOR = 0x1506, // s ^ d
+ GGL_OR = 0x1507, // s | d
+ GGL_NOR = 0x1508, // ~(s | d)
+ GGL_EQUIV = 0x1509, // ~(s ^ d)
+ GGL_INVERT = 0x150A, // ~d
+ GGL_OR_REVERSE = 0x150B, // s | ~d
+ GGL_COPY_INVERTED = 0x150C, // ~s
+ GGL_OR_INVERTED = 0x150D, // ~s | d
+ GGL_NAND = 0x150E, // ~(s & d)
+ GGL_SET = 0x150F, // 1
+
+ // blending equation & function
+ GGL_ZERO = 0, // SD
+ GGL_ONE = 1, // SD
+ GGL_SRC_COLOR = 0x0300, // D
+ GGL_ONE_MINUS_SRC_COLOR = 0x0301, // D
+ GGL_SRC_ALPHA = 0x0302, // SD
+ GGL_ONE_MINUS_SRC_ALPHA = 0x0303, // SD
+ GGL_DST_ALPHA = 0x0304, // SD
+ GGL_ONE_MINUS_DST_ALPHA = 0x0305, // SD
+ GGL_DST_COLOR = 0x0306, // S
+ GGL_ONE_MINUS_DST_COLOR = 0x0307, // S
+ GGL_SRC_ALPHA_SATURATE = 0x0308, // S
+
+ // clear bits
+ GGL_DEPTH_BUFFER_BIT = 0x00000100,
+ GGL_STENCIL_BUFFER_BIT = 0x00000400,
+ GGL_COLOR_BUFFER_BIT = 0x00004000,
+
+ // errors
+ GGL_NO_ERROR = 0,
+ GGL_INVALID_ENUM = 0x0500,
+ GGL_INVALID_VALUE = 0x0501,
+ GGL_INVALID_OPERATION = 0x0502,
+ GGL_STACK_OVERFLOW = 0x0503,
+ GGL_STACK_UNDERFLOW = 0x0504,
+ GGL_OUT_OF_MEMORY = 0x0505
+};
+
+// ----------------------------------------------------------------------------
+
+typedef struct {
+ GGLsizei version; // always set to sizeof(GGLSurface)
+ GGLuint width; // width in pixels
+ GGLuint height; // height in pixels
+ GGLint stride; // stride in pixels
+ GGLubyte* data; // pointer to the bits
+ GGLubyte format; // pixel format
+ GGLubyte rfu[3]; // must be zero
+ // these values are dependent on the used format
+ union {
+ GGLint compressedFormat;
+ GGLint vstride;
+ };
+ void* reserved;
+} GGLSurface;
+
+
+typedef struct {
+ // immediate rendering
+ void (*pointx)(void *con, const GGLcoord* v, GGLcoord r);
+ void (*linex)(void *con,
+ const GGLcoord* v0, const GGLcoord* v1, GGLcoord width);
+ void (*recti)(void* c, GGLint l, GGLint t, GGLint r, GGLint b);
+ void (*trianglex)(void* c,
+ GGLcoord const* v0, GGLcoord const* v1, GGLcoord const* v2);
+
+ // scissor
+ void (*scissor)(void* c, GGLint x, GGLint y, GGLsizei width, GGLsizei height);
+
+ // Set the textures and color buffers
+ void (*activeTexture)(void* c, GGLuint tmu);
+ void (*bindTexture)(void* c, const GGLSurface* surface);
+ void (*colorBuffer)(void* c, const GGLSurface* surface);
+ void (*readBuffer)(void* c, const GGLSurface* surface);
+ void (*depthBuffer)(void* c, const GGLSurface* surface);
+ void (*bindTextureLod)(void* c, GGLuint tmu, const GGLSurface* surface);
+
+ // enable/disable features
+ void (*enable)(void* c, GGLenum name);
+ void (*disable)(void* c, GGLenum name);
+ void (*enableDisable)(void* c, GGLenum name, GGLboolean en);
+
+ // specify the fragment's color
+ void (*shadeModel)(void* c, GGLenum mode);
+ void (*color4xv)(void* c, const GGLclampx* color);
+ // specify color iterators (16.16)
+ void (*colorGrad12xv)(void* c, const GGLcolor* grad);
+
+ // specify Z coordinate iterators (0.32)
+ void (*zGrad3xv)(void* c, const GGLfixed32* grad);
+
+ // specify W coordinate iterators (16.16)
+ void (*wGrad3xv)(void* c, const GGLfixed* grad);
+
+ // specify fog iterator & color (16.16)
+ void (*fogGrad3xv)(void* c, const GGLfixed* grad);
+ void (*fogColor3xv)(void* c, const GGLclampx* color);
+
+ // specify blending parameters
+ void (*blendFunc)(void* c, GGLenum src, GGLenum dst);
+ void (*blendFuncSeparate)(void* c, GGLenum src, GGLenum dst,
+ GGLenum srcAlpha, GGLenum dstAplha);
+
+ // texture environnement (REPLACE / MODULATE / DECAL / BLEND)
+ void (*texEnvi)(void* c, GGLenum target,
+ GGLenum pname,
+ GGLint param);
+
+ void (*texEnvxv)(void* c, GGLenum target,
+ GGLenum pname, const GGLfixed* params);
+
+ // texture parameters (Wrapping, filter)
+ void (*texParameteri)(void* c, GGLenum target,
+ GGLenum pname,
+ GGLint param);
+
+ // texture iterators (16.16)
+ void (*texCoord2i)(void* c, GGLint s, GGLint t);
+ void (*texCoord2x)(void* c, GGLfixed s, GGLfixed t);
+
+ // s, dsdx, dsdy, scale, t, dtdx, dtdy, tscale
+ // This api uses block floating-point for S and T texture coordinates.
+ // All values are given in 16.16, scaled by 'scale'. In other words,
+ // set scale to 0, for 16.16 values.
+ void (*texCoordGradScale8xv)(void* c, GGLint tmu, const int32_t* grad8);
+
+ void (*texGeni)(void* c, GGLenum coord, GGLenum pname, GGLint param);
+
+ // masking
+ void (*colorMask)(void* c, GGLboolean red,
+ GGLboolean green,
+ GGLboolean blue,
+ GGLboolean alpha);
+
+ void (*depthMask)(void* c, GGLboolean flag);
+
+ void (*stencilMask)(void* c, GGLuint mask);
+
+ // alpha func
+ void (*alphaFuncx)(void* c, GGLenum func, GGLclampx ref);
+
+ // depth func
+ void (*depthFunc)(void* c, GGLenum func);
+
+ // logic op
+ void (*logicOp)(void* c, GGLenum opcode);
+
+ // clear
+ void (*clear)(void* c, GGLbitfield mask);
+ void (*clearColorx)(void* c,
+ GGLclampx r, GGLclampx g, GGLclampx b, GGLclampx a);
+ void (*clearDepthx)(void* c, GGLclampx depth);
+ void (*clearStencil)(void* c, GGLint s);
+
+ // framebuffer operations
+ void (*copyPixels)(void* c, GGLint x, GGLint y,
+ GGLsizei width, GGLsizei height, GGLenum type);
+ void (*rasterPos2x)(void* c, GGLfixed x, GGLfixed y);
+ void (*rasterPos2i)(void* c, GGLint x, GGLint y);
+} GGLContext;
+
+// ----------------------------------------------------------------------------
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// construct / destroy the context
+ssize_t gglInit(GGLContext** context);
+ssize_t gglUninit(GGLContext* context);
+
+GGLint gglBitBlti(
+ GGLContext* c,
+ int tmu,
+ GGLint crop[4],
+ GGLint where[4]);
+
+#ifdef __cplusplus
+};
+#endif
+
+// ----------------------------------------------------------------------------
+
+#endif // ANDROID_PIXELFLINGER_H